[GTK] Minibrowser : Add home buton and keyboard support for home page load
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 10:49:09 +0000 (10:49 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 10:49:09 +0000 (10:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137486

Patch by Rohit Kumar <kumar.rohit@samsung.com> on 2014-10-14
Reviewed by Philippe Normand.

* MiniBrowser/gtk/BrowserWindow.c:
(loadHomePage): Callback for home page load.
(browser_window_init):
* MiniBrowser/gtk/BrowserWindow.h:
* MiniBrowser/gtk/main.c:
(main):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174679 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/MiniBrowser/gtk/BrowserWindow.c
Tools/MiniBrowser/gtk/BrowserWindow.h
Tools/MiniBrowser/gtk/main.c

index c74309e..89658c5 100644 (file)
@@ -1,3 +1,17 @@
+2014-10-14  Rohit Kumar  <kumar.rohit@samsung.com>
+
+        [GTK] Minibrowser : Add home buton and keyboard support for home page load
+        https://bugs.webkit.org/show_bug.cgi?id=137486
+
+        Reviewed by Philippe Normand.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (loadHomePage): Callback for home page load.
+        (browser_window_init):
+        * MiniBrowser/gtk/BrowserWindow.h:
+        * MiniBrowser/gtk/main.c:
+        (main):
+
 2014-10-14  Manuel Rego Casasnovas  <rego@igalia.com>
 
         import-w3c-tests doesn't prefix property values
index d69241e..d07e112 100644 (file)
@@ -546,6 +546,11 @@ static void stopPageLoad(BrowserWindow *window, gpointer user_data)
         webkit_web_view_stop_loading(window->webView);
 }
 
+static void loadHomePage(BrowserWindow *window, gpointer user_data)
+{
+    webkit_web_view_load_uri(window->webView, BROWSER_DEFAULT_URL);
+}
+
 static void browserWindowFinalize(GObject *gObject)
 {
     BrowserWindow *window = BROWSER_WINDOW(gObject);
@@ -637,6 +642,10 @@ static void browser_window_init(BrowserWindow *window)
     gtk_accel_group_connect(window->accelGroup, GDK_KEY_Escape, 0, GTK_ACCEL_VISIBLE,
         g_cclosure_new_swap(G_CALLBACK(stopPageLoad), window, NULL));
 
+    /* Load home page */ 
+    gtk_accel_group_connect(window->accelGroup, GDK_KEY_Home, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE,
+        g_cclosure_new_swap(G_CALLBACK(loadHomePage), window, NULL));
+
     GtkWidget *toolbar = gtk_toolbar_new();
     window->toolbar = toolbar;
     gtk_orientable_set_orientation(GTK_ORIENTABLE(toolbar), GTK_ORIENTATION_HORIZONTAL);
@@ -679,6 +688,12 @@ static void browser_window_init(BrowserWindow *window)
     gtk_widget_add_accelerator(GTK_WIDGET(item), "clicked", window->accelGroup, GDK_KEY_F, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
     gtk_widget_show(GTK_WIDGET(item));
 
+    item = gtk_tool_button_new_from_stock(GTK_STOCK_HOME);
+    g_signal_connect_swapped(item, "clicked", G_CALLBACK(loadHomePage), window);
+    gtk_toolbar_insert(GTK_TOOLBAR(toolbar), item, -1);
+    gtk_widget_add_accelerator(GTK_WIDGET(item), "clicked", window->accelGroup, GDK_KEY_Home, GDK_MOD1_MASK, GTK_ACCEL_VISIBLE);
+    gtk_widget_show(GTK_WIDGET(item));
+
     item = gtk_tool_item_new();
     gtk_tool_item_set_expand(item, TRUE);
     gtk_container_add(GTK_CONTAINER(item), window->uriEntry);
index 6667546..7910bed 100644 (file)
@@ -37,6 +37,7 @@ G_BEGIN_DECLS
 #define BROWSER_IS_WINDOW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), BROWSER_TYPE_WINDOW))
 #define BROWSER_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  BROWSER_TYPE_WINDOW))
 #define BROWSER_WINDOW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  BROWSER_TYPE_WINDOW, BrowserWindowClass))
+#define BROWSER_DEFAULT_URL            "http://www.webkitgtk.org/"
 
 typedef struct _BrowserWindow        BrowserWindow;
 typedef struct _BrowserWindowClass   BrowserWindowClass;
index 9418ca6..2bfc170 100644 (file)
@@ -279,7 +279,7 @@ int main(int argc, char *argv[])
         for (i = 0; uriArguments[i]; i++)
             createBrowserWindow(uriArguments[i], webkitSettings);
     } else
-        createBrowserWindow("http://www.webkitgtk.org/", webkitSettings);
+        createBrowserWindow(BROWSER_DEFAULT_URL, webkitSettings);
 
     g_clear_object(&webkitSettings);