Introduce MIDORI_EVENT_NEW_TAB and use it

Fixes: https://bugs.launchpad.net/midori/+bug/797224
Fixes: https://bugs.launchpad.net/midori/+bug/797229
This commit is contained in:
Christian Dywan 2011-09-28 17:45:37 +02:00
parent daa6fa0ee7
commit ae56fbf818
2 changed files with 22 additions and 17 deletions

View file

@ -2799,15 +2799,15 @@ midori_bookmarkbar_activate_item_alt (GtkAction* action,
guint button, guint button,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
if (button == 1) if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ()))
{
midori_browser_open_bookmark (browser, item);
}
else if (button == 2)
{ {
gint n = midori_browser_add_uri (browser, katze_item_get_uri (item)); gint n = midori_browser_add_uri (browser, katze_item_get_uri (item));
midori_browser_set_current_page_smartly (browser, n); midori_browser_set_current_page_smartly (browser, n);
} }
else if (button == 1)
{
midori_browser_open_bookmark (browser, item);
}
return TRUE; return TRUE;
} }
@ -2845,20 +2845,20 @@ _action_trash_activate_item_alt (GtkAction* action,
guint button, guint button,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
if (button == 1) if (MIDORI_EVENT_NEW_TAB (gtk_get_current_event ()))
{
guint n = midori_browser_add_item (browser, item);
midori_browser_set_current_page (browser, n);
katze_array_remove_item (browser->trash, item);
_midori_browser_update_actions (browser);
}
else if (button == 2)
{ {
gint n = midori_browser_add_item (browser, item); gint n = midori_browser_add_item (browser, item);
midori_browser_set_current_page_smartly (browser, n); midori_browser_set_current_page_smartly (browser, n);
katze_array_remove_item (browser->trash, item); katze_array_remove_item (browser->trash, item);
_midori_browser_update_actions (browser); _midori_browser_update_actions (browser);
} }
else if (button == 1)
{
guint n = midori_browser_add_item (browser, item);
midori_browser_set_current_page (browser, n);
katze_array_remove_item (browser->trash, item);
_midori_browser_update_actions (browser);
}
return TRUE; return TRUE;
} }
@ -4151,7 +4151,7 @@ midori_browser_menu_item_middle_click_event_cb (GtkWidget* toolitem,
GdkEventButton* event, GdkEventButton* event,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
if (event->button == 2) if (MIDORI_EVENT_NEW_TAB (event))
{ {
GtkAction* action; GtkAction* action;
@ -5056,7 +5056,7 @@ midori_browser_notebook_button_press_event_after_cb (GtkNotebook* notebook,
/* Open a new tab on double click or middle mouse click */ /* Open a new tab on double click or middle mouse click */
if (/*(event->type == GDK_2BUTTON_PRESS && event->button == 1) if (/*(event->type == GDK_2BUTTON_PRESS && event->button == 1)
|| */(event->type == GDK_BUTTON_PRESS && event->button == 2)) || */(event->type == GDK_BUTTON_PRESS && MIDORI_EVENT_NEW_TAB (event)))
{ {
gint n = midori_browser_add_uri (browser, ""); gint n = midori_browser_add_uri (browser, "");
midori_browser_set_current_page (browser, n); midori_browser_set_current_page (browser, n);
@ -6368,7 +6368,7 @@ midori_browser_toolbar_item_button_press_event_cb (GtkWidget* toolitem,
GdkEventButton* event, GdkEventButton* event,
MidoriBrowser* browser) MidoriBrowser* browser)
{ {
if (event->button == 2) if (MIDORI_EVENT_NEW_TAB (event))
{ {
GtkWidget* parent = gtk_widget_get_parent (toolitem); GtkWidget* parent = gtk_widget_get_parent (toolitem);
GtkAction* action = gtk_activatable_get_related_action ( GtkAction* action = gtk_activatable_get_related_action (
@ -6613,7 +6613,7 @@ midori_bookmarkbar_item_button_press_event_cb (GtkWidget* toolitem,
gint n; gint n;
item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem"); item = (KatzeItem*)g_object_get_data (G_OBJECT (toolitem), "KatzeItem");
if (event->button == 2) if (MIDORI_EVENT_NEW_TAB (event))
{ {
if (KATZE_ITEM_IS_BOOKMARK (item)) if (KATZE_ITEM_IS_BOOKMARK (item))
{ {

View file

@ -29,4 +29,9 @@
(evt->button == 3) (evt->button == 3)
#endif #endif
#define MIDORI_EVENT_NEW_TAB(evt) \
((((GdkEventButton*)evt)->button == 1 \
&& MIDORI_MOD_NEW_TAB(((GdkEventButton*)evt)->state)) \
|| (((GdkEventButton*)evt)->button == 2))
#endif /* !__MIDORI_PLATFORM_H__ */ #endif /* !__MIDORI_PLATFORM_H__ */