summaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-22 10:28:57 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-09-22 10:28:57 -0700
commit4c113ee01622e515492ac3c3197df0cd281d58d4 (patch)
treeec6f2eaaa148070927e4ee659b7a2d534043684c /divelist.c
parent68b666f50ab93f10b4261223f1036e0c4a1ca1b8 (diff)
downloadsubsurface-4c113ee01622e515492ac3c3197df0cd281d58d4.tar.gz
Put the default focus on the dive list at startup
This is some crazy stuff. Apparently the only sane way to do this is by hooking into the "realize" callback for the dive list widget. Whatever. Dirk did the googling to figure this all out. Suggested-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/divelist.c b/divelist.c
index c00da0bcc..97a5674bf 100644
--- a/divelist.c
+++ b/divelist.c
@@ -451,6 +451,15 @@ static GtkTreeViewColumn *divelist_column(struct DiveList *dl, int index, const
return col;
}
+/*
+ * This is some crazy crap. The only way to get default focus seems
+ * to be to grab focus as the widget is being shown the first time.
+ */
+static void realize_cb(GtkWidget *tree_view, gpointer userdata)
+{
+ gtk_widget_grab_focus(tree_view);
+}
+
GtkWidget *dive_list_create(void)
{
GtkTreeSelection *selection;
@@ -490,6 +499,7 @@ GtkWidget *dive_list_create(void)
"rules-hint", TRUE,
NULL);
+ g_signal_connect_after(dive_list.tree_view, "realize", G_CALLBACK(realize_cb), NULL);
g_signal_connect(selection, "changed", G_CALLBACK(selection_cb), dive_list.model);
dive_list.container_widget = gtk_scrolled_window_new(NULL, NULL);