Move up/ down key handling from the entry into MidoriLocationAction

This commit is contained in:
Christian Dywan 2010-01-01 18:23:15 +01:00
parent 15658145b2
commit 8039785073
4 changed files with 14 additions and 50 deletions

View file

@ -542,7 +542,7 @@ midori_location_action_create_tool_item (GtkAction* action)
alignment = gtk_alignment_new (0.0f, 0.5f, 1.0f, 0.1f); alignment = gtk_alignment_new (0.0f, 0.5f, 1.0f, 0.1f);
gtk_widget_show (alignment); gtk_widget_show (alignment);
gtk_container_add (GTK_CONTAINER (toolitem), 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_widget_show (location_entry);
gtk_container_add (GTK_CONTAINER (alignment), 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); g_signal_emit (action, signals[RESET_URI], 0);
return TRUE; 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; return FALSE;
} }

View file

@ -30,11 +30,6 @@ struct _MidoriLocationEntryClass
G_DEFINE_TYPE (MidoriLocationEntry, G_DEFINE_TYPE (MidoriLocationEntry,
midori_location_entry, GTK_TYPE_COMBO_BOX_ENTRY) midori_location_entry, GTK_TYPE_COMBO_BOX_ENTRY)
static gboolean
entry_key_press_event (GtkWidget* widget,
GdkEventKey* event,
MidoriLocationEntry* location_entry);
static void static void
midori_location_entry_class_init (MidoriLocationEntryClass* class) 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_set_icon_highlight (GTK_ICON_ENTRY (entry),
GTK_ICON_ENTRY_SECONDARY, TRUE); GTK_ICON_ENTRY_SECONDARY, TRUE);
#endif #endif
g_signal_connect_after (entry, "key-press-event",
G_CALLBACK (entry_key_press_event), location_entry);
#if !GTK_CHECK_VERSION (2, 16, 0) #if !GTK_CHECK_VERSION (2, 16, 0)
g_signal_connect_after (entry, "expose-event", g_signal_connect_after (entry, "expose-event",
G_CALLBACK (entry_expose_event), location_entry); G_CALLBACK (entry_expose_event), location_entry);
@ -402,40 +395,3 @@ midori_location_entry_init (MidoriLocationEntry* location_entry)
gtk_widget_show (entry); gtk_widget_show (entry);
gtk_container_add (GTK_CONTAINER (location_entry), 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);
}

View file

@ -29,9 +29,6 @@ typedef struct _MidoriLocationEntryClass MidoriLocationEntryClass;
GType GType
midori_location_entry_get_type (void); midori_location_entry_get_type (void);
GtkWidget*
midori_location_entry_new (void);
void void
midori_location_entry_set_progress (MidoriLocationEntry* location_entry, midori_location_entry_set_progress (MidoriLocationEntry* location_entry,
gdouble progress); gdouble progress);

View file

@ -205,8 +205,6 @@ main (int argc,
(gconstpointer)MIDORI_TYPE_EXTENSION, properties_type_test); (gconstpointer)MIDORI_TYPE_EXTENSION, properties_type_test);
g_test_add_data_func ("/properties/location-action", g_test_add_data_func ("/properties/location-action",
(gconstpointer)MIDORI_TYPE_LOCATION_ACTION, properties_type_test); (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", g_test_add_data_func ("/properties/panel",
(gconstpointer)MIDORI_TYPE_PANEL, properties_type_test); (gconstpointer)MIDORI_TYPE_PANEL, properties_type_test);
g_test_add_data_func ("/properties/preferences", g_test_add_data_func ("/properties/preferences",