Merge lp:~aauzi/midori/fix-1184716 into lp:midori

Proposed by André Auzi
Status: Superseded
Proposed branch: lp:~aauzi/midori/fix-1184716
Merge into: lp:midori
Diff against target: 619 lines (+276/-126)
3 files modified
katze/katze-arrayaction.c (+228/-77)
midori/marshal.list (+1/-0)
midori/midori-browser.c (+47/-49)
To merge this branch: bzr merge lp:~aauzi/midori/fix-1184716
Reviewer Review Type Date Requested Status
Midori Devs Pending
Review via email: mp+166146@code.launchpad.net

This proposal has been superseded by a proposal from 2013-09-28.

Description of the change

(For review: doesn't depend on other branches)

To post a comment you must log in.
lp:~aauzi/midori/fix-1184716 updated
6178. By André Auzi

merge lp:midori

6179. By André Auzi

merge lp:midori

6180. By André Auzi

fix most anoying weird menu behaviors when activating the context popup

6181. By André Auzi

merge lp:midori

6182. By André Auzi

merge lp:midori

6183. By André Auzi

merge lp:midori

6184. By André Auzi

merge lp:midori and build with Gtk3

6185. By André Auzi

simplify things by an straight forward evolution of activate-item-alt

6186. By André Auzi

select correct marshalling and update comment

Unmerged revisions

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 2012-12-16 18:40:00 +0000
3+++ katze/katze-arrayaction.c 2013-09-28 15:27:18 +0000
4@@ -52,6 +52,7 @@
5 POPULATE_FOLDER,
6 ACTIVATE_ITEM,
7 ACTIVATE_ITEM_ALT,
8+ ACTIVATE_ITEM_FULL,
9 LAST_SIGNAL
10 };
11
12@@ -167,7 +168,7 @@
13 * Return value: %TRUE if the event was handled. If %FALSE is returned,
14 * the default "activate-item" signal is emitted.
15 *
16- * Since: 0.1.7
17+ * Deprecated: 0.5.2: Use "activate-item-full" instead.
18 **/
19 signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt",
20 G_TYPE_FROM_CLASS (class),
21@@ -179,6 +180,34 @@
22 G_TYPE_BOOLEAN, 2,
23 KATZE_TYPE_ITEM, G_TYPE_UINT);
24
25+ /**
26+ * KatzeArrayAction::activate-item-full:
27+ * @array: the object on which the signal is emitted
28+ * @item: the item being activated
29+ * @event: the %GdkButtonEvent pressed
30+ * @proxy: the %GtkWidget that caught the event
31+ *
32+ * An item was clicked, with the specified @button.
33+ *
34+ * Return value: %TRUE if the event was handled. If %FALSE is returned,
35+ * the default "activate-item-alt" signal is emitted. If
36+ * "activate-item-alt" is not handled on its turn, the
37+ * "activate-item" signal is finally emitted.
38+ *
39+ * Since: 0.5.2
40+ **/
41+ signals[ACTIVATE_ITEM_FULL] = g_signal_new ("activate-item-full",
42+ G_TYPE_FROM_CLASS (class),
43+ (GSignalFlags) (G_SIGNAL_RUN_LAST),
44+ 0,
45+ 0,
46+ NULL,
47+ midori_cclosure_marshal_BOOLEAN__OBJECT_POINTER_OBJECT,
48+ G_TYPE_BOOLEAN, 3,
49+ KATZE_TYPE_ITEM,
50+ GDK_TYPE_EVENT,
51+ GTK_TYPE_WIDGET);
52+
53 gobject_class = G_OBJECT_CLASS (class);
54 gobject_class->finalize = katze_array_action_finalize;
55 gobject_class->set_property = katze_array_action_set_property;
56@@ -285,16 +314,76 @@
57 GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
58 }
59
60-static void
61+static gboolean
62 katze_array_action_activate_item (KatzeArrayAction* action,
63 KatzeItem* item,
64- gint button)
65+ GdkEventButton* event,
66+ GtkWidget* proxy)
67 {
68+ /* katze_array_action_activate_item emits the signal.
69+ * It can result from "clicked" event where the button event
70+ * is not provided.
71+ * We need to check if the current event is usable.
72+ * If it's not we just synthetize a usable button event.
73+ */
74+
75+ gboolean free_event = FALSE;
76 gboolean handled = FALSE;
77- g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,
78- button, &handled);
79+
80+ if (!event)
81+ {
82+ event = (GdkEventButton*)gtk_get_current_event ();
83+ if (event->type != GDK_BUTTON_PRESS)
84+ {
85+ gdk_event_free ((GdkEvent*)event);
86+ event = NULL;
87+ }
88+ else
89+ free_event = TRUE;
90+ }
91+
92+ if (!event)
93+ { /* Simulate a button 1 press event */
94+ gint x;
95+ gint y;
96+ gint x_root;
97+ gint y_root;
98+
99+ free_event = TRUE;
100+ event = (GdkEventButton*)gdk_event_new (GDK_BUTTON_PRESS);
101+ event->type = GDK_BUTTON_PRESS;
102+ event->window = proxy->window;
103+ event->send_event = FALSE;
104+ event->time = gtk_get_current_event_time();
105+ gdk_window_get_pointer (proxy->window,
106+ &x, &y,
107+ NULL);
108+ event->x = x;
109+ event->y = y;
110+ gtk_get_current_event_state (&event->state);
111+
112+ event->button = 1;
113+ event->device = NULL; /* FIXME: find the mouse device */
114+ gdk_window_get_root_coords (proxy->window,
115+ x, y,
116+ &x_root,
117+ &y_root);
118+ event->x_root = x_root;
119+ event->y_root = y_root;
120+ }
121+
122+ g_signal_emit (action, signals[ACTIVATE_ITEM_FULL], 0, item,
123+ event, proxy, &handled);
124+ if (!handled)
125+ g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,
126+ event->button, &handled);
127 if (!handled)
128 g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item);
129+
130+ if (free_event)
131+ gdk_event_free ((GdkEvent*)event);
132+
133+ return handled;
134 }
135
136 static void
137@@ -302,7 +391,46 @@
138 KatzeArrayAction* array_action)
139 {
140 KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
141- katze_array_action_activate_item (array_action, item, 1);
142+
143+ katze_array_action_activate_item (array_action, item, NULL, proxy);
144+}
145+
146+static gboolean
147+katze_array_action_menu_item_button_press_cb (GtkWidget* proxy,
148+ GdkEventButton* event,
149+ KatzeArrayAction* array_action)
150+{
151+ KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
152+
153+ return katze_array_action_activate_item (array_action, item, event, proxy);
154+}
155+
156+static gboolean
157+pointer_in_menu_window (GtkWidget *widget,
158+ gdouble x_root,
159+ gdouble y_root)
160+{
161+ GtkMenu *menu = GTK_MENU (widget);
162+
163+ if (gtk_widget_get_mapped (menu->toplevel))
164+ {
165+ GtkMenuShell *menu_shell;
166+ gint window_x, window_y;
167+
168+ gdk_window_get_position (menu->toplevel->window, &window_x, &window_y);
169+
170+ if (x_root >= window_x && x_root < window_x + widget->allocation.width &&
171+ y_root >= window_y && y_root < window_y + widget->allocation.height)
172+ return TRUE;
173+
174+ menu_shell = GTK_MENU_SHELL (widget);
175+
176+ if (GTK_IS_MENU (menu_shell->parent_menu_shell))
177+ return pointer_in_menu_window (menu_shell->parent_menu_shell,
178+ x_root, y_root);
179+ }
180+
181+ return FALSE;
182 }
183
184 static gboolean
185@@ -310,22 +438,74 @@
186 GdkEventButton* event,
187 KatzeArrayAction* array_action)
188 {
189- KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
190-
191- katze_array_action_activate_item (array_action, item, event->button);
192-
193- /* we need to block the 'activate' handler which would be called
194- * otherwise as well */
195- g_signal_handlers_block_by_func (proxy,
196- katze_array_action_menu_activate_cb, array_action);
197-
198- return TRUE;
199+ /* Take precedence over menu button-press-event handling to avoid
200+ menu item activation and menu disparition for popup opening
201+ */
202+
203+ if (GTK_IS_MENU_SHELL (gtk_get_event_widget ((GdkEvent *) event)) &&
204+ pointer_in_menu_window (proxy, event->x_root, event->y_root))
205+ return FALSE;
206+
207+ return katze_array_action_menu_item_button_press_cb (gtk_get_event_widget ((GdkEvent *) event), event, array_action);
208+}
209+
210+static gboolean
211+katze_array_action_tool_item_child_button_press_cb (GtkWidget* proxy,
212+ GdkEventButton* event,
213+ KatzeArrayAction* array_action)
214+{
215+ GtkWidget* toolitem = proxy->parent;
216+ KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
217+
218+ /* let the 'clicked' signal be processed normally */
219+ if (event->button == 1)
220+ return FALSE;
221+
222+ return katze_array_action_activate_item (array_action, item, event, proxy);
223 }
224
225 static void
226 katze_array_action_menu_item_select_cb (GtkWidget* proxy,
227 KatzeArrayAction* array_action);
228
229+static GtkWidget*
230+katze_array_action_menu_item_new (KatzeArrayAction* array_action,
231+ KatzeItem* item)
232+{
233+ GtkWidget* menuitem = katze_image_menu_item_new_ellipsized (
234+ katze_item_get_name (item));
235+ GtkWidget* image = katze_item_get_image (item, menuitem);
236+
237+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
238+ gtk_image_menu_item_set_always_show_image (
239+ GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
240+
241+ g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
242+
243+ if (KATZE_ITEM_IS_FOLDER (item))
244+ {
245+ GtkWidget* submenu = gtk_menu_new ();
246+ gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
247+ g_signal_connect (submenu, "button-press-event",
248+ G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
249+ g_signal_connect (menuitem, "select",
250+ G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
251+ g_signal_connect (menuitem, "activate",
252+ G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
253+ }
254+ else
255+ {
256+ /* we need the 'activate' signal as well for keyboard events */
257+ g_signal_connect (menuitem, "activate",
258+ G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
259+ }
260+
261+ g_signal_connect (menuitem, "button-press-event",
262+ G_CALLBACK (katze_array_action_menu_item_button_press_cb), array_action);
263+
264+ return menuitem;
265+}
266+
267 /**
268 * katze_array_action_generate_menu:
269 * @array_action: a #KatzeArrayAction
270@@ -355,15 +535,13 @@
271 gint summand;
272 KatzeItem* item;
273 GtkWidget* menuitem;
274- GtkWidget* image;
275- GtkWidget* submenu;
276
277 g_return_if_fail (KATZE_IS_ARRAY_ACTION (array_action));
278 g_return_if_fail (KATZE_IS_ITEM (array));
279 g_return_if_fail (GTK_IS_MENU_SHELL (menu));
280 g_return_if_fail (GTK_IS_TOOL_ITEM (proxy)
281- || GTK_IS_MENU_ITEM (proxy)
282- || GTK_IS_WINDOW (proxy));
283+ || GTK_IS_MENU_ITEM (proxy)
284+ || GTK_IS_WINDOW (proxy));
285
286 if (!KATZE_IS_ARRAY (array))
287 return;
288@@ -388,35 +566,19 @@
289 gtk_menu_shell_append (menu, menuitem);
290 continue;
291 }
292- menuitem = katze_image_menu_item_new_ellipsized (
293- katze_item_get_name (item));
294- image = katze_item_get_image (item, menuitem);
295- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
296- gtk_image_menu_item_set_always_show_image (
297- GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
298- gtk_menu_shell_append (menu, menuitem);
299- g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
300+
301+ menuitem = katze_array_action_menu_item_new (array_action, item);
302+
303 if (KATZE_ITEM_IS_FOLDER (item))
304 {
305- submenu = gtk_menu_new ();
306- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
307+ GtkWidget* submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem));
308 /* Make sure menu appears to contain items */
309 gtk_menu_shell_append (GTK_MENU_SHELL (submenu),
310 gtk_separator_menu_item_new ());
311- g_signal_connect (menuitem, "select",
312- G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
313- g_signal_connect (menuitem, "activate",
314- G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
315- }
316- else
317- {
318- /* we need the 'activate' signal as well for keyboard events */
319- g_signal_connect (menuitem, "activate",
320- G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
321- }
322- g_signal_connect (menuitem, "button-press-event",
323- G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
324+ }
325+
326 gtk_widget_show (menuitem);
327+ gtk_menu_shell_append (menu, menuitem);
328 }
329 }
330
331@@ -444,7 +606,7 @@
332 katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy);
333 g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);
334 g_object_set_data (G_OBJECT (proxy), "last-update",
335- GINT_TO_POINTER (time (NULL)));
336+ GINT_TO_POINTER (time (NULL)));
337 return TRUE;
338 }
339
340@@ -476,13 +638,14 @@
341 gboolean handled = FALSE;
342
343 array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeItem");
344+
345 if (GTK_IS_MENU_ITEM (proxy))
346 {
347 if (katze_array_action_menu_item_need_update (array_action, proxy))
348 {
349 g_signal_emit (array_action, signals[POPULATE_FOLDER], 0,
350- gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)),
351- array, &handled);
352+ gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)),
353+ array, &handled);
354 if (!handled)
355 g_signal_emit (array_action, signals[POPULATE_POPUP], 0,
356 gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)));
357@@ -492,7 +655,7 @@
358
359 if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array))
360 {
361- katze_array_action_activate_item (array_action, KATZE_ITEM (array), 1);
362+ katze_array_action_activate_item (array_action, KATZE_ITEM (array), NULL, proxy);
363 return;
364 }
365
366@@ -512,7 +675,7 @@
367 }
368
369 katze_widget_popup (GTK_WIDGET (proxy), GTK_MENU (menu),
370- NULL, KATZE_MENU_POSITION_LEFT);
371+ NULL, KATZE_MENU_POSITION_LEFT);
372 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE);
373 g_object_set_data (G_OBJECT (menu), "KatzeArrayAction", array_action);
374 g_signal_connect (menu, "deactivate",
375@@ -606,31 +769,9 @@
376 {
377 KatzeArrayAction* array_action;
378 GtkWidget* menuitem;
379- GtkWidget* image;
380
381 array_action = g_object_get_data (G_OBJECT (proxy), "KatzeArrayAction");
382- menuitem = katze_image_menu_item_new_ellipsized (
383- katze_item_get_name (item));
384- image = katze_item_get_image (item, menuitem);
385- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
386- gtk_image_menu_item_set_always_show_image (
387- GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
388- g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
389- if (KATZE_ITEM_IS_FOLDER (item))
390- {
391- GtkWidget* submenu = gtk_menu_new ();
392- gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
393- g_signal_connect (menuitem, "select",
394- G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
395- }
396- else
397- {
398- g_signal_connect (menuitem, "button-press-event",
399- G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
400- /* we need the 'activate' signal as well for keyboard events */
401- g_signal_connect (menuitem, "activate",
402- G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
403- }
404+ menuitem = katze_array_action_menu_item_new (array_action, item);
405 gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (proxy),
406 "katze-tool-item-menu", menuitem);
407 return TRUE;
408@@ -706,9 +847,19 @@
409 else
410 gtk_tool_item_set_tooltip_text (toolitem, uri);
411
412- g_object_set_data (G_OBJECT (toolitem), "KatzeArray", item);
413+ g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
414 g_signal_connect (toolitem, "clicked",
415 G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);
416+ if (KATZE_IS_ITEM (item))
417+ {
418+ /* Tool items block the "button-press-event" but we can get it
419+ * when connecting it to the tool item's child widget
420+ */
421+
422+ GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
423+ g_signal_connect (child, "button-press-event",
424+ G_CALLBACK (katze_array_action_tool_item_child_button_press_cb), array_action);
425+ }
426
427 g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action);
428 g_signal_connect (item, "notify",
429@@ -779,11 +930,11 @@
430
431 /* FIXME: Add and remove items dynamically */
432 /*g_object_connect (array,
433- "signal-after::add-item",
434- katze_array_action_engines_add_item_cb, array_action,
435- "signal-after::remove-item",
436- katze_array_action_engines_remove_item_cb, array_action,
437- NULL);*/
438+ "signal-after::add-item",
439+ katze_array_action_engines_add_item_cb, array_action,
440+ "signal-after::remove-item",
441+ katze_array_action_engines_remove_item_cb, array_action,
442+ NULL);*/
443
444 g_object_notify (G_OBJECT (array_action), "array");
445
446
447=== modified file 'midori/marshal.list'
448--- midori/marshal.list 2013-09-03 14:45:17 +0000
449+++ midori/marshal.list 2013-09-28 15:27:18 +0000
450@@ -1,6 +1,7 @@
451 BOOLEAN:OBJECT
452 BOOLEAN:OBJECT,OBJECT
453 BOOLEAN:OBJECT,UINT
454+BOOLEAN:OBJECT,POINTER,OBJECT
455 BOOLEAN:VOID
456 BOOLEAN:STRING
457 OBJECT:OBJECT
458
459=== modified file 'midori/midori-browser.c'
460--- midori/midori-browser.c 2013-09-17 19:34:23 +0000
461+++ midori/midori-browser.c 2013-09-28 15:27:18 +0000
462@@ -3124,18 +3124,31 @@
463 return TRUE;
464 }
465
466+static void
467+midori_browser_bookmark_popup (GtkWidget* proxy,
468+ GdkEventButton* event,
469+ KatzeItem* item,
470+ MidoriBrowser* browser);
471+
472 static gboolean
473-midori_bookmarkbar_activate_item_alt (GtkAction* action,
474- KatzeItem* item,
475- guint button,
476- MidoriBrowser* browser)
477+midori_bookmarkbar_activate_item_full (GtkAction* action,
478+ KatzeItem* item,
479+ GdkEventButton* event,
480+ GtkWidget* proxy,
481+ MidoriBrowser* browser)
482 {
483- if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ()))
484+ g_assert (event);
485+
486+ if (MIDORI_EVENT_NEW_TAB (event))
487 {
488 GtkWidget* view = midori_browser_add_item (browser, item);
489 midori_browser_set_current_tab_smartly (browser, view);
490 }
491- else if (button == 1)
492+ else if (MIDORI_EVENT_CONTEXT_MENU (event))
493+ {
494+ midori_browser_bookmark_popup (proxy, NULL, item, browser);
495+ }
496+ else if (event->button == 1)
497 {
498 midori_browser_open_bookmark (browser, item);
499 }
500@@ -3240,12 +3253,6 @@
501 midori_context_action_create_menu (menu, default_menu, TRUE);
502 }
503
504-static void
505-midori_browser_bookmark_popup (GtkWidget* widget,
506- GdkEventButton* event,
507- KatzeItem* item,
508- MidoriBrowser* browser);
509-
510 static gboolean
511 _action_bookmarks_populate_folder (GtkAction* action,
512 GtkMenuShell* menu,
513@@ -4373,6 +4380,9 @@
514 it is an item, we forward it to the actual widget. */
515 if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem)))
516 {
517+ if (toolitem->window != event->window)
518+ return FALSE;
519+
520 midori_browser_toolbar_popup_context_menu_cb (
521 GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
522 gtk_widget_get_parent (toolitem) : toolitem,
523@@ -6202,8 +6212,8 @@
524 g_object_connect (action,
525 "signal::populate-folder",
526 _action_bookmarks_populate_folder, browser,
527- "signal::activate-item-alt",
528- midori_bookmarkbar_activate_item_alt, browser,
529+ "signal::activate-item-full",
530+ midori_bookmarkbar_activate_item_full, browser,
531 NULL);
532 gtk_action_group_add_action_with_accel (browser->action_group, action, "");
533 g_object_unref (action);
534@@ -6220,8 +6230,6 @@
535 g_object_connect (action,
536 "signal::populate-popup",
537 _action_tools_populate_popup, browser,
538- "signal::activate-item-alt",
539- midori_bookmarkbar_activate_item_alt, browser,
540 NULL);
541 gtk_action_group_add_action (browser->action_group, action);
542 g_object_unref (action);
543@@ -6989,29 +6997,6 @@
544 g_value_unset (&value);
545 }
546
547-static gboolean
548-midori_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem,
549- GdkEventButton* event,
550- MidoriBrowser* browser)
551-{
552- KatzeItem* item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
553- if (MIDORI_EVENT_NEW_TAB (event))
554- {
555- if (KATZE_ITEM_IS_BOOKMARK (item))
556- {
557- GtkWidget* view = midori_browser_add_uri (browser, katze_item_get_uri (item));
558- midori_browser_set_current_tab_smartly (browser, view);
559- return TRUE;
560- }
561- }
562- else if (MIDORI_EVENT_CONTEXT_MENU (event))
563- {
564- midori_browser_bookmark_popup (toolitem, NULL, item, browser);
565- return TRUE;
566- }
567- return FALSE;
568-}
569-
570 static void
571 midori_bookmarkbar_insert_item (GtkWidget* toolbar,
572 KatzeItem* item)
573@@ -7022,15 +7007,7 @@
574 KATZE_ARRAY_ACTION (action), item);
575 g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
576
577- if (KATZE_IS_ITEM (item))
578- {
579- GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
580- g_object_set_data (G_OBJECT (child), "KatzeItem", item);
581- g_signal_connect (child, "button-press-event",
582- G_CALLBACK (midori_bookmarkbar_item_button_press_event_cb),
583- browser);
584- }
585- else /* Separator */
586+ if (!KATZE_IS_ITEM (item)) /* Separator */
587 gtk_tool_item_set_use_drag_window (toolitem, TRUE);
588
589 gtk_widget_show (GTK_WIDGET (toolitem));
590@@ -7899,7 +7876,28 @@
591
592 browser = gtk_window_get_transient_for (GTK_WINDOW (browser));
593 if (!MIDORI_IS_BROWSER (browser))
594- return NULL;
595+ {
596+ /* For some reason, when called on the wiget of the
597+ * application menubar we get here.
598+ */
599+
600+ GList* top_levels = gtk_window_list_toplevels ();
601+ GList *iter;
602+
603+ for (iter = top_levels; iter; iter = g_list_next (iter))
604+ {
605+ browser = iter->data;
606+
607+ if (MIDORI_IS_BROWSER (browser))
608+ {
609+ g_list_free (top_levels);
610+ return MIDORI_BROWSER (browser);
611+ }
612+ }
613+
614+ g_list_free (top_levels);
615+ return NULL;
616+ }
617 }
618
619 return MIDORI_BROWSER (browser);

Subscribers

People subscribed via source and target branches

to all changes: