Title: [99207] trunk/Tools
Revision
99207
Author
[email protected]
Date
2011-11-03 10:06:51 -0700 (Thu, 03 Nov 2011)

Log Message

[GTK] Show url of history items in a status bar in MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=71474

Reviewed by Martin Robinson.

* MiniBrowser/gtk/BrowserWindow.c:
(browserWindowSetStatusText): Set status text and show/hide the
status label.
(resetStatusText): Reset status text when history menu is hidden.
(browserWindowHistoryItemSelected): Show url of currently selected
history item.
(browserWindowCreateBackForwardMenu): Connect to hide signal of
menu to reset the status text.
(browserWindowConstructed): Use GtkOverlay if available to show
status text.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (99206 => 99207)


--- trunk/Tools/ChangeLog	2011-11-03 17:01:42 UTC (rev 99206)
+++ trunk/Tools/ChangeLog	2011-11-03 17:06:51 UTC (rev 99207)
@@ -1,5 +1,23 @@
 2011-11-03  Carlos Garcia Campos  <[email protected]>
 
+        [GTK] Show url of history items in a status bar in MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=71474
+
+        Reviewed by Martin Robinson.
+
+        * MiniBrowser/gtk/BrowserWindow.c:
+        (browserWindowSetStatusText): Set status text and show/hide the
+        status label.
+        (resetStatusText): Reset status text when history menu is hidden.
+        (browserWindowHistoryItemSelected): Show url of currently selected
+        history item.
+        (browserWindowCreateBackForwardMenu): Connect to hide signal of
+        menu to reset the status text.
+        (browserWindowConstructed): Use GtkOverlay if available to show
+        status text.
+
+2011-11-03  Carlos Garcia Campos  <[email protected]>
+
         [GTK] Add back/forward menus to MiniBrowser using WebKit2 GTK+ API
         https://bugs.webkit.org/show_bug.cgi?id=71466
 

Modified: trunk/Tools/MiniBrowser/gtk/BrowserWindow.c (99206 => 99207)


--- trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2011-11-03 17:01:42 UTC (rev 99206)
+++ trunk/Tools/MiniBrowser/gtk/BrowserWindow.c	2011-11-03 17:06:51 UTC (rev 99207)
@@ -40,6 +40,7 @@
     GtkWidget *uriEntry;
     GtkWidget *backItem;
     GtkWidget *forwardItem;
+    GtkWidget *statusLabel;
     WebKitWebView *webView;
 
 };
@@ -52,6 +53,19 @@
 
 G_DEFINE_TYPE(BrowserWindow, browser_window, GTK_TYPE_WINDOW)
 
+static void browserWindowSetStatusText(BrowserWindow *window, const char *text)
+{
+#if GTK_CHECK_VERSION(3, 2, 0)
+    gtk_label_set_text(GTK_LABEL(window->statusLabel), text);
+    gtk_widget_set_visible(window->statusLabel, !!text);
+#endif
+}
+
+static void resetStatusText(GtkWidget *widget, BrowserWindow *window)
+{
+    browserWindowSetStatusText(window, NULL);
+}
+
 static void activateUriEntryCallback(BrowserWindow *window)
 {
     webkit_web_view_load_uri(window->webView, gtk_entry_get_text(GTK_ENTRY(window->uriEntry)));
@@ -86,6 +100,12 @@
         g_timeout_add(500, (GSourceFunc)resetEntryProgress, window->uriEntry);
 }
 
+static void browserWindowHistoryItemSelected(BrowserWindow *window, GtkMenuItem *item)
+{
+    GtkAction *action = ""
+    browserWindowSetStatusText(window, action ? gtk_action_get_name(action) : NULL);
+}
+
 static void browserWindowHistoryItemActivated(BrowserWindow *window, GtkAction *action)
 {
     WebKitBackForwardListItem *item = g_object_get_data(G_OBJECT(action), "back-forward-list-item");
@@ -112,12 +132,18 @@
         g_signal_connect_swapped(action, "activate", G_CALLBACK(browserWindowHistoryItemActivated), window);
 
         GtkWidget *menuItem = gtk_action_create_menu_item(action);
+        g_signal_connect_swapped(menuItem, "select", G_CALLBACK(browserWindowHistoryItemSelected), window);
         g_object_unref(action);
 
         gtk_menu_shell_prepend(GTK_MENU_SHELL(menu), menuItem);
         gtk_widget_show(menuItem);
     }
 
+    /* FIXME: This shoulnd't be necessary when didMouseMoveOverElement
+     * is implemented in WebKit2 GTK+ API.
+     */
+    g_signal_connect(menu, "hide", G_CALLBACK(resetStatusText), window);
+
     return menu;
 }
 
@@ -234,7 +260,24 @@
     WebKitBackForwardList *backForwadlist = webkit_web_view_get_back_forward_list(window->webView);
     g_signal_connect(backForwadlist, "changed", G_CALLBACK(backForwadlistChanged), window);
 
+#if GTK_CHECK_VERSION(3, 2, 0)
+    GtkWidget *overlay = gtk_overlay_new();
+    gtk_box_pack_start(GTK_BOX(window->mainBox), overlay, TRUE, TRUE, 0);
+    gtk_widget_show(overlay);
+
+    window->statusLabel = gtk_label_new(NULL);
+    gtk_widget_set_halign(window->statusLabel, GTK_ALIGN_START);
+    gtk_widget_set_valign(window->statusLabel, GTK_ALIGN_END);
+    gtk_widget_set_margin_left(window->statusLabel, 1);
+    gtk_widget_set_margin_right(window->statusLabel, 1);
+    gtk_widget_set_margin_top(window->statusLabel, 1);
+    gtk_widget_set_margin_bottom(window->statusLabel, 1);
+    gtk_overlay_add_overlay(GTK_OVERLAY(overlay), window->statusLabel);
+
+    gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(window->webView));
+#else
     gtk_box_pack_start(GTK_BOX(window->mainBox), GTK_WIDGET(window->webView), TRUE, TRUE, 0);
+#endif
     gtk_widget_show(GTK_WIDGET(window->webView));
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to