Merge lp:~gue5t/midori/restore-middle-btn-up-2 into lp:midori

Proposed by gue5t gue5t
Status: Merged
Approved by: Cris Dywan
Approved revision: 6901
Merged at revision: 6906
Proposed branch: lp:~gue5t/midori/restore-middle-btn-up-2
Merge into: lp:midori
Diff against target: 337 lines (+104/-74)
2 files modified
katze/katze-arrayaction.c (+60/-30)
midori/midori-browser.c (+44/-44)
To merge this branch: bzr merge lp:~gue5t/midori/restore-middle-btn-up-2
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+253532@code.launchpad.net

This proposal supersedes a proposal from 2013-11-15.

Commit message

Rework mouse button handling in KatzeArrayAction

Description of the change

This changes the semantics of the "activate-item" and "activate-item-alt" signals, and documents their behavior more clearly than previously. The former is used for regular activations, based on keyboard interaction, mouse clicks, or other input methods, and is triggered by the normal GTK "activate" signal, but carries information about whether the event requested a new tab. The latter is used to open popup menus or operate on items within menus without properly activating them.

The keyboard now works to activate items in the bookmarks/tabs/trash menus, and clicking on these items behaves the same as normal items. Right-clicking bookmarks and bookmark folders still works as expected.

To post a comment you must log in.
Revision history for this message
Cris Dywan (kalikiana) wrote : Posted in a previous version of this proposal

Did you test with global menubars?

review: Needs Information
Revision history for this message
gue5t gue5t (gue5t) wrote : Posted in a previous version of this proposal

The global menubars only emit the "activate" event, but I have not. I'll trek on over to the nearest Ubuntu box and see if I can test.

Revision history for this message
Cris Dywan (kalikiana) wrote : Posted in a previous version of this proposal

Testing I get this while using menus

gtk_widget_get_preferred_height_for_width: assertion 'width >= 0' failed

review: Needs Fixing
Revision history for this message
gue5t gue5t (gue5t) wrote : Posted in a previous version of this proposal

Does the gtk_widget_get_preferred_height_for_width fail with the Ubuntu global menubar, or with a certain GTK3 theme? I can't seem to reproduce it locally. The assertion sounds like maybe a widget hasn't been realized yet at some point, but it's difficult to figure out realization ordering issues just by looking at code.

Revision history for this message
Cris Dywan (kalikiana) wrote : Posted in a previous version of this proposal

Hrm something more fundamental must have broken I can't get the menubar to appear in the global panel at all even if I override UBUNTU_MENUPROXY. Though no errors either. But the only change due to Midori assuming there is a global bar I can see is the menu item [x] Menubar disappearing from the menus.

Revision history for this message
Cris Dywan (kalikiana) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
RabbitBot (rabbitbot-a) wrote : Posted in a previous version of this proposal

Attempt to merge into lp:midori failed due to conflicts:

text conflict in katze/katze-arrayaction.c

Revision history for this message
gue5t gue5t (gue5t) wrote :

I've rebased this and changed the approach; it now makes a lot of the code and behavior more sane. Please rereview when you get a chance.

Revision history for this message
Cris Dywan (kalikiana) wrote :

I'm afraid changing the signature of an existing signal is a bad idea, it will crash any existing extensions that use it.
We could consider this in the coming new trunk which breaks compat anyway - where there's the whole new question of porting to glib menu API.

review: Needs Fixing
6899. By gue5t <email address hidden>

Rename activate-item signal to activate-item-event to carry event and avoid compatibility worries

6900. By gue5t <email address hidden>

Restore full backwards compatibility by reverting signal names and adding activate-item-new-tab signal to KatzeArrayAction

6901. By gue5t <email address hidden>

Fix leak of GdkEvent

Revision history for this message
Cris Dywan (kalikiana) wrote :

