/*
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
+ Copyright (C) 2009 Enrico Tröger <enrico.troeger@uvena.de>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
#include "katze-net.h"
#include "katze-utils.h"
+#include "marshal.h"
#include <string.h>
#include <glib/gi18n.h>
{
POPULATE_POPUP,
ACTIVATE_ITEM,
+ ACTIVATE_ITEM_ALT,
LAST_SIGNAL
};
G_TYPE_NONE, 1,
KATZE_TYPE_ITEM);
+ /**
+ * KatzeArrayAction::activate-item-alt:
+ * @array: the object on which the signal is emitted
+ * @item: the item being activated
+ * @button: the mouse button pressed
+ *
+ * An item was clicked with a particular button. Use this if you need
+ * to handle middle or right clicks specially.
+ *
+ * Return value: %TRUE if the event was handled. If %FALSE is returned,
+ * the default "activate-item" signal is emitted.
+ *
+ * Since: 0.1.7
+ **/
+ signals[ACTIVATE_ITEM_ALT] = g_signal_new ("activate-item-alt",
+ G_TYPE_FROM_CLASS (class),
+ (GSignalFlags) (G_SIGNAL_RUN_LAST),
+ 0,
+ 0,
+ NULL,
+ katze_cclosure_marshal_BOOLEAN__OBJECT_UINT,
+ G_TYPE_BOOLEAN, 2,
+ KATZE_TYPE_ITEM, G_TYPE_UINT);
+
gobject_class = G_OBJECT_CLASS (class);
gobject_class->finalize = katze_array_action_finalize;
gobject_class->set_property = katze_array_action_set_property;
GTK_ACTION_CLASS (katze_array_action_parent_class)->activate (action);
}
-static void
-katze_array_action_menu_item_activate_cb (GtkWidget* proxy,
- KatzeArrayAction* array_action)
+static gboolean
+katze_array_action_menu_button_press_cb (GtkWidget* proxy,
+ GdkEventButton* event,
+ KatzeArrayAction* array_action)
{
KatzeItem* item = g_object_get_data (G_OBJECT (proxy), "KatzeItem");
- g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, item);
+ gboolean handled;
+
+ g_signal_emit (array_action, signals[ACTIVATE_ITEM_ALT], 0, item, event->button, &handled);
+
+ if (!handled)
+ g_signal_emit (array_action, signals[ACTIVATE_ITEM], 0, item);
+
+ return TRUE;
}
static void
G_CALLBACK (katze_array_action_menu_item_select_cb), array_action);
}
else
- g_signal_connect (menuitem, "activate",
- G_CALLBACK (katze_array_action_menu_item_activate_cb), array_action);
+ {
+ g_signal_connect (menuitem, "button-press-event",
+ G_CALLBACK (katze_array_action_menu_button_press_cb), array_action);
+ }
gtk_widget_show (menuitem);
}
if (!i)
gtk_widget_grab_focus (midori_browser_get_current_tab (browser));
}
+static gboolean
+_action_bookmarks_activate_item_alt (GtkAction* action,
+ KatzeItem* item,
+ guint button,
+ MidoriBrowser* browser)
+{
+ if (button == 2)
+ {
+ gint n;
+ gboolean open_in_background;
+
+ g_object_get (browser->settings, "open-tabs-in-the-background",
+ &open_in_background, NULL);
+
+ n = midori_browser_add_uri (browser, katze_item_get_uri (item));
+
+ if (!open_in_background)
+ midori_browser_set_current_page (browser, n);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
_action_window_populate_popup (GtkAction* action,
GtkMenu* menu,
_action_bookmarks_populate_popup, browser,
"signal::activate-item",
_action_bookmarks_activate_item, browser,
+ "signal::activate-item-alt",
+ _action_bookmarks_activate_item_alt, browser,
NULL);
gtk_action_group_add_action_with_accel (browser->action_group, action, "");
g_object_unref (action);