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
=== modified file 'katze/katze-arrayaction.c'
--- katze/katze-arrayaction.c 2012-12-16 18:40:00 +0000
+++ katze/katze-arrayaction.c 2013-09-28 15:27:18 +0000
@@ -52,6 +52,7 @@
52 POPULATE_FOLDER,52 POPULATE_FOLDER,
53 ACTIVATE_ITEM,53 ACTIVATE_ITEM,
54 ACTIVATE_ITEM_ALT,54 ACTIVATE_ITEM_ALT,
55 ACTIVATE_ITEM_FULL,
55 LAST_SIGNAL56 LAST_SIGNAL
56};57};
5758
@@ -167,7 +168,7 @@
167 * Return value: %TRUE if the event was handled. If %FALSE is returned,168 * Return value: %TRUE if the event was handled. If %FALSE is returned,
168 * the default "activate-item" signal is emitted.169 * the default "activate-item" signal is emitted.
169 *170 *
170 * Since: 0.1.7171 * Deprecated: 0.5.2: Use "activate-item-full" instead.
171 **/172 **/
172 signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt",173 signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt",
173 G_TYPE_FROM_CLASS (class),174 G_TYPE_FROM_CLASS (class),
@@ -179,6 +180,34 @@
179 G_TYPE_BOOLEAN, 2,180 G_TYPE_BOOLEAN, 2,
180 KATZE_TYPE_ITEM, G_TYPE_UINT);181 KATZE_TYPE_ITEM, G_TYPE_UINT);
181182
183 /**
184 * KatzeArrayAction::activate-item-full:
185 * @array: the object on which the signal is emitted
186 * @item: the item being activated
187 * @event: the %GdkButtonEvent pressed
188 * @proxy: the %GtkWidget that caught the event
189 *
190 * An item was clicked, with the specified @button.
191 *
192 * Return value: %TRUE if the event was handled. If %FALSE is returned,
193 * the default "activate-item-alt" signal is emitted. If
194 * "activate-item-alt" is not handled on its turn, the
195 * "activate-item" signal is finally emitted.
196 *
197 * Since: 0.5.2
198 **/
199 signals[ACTIVATE_ITEM_FULL] = g_signal_new ("activate-item-full",
200 G_TYPE_FROM_CLASS (class),
201 (GSignalFlags) (G_SIGNAL_RUN_LAST),
202 0,
203 0,
204 NULL,
205 midori_cclosure_marshal_BOOLEAN__OBJECT_POINTER_OBJECT,
206 G_TYPE_BOOLEAN, 3,
207 KATZE_TYPE_ITEM,
208 GDK_TYPE_EVENT,
209 GTK_TYPE_WIDGET);
210
182 gobject_class = G_OBJECT_CLASS (class);211 gobject_class = G_OBJECT_CLASS (class);
183 gobject_class->finalize = katze_array_action_finalize;212 gobject_class->finalize = katze_array_action_finalize;
184 gobject_class->set_property = katze_array_action_set_property;213 gobject_class->set_property = katze_array_action_set_property;
@@ -285,16 +314,76 @@
285 GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);314 GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
286}315}
287316
288static void317static gboolean
289katze_array_action_activate_item (KatzeArrayAction* action,318katze_array_action_activate_item (KatzeArrayAction* action,
290 KatzeItem* item,319 KatzeItem* item,
291 gint button)320 GdkEventButton* event,
321 GtkWidget* proxy)
292{322{
323 /* katze_array_action_activate_item emits the signal.
324 * It can result from "clicked" event where the button event
325 * is not provided.
326 * We need to check if the current event is usable.
327 * If it's not we just synthetize a usable button event.
328 */
329
330 gboolean free_event = FALSE;
293 gboolean handled = FALSE;331 gboolean handled = FALSE;
294 g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,332
295 button, &handled);333 if (!event)
334 {
335 event = (GdkEventButton*)gtk_get_current_event ();
336 if (event->type != GDK_BUTTON_PRESS)
337 {
338 gdk_event_free ((GdkEvent*)event);
339 event = NULL;
340 }
341 else
342 free_event = TRUE;
343 }
344
345 if (!event)
346 { /* Simulate a button 1 press event */
347 gint x;
348 gint y;
349 gint x_root;
350 gint y_root;
351
352 free_event = TRUE;
353 event = (GdkEventButton*)gdk_event_new (GDK_BUTTON_PRESS);
354 event->type = GDK_BUTTON_PRESS;
355 event->window = proxy->window;
356 event->send_event = FALSE;
357 event->time = gtk_get_current_event_time();
358 gdk_window_get_pointer (proxy->window,
359 &x, &y,
360 NULL);
361 event->x = x;
362 event->y = y;
363 gtk_get_current_event_state (&event->state);
364
365 event->button = 1;
366 event->device = NULL; /* FIXME: find the mouse device */
367 gdk_window_get_root_coords (proxy->window,
368 x, y,
369 &x_root,
370 &y_root);
371 event->x_root = x_root;
372 event->y_root = y_root;
373 }
374
375 g_signal_emit (action, signals[ACTIVATE_ITEM_FULL], 0, item,
376 event, proxy, &handled);
377 if (!handled)
378 g_signal_emit (action, signals[ACTIVATE_ITEM_ALT], 0, item,
379 event->button, &handled);
296 if (!handled)380 if (!handled)
297 g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item);381 g_signal_emit (action, signals[ACTIVATE_ITEM], 0, item);
382
383 if (free_event)
384 gdk_event_free ((GdkEvent*)event);
385
386 return handled;
298}387}
299388
300static void389static void
@@ -302,7 +391,46 @@
302 KatzeArrayAction* array_action)391 KatzeArrayAction* array_action)
303{392{
304 KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");393 KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
305 katze_array_action_activate_item (array_action, item, 1);394
395 katze_array_action_activate_item (array_action, item, NULL, proxy);
396}
397
398static gboolean
399katze_array_action_menu_item_button_press_cb (GtkWidget* proxy,
400 GdkEventButton* event,
401 KatzeArrayAction* array_action)
402{
403 KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
404
405 return katze_array_action_activate_item (array_action, item, event, proxy);
406}
407
408static gboolean
409pointer_in_menu_window (GtkWidget *widget,
410 gdouble x_root,
411 gdouble y_root)
412{
413 GtkMenu *menu = GTK_MENU (widget);
414
415 if (gtk_widget_get_mapped (menu->toplevel))
416 {
417 GtkMenuShell *menu_shell;
418 gint window_x, window_y;
419
420 gdk_window_get_position (menu->toplevel->window, &window_x, &window_y);
421
422 if (x_root >= window_x && x_root < window_x + widget->allocation.width &&
423 y_root >= window_y && y_root < window_y + widget->allocation.height)
424 return TRUE;
425
426 menu_shell = GTK_MENU_SHELL (widget);
427
428 if (GTK_IS_MENU (menu_shell->parent_menu_shell))
429 return pointer_in_menu_window (menu_shell->parent_menu_shell,
430 x_root, y_root);
431 }
432
433 return FALSE;
306}434}
307435
308static gboolean436static gboolean
@@ -310,22 +438,74 @@
310 GdkEventButton* event,438 GdkEventButton* event,
311 KatzeArrayAction* array_action)439 KatzeArrayAction* array_action)
312{440{
313 KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");441 /* Take precedence over menu button-press-event handling to avoid
314442 menu item activation and menu disparition for popup opening
315 katze_array_action_activate_item (array_action, item, event->button);443 */
316444
317 /* we need to block the 'activate' handler which would be called445 if (GTK_IS_MENU_SHELL (gtk_get_event_widget ((GdkEvent *) event)) &&
318 * otherwise as well */446 pointer_in_menu_window (proxy, event->x_root, event->y_root))
319 g_signal_handlers_block_by_func (proxy,447 return FALSE;
320 katze_array_action_menu_activate_cb, array_action);448
321449 return katze_array_action_menu_item_button_press_cb (gtk_get_event_widget ((GdkEvent *) event), event, array_action);
322 return TRUE;450}
451
452static gboolean
453katze_array_action_tool_item_child_button_press_cb (GtkWidget* proxy,
454 GdkEventButton* event,
455 KatzeArrayAction* array_action)
456{
457 GtkWidget* toolitem = proxy->parent;
458 KatzeItem* item = g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
459
460 /* let the 'clicked' signal be processed normally */
461 if (event->button == 1)
462 return FALSE;
463
464 return katze_array_action_activate_item (array_action, item, event, proxy);
323}465}
324466
325static void467static void
326katze_array_action_menu_item_select_cb (GtkWidget* proxy,468katze_array_action_menu_item_select_cb (GtkWidget* proxy,
327 KatzeArrayAction* array_action);469 KatzeArrayAction* array_action);
328470
471static GtkWidget*
472katze_array_action_menu_item_new (KatzeArrayAction* array_action,
473 KatzeItem* item)
474{
475 GtkWidget* menuitem = katze_image_menu_item_new_ellipsized (
476 katze_item_get_name (item));
477 GtkWidget* image = katze_item_get_image (item, menuitem);
478
479 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
480 gtk_image_menu_item_set_always_show_image (
481 GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
482
483 g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
484
485 if (KATZE_ITEM_IS_FOLDER (item))
486 {
487 GtkWidget* submenu = gtk_menu_new ();
488 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
489 g_signal_connect (submenu, "button-press-event",
490 G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
491 g_signal_connect (menuitem, "select",
492 G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
493 g_signal_connect (menuitem, "activate",
494 G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
495 }
496 else
497 {
498 /* we need the 'activate' signal as well for keyboard events */
499 g_signal_connect (menuitem, "activate",
500 G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
501 }
502
503 g_signal_connect (menuitem, "button-press-event",
504 G_CALLBACK (katze_array_action_menu_item_button_press_cb), array_action);
505
506 return menuitem;
507}
508
329/**509/**
330 * katze_array_action_generate_menu:510 * katze_array_action_generate_menu:
331 * @array_action: a #KatzeArrayAction511 * @array_action: a #KatzeArrayAction
@@ -355,15 +535,13 @@
355 gint summand;535 gint summand;
356 KatzeItem* item;536 KatzeItem* item;
357 GtkWidget* menuitem;537 GtkWidget* menuitem;
358 GtkWidget* image;
359 GtkWidget* submenu;
360538
361 g_return_if_fail (KATZE_IS_ARRAY_ACTION (array_action));539 g_return_if_fail (KATZE_IS_ARRAY_ACTION (array_action));
362 g_return_if_fail (KATZE_IS_ITEM (array));540 g_return_if_fail (KATZE_IS_ITEM (array));
363 g_return_if_fail (GTK_IS_MENU_SHELL (menu));541 g_return_if_fail (GTK_IS_MENU_SHELL (menu));
364 g_return_if_fail (GTK_IS_TOOL_ITEM (proxy)542 g_return_if_fail (GTK_IS_TOOL_ITEM (proxy)
365 || GTK_IS_MENU_ITEM (proxy)543 || GTK_IS_MENU_ITEM (proxy)
366 || GTK_IS_WINDOW (proxy));544 || GTK_IS_WINDOW (proxy));
367545
368 if (!KATZE_IS_ARRAY (array))546 if (!KATZE_IS_ARRAY (array))
369 return;547 return;
@@ -388,35 +566,19 @@
388 gtk_menu_shell_append (menu, menuitem);566 gtk_menu_shell_append (menu, menuitem);
389 continue;567 continue;
390 }568 }
391 menuitem = katze_image_menu_item_new_ellipsized (569
392 katze_item_get_name (item));570 menuitem = katze_array_action_menu_item_new (array_action, item);
393 image = katze_item_get_image (item, menuitem);571
394 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
395 gtk_image_menu_item_set_always_show_image (
396 GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
397 gtk_menu_shell_append (menu, menuitem);
398 g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
399 if (KATZE_ITEM_IS_FOLDER (item))572 if (KATZE_ITEM_IS_FOLDER (item))
400 {573 {
401 submenu = gtk_menu_new ();574 GtkWidget* submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (menuitem));
402 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
403 /* Make sure menu appears to contain items */575 /* Make sure menu appears to contain items */
404 gtk_menu_shell_append (GTK_MENU_SHELL (submenu),576 gtk_menu_shell_append (GTK_MENU_SHELL (submenu),
405 gtk_separator_menu_item_new ());577 gtk_separator_menu_item_new ());
406 g_signal_connect (menuitem, "select",578 }
407 G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);579
408 g_signal_connect (menuitem, "activate",
409 G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
410 }
411 else
412 {
413 /* we need the 'activate' signal as well for keyboard events */
414 g_signal_connect (menuitem, "activate",
415 G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
416 }
417 g_signal_connect (menuitem, "button-press-event",
418 G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
419 gtk_widget_show (menuitem);580 gtk_widget_show (menuitem);
581 gtk_menu_shell_append (menu, menuitem);
420 }582 }
421}583}
422584
@@ -444,7 +606,7 @@
444 katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy);606 katze_array_action_generate_menu (array_action, array, GTK_MENU_SHELL (menu), proxy);
445 g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);607 g_signal_emit (array_action, signals[POPULATE_FOLDER], 0, menu, array, &handled);
446 g_object_set_data (G_OBJECT (proxy), "last-update",608 g_object_set_data (G_OBJECT (proxy), "last-update",
447 GINT_TO_POINTER (time (NULL)));609 GINT_TO_POINTER (time (NULL)));
448 return TRUE;610 return TRUE;
449}611}
450612
@@ -476,13 +638,14 @@
476 gboolean handled = FALSE;638 gboolean handled = FALSE;
477639
478 array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeItem");640 array = (KatzeArray*)g_object_get_data (G_OBJECT (proxy), "KatzeItem");
641
479 if (GTK_IS_MENU_ITEM (proxy))642 if (GTK_IS_MENU_ITEM (proxy))
480 {643 {
481 if (katze_array_action_menu_item_need_update (array_action, proxy))644 if (katze_array_action_menu_item_need_update (array_action, proxy))
482 {645 {
483 g_signal_emit (array_action, signals[POPULATE_FOLDER], 0,646 g_signal_emit (array_action, signals[POPULATE_FOLDER], 0,
484 gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)),647 gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)),
485 array, &handled);648 array, &handled);
486 if (!handled)649 if (!handled)
487 g_signal_emit (array_action, signals[POPULATE_POPUP], 0,650 g_signal_emit (array_action, signals[POPULATE_POPUP], 0,
488 gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)));651 gtk_menu_item_get_submenu (GTK_MENU_ITEM (proxy)));
@@ -492,7 +655,7 @@
492655
493 if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array))656 if (KATZE_IS_ITEM (array) && katze_item_get_uri ((KatzeItem*)array))
494 {657 {
495 katze_array_action_activate_item (array_action, KATZE_ITEM (array), 1);658 katze_array_action_activate_item (array_action, KATZE_ITEM (array), NULL, proxy);
496 return;659 return;
497 }660 }
498661
@@ -512,7 +675,7 @@
512 }675 }
513676
514 katze_widget_popup (GTK_WIDGET (proxy), GTK_MENU (menu),677 katze_widget_popup (GTK_WIDGET (proxy), GTK_MENU (menu),
515 NULL, KATZE_MENU_POSITION_LEFT);678 NULL, KATZE_MENU_POSITION_LEFT);
516 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE);679 gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), TRUE);
517 g_object_set_data (G_OBJECT (menu), "KatzeArrayAction", array_action);680 g_object_set_data (G_OBJECT (menu), "KatzeArrayAction", array_action);
518 g_signal_connect (menu, "deactivate",681 g_signal_connect (menu, "deactivate",
@@ -606,31 +769,9 @@
606{769{
607 KatzeArrayAction* array_action;770 KatzeArrayAction* array_action;
608 GtkWidget* menuitem;771 GtkWidget* menuitem;
609 GtkWidget* image;
610772
611 array_action = g_object_get_data (G_OBJECT (proxy), "KatzeArrayAction");773 array_action = g_object_get_data (G_OBJECT (proxy), "KatzeArrayAction");
612 menuitem = katze_image_menu_item_new_ellipsized (774 menuitem = katze_array_action_menu_item_new (array_action, item);
613 katze_item_get_name (item));
614 image = katze_item_get_image (item, menuitem);
615 gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
616 gtk_image_menu_item_set_always_show_image (
617 GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
618 g_object_set_data (G_OBJECT (menuitem), "KatzeItem", item);
619 if (KATZE_ITEM_IS_FOLDER (item))
620 {
621 GtkWidget* submenu = gtk_menu_new ();
622 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
623 g_signal_connect (menuitem, "select",
624 G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
625 }
626 else
627 {
628 g_signal_connect (menuitem, "button-press-event",
629 G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
630 /* we need the 'activate' signal as well for keyboard events */
631 g_signal_connect (menuitem, "activate",
632 G_CALLBACK (katze_array_action_menu_activate_cb), array_action);
633 }
634 gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (proxy),775 gtk_tool_item_set_proxy_menu_item (GTK_TOOL_ITEM (proxy),
635 "katze-tool-item-menu", menuitem);776 "katze-tool-item-menu", menuitem);
636 return TRUE;777 return TRUE;
@@ -706,9 +847,19 @@
706 else847 else
707 gtk_tool_item_set_tooltip_text (toolitem, uri);848 gtk_tool_item_set_tooltip_text (toolitem, uri);
708849
709 g_object_set_data (G_OBJECT (toolitem), "KatzeArray", item);850 g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
710 g_signal_connect (toolitem, "clicked",851 g_signal_connect (toolitem, "clicked",
711 G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);852 G_CALLBACK (katze_array_action_proxy_clicked_cb), array_action);
853 if (KATZE_IS_ITEM (item))
854 {
855 /* Tool items block the "button-press-event" but we can get it
856 * when connecting it to the tool item's child widget
857 */
858
859 GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
860 g_signal_connect (child, "button-press-event",
861 G_CALLBACK (katze_array_action_tool_item_child_button_press_cb), array_action);
862 }
712863
713 g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action);864 g_object_set_data (G_OBJECT (toolitem), "KatzeArrayAction", array_action);
714 g_signal_connect (item, "notify",865 g_signal_connect (item, "notify",
@@ -779,11 +930,11 @@
779930
780 /* FIXME: Add and remove items dynamically */931 /* FIXME: Add and remove items dynamically */
781 /*g_object_connect (array,932 /*g_object_connect (array,
782 "signal-after::add-item",933 "signal-after::add-item",
783 katze_array_action_engines_add_item_cb, array_action,934 katze_array_action_engines_add_item_cb, array_action,
784 "signal-after::remove-item",935 "signal-after::remove-item",
785 katze_array_action_engines_remove_item_cb, array_action,936 katze_array_action_engines_remove_item_cb, array_action,
786 NULL);*/937 NULL);*/
787938
788 g_object_notify (G_OBJECT (array_action), "array");939 g_object_notify (G_OBJECT (array_action), "array");
789940
790941
=== modified file 'midori/marshal.list'
--- midori/marshal.list 2013-09-03 14:45:17 +0000
+++ midori/marshal.list 2013-09-28 15:27:18 +0000
@@ -1,6 +1,7 @@
1BOOLEAN:OBJECT1BOOLEAN:OBJECT
2BOOLEAN:OBJECT,OBJECT2BOOLEAN:OBJECT,OBJECT
3BOOLEAN:OBJECT,UINT3BOOLEAN:OBJECT,UINT
4BOOLEAN:OBJECT,POINTER,OBJECT
4BOOLEAN:VOID5BOOLEAN:VOID
5BOOLEAN:STRING6BOOLEAN:STRING
6OBJECT:OBJECT7OBJECT:OBJECT
78
=== modified file 'midori/midori-browser.c'
--- midori/midori-browser.c 2013-09-17 19:34:23 +0000
+++ midori/midori-browser.c 2013-09-28 15:27:18 +0000
@@ -3124,18 +3124,31 @@
3124 return TRUE;3124 return TRUE;
3125}3125}
31263126
3127static void
3128midori_browser_bookmark_popup (GtkWidget* proxy,
3129 GdkEventButton* event,
3130 KatzeItem* item,
3131 MidoriBrowser* browser);
3132
3127static gboolean3133static gboolean
3128midori_bookmarkbar_activate_item_alt (GtkAction* action,3134midori_bookmarkbar_activate_item_full (GtkAction* action,
3129 KatzeItem* item,3135 KatzeItem* item,
3130 guint button,3136 GdkEventButton* event,
3131 MidoriBrowser* browser)3137 GtkWidget* proxy,
3138 MidoriBrowser* browser)
3132{3139{
3133 if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ()))3140 g_assert (event);
3141
3142 if (MIDORI_EVENT_NEW_TAB (event))
3134 {3143 {
3135 GtkWidget* view = midori_browser_add_item (browser, item);3144 GtkWidget* view = midori_browser_add_item (browser, item);
3136 midori_browser_set_current_tab_smartly (browser, view);3145 midori_browser_set_current_tab_smartly (browser, view);
3137 }3146 }
3138 else if (button == 1)3147 else if (MIDORI_EVENT_CONTEXT_MENU (event))
3148 {
3149 midori_browser_bookmark_popup (proxy, NULL, item, browser);
3150 }
3151 else if (event->button == 1)
3139 {3152 {
3140 midori_browser_open_bookmark (browser, item);3153 midori_browser_open_bookmark (browser, item);
3141 }3154 }
@@ -3240,12 +3253,6 @@
3240 midori_context_action_create_menu (menu, default_menu, TRUE);3253 midori_context_action_create_menu (menu, default_menu, TRUE);
3241}3254}
32423255
3243static void
3244midori_browser_bookmark_popup (GtkWidget* widget,
3245 GdkEventButton* event,
3246 KatzeItem* item,
3247 MidoriBrowser* browser);
3248
3249static gboolean3256static gboolean
3250_action_bookmarks_populate_folder (GtkAction* action,3257_action_bookmarks_populate_folder (GtkAction* action,
3251 GtkMenuShell* menu,3258 GtkMenuShell* menu,
@@ -4373,6 +4380,9 @@
4373 it is an item, we forward it to the actual widget. */4380 it is an item, we forward it to the actual widget. */
4374 if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem)))4381 if ((GTK_IS_BOX (toolitem) || GTK_IS_MENU_BAR (toolitem)))
4375 {4382 {
4383 if (toolitem->window != event->window)
4384 return FALSE;
4385
4376 midori_browser_toolbar_popup_context_menu_cb (4386 midori_browser_toolbar_popup_context_menu_cb (
4377 GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?4387 GTK_IS_BIN (toolitem) && gtk_bin_get_child (GTK_BIN (toolitem)) ?
4378 gtk_widget_get_parent (toolitem) : toolitem,4388 gtk_widget_get_parent (toolitem) : toolitem,
@@ -6202,8 +6212,8 @@
6202 g_object_connect (action,6212 g_object_connect (action,
6203 "signal::populate-folder",6213 "signal::populate-folder",
6204 _action_bookmarks_populate_folder, browser,6214 _action_bookmarks_populate_folder, browser,
6205 "signal::activate-item-alt",6215 "signal::activate-item-full",
6206 midori_bookmarkbar_activate_item_alt, browser,6216 midori_bookmarkbar_activate_item_full, browser,
6207 NULL);6217 NULL);
6208 gtk_action_group_add_action_with_accel (browser->action_group, action, "");6218 gtk_action_group_add_action_with_accel (browser->action_group, action, "");
6209 g_object_unref (action);6219 g_object_unref (action);
@@ -6220,8 +6230,6 @@
6220 g_object_connect (action,6230 g_object_connect (action,
6221 "signal::populate-popup",6231 "signal::populate-popup",
6222 _action_tools_populate_popup, browser,6232 _action_tools_populate_popup, browser,
6223 "signal::activate-item-alt",
6224 midori_bookmarkbar_activate_item_alt, browser,
6225 NULL);6233 NULL);
6226 gtk_action_group_add_action (browser->action_group, action);6234 gtk_action_group_add_action (browser->action_group, action);
6227 g_object_unref (action);6235 g_object_unref (action);
@@ -6989,29 +6997,6 @@
6989 g_value_unset (&value);6997 g_value_unset (&value);
6990}6998}
69916999
6992static gboolean
6993midori_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem,
6994 GdkEventButton* event,
6995 MidoriBrowser* browser)
6996{
6997 KatzeItem* item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
6998 if (MIDORI_EVENT_NEW_TAB (event))
6999 {
7000 if (KATZE_ITEM_IS_BOOKMARK (item))
7001 {
7002 GtkWidget* view = midori_browser_add_uri (browser, katze_item_get_uri (item));
7003 midori_browser_set_current_tab_smartly (browser, view);
7004 return TRUE;
7005 }
7006 }
7007 else if (MIDORI_EVENT_CONTEXT_MENU (event))
7008 {
7009 midori_browser_bookmark_popup (toolitem, NULL, item, browser);
7010 return TRUE;
7011 }
7012 return FALSE;
7013}
7014
7015static void7000static void
7016midori_bookmarkbar_insert_item (GtkWidget* toolbar,7001midori_bookmarkbar_insert_item (GtkWidget* toolbar,
7017 KatzeItem* item)7002 KatzeItem* item)
@@ -7022,15 +7007,7 @@
7022 KATZE_ARRAY_ACTION (action), item);7007 KATZE_ARRAY_ACTION (action), item);
7023 g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);7008 g_object_set_data (G_OBJECT (toolitem), "KatzeItem", item);
70247009
7025 if (KATZE_IS_ITEM (item))7010 if (!KATZE_IS_ITEM (item)) /* Separator */
7026 {
7027 GtkWidget* child = gtk_bin_get_child (GTK_BIN (toolitem));
7028 g_object_set_data (G_OBJECT (child), "KatzeItem", item);
7029 g_signal_connect (child, "button-press-event",
7030 G_CALLBACK (midori_bookmarkbar_item_button_press_event_cb),
7031 browser);
7032 }
7033 else /* Separator */
7034 gtk_tool_item_set_use_drag_window (toolitem, TRUE);7011 gtk_tool_item_set_use_drag_window (toolitem, TRUE);
70357012
7036 gtk_widget_show (GTK_WIDGET (toolitem));7013 gtk_widget_show (GTK_WIDGET (toolitem));
@@ -7899,7 +7876,28 @@
78997876
7900 browser = gtk_window_get_transient_for (GTK_WINDOW (browser));7877 browser = gtk_window_get_transient_for (GTK_WINDOW (browser));
7901 if (!MIDORI_IS_BROWSER (browser))7878 if (!MIDORI_IS_BROWSER (browser))
7902 return NULL;7879 {
7880 /* For some reason, when called on the wiget of the
7881 * application menubar we get here.
7882 */
7883
7884 GList* top_levels = gtk_window_list_toplevels ();
7885 GList *iter;
7886
7887 for (iter = top_levels; iter; iter = g_list_next (iter))
7888 {
7889 browser = iter->data;
7890
7891 if (MIDORI_IS_BROWSER (browser))
7892 {
7893 g_list_free (top_levels);
7894 return MIDORI_BROWSER (browser);
7895 }
7896 }
7897
7898 g_list_free (top_levels);
7899 return NULL;
7900 }
7903 }7901 }
79047902
7905 return MIDORI_BROWSER (browser);7903 return MIDORI_BROWSER (browser);

Subscribers

People subscribed via source and target branches

to all changes: