Changeset 99207 in webkit


Ignore:
Timestamp:
Nov 3, 2011 10:06:51 AM (13 years ago)
Author:
Carlos Garcia Campos
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.

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r99206 r99207  
     12011-11-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Show url of history items in a status bar in MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=71474
     5
     6        Reviewed by Martin Robinson.
     7
     8        * MiniBrowser/gtk/BrowserWindow.c:
     9        (browserWindowSetStatusText): Set status text and show/hide the
     10        status label.
     11        (resetStatusText): Reset status text when history menu is hidden.
     12        (browserWindowHistoryItemSelected): Show url of currently selected
     13        history item.
     14        (browserWindowCreateBackForwardMenu): Connect to hide signal of
     15        menu to reset the status text.
     16        (browserWindowConstructed): Use GtkOverlay if available to show
     17        status text.
     18
    1192011-11-03  Carlos Garcia Campos  <cgarcia@igalia.com>
    220
  • trunk/Tools/MiniBrowser/gtk/BrowserWindow.c

    r99206 r99207  
    4141    GtkWidget *backItem;
    4242    GtkWidget *forwardItem;
     43    GtkWidget *statusLabel;
    4344    WebKitWebView *webView;
    4445
     
    5253
    5354G_DEFINE_TYPE(BrowserWindow, browser_window, GTK_TYPE_WINDOW)
     55
     56static void browserWindowSetStatusText(BrowserWindow *window, const char *text)
     57{
     58#if GTK_CHECK_VERSION(3, 2, 0)
     59    gtk_label_set_text(GTK_LABEL(window->statusLabel), text);
     60    gtk_widget_set_visible(window->statusLabel, !!text);
     61#endif
     62}
     63
     64static void resetStatusText(GtkWidget *widget, BrowserWindow *window)
     65{
     66    browserWindowSetStatusText(window, NULL);
     67}
    5468
    5569static void activateUriEntryCallback(BrowserWindow *window)
     
    8599    if (progress == 1.0)
    86100        g_timeout_add(500, (GSourceFunc)resetEntryProgress, window->uriEntry);
     101}
     102
     103static void browserWindowHistoryItemSelected(BrowserWindow *window, GtkMenuItem *item)
     104{
     105    GtkAction *action = gtk_activatable_get_related_action(GTK_ACTIVATABLE(item));
     106    browserWindowSetStatusText(window, action ? gtk_action_get_name(action) : NULL);
    87107}
    88108
     
    113133
    114134        GtkWidget *menuItem = gtk_action_create_menu_item(action);
     135        g_signal_connect_swapped(menuItem, "select", G_CALLBACK(browserWindowHistoryItemSelected), window);
    115136        g_object_unref(action);
    116137
     
    118139        gtk_widget_show(menuItem);
    119140    }
     141
     142    /* FIXME: This shoulnd't be necessary when didMouseMoveOverElement
     143     * is implemented in WebKit2 GTK+ API.
     144     */
     145    g_signal_connect(menu, "hide", G_CALLBACK(resetStatusText), window);
    120146
    121147    return menu;
     
    235261    g_signal_connect(backForwadlist, "changed", G_CALLBACK(backForwadlistChanged), window);
    236262
     263#if GTK_CHECK_VERSION(3, 2, 0)
     264    GtkWidget *overlay = gtk_overlay_new();
     265    gtk_box_pack_start(GTK_BOX(window->mainBox), overlay, TRUE, TRUE, 0);
     266    gtk_widget_show(overlay);
     267
     268    window->statusLabel = gtk_label_new(NULL);
     269    gtk_widget_set_halign(window->statusLabel, GTK_ALIGN_START);
     270    gtk_widget_set_valign(window->statusLabel, GTK_ALIGN_END);
     271    gtk_widget_set_margin_left(window->statusLabel, 1);
     272    gtk_widget_set_margin_right(window->statusLabel, 1);
     273    gtk_widget_set_margin_top(window->statusLabel, 1);
     274    gtk_widget_set_margin_bottom(window->statusLabel, 1);
     275    gtk_overlay_add_overlay(GTK_OVERLAY(overlay), window->statusLabel);
     276
     277    gtk_container_add(GTK_CONTAINER(overlay), GTK_WIDGET(window->webView));
     278#else
    237279    gtk_box_pack_start(GTK_BOX(window->mainBox), GTK_WIDGET(window->webView), TRUE, TRUE, 0);
     280#endif
    238281    gtk_widget_show(GTK_WIDGET(window->webView));
    239282}
Note: See TracChangeset for help on using the changeset viewer.