Looks nice now, I appreciate your updates despite the confusion whilst discussing this.

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 2014-07-24 06:01:27 +0000
3+++ katze/katze-arrayaction.c 2015-03-23 20:01:00 +0000
4@@ -12,6 +12,7 @@
5
6 #include "katze-arrayaction.h"
7
8+#include "midori/midori-platform.h"
9 #include "katze-utils.h"
10 #include "marshal.h"
11
12@@ -51,6 +52,7 @@
13 POPULATE_POPUP,
14 POPULATE_FOLDER,
15 ACTIVATE_ITEM,
16+ ACTIVATE_ITEM_NEW_TAB,
17 ACTIVATE_ITEM_ALT,
18 LAST_SIGNAL
19 };
20@@ -115,7 +117,7 @@
21 * @menu: the menu shell being opened
22 * @folder: the folder being opened
23 *
24- * A context menu is going to be opened for @folder,
25+ * A submenu is going to be opened for @folder,
26 * the provided @menu can be populated accordingly.
27 *
28 * Unlike "populate-popup" this signal is emitted for
29@@ -141,20 +143,39 @@
30 * KatzeArrayAction::activate-item:
31 * @array: the object on which the signal is emitted
32 * @item: the item being activated
33- *
34- * An item was clicked with the first button.
35- *
36- * Deprecated: 0.2.8: Use "activate-item-alt" instead.
37+ * @event: (allow-none): the event that caused the activation
38+ *
39+ * An item was activated.
40 **/
41 signals[ACTIVATE_ITEM] = g_signal_new ("activate-item",
42- G_TYPE_FROM_CLASS (class),
43- (GSignalFlags) (G_SIGNAL_RUN_LAST),
44- 0,
45- 0,
46- NULL,
47- g_cclosure_marshal_VOID__OBJECT,
48- G_TYPE_NONE, 1,
49- KATZE_TYPE_ITEM);
50+ G_TYPE_FROM_CLASS (class),
51+ (GSignalFlags) (G_SIGNAL_RUN_LAST),
52+ 0,
53+ 0,
54+ NULL,
55+ g_cclosure_marshal_VOID__OBJECT,
56+ G_TYPE_NONE, 1,
57+ KATZE_TYPE_ITEM);
58+
59+ /**
60+ * KatzeArrayAction::activate-item-new-tab:
61+ * @array: the object on which the signal is emitted
62+ * @item: the item being activated
63+ * @event: (allow-none): the event that caused the activation
64+ *
65+ * An item was activated and should be opened in a new tab.
66+ *
67+ * Since: 0.6.0
68+ **/
69+ signals[ACTIVATE_ITEM_NEW_TAB] = g_signal_new ("activate-item-new-tab",
70+ G_TYPE_FROM_CLASS (class),
71+ (GSignalFlags) (G_SIGNAL_RUN_LAST),
72+ 0,
73+ 0,
74+ NULL,
75+ g_cclosure_marshal_VOID__OBJECT,
76+ G_TYPE_NONE, 1,
77+ KATZE_TYPE_ITEM);
78
79 /**
80 * KatzeArrayAction::activate-item-alt:
81@@ -163,10 +184,9 @@
82 * @item: the item being activated
83 * @event: the mouse button pressed event
84 *
85- * An item was clicked, with the specified @button.
86+ * The specified @button has been pressed (but not yet released) on the item.
87 *
88- * Return value: %TRUE if the event was handled. If %FALSE is returned,
89- * the default "activate-item" signal is emitted.
90+ * Return value: %TRUE if the event was handled.
91 **/
92 signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt",
93 G_TYPE_FROM_CLASS (class),
94@@ -291,6 +311,13 @@
95 g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item);
96 }
97
98+static void
99+katze_array_action_activate_item_new_tab (KatzeArrayAction* action,
100+ KatzeItem* item)
101+{
102+ g_signal_emit (action, signals[ACTIVATE_ITEM_NEW_TAB], 0, item);
103+}
104+
105 static gboolean
106 katze_array_action_activate_item_alt (KatzeArrayAction* action,
107 KatzeItem* item,
108@@ -309,9 +336,6 @@
109 g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,
110 proxy, event, &handled);
111
112- if (!handled)
113- katze_array_action_activate_item (action, item);
114-
115 return handled;
116 }
117
118@@ -321,7 +345,15 @@
119 {
120 KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
121
122- katze_array_action_activate_item (array_action, item);
123+ GdkEvent* event = gtk_get_current_event();
124+
125+ if (event && MIDORI_EVENT_NEW_TAB (event))
126+ katze_array_action_activate_item_new_tab (array_action, item);
127+ else
128+ katze_array_action_activate_item (array_action, item);
129+
130+ if (event)
131+ gdk_event_free (event);
132 }
133
134 static gboolean
135@@ -339,8 +371,8 @@
136 GdkEventButton* event,
137 KatzeArrayAction* array_action)
138 {
139- /* Take precedence over menu button-press-event handling to avoid
140- menu item activation and menu disparition for popup opening
141+ /* Override the button-press handler for menus which would
142+ open a submenu to instead show a popup menu
143 */
144
145 return katze_array_action_menu_item_button_press_cb (gtk_get_event_widget ((GdkEvent *) event), event, array_action);
146@@ -354,7 +386,7 @@
147 GtkWidget* toolitem = gtk_widget_get_parent (proxy);
148 KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
149
150- /* let the 'clicked' signal be processed normally */
151+ /* Left button clicks (e.g. for activation) should not be handled until button release */
152 if (event->button == 1)
153 return FALSE;
154
155@@ -383,6 +415,7 @@
156 {
157 GtkWidget* submenu = gtk_menu_new ();
158 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
159+ /* Handle popup menus on menuitems which have open submenus */
160 g_signal_connect (submenu, "button-press-event",
161 G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
162 g_signal_connect (menuitem, "select",
163@@ -392,11 +425,14 @@
164 }
165 else
166 {
167- /* we need the 'activate' signal as well for keyboard events */
168+ /* We need the 'activate' signal for actual item activation */
169 g_signal_connect (menuitem, "activate",
170 G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
171 }
172
173+ /* Connect to button-press-event to catch right-clicks to open popup menus.
174+ Note that this is also necessary for menuitems which have submenus
175+ but whose submenus are not open at present! */
176 g_signal_connect (menuitem, "button-press-event",
177 G_CALLBACK (katze_array_action_menu_item_button_press_cb), array_action);
178
179@@ -550,12 +586,6 @@
180 return;
181 }
182
183- if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array))
184- {
185- katze_array_action_activate_item (array_action, KATZE_ITEM (array));
186- return;
187- }
188-
189 menu = gtk_menu_new ();
190 gtk_menu_attach_to_widget (GTK_MENU (menu), proxy, NULL);
191
192
193=== modified file 'midori/midori-browser.c'
194--- midori/midori-browser.c 2015-03-15 18:00:54 +0000
195+++ midori/midori-browser.c 2015-03-23 20:01:00 +0000
196@@ -3139,12 +3139,21 @@
197 KatzeItem* item,
198 MidoriBrowser* browser);
199
200-static gboolean
201-midori_bookmarkbar_activate_item (GtkAction* action,
202- KatzeItem* item,
203+static void
204+midori_bookmarkbar_activate_item (GtkAction* action,
205+ KatzeItem* item,
206 MidoriBrowser* browser)
207 {
208- return midori_browser_open_bookmark (browser, item);;
209+ midori_browser_open_bookmark (browser, item);
210+}
211+
212+static void
213+midori_bookmarkbar_activate_item_new_tab (GtkAction* action,
214+ KatzeItem* item,
215+ MidoriBrowser* browser)
216+{
217+ GtkWidget* view = midori_browser_add_item (browser, item);
218+ midori_browser_set_current_tab_smartly (browser, view);
219 }
220
221 static gboolean
222@@ -3156,19 +3165,10 @@
223 {
224 g_assert (event);
225
226- if (MIDORI_EVENT_NEW_TAB (event))
227- {
228- GtkWidget* view = midori_browser_add_item (browser, item);
229- midori_browser_set_current_tab_smartly (browser, view);
230- }
231- else if (MIDORI_EVENT_CONTEXT_MENU (event))
232+ if (MIDORI_EVENT_CONTEXT_MENU (event))
233 {
234 midori_browser_bookmark_popup (proxy, NULL, item, browser);
235 }
236- else if (event->button == 1)
237- {
238- midori_bookmarkbar_activate_item (action, item, browser);
239- }
240
241 return TRUE;
242 }
243@@ -3203,27 +3203,22 @@
244 return view;
245 }
246
247-static gboolean
248-_action_trash_activate_item_alt (GtkAction* action,
249- KatzeItem* item,
250- GtkWidget* proxy,
251- GdkEventButton* event,
252- MidoriBrowser* browser)
253-{
254- g_assert (event);
255-
256- if (MIDORI_EVENT_NEW_TAB (event))
257- {
258- midori_browser_set_current_tab_smartly (browser,
259- midori_browser_restore_tab (browser, item));
260- }
261- else if (event->button == 1)
262- {
263- midori_browser_set_current_tab (browser,
264- midori_browser_restore_tab (browser, item));
265- }
266-
267- return TRUE;
268+static void
269+_action_trash_activate_item (GtkAction* action,
270+ KatzeItem* item,
271+ MidoriBrowser* browser)
272+{
273+ midori_browser_set_current_tab (browser,
274+ midori_browser_restore_tab (browser, item));
275+}
276+
277+static void
278+_action_trash_activate_item_new_tab (GtkAction* action,
279+ KatzeItem* item,
280+ MidoriBrowser* browser)
281+{
282+ midori_browser_set_current_tab_smartly (browser,
283+ midori_browser_restore_tab (browser, item));
284 }
285
286 /* static */ gboolean
287@@ -3339,11 +3334,9 @@
288 }
289
290 static void
291-_action_window_activate_item_alt (GtkAction* action,
292- KatzeItem* item,
293- GtkWidget* proxy,
294- GdkEventButton* event,
295- MidoriBrowser* browser)
296+_action_window_activate_item (GtkAction* action,
297+ KatzeItem* item,
298+ MidoriBrowser* browser)
299 {
300 midori_browser_set_current_item (browser, item);
301 }
302@@ -6038,8 +6031,10 @@
303 g_object_connect (action,
304 "signal::populate-popup",
305 _action_trash_populate_popup, browser,
306- "signal::activate-item-alt",
307- _action_trash_activate_item_alt, browser,
308+ "signal::activate-item",
309+ _action_trash_activate_item, browser,
310+ "signal::activate-item-new-tab",
311+ _action_trash_activate_item_new_tab, browser,
312 NULL);
313 gtk_action_group_add_action_with_accel (browser->action_group, action, "");
314 g_object_unref (action);
315@@ -6060,6 +6055,8 @@
316 midori_bookmarkbar_activate_item_alt, browser,
317 "signal::activate-item",
318 midori_bookmarkbar_activate_item, browser,
319+ "signal::activate-item-new-tab",
320+ midori_bookmarkbar_activate_item_new_tab, browser,
321 NULL);
322 gtk_action_group_add_action_with_accel (browser->action_group, action, "");
323 g_object_unref (action);
324@@ -6091,8 +6088,11 @@
325 g_object_connect (action,
326 "signal::populate-popup",
327 _action_window_populate_popup, browser,
328- "signal::activate-item-alt",
329- _action_window_activate_item_alt, browser,
330+ "signal::activate-item",
331+ _action_window_activate_item, browser,
332+ /* middle-clicks on tab menu entries behave like left-clicks */
333+ "signal::activate-item-new-tab",
334+ _action_window_activate_item, browser,
335 NULL);
336 gtk_action_group_add_action_with_accel (browser->action_group, action, "");
337 g_object_unref (action);

Subscribers

People subscribed via source and target branches

to all changes: