aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog32
-rw-r--r--data/ui/epiphany-ui.xml1
-rw-r--r--lib/widgets/ephy-location-entry.c186
-rw-r--r--lib/widgets/ephy-location-entry.h13
-rw-r--r--src/ephy-location-action.c58
-rw-r--r--src/ephy-location-action.h3
-rw-r--r--src/ephy-lockdown.c2
-rw-r--r--src/ephy-tab.c12
-rwxr-xr-xsrc/ephy-toolbar.c7
-rw-r--r--src/ephy-toolbar.h4
-rw-r--r--src/ephy-window.c44
11 files changed, 280 insertions, 82 deletions
diff --git a/ChangeLog b/ChangeLog
index 5432f0f6d..122b2e23c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+2005-07-24 Christian Persch <chpe@cvs.gnome.org>
+
+ * data/ui/epiphany-ui.xml:
+ * lib/widgets/ephy-location-entry.c:
+ (ephy_location_entry_finalize), (update_address_state),
+ (update_favicon), (editable_changed_cb), (entry_button_press_cb),
+ (match_selected_cb), (entry_key_press_cb),
+ (ephy_location_entry_construct_contents),
+ (ephy_location_entry_set_location), (ephy_location_entry_reset),
+ (ephy_location_entry_set_favicon):
+ * lib/widgets/ephy-location-entry.h:
+ * src/ephy-location-action.c: (entry_activate_cb),
+ (user_changed_cb), (sync_address), (connect_proxy),
+ (ephy_location_action_set_property),
+ (ephy_location_action_finalize),
+ (ephy_location_action_set_address):
+ * src/ephy-location-action.h:
+ * src/ephy-lockdown.c: (update_location_editable):
+ * src/ephy-tab.c: (ephy_tab_get_typed_address):
+ * src/ephy-toolbar.c: (ephy_toolbar_set_location):
+ * src/ephy-toolbar.h:
+ * src/ephy-window.c: (ephy_window_key_press_event),
+ (sync_tab_address), (ephy_window_set_active_tab), (modal_alert_cb):
+ * src/epiphany.defs:
+ * src/window-commands.c: (window_cmd_view_stop):
+
+ Fix ESC behaviour to always stop, and to reset the location entry
+ when it's focused only. Reset the location entry favicon to the stock
+ icon when the address shown is != the tab's address.
+ When switching tab, preserve the selection if it was owned by the
+ location entry. Fixes bug #155824.
+
2005-07-25 Martin Kretzschmar <martink@gnome.org>
* embed/print-dialog.c (using_pdf_printer): new function.
diff --git a/data/ui/epiphany-ui.xml b/data/ui/epiphany-ui.xml
index 2c699c4a9..2dc30a7ea 100644
--- a/data/ui/epiphany-ui.xml
+++ b/data/ui/epiphany-ui.xml
@@ -221,6 +221,7 @@
<menuitem name="TabDetachENP" action="TabsDetach"/>
</popup>
+<accelerator name="AlwaysStopAccel" action="ViewAlwaysStop"/>
<accelerator name="BrowseWithCaretAccel" action="BrowseWithCaret"/>
<accelerator name="FileSaveAccel" action="FileSave"/>
<accelerator name="ForceReloadAccel" action="ForceReload"/>
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 94033d8f6..8d04209d7 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -29,6 +29,7 @@
#include "ephy-signal-accumulator.h"
#include "ephy-dnd.h"
#include "egg-editable-toolbar.h"
+#include "ephy-stock-icons.h"
#include "ephy-debug.h"
#include <glib/gi18n.h>
@@ -49,6 +50,7 @@
#include <gtk/gtkseparatormenuitem.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkalignment.h>
+#include <gtk/gtkclipboard.h>
#include <string.h>
@@ -63,14 +65,18 @@ struct _EphyLocationEntryPrivate
GtkWidget *icon;
GtkWidget *lock_ebox;
GtkWidget *lock;
+ GdkPixbuf *favicon;
char *before_completion;
- gboolean user_changed;
guint text_col;
guint action_col;
guint keywords_col;
guint relevance_col;
+
+ guint hash;
+ guint user_changed : 1;
+ guint original_address : 1;
};
static const struct
@@ -161,6 +167,11 @@ ephy_location_entry_finalize (GObject *object)
EphyLocationEntry *entry = EPHY_LOCATION_ENTRY (object);
EphyLocationEntryPrivate *priv = entry->priv;
+ if (priv->favicon != NULL)
+ {
+ g_object_unref (priv->favicon);
+ }
+
g_object_unref (priv->tips);
parent_class->finalize (object);
@@ -223,16 +234,52 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass)
}
static void
-editable_changed_cb (GtkEditable *editable, EphyLocationEntry *e)
+update_address_state (EphyLocationEntry *entry)
{
- EphyLocationEntryPrivate *p = e->priv;
+ EphyLocationEntryPrivate *priv = entry->priv;
+ const char *text;
- if (p->user_changed)
+ text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ priv->original_address = text != NULL &&
+ g_str_hash (text) == priv->hash;
+}
+
+static void
+update_favicon (EphyLocationEntry *entry)
+{
+ EphyLocationEntryPrivate *priv = entry->priv;
+ GtkImage *image = GTK_IMAGE (priv->icon);
+
+ /* Only show the favicon if the entry's text is the
+ * address of the current page.
+ */
+ if (priv->favicon != NULL && priv->original_address)
{
- g_signal_emit (e, signals[USER_CHANGED], 0);
+ gtk_image_set_from_pixbuf (image, priv->favicon);
+ }
+ else
+ {
+ gtk_image_set_from_stock (image,
+ GTK_STOCK_NEW,
+ GTK_ICON_SIZE_MENU);
}
}
+static void
+editable_changed_cb (GtkEditable *editable,
+ EphyLocationEntry *entry)
+{
+ EphyLocationEntryPrivate *priv = entry->priv;
+
+ update_address_state (entry);
+
+ if (priv->user_changed == FALSE) return;
+
+ update_favicon (entry);
+
+ g_signal_emit (entry, signals[USER_CHANGED], 0);
+}
+
static gboolean
entry_button_press_cb (GtkWidget *entry, GdkEventButton *event, EphyLocationEntry *le)
{
@@ -246,17 +293,23 @@ entry_button_press_cb (GtkWidget *entry, GdkEventButton *event, EphyLocationEntr
}
static gboolean
-entry_key_press_cb (GtkWidget *widget,
+entry_key_press_cb (GtkEntry *entry,
GdkEventKey *event,
- EphyLocationEntry *entry)
+ EphyLocationEntry *lentry)
{
- if (event->keyval == GDK_Escape)
+ guint mask = gtk_accelerator_get_default_mod_mask ();
+
+ if ((event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter) &&
+ (event->state & mask) == GDK_CONTROL_MASK)
{
- ephy_location_entry_restore_location (entry);
+ g_signal_emit_by_name (entry, "activate");
- /* Don't consume the keypress, since we want the default
- * action (close autocompletion popup) too.
- */
+ return TRUE;
+ }
+ else if (event->keyval == GDK_Escape && (event->state & mask) == 0)
+ {
+ ephy_location_entry_reset (lentry);
+ /* don't return TRUE since we want to cancel the autocompletion popup too */
}
return FALSE;
@@ -354,8 +407,9 @@ match_selected_cb (GtkEntryCompletion *completion,
gtk_tree_model_get (model, iter,
le->priv->action_col, &item, -1);
+ if (item == NULL) return FALSE;
- ephy_location_entry_set_location (le, item);
+ ephy_location_entry_set_location (le, item, NULL);
g_signal_emit_by_name (le->priv->entry, "activate");
g_free (item);
@@ -585,8 +639,8 @@ ephy_location_entry_construct_contents (EphyLocationEntry *entry)
gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->lock_ebox), FALSE);
gtk_box_pack_end (GTK_BOX (hbox), priv->lock_ebox, FALSE, FALSE, 2);
- //priv->lock = gtk_image_new ();
- priv->lock = gtk_image_new_from_stock (GTK_STOCK_QUIT, GTK_ICON_SIZE_MENU);
+ priv->lock = gtk_image_new_from_stock (STOCK_LOCK_INSECURE,
+ GTK_ICON_SIZE_MENU);
gtk_container_add (GTK_CONTAINER (priv->lock_ebox), priv->lock);
gtk_widget_show_all (alignment);
@@ -601,10 +655,10 @@ ephy_location_entry_construct_contents (EphyLocationEntry *entry)
G_CALLBACK (favicon_drag_data_get_cb), entry);
g_signal_connect (priv->entry, "populate_popup",
G_CALLBACK (entry_populate_popup_cb), entry);
- g_signal_connect (priv->entry, "button_press_event",
- G_CALLBACK (entry_button_press_cb), entry);
g_signal_connect (priv->entry, "key-press-event",
G_CALLBACK (entry_key_press_cb), entry);
+ g_signal_connect (priv->entry, "button_press_event",
+ G_CALLBACK (entry_button_press_cb), entry);
g_signal_connect (priv->entry, "changed",
G_CALLBACK (editable_changed_cb), entry);
g_signal_connect (priv->entry, "drag_motion",
@@ -700,18 +754,67 @@ ephy_location_entry_set_completion (EphyLocationEntry *le,
}
void
-ephy_location_entry_set_location (EphyLocationEntry *le,
- const gchar *new_location)
+ephy_location_entry_set_location (EphyLocationEntry *entry,
+ const char *address,
+ const char *typed_address)
{
- EphyLocationEntryPrivate *p = le->priv;
+ EphyLocationEntryPrivate *priv = entry->priv;
+ GtkClipboard *clipboard;
+ const char *text;
+ char* selection = NULL;
+ int start, end;
- g_return_if_fail (new_location != NULL);
+ g_return_if_fail (address != NULL);
- p->user_changed = FALSE;
+ /* Setting a new text will clear the clipboard. This makes it impossible
+ * to copy&paste from the location entry of one tab into another tab, see
+ * bug #155824. So we save the selection iff the clipboard was owned by
+ * the location entry.
+ */
+ if (GTK_WIDGET_REALIZED (priv->entry))
+ {
+ clipboard = gtk_widget_get_clipboard (priv->entry,
+ GDK_SELECTION_PRIMARY);
+ g_return_if_fail (clipboard != NULL);
- gtk_entry_set_text (GTK_ENTRY (p->entry), new_location);
+ if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (priv->entry) &&
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (priv->entry),
+ &start, &end))
+ {
+ selection = gtk_editable_get_chars (GTK_EDITABLE (priv->entry),
+ start, end);
+ }
+ }
- p->user_changed = TRUE;
+ if (typed_address != NULL)
+ {
+ text = typed_address;
+ }
+ else if (address != NULL && strcmp (address, "about:blank") != 0)
+ {
+ text = address;
+ }
+ else
+ {
+ text = "";
+ }
+
+ priv->user_changed = FALSE;
+ gtk_entry_set_text (GTK_ENTRY (priv->entry), text);
+ priv->user_changed = TRUE;
+
+ priv->hash = g_str_hash (address);
+ update_favicon (entry);
+
+ /* Now restore the selection.
+ * Note that it's not owned by the entry anymore!
+ */
+ if (selection != NULL)
+ {
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY),
+ selection, strlen (selection));
+ g_free (selection);
+ }
}
const char *
@@ -720,16 +823,25 @@ ephy_location_entry_get_location (EphyLocationEntry *le)
return gtk_entry_get_text (GTK_ENTRY (le->priv->entry));
}
-void
-ephy_location_entry_restore_location (EphyLocationEntry *entry)
+gboolean
+ephy_location_entry_reset (EphyLocationEntry *entry)
{
+ EphyLocationEntryPrivate *priv = entry->priv;
+ const char *text, *old_text;
char *url = NULL;
-
- g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+ gboolean retval;
g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
- gtk_entry_set_text (GTK_ENTRY (entry->priv->entry), url ? url : "");
+ text = url != NULL ? url : "";
+ old_text = gtk_entry_get_text (GTK_ENTRY (priv->entry));
+ old_text = old_text != NULL ? old_text : "";
+
+ retval = g_str_hash (text) != g_str_hash (old_text);
+
+ ephy_location_entry_set_location (entry, text, NULL);
g_free (url);
+
+ return retval;
}
void
@@ -755,18 +867,16 @@ void
ephy_location_entry_set_favicon (EphyLocationEntry *entry,
GdkPixbuf *pixbuf)
{
- GtkImage *image = GTK_IMAGE (entry->priv->icon);
+ EphyLocationEntryPrivate *priv = entry->priv;
- if (pixbuf != NULL)
+ if (priv->favicon != NULL)
{
- gtk_image_set_from_pixbuf (image, pixbuf);
- }
- else
- {
- gtk_image_set_from_stock (image,
- GTK_STOCK_NEW,
- GTK_ICON_SIZE_MENU);
+ g_object_unref (priv->favicon);
}
+
+ priv->favicon = pixbuf ? g_object_ref (pixbuf) : NULL;
+
+ update_favicon (entry);
}
void
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index 1373a5ba2..7838abd93 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -47,11 +47,11 @@ struct _EphyLocationEntryClass
GtkToolItemClass parent_class;
/* Signals */
- void (*user_changed) (EphyLocationEntry *entry);
- void (* lock_clicked) (EphyLocationEntry *entry);
+ void (* user_changed) (EphyLocationEntry *entry);
+ void (* lock_clicked) (EphyLocationEntry *entry);
/* for getting the drag data */
- char * (* get_location) (EphyLocationEntry *entry);
- char * (* get_title) (EphyLocationEntry *entry);
+ char * (* get_location) (EphyLocationEntry *entry);
+ char * (* get_title) (EphyLocationEntry *entry);
};
struct _EphyLocationEntry
@@ -74,11 +74,12 @@ void ephy_location_entry_set_completion (EphyLocationEntry *le,
guint relevance_col);
void ephy_location_entry_set_location (EphyLocationEntry *le,
- const char *new_location);
+ const char *address,
+ const char *typed_address);
const char *ephy_location_entry_get_location (EphyLocationEntry *le);
-void ephy_location_entry_restore_location (EphyLocationEntry *le);
+gboolean ephy_location_entry_reset (EphyLocationEntry *entry);
void ephy_location_entry_activate (EphyLocationEntry *le);
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index 9043cac94..73d4456a3 100644
--- a/src/ephy-location-action.c
+++ b/src/ephy-location-action.c
@@ -29,10 +29,12 @@
#include "ephy-link.h"
#include "ephy-debug.h"
+#include <gdk/gdkkeysyms.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkstock.h>
#include <gtk/gtkimage.h>
#include <gtk/gtkentrycompletion.h>
+#include <gtk/gtkmain.h>
#define EPHY_LOCATION_ACTION_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LOCATION_ACTION, EphyLocationActionPrivate))
@@ -41,14 +43,15 @@ struct _EphyLocationActionPrivate
EphyWindow *window;
GList *actions;
char *address;
- gboolean editable;
+ char *typed_address;
EphyNode *smart_bmks;
EphyBookmarks *bookmarks;
char *icon;
EphyFaviconCache *cache;
char *lock_stock_id;
char *lock_tooltip;
- gboolean show_lock;
+ guint editable : 1;
+ guint show_lock : 1;
};
static void ephy_location_action_init (EphyLocationAction *action);
@@ -142,16 +145,31 @@ action_activated_cb (GtkEntryCompletion *completion,
}
static void
-location_url_activate_cb (GtkEntry *entry,
- EphyLocationAction *action)
+entry_activate_cb (GtkEntry *entry,
+ EphyLocationAction *action)
{
const char *content;
+ GdkEvent *event;
+ gboolean control = FALSE;
content = gtk_entry_get_text (entry);
- if (content != NULL)
+ if (content == NULL || content[0] == '\0') return;
+
+ event = gtk_get_current_event ();
+ if (event)
{
- ephy_link_open (EPHY_LINK (action), content, NULL, 0);
+ 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);
}
+
+
+ ephy_link_open (EPHY_LINK (action), content, NULL,
+ control ? EPHY_LINK_NEW_TAB : 0);
}
static void
@@ -164,7 +182,7 @@ user_changed_cb (GtkWidget *proxy, EphyLocationAction *action)
LOG ("user_changed_cb, new address %s", address);
g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), proxy);
- ephy_location_action_set_address (action, address);
+ ephy_location_action_set_address (action, address, NULL);
g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy);
}
@@ -181,12 +199,14 @@ sync_address (GtkAction *gaction,
GtkWidget *proxy)
{
EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
+ EphyLocationActionPrivate *priv = action->priv;
EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
LOG ("sync_address %s", action->priv->address);
g_signal_handlers_block_by_func (proxy, G_CALLBACK (user_changed_cb), action);
- ephy_location_entry_set_location (lentry, action->priv->address);
+ ephy_location_entry_set_location (lentry, priv->address,
+ priv->typed_address);
g_signal_handlers_unblock_by_func (proxy, G_CALLBACK (user_changed_cb), action);
}
@@ -372,9 +392,9 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
entry = ephy_location_entry_get_entry (lentry);
g_signal_connect_object (entry, "activate",
- G_CALLBACK (location_url_activate_cb),
+ G_CALLBACK (entry_activate_cb),
action, 0);
- g_signal_connect_object (proxy, "user_changed",
+ g_signal_connect_object (proxy, "user-changed",
G_CALLBACK (user_changed_cb), action, 0);
g_signal_connect_object (proxy, "lock-clicked",
G_CALLBACK (lock_clicked_cb), action, 0);
@@ -419,7 +439,7 @@ ephy_location_action_set_property (GObject *object,
switch (prop_id)
{
case PROP_ADDRESS:
- ephy_location_action_set_address (action, g_value_get_string (value));
+ ephy_location_action_set_address (action, g_value_get_string (value), NULL);
break;
case PROP_EDITABLE:
action->priv->editable = g_value_get_boolean (value);
@@ -707,6 +727,7 @@ ephy_location_action_finalize (GObject *object)
g_list_free (priv->actions);
g_free (priv->address);
+ g_free (priv->typed_address);
g_free (priv->icon);
g_free (priv->lock_stock_id);
g_free (priv->lock_tooltip);
@@ -725,13 +746,22 @@ ephy_location_action_get_address (EphyLocationAction *action)
void
ephy_location_action_set_address (EphyLocationAction *action,
- const char *address)
+ const char *address,
+ const char *typed_address)
{
+ EphyLocationActionPrivate *priv;
+
g_return_if_fail (EPHY_IS_LOCATION_ACTION (action));
+ priv = action->priv;
+
LOG ("set_address %s", address);
- g_free (action->priv->address);
- action->priv->address = g_strdup (address);
+ g_free (priv->address);
+ priv->address = g_strdup (address);
+
+ g_free (priv->typed_address);
+ priv->typed_address = typed_address ? g_strdup (typed_address) : NULL;
+
g_object_notify (G_OBJECT (action), "address");
}
diff --git a/src/ephy-location-action.h b/src/ephy-location-action.h
index 15ad6f123..562ac67d8 100644
--- a/src/ephy-location-action.h
+++ b/src/ephy-location-action.h
@@ -57,7 +57,8 @@ GType ephy_location_action_get_type (void);
const char *ephy_location_action_get_address (EphyLocationAction *action);
void ephy_location_action_set_address (EphyLocationAction *action,
- const char *address);
+ const char *address,
+ const char *typed_address);
G_END_DECLS
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 0a5b1b7d9..e02ebb79f 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -107,7 +107,7 @@ update_location_editable (EphyWindow *window,
g_return_if_fail (embed != NULL);
address = ephy_embed_get_location (embed, TRUE);
- ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address);
+ ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address, NULL);
ephy_tab_set_typed_address (tab, NULL);
g_free (address);
}
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 54ba837c8..8c244f6cc 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -2208,22 +2208,12 @@ const char *
ephy_tab_get_typed_address (EphyTab *tab)
{
EphyTabPrivate *priv;
- const char *address = "";
g_return_val_if_fail (EPHY_IS_TAB (tab), NULL);
priv = tab->priv;
- if (priv->typed_address)
- {
- address = priv->typed_address;
- }
- else if (priv->address)
- {
- address = priv->address;
- }
-
- return address;
+ return priv->typed_address;
}
/**
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 24b7104d0..1dea8471b 100755
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -442,15 +442,16 @@ ephy_toolbar_get_location (EphyToolbar *toolbar)
void
ephy_toolbar_set_location (EphyToolbar *toolbar,
- const char *address)
+ const char *address,
+ const char *typed_address)
{
EphyToolbarPrivate *priv = toolbar->priv;
EphyLocationAction *action = EPHY_LOCATION_ACTION (priv->actions[LOCATION_ACTION]);
-
+
if (priv->updating_address) return;
priv->updating_address = TRUE;
- ephy_location_action_set_address (action, address);
+ ephy_location_action_set_address (action, address, typed_address);
priv->updating_address = FALSE;
}
diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h
index a7b90a81d..be9860c82 100644
--- a/src/ephy-toolbar.h
+++ b/src/ephy-toolbar.h
@@ -75,8 +75,8 @@ void ephy_toolbar_activate_location (EphyToolbar *t);
const char *ephy_toolbar_get_location (EphyToolbar *t);
void ephy_toolbar_set_location (EphyToolbar *toolbar,
- const char *location);
-
+ const char *address,
+ const char *typed_address);
void ephy_toolbar_set_navigation_actions (EphyToolbar *toolbar,
gboolean back,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index e474f75b2..b6d5955da 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -200,6 +200,8 @@ static const GtkActionEntry ephy_menu_entries [] = {
{ "ViewStop", GTK_STOCK_STOP, N_("_Stop"), "Escape",
N_("Stop current data transfer"),
G_CALLBACK (window_cmd_view_stop) },
+ { "ViewAlwaysStop", GTK_STOCK_STOP, N_("_Stop"), "Escape",
+ NULL, G_CALLBACK (window_cmd_view_stop) },
{ "ViewReload", GTK_STOCK_REFRESH, N_("_Reload"), "<control>R",
N_("Display the latest content of the current page"),
G_CALLBACK (window_cmd_view_reload) },
@@ -705,6 +707,35 @@ ephy_window_key_press_event (GtkWidget *widget,
guint mask = gtk_accelerator_get_default_mod_mask ();
char *accel = NULL;
+ /* Handle ESC here instead of an action callback, so we can
+ * handle it differently in the location entry, and we can
+ * stop even when the page is not loading (to stop animations).
+ */
+ if (event->keyval == GDK_Escape && (event->state & mask) == 0)
+ {
+ GtkWidget *widget;
+ EphyEmbed *embed;
+ gboolean handled = FALSE;
+
+ widget = gtk_window_get_focus (GTK_WINDOW (window));
+
+ if (GTK_IS_WIDGET (widget))
+ {
+ handled = gtk_widget_event (widget, (GdkEvent*)event);
+ }
+
+ embed = ephy_window_get_active_embed (window);
+ if (handled == FALSE && embed != NULL)
+ {
+ ephy_embed_activate (embed);
+ ephy_embed_stop_load (embed);
+
+ handled = TRUE;
+ }
+
+ return handled;
+ }
+
/* Don't activate menubar in ppv mode, or in lockdown mode */
if (window->priv->ppv_mode || eel_gconf_get_boolean (CONF_LOCKDOWN_HIDE_MENUBAR))
{
@@ -1114,11 +1145,12 @@ setup_ui_manager (EphyWindow *window)
}
static void
-sync_tab_typed_address (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
+sync_tab_address (EphyTab *tab, GParamSpec *pspec, EphyWindow *window)
{
if (window->priv->closing) return;
ephy_toolbar_set_location (window->priv->toolbar,
+ ephy_tab_get_address (tab),
ephy_tab_get_typed_address (tab));
}
@@ -1868,7 +1900,7 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
if (old_tab != NULL)
{
g_signal_handlers_disconnect_by_func (old_tab,
- G_CALLBACK (sync_tab_typed_address),
+ G_CALLBACK (sync_tab_address),
window);
g_signal_handlers_disconnect_by_func (old_tab,
G_CALLBACK (sync_tab_document_type),
@@ -1916,7 +1948,7 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
if (new_tab != NULL)
{
- sync_tab_typed_address (new_tab, NULL, window);
+ sync_tab_address (new_tab, NULL, window);
sync_tab_document_type (new_tab, NULL, window);
sync_tab_icon (new_tab, NULL, window);
sync_tab_load_progress (new_tab, NULL, window);
@@ -1929,8 +1961,8 @@ ephy_window_set_active_tab (EphyWindow *window, EphyTab *new_tab)
sync_tab_title (new_tab, NULL, window);
sync_tab_zoom (new_tab, NULL, window);
- g_signal_connect_object (new_tab, "notify::typed-address",
- G_CALLBACK (sync_tab_typed_address),
+ g_signal_connect_object (new_tab, "notify::address",
+ G_CALLBACK (sync_tab_address),
window, 0);
g_signal_connect_object (new_tab, "notify::document-type",
G_CALLBACK (sync_tab_document_type),
@@ -2035,7 +2067,7 @@ modal_alert_cb (EphyEmbed *embed,
/* make sure the location entry shows the real URL of the tab's page */
address = ephy_embed_get_location (embed, TRUE);
- ephy_toolbar_set_location (priv->toolbar, address);
+ ephy_toolbar_set_location (priv->toolbar, address, NULL);
g_free (address);
/* don't suppress alert */