aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2006-01-30 05:47:22 +0800
committerChristian Persch <chpe@src.gnome.org>2006-01-30 05:47:22 +0800
commitbf0ea37b5138af83fde8e7aaba16669c4e43fd9c (patch)
tree0577a38705f373970c0f167ca73b34e24a33ecd0 /src
parent34e421be7f10496d476266e656ddffe00b42b4e7 (diff)
downloadgsoc2013-epiphany-bf0ea37b5138af83fde8e7aaba16669c4e43fd9c.tar
gsoc2013-epiphany-bf0ea37b5138af83fde8e7aaba16669c4e43fd9c.tar.gz
gsoc2013-epiphany-bf0ea37b5138af83fde8e7aaba16669c4e43fd9c.tar.bz2
gsoc2013-epiphany-bf0ea37b5138af83fde8e7aaba16669c4e43fd9c.tar.lz
gsoc2013-epiphany-bf0ea37b5138af83fde8e7aaba16669c4e43fd9c.tar.xz
gsoc2013-epiphany-bf0ea37b5138af83fde8e7aaba16669c4e43fd9c.tar.zst
gsoc2013-epiphany-bf0ea37b5138af83fde8e7aaba16669c4e43fd9c.zip
Add a convenience function to get current event data.
2006-01-29 Christian Persch <chpe@cvs.gnome.org> * lib/ephy-gui.c: (ephy_gui_get_current_event): * lib/ephy-gui.h: Add a convenience function to get current event data. * src/ephy-link.c: (ephy_link_open), (ephy_link_flags_from_current_event): * src/ephy-link.h: Add a convenience function to translate the current event into EphyLinkFlags. * src/ephy-go-action.c: (ephy_go_action_get_type): * src/ephy-go-action.h: Make this an EphyLinkAction. * lib/widgets/ephy-location-entry.c: (entry_key_press_cb): * src/ephy-home-action.c: (ephy_home_action_activate): * src/ephy-location-action.c: (entry_activate_cb): * src/ephy-tab.c: (open_link_in_new), (ephy_tab_dom_mouse_click_cb): * src/window-commands.c: (window_cmd_load_location): Fix link activation to respect ctrl and shift modifiers. Part of bug #310814. 2006-01-29 Christian Persch <chpe@cvs.gnome.org>
Diffstat (limited to 'src')
-rw-r--r--src/ephy-go-action.c2
-rw-r--r--src/ephy-go-action.h6
-rw-r--r--src/ephy-home-action.c2
-rw-r--r--src/ephy-link.c36
-rw-r--r--src/ephy-link.h2
-rw-r--r--src/ephy-location-action.c17
-rw-r--r--src/ephy-session.c2
-rw-r--r--src/ephy-tab.c48
-rw-r--r--src/window-commands.c5
9 files changed, 74 insertions, 46 deletions
diff --git a/src/ephy-go-action.c b/src/ephy-go-action.c
index e84860c23..347398183 100644
--- a/src/ephy-go-action.c
+++ b/src/ephy-go-action.c
@@ -52,7 +52,7 @@ ephy_go_action_get_type (void)
(GInstanceInitFunc) NULL,
};
- type = g_type_register_static (GTK_TYPE_ACTION,
+ type = g_type_register_static (EPHY_TYPE_LINK_ACTION,
"EphyGoAction",
&type_info, 0);
}
diff --git a/src/ephy-go-action.h b/src/ephy-go-action.h
index a3a74784c..063014825 100644
--- a/src/ephy-go-action.h
+++ b/src/ephy-go-action.h
@@ -21,7 +21,7 @@
#ifndef EPHY_GO_ACTION_H
#define EPHY_GO_ACTION_H
-#include <gtk/gtkaction.h>
+#include "ephy-link-action.h"
#define EPHY_TYPE_GO_ACTION (ephy_go_action_get_type ())
#define EPHY_GO_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EPHY_TYPE_GO_ACTION, EphyGoAction))
@@ -35,12 +35,12 @@ typedef struct _EphyGoActionClass EphyGoActionClass;
struct _EphyGoAction
{
- GtkAction parent;
+ EphyLinkAction parent;
};
struct _EphyGoActionClass
{
- GtkActionClass parent_class;
+ EphyLinkActionClass parent_class;
};
GType ephy_go_action_get_type (void);
diff --git a/src/ephy-home-action.c b/src/ephy-home-action.c
index 52e86ef83..7d2357bd3 100644
--- a/src/ephy-home-action.c
+++ b/src/ephy-home-action.c
@@ -36,7 +36,7 @@ ephy_home_action_activate (GtkAction *action)
ephy_link_open (EPHY_LINK (action),
address != NULL && address[0] != '\0' ? address : "about:blank",
NULL,
- ephy_gui_is_middle_click () ? EPHY_LINK_NEW_TAB : 0);
+ ephy_link_flags_from_current_event ());
g_free (address);
}
diff --git a/src/ephy-link.c b/src/ephy-link.c
index e48758e8c..67be0e221 100644
--- a/src/ephy-link.c
+++ b/src/ephy-link.c
@@ -25,6 +25,7 @@
#include "ephy-type-builtins.h"
#include "ephy-marshal.h"
#include "ephy-signal-accumulator.h"
+#include "ephy-gui.h"
#include "ephy-debug.h"
enum
@@ -97,3 +98,38 @@ ephy_link_open (EphyLink *link,
return new_tab;
}
+
+EphyLinkFlags
+ephy_link_flags_from_current_event (void)
+{
+ GdkEventType type = GDK_NOTHING;
+ guint state = 0, button = (guint) -1;
+ EphyLinkFlags flags = 0;
+
+ ephy_gui_get_current_event (&type, &state, &button);
+
+ if (button == 2 && type == GDK_BUTTON_PRESS)
+ {
+ if (state == GDK_SHIFT_MASK)
+ {
+ flags = EPHY_LINK_NEW_WINDOW;
+ }
+ else
+ {
+ flags = EPHY_LINK_NEW_TAB;
+ }
+ }
+ else
+ {
+ if (state == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
+ {
+ flags = EPHY_LINK_NEW_WINDOW;
+ }
+ else if (state == GDK_CONTROL_MASK)
+ {
+ flags = EPHY_LINK_NEW_TAB;
+ }
+ }
+
+ return flags;
+}
diff --git a/src/ephy-link.h b/src/ephy-link.h
index a1e80cf03..4287ba174 100644
--- a/src/ephy-link.h
+++ b/src/ephy-link.h
@@ -64,6 +64,8 @@ EphyTab *ephy_link_open (EphyLink *link,
EphyTab *tab,
EphyLinkFlags flags);
+EphyLinkFlags ephy_link_flags_from_current_event (void);
+
G_END_DECLS
#endif /* EPHY_LINK_H */
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index a15bd41d7..922f14298 100644
--- a/src/ephy-location-action.c
+++ b/src/ephy-location-action.c
@@ -149,8 +149,6 @@ entry_activate_cb (GtkEntry *entry,
EphyLocationAction *action)
{
EphyBookmarks *bookmarks;
- GdkEvent *event;
- gboolean control = FALSE;
const char *content;
char *address;
@@ -162,21 +160,8 @@ entry_activate_cb (GtkEntry *entry,
address = ephy_bookmarks_resolve_address (bookmarks, content, NULL);
g_return_if_fail (address != NULL);
- event = gtk_get_current_event ();
- if (event)
- {
- if (event->type == GDK_KEY_PRESS ||
- event->type == GDK_KEY_RELEASE)
- {
- control = (event->key.state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK;
- }
-
- gdk_event_free (event);
- }
-
- /* FIXME use ephy_bookmarks_resolve_address here too? */
ephy_link_open (EPHY_LINK (action), address, NULL,
- control ? EPHY_LINK_NEW_TAB : 0);
+ ephy_link_flags_from_current_event ());
g_free (address);
}
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 6f10554a4..ffa81bbe6 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 Jorn Baayen
* Copyright (C) 2003, 2004 Marco Pesenti Gritti
- * Copyright (C) 2003, 2004, 2005 Christian Persch
+ * Copyright (C) 2003, 2004, 2005, 2006 Christian Persch
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 3d91ded53..8a95ff477 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -1833,28 +1833,26 @@ ephy_tab_visibility_cb (EphyEmbed *embed, gboolean visibility,
}
static gboolean
-open_link_in_new_tab (EphyTab *tab,
- const char *link_address)
+open_link_in_new (EphyTab *tab,
+ const char *link_address,
+ guint state)
{
- gboolean new_tab;
+ EphyTab *dest;
- new_tab = address_has_web_scheme (link_address);
+ if (!address_has_web_scheme (link_address)) return FALSE;
- if (new_tab)
- {
- EphyTab *dest;
- dest = ephy_link_open (EPHY_LINK (tab), link_address,
- tab, EPHY_LINK_NEW_TAB);
+ dest = ephy_link_open (EPHY_LINK (tab), link_address, tab,
+ state & GDK_SHIFT_MASK ? EPHY_LINK_NEW_WINDOW
+ : EPHY_LINK_NEW_TAB);
- if (dest)
- {
- ephy_embed_shistory_copy (ephy_tab_get_embed (tab),
- ephy_tab_get_embed (dest),
- TRUE, /* back history */
- FALSE, /* forward history */
- FALSE); /* current index */
- return TRUE;
- }
+ if (dest)
+ {
+ ephy_embed_shistory_copy (ephy_tab_get_embed (tab),
+ ephy_tab_get_embed (dest),
+ TRUE, /* back history */
+ FALSE, /* forward history */
+ FALSE); /* current index */
+ return TRUE;
}
return FALSE;
@@ -1915,7 +1913,8 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
EphyEmbedEventContext context;
guint button, modifier;
gboolean handled = TRUE;
- gboolean with_control, with_shift, is_left_click, is_middle_click;
+ gboolean with_control, with_shift, with_shift_control;
+ gboolean is_left_click, is_middle_click;
gboolean is_link, is_image, is_middle_clickable;
gboolean middle_click_opens;
gboolean is_input;
@@ -1929,8 +1928,9 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
LOG ("ephy_tab_dom_mouse_click_cb: button %d, context %x, modifier %x",
button, context, modifier);
- with_control = (modifier & GDK_CONTROL_MASK) != 0;
- with_shift = (modifier & GDK_SHIFT_MASK) != 0;
+ with_control = (modifier & GDK_CONTROL_MASK) == GDK_CONTROL_MASK;
+ with_shift = (modifier & GDK_SHIFT_MASK) == GDK_SHIFT_MASK;
+ with_shift_control = (modifier & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) == (GDK_SHIFT_MASK | GDK_CONTROL_MASK);
is_left_click = (button == 1);
is_middle_click = (button == 2);
@@ -1946,14 +1946,16 @@ ephy_tab_dom_mouse_click_cb (EphyEmbed *embed,
is_input = (context & EPHY_EMBED_CONTEXT_INPUT) != 0;
/* ctrl+click or middle click opens the link in new tab */
- if (is_link && ((is_left_click && with_control) || is_middle_click))
+ if (is_link &&
+ ((is_left_click && (with_control || with_shift_control)) ||
+ is_middle_click))
{
const GValue *value;
const char *link_address;
value = ephy_embed_event_get_property (event, "link");
link_address = g_value_get_string (value);
- handled = open_link_in_new_tab (tab, link_address);
+ handled = open_link_in_new (tab, link_address, modifier);
}
/* shift+click saves the link target */
else if (is_link && is_left_click && with_shift)
diff --git a/src/window-commands.c b/src/window-commands.c
index fffcedfe1..96321d08b 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -45,6 +45,7 @@
#include "ephy-find-toolbar.h"
#include "ephy-location-entry.h"
#include "ephy-bookmarks-ui.h"
+#include "ephy-link.h"
#include "pdm-dialog.h"
#include <string.h>
@@ -884,7 +885,9 @@ window_cmd_load_location (GtkAction *action,
if (location)
{
- ephy_window_load_url (window, location);
+ ephy_link_open (EPHY_LINK (window), location,
+ ephy_window_get_active_tab (window),
+ ephy_link_flags_from_current_event ());
}
}