diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-09-19 01:12:32 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-09-19 01:14:41 (EDT) |
commit | 43772f9dae00572d94d6ffe9e331513724dc5dda (patch) | |
tree | 19e3b3d0398f13dde010c98bd5fe133702f65776 /src | |
parent | 2f9cd52f0359e79dea158a43436c4a09bafb0f22 (diff) | |
download | marquee-43772f9dae00572d94d6ffe9e331513724dc5dda.zip marquee-43772f9dae00572d94d6ffe9e331513724dc5dda.tar.gz marquee-43772f9dae00572d94d6ffe9e331513724dc5dda.tar.bz2 |
src/tab-chrome.[ch]: Close back/forward popover on row activation
Diffstat (limited to 'src')
-rw-r--r-- | src/tab-chrome.c | 23 | ||||
-rw-r--r-- | src/tab-chrome.h | 2 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/tab-chrome.c b/src/tab-chrome.c index d628473..c9b7dca 100644 --- a/src/tab-chrome.c +++ b/src/tab-chrome.c @@ -96,6 +96,18 @@ back_forward_list_item_new(WebKitBackForwardListItem *list_item, return box; } +static void +back_forward_list_box_row_activated_cb(GtkListBox __attribute__((unused)) *box, + GtkListBoxRow *row, MqTabChrome *chrome) +{ + webkit_web_view_go_to_back_forward_list_item(chrome->web_view, + webkit_back_forward_list_get_nth_item( + webkit_web_view_get_back_forward_list(chrome->web_view), + gtk_list_box_row_get_index(row) - chrome->back_items)); + + gtk_widget_hide(chrome->back_forward_popover); +} + static gboolean back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, MqTabChrome *chrome) @@ -106,7 +118,6 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, GtkWidget *stack; GtkWidget *toggle_button; GtkWidget *box; - GtkWidget *popover; /* Make sure this is a mouse button press event. Either the middle or * right button is OK. */ @@ -123,6 +134,8 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, gtk_list_box_set_selection_mode(GTK_LIST_BOX(list_box), GTK_SELECTION_BROWSE); gtk_list_box_set_activate_on_single_click(GTK_LIST_BOX(list_box), TRUE); + g_signal_connect(list_box, "row-activated", + G_CALLBACK(back_forward_list_box_row_activated_cb), chrome); /* Insert the current item. */ gtk_list_box_insert(GTK_LIST_BOX(list_box), back_forward_list_item_new( @@ -134,9 +147,11 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, /* Insert back list items. */ list_item = webkit_back_forward_list_get_back_list( back_forward_list); + chrome->back_items = 0; for (; list_item; list_item = list_item->next) { gtk_list_box_insert(GTK_LIST_BOX(list_box), back_forward_list_item_new(list_item->data, -1), 0); + ++chrome->back_items; } /* Insert forward list items. */ @@ -168,11 +183,11 @@ back_forward_box_button_press_cb(GtkWidget *widget, GdkEvent *event, gtk_box_pack_start(GTK_BOX(box), stack, TRUE, FALSE, 0); /* Set up the popover. */ - popover = gtk_popover_new(widget); - gtk_container_add(GTK_CONTAINER(popover), box); + chrome->back_forward_popover = gtk_popover_new(widget); + gtk_container_add(GTK_CONTAINER(chrome->back_forward_popover), box); /* NB: gtk_popover_popup() is new in GTK+ 3.22. */ - gtk_widget_show_all(popover); + gtk_widget_show_all(chrome->back_forward_popover); return FALSE; } diff --git a/src/tab-chrome.h b/src/tab-chrome.h index ecd874f..baf0e3a 100644 --- a/src/tab-chrome.h +++ b/src/tab-chrome.h @@ -40,6 +40,8 @@ typedef struct { PangoAttrList *hovered_link_style; WebKitWebView *web_view; gboolean load_failed; + GtkWidget *back_forward_popover; + gint back_items; } MqTabChrome; MqTabChrome * |