[gnome-control-center] datetime: Connect arrow up/down keynav across list boxes
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] datetime: Connect arrow up/down keynav across list boxes
- Date: Sun, 15 Sep 2013 22:38:48 +0000 (UTC)
commit 47e8406ed6940982d28184e5e403b7296197523a
Author: Kalev Lember <kalevlember gmail com>
Date: Thu Sep 12 21:24:41 2013 +0200
datetime: Connect arrow up/down keynav across list boxes
https://bugzilla.gnome.org/show_bug.cgi?id=707942
panels/datetime/cc-datetime-panel.c | 46 +++++++++++++++++++++++++++++++---
panels/datetime/datetime.ui | 4 +-
2 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/panels/datetime/cc-datetime-panel.c b/panels/datetime/cc-datetime-panel.c
index 443c058..50a840d 100644
--- a/panels/datetime/cc-datetime-panel.c
+++ b/panels/datetime/cc-datetime-panel.c
@@ -71,6 +71,9 @@ struct _CcDateTimePanelPrivate
GtkBuilder *builder;
GtkWidget *map;
+ GList *listboxes;
+ GList *listboxes_reverse;
+
TzLocation *current_location;
GtkTreeModelFilter *city_filter;
@@ -142,6 +145,9 @@ cc_date_time_panel_dispose (GObject *object)
g_clear_pointer (&priv->date, g_date_time_unref);
+ g_clear_pointer (&priv->listboxes, g_list_free);
+ g_clear_pointer (&priv->listboxes_reverse, g_list_free);
+
G_OBJECT_CLASS (cc_date_time_panel_parent_class)->dispose (object);
}
@@ -827,6 +833,31 @@ on_timedated_properties_changed (GDBusProxy *proxy,
}
}
+static gboolean
+keynav_failed (GtkWidget *listbox,
+ GtkDirectionType direction,
+ CcDateTimePanel *self)
+{
+ CcDateTimePanelPrivate *priv = self->priv;
+ GList *item, *listboxes;
+
+ /* Find the listbox in the list of GtkListBoxes */
+ if (direction == GTK_DIR_DOWN)
+ listboxes = priv->listboxes;
+ else
+ listboxes = priv->listboxes_reverse;
+
+ item = g_list_find (listboxes, listbox);
+ g_assert (item);
+ if (item->next)
+ {
+ gtk_widget_child_focus (GTK_WIDGET (item->next->data), direction);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static void
update_header (GtkListBoxRow *row,
GtkListBoxRow *before,
@@ -936,15 +967,20 @@ list_box_row_activated (GtkListBox *listbox,
}
static void
-setup_main_listview (CcDateTimePanel *self)
+setup_listbox (CcDateTimePanel *self,
+ GtkWidget *listbox)
{
CcDateTimePanelPrivate *priv = self->priv;
- GtkWidget *listbox;
- listbox = W ("listbox");
gtk_list_box_set_header_func (GTK_LIST_BOX (listbox), update_header, NULL, NULL);
g_signal_connect (listbox, "row-activated",
G_CALLBACK (list_box_row_activated), self);
+
+ g_signal_connect (listbox, "keynav-failed",
+ G_CALLBACK (keynav_failed), self);
+
+ priv->listboxes = g_list_append (priv->listboxes, listbox);
+ priv->listboxes_reverse = g_list_prepend (priv->listboxes_reverse, listbox);
}
static gboolean
@@ -1232,7 +1268,9 @@ cc_date_time_panel_init (CcDateTimePanel *self)
setup_timezone_dialog (self);
setup_datetime_dialog (self);
- setup_main_listview (self);
+
+ setup_listbox (self, W ("listbox1"));
+ setup_listbox (self, W ("listbox2"));
/* set up network time switch */
bind_switch_to_row (self,
diff --git a/panels/datetime/datetime.ui b/panels/datetime/datetime.ui
index f516729..1875826 100644
--- a/panels/datetime/datetime.ui
+++ b/panels/datetime/datetime.ui
@@ -485,7 +485,7 @@
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkListBox" id="listbox">
+ <object class="GtkListBox" id="listbox1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
@@ -751,7 +751,7 @@
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkListBox" id="listbox1">
+ <object class="GtkListBox" id="listbox2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]