Merge lp:~gue5t/midori/bookmark-bar-click into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6983
Merged at revision: 6993
Proposed branch: lp:~gue5t/midori/bookmark-bar-click
Merge into: lp:midori
Diff against target: 86 lines (+41/-8)
1 file modified
katze/katze-arrayaction.c (+41/-8)
To merge this branch: bzr merge lp:~gue5t/midori/bookmark-bar-click
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+263421@code.launchpad.net

Commit message

Fix middle/ctrl/normal clicking bookmarks (not folders) in the bookmarkbar.

Description of the change

http://bazaar.launchpad.net/~midori/midori/trunk/revision/6906 cleaned up KatzeArrayAction events, in particular making sure the right events were dispatched on button press vs. release for menuitems. However I neglected to consider the effect of these changes on the bookmarkbar, which was written to open bookmarks on button-press.

So middle/ctr/normal clicks on bookmarkbar entries which were not folders no longer did anything.

This patch fixes bookmarkbar entries to open on button-release as is expected in GTK user interfaces, and adds several comments explaining the implementation details.

To post a comment you must log in.
lp:~gue5t/midori/bookmark-bar-click updated
6983. By gue5t <email address hidden>

make katze_array_action_tool_item_child_button_release_cb more careful about return value

Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'katze/katze-arrayaction.c'
2--- katze/katze-arrayaction.c 2015-04-19 23:03:37 +0000
3+++ katze/katze-arrayaction.c 2015-06-30 22:38:48 +0000
4@@ -380,8 +380,8 @@
5
6 static gboolean
7 katze_array_action_tool_item_child_button_press_cb (GtkWidget* proxy,
8- GdkEventButton* event,
9- KatzeArrayAction* array_action)
10+ GdkEventButton* event,
11+ KatzeArrayAction* array_action)
12 {
13 GtkWidget* toolitem = gtk_widget_get_parent (proxy);
14 KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
15@@ -393,6 +393,27 @@
16 return katze_array_action_activate_item_alt (array_action, item, event, proxy);
17 }
18
19+/* GtkToolItem does not emit the "clicked" event for middle-clicks, so handle them (but not
20+ regular or ctrl-clicks) manually via the button-release-event signal. */
21+static gboolean
22+katze_array_action_tool_item_child_button_release_cb (GtkWidget* proxy,
23+ GdkEventButton* event,
24+ KatzeArrayAction* array_action)
25+{
26+ GtkWidget* toolitem = gtk_widget_get_parent (proxy);
27+ KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
28+
29+ /* We only need to handle middle-clicks here, since proper handling for
30+ * ctrl-clicks, right-clicks, and left-clicks has been done elsewhere. */
31+ if (event && MIDORI_EVENT_NEW_TAB (event))
32+ {
33+ katze_array_action_activate_item_new_tab (array_action, item);
34+ return TRUE;
35+ }
36+
37+ return FALSE;
38+}
39+
40 static void
41 katze_array_action_menu_item_select_cb (GtkWidget* proxy,
42 KatzeArrayAction* array_action);
43@@ -570,7 +591,7 @@
44 KatzeArray* array;
45 gboolean handled = FALSE;
46
47- array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeItem");
48+ array = KATZE_ARRAY (g_object_get_data (G_OBJECT (proxy), "KatzeItem"));
49
50 if (GTK_IS_MENU_ITEM (proxy))
51 {
52@@ -775,17 +796,29 @@
53 gtk_tool_item_set_tooltip_text (toolitem, uri);
54
55 g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
56- g_signal_connect (toolitem, "clicked",
57- G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);
58- if (KATZE_IS_ITEM (item))
59+ if (KATZE_ITEM_IS_FOLDER (item))
60+ g_signal_connect (toolitem, "clicked",
61+ G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);
62+ else if (KATZE_IS_ITEM (item))
63 {
64- /* Tool items block the "button-press-event" but we can get it
65+ /* Connect to "button-press-event" to handle right-clicks.
66+ * Tool items block the "button-press-event" but we can get it
67 * when connecting it to the tool item's child widget
68 */
69-
70 GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
71 g_signal_connect (child, "button-press-event",
72 G_CALLBACK (katze_array_action_tool_item_child_button_press_cb), array_action);
73+
74+ /* Connect to the "clicked" signal to handle normal keyboard and mouse
75+ * activations, checking the event to see if a new tab should be
76+ * opened. */
77+ g_signal_connect (toolitem, "clicked",
78+ G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
79+
80+ /* Connect to the "button-released-event" signal to handle middle clicks, since
81+ * GtkToolButton does not emit "clicked" for middle-clicks. */
82+ g_signal_connect (child, "button-release-event",
83+ G_CALLBACK (katze_array_action_tool_item_child_button_release_cb), array_action);
84 }
85
86 g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action);

Subscribers

People subscribed via source and target branches

to all changes: