Changeset 221833 in webkit


Ignore:
Timestamp:
Sep 10, 2017 2:54:31 AM (7 years ago)
Author:
Michael Catanzaro
Message:

[GTK] Improve Ctrl+W and Ctrl+Q shortcuts in MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=176619

Reviewed by Carlos Garcia Campos.

There are two different problems here. First, Ctrl+W is closing the entire window. That made
sense when I implemented the shortcut a couple years ago, but now MiniBrowser supports tabs
and it should really close only one single tab. Fix that.

Next, the keyboard shortcuts are not using webkit_web_view_try_close() and so are bypassing
onbeforeunload handlers, which are respected when closing with the mouse. Fix that too.

  • MiniBrowser/gtk/BrowserWindow.c:

(browserWindowTryCloseCurrentWebView):
(browserWindowTryClose):
(browser_window_init):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r221829 r221833  
     12017-09-10  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [GTK] Improve Ctrl+W and Ctrl+Q shortcuts in MiniBrowser
     4        https://bugs.webkit.org/show_bug.cgi?id=176619
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        There are two different problems here. First, Ctrl+W is closing the entire window. That made
     9        sense when I implemented the shortcut a couple years ago, but now MiniBrowser supports tabs
     10        and it should really close only one single tab. Fix that.
     11
     12        Next, the keyboard shortcuts are not using webkit_web_view_try_close() and so are bypassing
     13        onbeforeunload handlers, which are respected when closing with the mouse. Fix that too.
     14
     15        * MiniBrowser/gtk/BrowserWindow.c:
     16        (browserWindowTryCloseCurrentWebView):
     17        (browserWindowTryClose):
     18        (browser_window_init):
     19
    1202017-09-07  Myles C. Maxfield  <mmaxfield@apple.com>
    221
  • trunk/Tools/MiniBrowser/gtk/BrowserWindow.c

    r221827 r221833  
    255255}
    256256
     257static void browserWindowTryCloseCurrentWebView(BrowserWindow *window)
     258{
     259    int currentPage = gtk_notebook_get_current_page(GTK_NOTEBOOK(window->notebook));
     260    BrowserTab *tab = (BrowserTab *)gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->notebook), currentPage);
     261    webkit_web_view_try_close(browser_tab_get_web_view(tab));
     262}
     263
     264static void browserWindowTryClose(BrowserWindow *window)
     265{
     266    GSList *webViews = NULL;
     267    int n = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->notebook));
     268    int i;
     269
     270    for (i = 0; i < n; ++i) {
     271        BrowserTab *tab = (BrowserTab *)gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->notebook), i);
     272        webViews = g_slist_prepend(webViews, browser_tab_get_web_view(tab));
     273    }
     274
     275    GSList *link;
     276    for (link = webViews; link; link = link->next)
     277        webkit_web_view_try_close(link->data);
     278}
     279
    257280static void backForwardlistChanged(WebKitBackForwardList *backForwardlist, WebKitBackForwardListItem *itemAdded, GList *itemsRemoved, BrowserWindow *window)
    258281{
     
    934957    /* Quit */
    935958    gtk_accel_group_connect(window->accelGroup, GDK_KEY_Q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE,
    936         g_cclosure_new_swap(G_CALLBACK(gtk_widget_destroy), window, NULL));
     959        g_cclosure_new_swap(G_CALLBACK(browserWindowTryClose), window, NULL));
    937960    gtk_accel_group_connect(window->accelGroup, GDK_KEY_W, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE,
    938         g_cclosure_new_swap(G_CALLBACK(gtk_widget_destroy), window, NULL));
     961        g_cclosure_new_swap(G_CALLBACK(browserWindowTryCloseCurrentWebView), window, NULL));
    939962
    940963    /* Print */
     
    10461069}
    10471070
    1048 static void browserWindowTryClose(BrowserWindow *window)
    1049 {
    1050     GSList *webViews = NULL;
    1051     int n = gtk_notebook_get_n_pages(GTK_NOTEBOOK(window->notebook));
    1052     int i;
    1053 
    1054     for (i = 0; i < n; ++i) {
    1055         BrowserTab *tab = (BrowserTab *)gtk_notebook_get_nth_page(GTK_NOTEBOOK(window->notebook), i);
    1056         webViews = g_slist_prepend(webViews, browser_tab_get_web_view(tab));
    1057     }
    1058 
    1059     GSList *link;
    1060     for (link = webViews; link; link = link->next)
    1061         webkit_web_view_try_close(link->data);
    1062 }
    1063 
    10641071static gboolean browserWindowDeleteEvent(GtkWidget *widget, GdkEventAny* event)
    10651072{
Note: See TracChangeset for help on using the changeset viewer.