From 8039785073aaac784ae1917db2a46e9cb86190cb Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Fri, 1 Jan 2010 18:23:15 +0100 Subject: [PATCH] Move up/ down key handling from the entry into MidoriLocationAction --- midori/midori-locationaction.c | 15 +++++++++++- midori/midori-locationentry.c | 44 ---------------------------------- midori/midori-locationentry.h | 3 --- tests/properties.c | 2 -- 4 files changed, 14 insertions(+), 50 deletions(-) diff --git a/midori/midori-locationaction.c b/midori/midori-locationaction.c index 4939b567..73fe6af1 100644 --- a/midori/midori-locationaction.c +++ b/midori/midori-locationaction.c @@ -542,7 +542,7 @@ midori_location_action_create_tool_item (GtkAction* action) alignment = gtk_alignment_new (0.0f, 0.5f, 1.0f, 0.1f); gtk_widget_show (alignment); gtk_container_add (GTK_CONTAINER (toolitem), alignment); - location_entry = midori_location_entry_new (); + location_entry = g_object_new (MIDORI_TYPE_LOCATION_ENTRY, NULL); gtk_widget_show (location_entry); gtk_container_add (GTK_CONTAINER (alignment), location_entry); @@ -581,6 +581,19 @@ midori_location_action_key_press_event_cb (GtkEntry* entry, g_signal_emit (action, signals[RESET_URI], 0); return TRUE; } + case GDK_Down: + case GDK_Up: + { + GtkWidget* parent = gtk_widget_get_parent (GTK_WIDGET (entry)); + if (!katze_object_get_boolean (parent, "popup-shown")) + gtk_combo_box_popup (GTK_COMBO_BOX (parent)); + return TRUE; + } + case GDK_Page_Up: + case GDK_Page_Down: + { + return TRUE; + } } return FALSE; } diff --git a/midori/midori-locationentry.c b/midori/midori-locationentry.c index cb42c67c..5dc5a429 100644 --- a/midori/midori-locationentry.c +++ b/midori/midori-locationentry.c @@ -30,11 +30,6 @@ struct _MidoriLocationEntryClass G_DEFINE_TYPE (MidoriLocationEntry, midori_location_entry, GTK_TYPE_COMBO_BOX_ENTRY) -static gboolean -entry_key_press_event (GtkWidget* widget, - GdkEventKey* event, - MidoriLocationEntry* location_entry); - static void midori_location_entry_class_init (MidoriLocationEntryClass* class) { @@ -393,8 +388,6 @@ midori_location_entry_init (MidoriLocationEntry* location_entry) gtk_icon_entry_set_icon_highlight (GTK_ICON_ENTRY (entry), GTK_ICON_ENTRY_SECONDARY, TRUE); #endif - g_signal_connect_after (entry, "key-press-event", - G_CALLBACK (entry_key_press_event), location_entry); #if !GTK_CHECK_VERSION (2, 16, 0) g_signal_connect_after (entry, "expose-event", G_CALLBACK (entry_expose_event), location_entry); @@ -402,40 +395,3 @@ midori_location_entry_init (MidoriLocationEntry* location_entry) gtk_widget_show (entry); gtk_container_add (GTK_CONTAINER (location_entry), entry); } - -static gboolean -entry_key_press_event (GtkWidget* widget, - GdkEventKey* event, - MidoriLocationEntry* location_entry) -{ - switch (event->keyval) - { - case GDK_Down: - case GDK_Up: - { - if (!katze_object_get_boolean (location_entry, "popup-shown")) - gtk_combo_box_popup (GTK_COMBO_BOX (location_entry)); - return TRUE; - } - case GDK_Page_Up: - case GDK_Page_Down: - { - return TRUE; - } - } - - return FALSE; -} - -/** - * midori_location_entry_new: - * - * Creates a new #MidoriLocationEntry. - * - * Return value: a new #MidoriLocationEntry - **/ -GtkWidget* -midori_location_entry_new (void) -{ - return g_object_new (MIDORI_TYPE_LOCATION_ENTRY, NULL); -} diff --git a/midori/midori-locationentry.h b/midori/midori-locationentry.h index 7a2317f4..8841f54b 100644 --- a/midori/midori-locationentry.h +++ b/midori/midori-locationentry.h @@ -29,9 +29,6 @@ typedef struct _MidoriLocationEntryClass MidoriLocationEntryClass; GType midori_location_entry_get_type (void); -GtkWidget* -midori_location_entry_new (void); - void midori_location_entry_set_progress (MidoriLocationEntry* location_entry, gdouble progress); diff --git a/tests/properties.c b/tests/properties.c index 239717ca..93bf2228 100644 --- a/tests/properties.c +++ b/tests/properties.c @@ -205,8 +205,6 @@ main (int argc, (gconstpointer)MIDORI_TYPE_EXTENSION, properties_type_test); g_test_add_data_func ("/properties/location-action", (gconstpointer)MIDORI_TYPE_LOCATION_ACTION, properties_type_test); - g_test_add_data_func ("/properties/location-entry", - (gconstpointer)MIDORI_TYPE_LOCATION_ENTRY, properties_type_test); g_test_add_data_func ("/properties/panel", (gconstpointer)MIDORI_TYPE_PANEL, properties_type_test); g_test_add_data_func ("/properties/preferences",