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
=== modified file 'katze/katze-arrayaction.c'
--- katze/katze-arrayaction.c 2015-04-19 23:03:37 +0000
+++ katze/katze-arrayaction.c 2015-06-30 22:38:48 +0000
@@ -380,8 +380,8 @@
380380
381static gboolean381static gboolean
382katze_array_action_tool_item_child_button_press_cb (GtkWidget* proxy,382katze_array_action_tool_item_child_button_press_cb (GtkWidget* proxy,
383 GdkEventButton* event,383 GdkEventButton* event,
384 KatzeArrayAction* array_action)384 KatzeArrayAction* array_action)
385{385{
386 GtkWidget* toolitem = gtk_widget_get_parent (proxy);386 GtkWidget* toolitem = gtk_widget_get_parent (proxy);
387 KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");387 KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
@@ -393,6 +393,27 @@
393 return katze_array_action_activate_item_alt (array_action, item, event, proxy);393 return katze_array_action_activate_item_alt (array_action, item, event, proxy);
394}394}
395395
396/* GtkToolItem does not emit the "clicked" event for middle-clicks, so handle them (but not
397 regular or ctrl-clicks) manually via the button-release-event signal. */
398static gboolean
399katze_array_action_tool_item_child_button_release_cb (GtkWidget* proxy,
400 GdkEventButton* event,
401 KatzeArrayAction* array_action)
402{
403 GtkWidget* toolitem = gtk_widget_get_parent (proxy);
404 KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
405
406 /* We only need to handle middle-clicks here, since proper handling for
407 * ctrl-clicks, right-clicks, and left-clicks has been done elsewhere. */
408 if (event && MIDORI_EVENT_NEW_TAB (event))
409 {
410 katze_array_action_activate_item_new_tab (array_action, item);
411 return TRUE;
412 }
413
414 return FALSE;
415}
416
396static void417static void
397katze_array_action_menu_item_select_cb (GtkWidget* proxy,418katze_array_action_menu_item_select_cb (GtkWidget* proxy,
398 KatzeArrayAction* array_action);419 KatzeArrayAction* array_action);
@@ -570,7 +591,7 @@
570 KatzeArray* array;591 KatzeArray* array;
571 gboolean handled = FALSE;592 gboolean handled = FALSE;
572593
573 array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeItem");594 array = KATZE_ARRAY (g_object_get_data (G_OBJECT (proxy), "KatzeItem"));
574595
575 if (GTK_IS_MENU_ITEM (proxy))596 if (GTK_IS_MENU_ITEM (proxy))
576 {597 {
@@ -775,17 +796,29 @@
775 gtk_tool_item_set_tooltip_text (toolitem, uri);796 gtk_tool_item_set_tooltip_text (toolitem, uri);
776797
777 g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);798 g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
778 g_signal_connect (toolitem, "clicked",799 if (KATZE_ITEM_IS_FOLDER (item))
779 G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);800 g_signal_connect (toolitem, "clicked",
780 if (KATZE_IS_ITEM (item))801 G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);
802 else if (KATZE_IS_ITEM (item))
781 {803 {
782 /* Tool items block the "button-press-event" but we can get it804 /* Connect to "button-press-event" to handle right-clicks.
805 * Tool items block the "button-press-event" but we can get it
783 * when connecting it to the tool item's child widget806 * when connecting it to the tool item's child widget
784 */807 */
785
786 GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));808 GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
787 g_signal_connect (child, "button-press-event",809 g_signal_connect (child, "button-press-event",
788 G_CALLBACK (katze_array_action_tool_item_child_button_press_cb), array_action);810 G_CALLBACK (katze_array_action_tool_item_child_button_press_cb), array_action);
811
812 /* Connect to the "clicked" signal to handle normal keyboard and mouse
813 * activations, checking the event to see if a new tab should be
814 * opened. */
815 g_signal_connect (toolitem, "clicked",
816 G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
817
818 /* Connect to the "button-released-event" signal to handle middle clicks, since
819 * GtkToolButton does not emit "clicked" for middle-clicks. */
820 g_signal_connect (child, "button-release-event",
821 G_CALLBACK (katze_array_action_tool_item_child_button_release_cb), array_action);
789 }822 }
790823
791 g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action);824 g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action);

Subscribers

People subscribed via source and target branches

to all changes: