diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-location-action.c | 58 | ||||
-rw-r--r-- | src/ephy-location-action.h | 3 | ||||
-rw-r--r-- | src/ephy-lockdown.c | 2 | ||||
-rw-r--r-- | src/ephy-tab.c | 12 | ||||
-rwxr-xr-x | src/ephy-toolbar.c | 7 | ||||
-rw-r--r-- | src/ephy-toolbar.h | 4 | ||||
-rw-r--r-- | src/ephy-window.c | 44 |
7 files changed, 92 insertions, 38 deletions
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 */ |