aboutsummaryrefslogtreecommitdiffstats
path: root/lib/widgets/ephy-location-entry.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-04-11 03:28:10 +0800
committerChristian Persch <chpe@src.gnome.org>2005-04-11 03:28:10 +0800
commit36dbd0e5b656c62c8a0860f668c313cf3ae010de (patch)
treee12e05e4d94962431db354d0ab5424768a60cd4d /lib/widgets/ephy-location-entry.c
parentb53d58efcee1ef734894b4b7d27afe9535f9e922 (diff)
downloadgsoc2013-epiphany-36dbd0e5b656c62c8a0860f668c313cf3ae010de.tar.gz
gsoc2013-epiphany-36dbd0e5b656c62c8a0860f668c313cf3ae010de.tar.zst
gsoc2013-epiphany-36dbd0e5b656c62c8a0860f668c313cf3ae010de.zip
Restore original URL when pressing ESC. Fixes bug #171179.
2005-04-10 Christian Persch <chpe@cvs.gnome.org> * lib/widgets/ephy-location-entry.c: (entry_key_press_cb), (ephy_location_entry_construct_contents), (ephy_location_entry_get_location), (ephy_location_entry_restore_location): * lib/widgets/ephy-location-entry.h: Restore original URL when pressing ESC. Fixes bug #171179.
Diffstat (limited to 'lib/widgets/ephy-location-entry.c')
-rw-r--r--lib/widgets/ephy-location-entry.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index b78612f72..426c874b9 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -32,6 +32,7 @@
#include "ephy-debug.h"
#include <glib/gi18n.h>
+#include <gdk/gdkkeysyms.h>
#include <gtk/gtktoolbar.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkwindow.h>
@@ -246,6 +247,23 @@ entry_button_press_cb (GtkWidget *entry, GdkEventButton *event, EphyLocationEntr
}
static gboolean
+entry_key_press_cb (GtkWidget *widget,
+ GdkEventKey *event,
+ EphyLocationEntry *entry)
+{
+ if (event->keyval == GDK_Escape)
+ {
+ ephy_location_entry_restore_location (entry);
+
+ /* Don't consume the keypress, since we want the default
+ * action (close autocompletion popup) too.
+ */
+ }
+
+ return FALSE;
+}
+
+static gboolean
keyword_match (const char *list,
const char *keyword)
{
@@ -586,6 +604,8 @@ ephy_location_entry_construct_contents (EphyLocationEntry *entry)
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, "changed",
G_CALLBACK (editable_changed_cb), entry);
g_signal_connect (priv->entry, "drag_motion",
@@ -702,6 +722,18 @@ ephy_location_entry_get_location (EphyLocationEntry *le)
}
void
+ephy_location_entry_restore_location (EphyLocationEntry *entry)
+{
+ char *url = NULL;
+
+ g_return_if_fail (EPHY_IS_LOCATION_ENTRY (entry));
+
+ g_signal_emit (entry, signals[GET_LOCATION], 0, &url);
+ gtk_entry_set_text (GTK_ENTRY (entry->priv->entry), url ? url : "");
+ g_free (url);
+}
+
+void
ephy_location_entry_activate (EphyLocationEntry *le)
{
GtkWidget *toplevel;