aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Kaser <f.kaser@gmx.net>2010-07-27 22:59:58 +0800
committerFelix Kaser <f.kaser@gmx.net>2010-07-29 21:48:13 +0800
commit6568f7b78787cd1c6dbf7a447b71865986b12bc6 (patch)
tree18b0670613ebbdd395386cc2be2644d49df229df
parent2e4f5741143341616ed2cca3bf27a0204483d4ff (diff)
downloadgsoc2013-empathy-6568f7b78787cd1c6dbf7a447b71865986b12bc6.tar
gsoc2013-empathy-6568f7b78787cd1c6dbf7a447b71865986b12bc6.tar.gz
gsoc2013-empathy-6568f7b78787cd1c6dbf7a447b71865986b12bc6.tar.bz2
gsoc2013-empathy-6568f7b78787cd1c6dbf7a447b71865986b12bc6.tar.lz
gsoc2013-empathy-6568f7b78787cd1c6dbf7a447b71865986b12bc6.tar.xz
gsoc2013-empathy-6568f7b78787cd1c6dbf7a447b71865986b12bc6.tar.zst
gsoc2013-empathy-6568f7b78787cd1c6dbf7a447b71865986b12bc6.zip
enable keynavigation during search in contact-list
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c24
-rw-r--r--libempathy-gtk/empathy-live-search.c28
2 files changed, 48 insertions, 4 deletions
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 5860adef8..11c9e78a2 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -1277,6 +1277,24 @@ contact_list_view_search_activate_cb (GtkWidget *search,
}
static void
+contact_list_view_search_key_navigation_cb (GtkWidget *search,
+ gpointer eventkey,
+ EmpathyContactListView *view)
+{
+ GdkEventKey *event = ((GdkEventKey *) eventkey);
+ if (event->keyval == GDK_Up || event->keyval == GDK_Down) {
+ GdkEvent *new_event;
+
+ new_event = gdk_event_copy ((GdkEvent *) event);
+ gtk_widget_grab_focus (GTK_WIDGET (view));
+ gtk_widget_event (GTK_WIDGET (view), new_event);
+ gtk_widget_grab_focus (search);
+
+ gdk_event_free (new_event);
+ }
+}
+
+static void
contact_list_view_search_hide_cb (EmpathyLiveSearch *search,
EmpathyContactListView *view)
{
@@ -2144,6 +2162,9 @@ empathy_contact_list_view_set_live_search (EmpathyContactListView *view,
contact_list_view_search_activate_cb,
view);
g_signal_handlers_disconnect_by_func (priv->search_widget,
+ contact_list_view_search_key_navigation_cb,
+ view);
+ g_signal_handlers_disconnect_by_func (priv->search_widget,
contact_list_view_search_hide_cb,
view);
g_signal_handlers_disconnect_by_func (priv->search_widget,
@@ -2167,6 +2188,9 @@ empathy_contact_list_view_set_live_search (EmpathyContactListView *view,
g_signal_connect (priv->search_widget, "activate",
G_CALLBACK (contact_list_view_search_activate_cb),
view);
+ g_signal_connect (priv->search_widget, "key-navigation",
+ G_CALLBACK (contact_list_view_search_key_navigation_cb),
+ view);
g_signal_connect (priv->search_widget, "hide",
G_CALLBACK (contact_list_view_search_hide_cb),
view);
diff --git a/libempathy-gtk/empathy-live-search.c b/libempathy-gtk/empathy-live-search.c
index 9de2e199a..414a266f6 100644
--- a/libempathy-gtk/empathy-live-search.c
+++ b/libempathy-gtk/empathy-live-search.c
@@ -53,6 +53,7 @@ enum
enum
{
ACTIVATE,
+ KEYNAV,
LAST_SIGNAL
};
@@ -139,6 +140,14 @@ live_search_entry_key_pressed_cb (GtkEntry *entry,
return TRUE;
}
+ /* emit key navigation signal, so other widgets can respond to it properly */
+ if (event->keyval == GDK_Up || event->keyval == GDK_Down
+ || event->keyval == GDK_Left || event->keyval == GDK_Right)
+ {
+ g_signal_emit (self, signals[KEYNAV], 0, event);
+ return TRUE;
+ }
+
return FALSE;
}
@@ -197,10 +206,10 @@ live_search_key_press_event_cb (GtkWidget *widget,
event->keyval == GDK_Control_R)
return FALSE;
- /* dont forward the arrow up/down key to the entry, it is needed for
- * navigation in the treeview */
+ /* dont forward the up and down arrow keys to the entry, they are needed for
+ * navigation in the treeview and are not needed in the search entry */
if (event->keyval == GDK_Up || event->keyval == GDK_Down)
- return FALSE;
+ return FALSE;
/* realize the widget if it is not realized yet */
gtk_widget_realize (priv->search_entry);
@@ -350,7 +359,10 @@ live_search_grab_focus (GtkWidget *widget)
EmpathyLiveSearchPriv *priv = GET_PRIV (self);
if (!gtk_widget_has_focus (priv->search_entry))
- gtk_widget_grab_focus (priv->search_entry);
+ {
+ gtk_widget_grab_focus (priv->search_entry);
+ gtk_editable_set_position (GTK_EDITABLE (priv->search_entry), -1);
+ }
}
static void
@@ -377,6 +389,14 @@ empathy_live_search_class_init (EmpathyLiveSearchClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ signals[KEYNAV] = g_signal_new ("key-navigation",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
param_spec = g_param_spec_object ("hook-widget", "Live Searchs Hook Widget",
"The live search catches key-press-events on this widget",
GTK_TYPE_WIDGET, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);