aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-05-20 02:42:22 +0800
committerChristian Persch <chpe@src.gnome.org>2004-05-20 02:42:22 +0800
commitc26be9eaf445f04efd11ff3cb3daed38626b1b12 (patch)
tree92ae7f09f9ec0b7981675f676faa6cca8f09629e /src
parentf7d64a2da37e5d187d259fa6bb15e2a1e8e959d7 (diff)
downloadgsoc2013-epiphany-c26be9eaf445f04efd11ff3cb3daed38626b1b12.tar
gsoc2013-epiphany-c26be9eaf445f04efd11ff3cb3daed38626b1b12.tar.gz
gsoc2013-epiphany-c26be9eaf445f04efd11ff3cb3daed38626b1b12.tar.bz2
gsoc2013-epiphany-c26be9eaf445f04efd11ff3cb3daed38626b1b12.tar.lz
gsoc2013-epiphany-c26be9eaf445f04efd11ff3cb3daed38626b1b12.tar.xz
gsoc2013-epiphany-c26be9eaf445f04efd11ff3cb3daed38626b1b12.tar.zst
gsoc2013-epiphany-c26be9eaf445f04efd11ff3cb3daed38626b1b12.zip
Open bookmark in new tab on middle-click. Fixes bug #106250.
2004-05-19 Christian Persch <chpe@cvs.gnome.org> * src/bookmarks/ephy-bookmark-action.c: (activate_cb), (button_press_cb), (button_release_cb), (connect_proxy), (ephy_bookmark_action_class_init): * src/toolbar.c: (go_location_cb): Open bookmark in new tab on middle-click. Fixes bug #106250.
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmark-action.c40
-rwxr-xr-xsrc/toolbar.c38
2 files changed, 72 insertions, 6 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index 6bdc0d72e..479790bc1 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -69,7 +69,7 @@ enum
static GObjectClass *parent_class = NULL;
-static guint ephy_bookmark_action_signals[LAST_SIGNAL] = { 0 };
+static guint signals[LAST_SIGNAL] = { 0 };
GType
ephy_bookmark_action_get_type (void)
@@ -319,14 +319,40 @@ activate_cb (GtkWidget *widget, GtkAction *action)
}
}
- g_signal_emit (action,
- ephy_bookmark_action_signals[GO_LOCATION],
- 0, location);
+ g_signal_emit (action, signals[GO_LOCATION], 0, location);
g_free (location);
g_free (text);
}
+static gboolean
+button_press_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer dummy)
+{
+ if (event->type == GDK_BUTTON_PRESS && event->button == 2)
+ {
+ gtk_button_pressed (GTK_BUTTON (widget));
+ }
+
+ return FALSE;
+}
+
+static gboolean
+button_release_cb (GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer dummy)
+{
+ if (event->type == GDK_BUTTON_RELEASE && event->button == 2)
+ {
+ gtk_button_released (GTK_BUTTON (widget));
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
connect_proxy (GtkAction *action, GtkWidget *proxy)
{
@@ -352,6 +378,10 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
{
button = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "button"));
g_signal_connect (button, "clicked", G_CALLBACK (activate_cb), action);
+ g_signal_connect (button, "button-press-event",
+ G_CALLBACK (button_press_cb), NULL);
+ g_signal_connect (button, "button-release-event",
+ G_CALLBACK (button_release_cb), NULL);
entry = GTK_WIDGET (g_object_get_data (G_OBJECT (proxy), "entry"));
g_signal_connect (entry, "activate", G_CALLBACK (activate_cb), action);
@@ -450,7 +480,7 @@ ephy_bookmark_action_class_init (EphyBookmarkActionClass *class)
object_class->set_property = ephy_bookmark_action_set_property;
object_class->get_property = ephy_bookmark_action_get_property;
- ephy_bookmark_action_signals[GO_LOCATION] =
+ signals[GO_LOCATION] =
g_signal_new ("go_location",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
diff --git a/src/toolbar.c b/src/toolbar.c
index 0d52339ee..2a24815bd 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -166,7 +166,43 @@ arbitrary_url_notifier (GConfClient *client,
static void
go_location_cb (GtkAction *action, char *location, EphyWindow *window)
{
- ephy_window_load_url (window, location);
+ GdkEvent *event;
+ gboolean new_tab = FALSE;
+
+ event = gtk_get_current_event ();
+ if (event != NULL)
+ {
+ if (event->type == GDK_BUTTON_RELEASE)
+ {
+ guint modifiers, button, state;
+
+ modifiers = gtk_accelerator_get_default_mod_mask ();
+ button = event->button.button;
+ state = event->button.state;
+
+ /* middle-click or control-click */
+ if ((button == 1 && ((state & modifiers) == GDK_CONTROL_MASK)) ||
+ (button == 2))
+ {
+ new_tab = TRUE;
+ }
+ }
+
+ gdk_event_free (event);
+ }
+
+ if (new_tab)
+ {
+ ephy_shell_new_tab (ephy_shell, window,
+ ephy_window_get_active_tab (window),
+ location,
+ EPHY_NEW_TAB_OPEN_PAGE |
+ EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+ }
+ else
+ {
+ ephy_window_load_url (window, location);
+ }
}
static void