From 0f9d55ef5fb04568bd96089eeb069b549b2b675d Mon Sep 17 00:00:00 2001 From: compudj Date: Sun, 8 Aug 2004 06:59:50 +0000 Subject: [PATCH] tweak : select the first widget by default git-svn-id: http://ltt.polymtl.ca/svn@675 04897980-b3bd-0310-b5e0-8ef037075253 --- .../gui/lttvwindow/lttvwindow/callbacks.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c index 455113bc..1ea288a5 100644 --- a/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c +++ b/ltt/branches/poly/lttv/modules/gui/lttvwindow/lttvwindow/callbacks.c @@ -227,9 +227,7 @@ void insert_viewer(GtkWidget* widget, lttvwindow_viewer_constructor constructor) * child of this widget. The little trick is to get each child * of each GTK_CONTAINER, even subchildren. */ - { - connect_focus_recursive(viewer, viewer); - } + connect_focus_recursive(viewer, viewer); } } @@ -472,6 +470,11 @@ void create_new_window(GtkWidget* widget, gpointer user_data, gboolean clone) } } +/* Get the currently focused viewer. + * If no viewer is focused, use the first one. + * + * If no viewer available, return NULL. + */ GtkWidget *viewer_container_focus(GtkWidget *container) { GtkWidget *widget; @@ -479,7 +482,14 @@ GtkWidget *viewer_container_focus(GtkWidget *container) widget = (GtkWidget*)g_object_get_data(G_OBJECT(container), "focused_viewer"); - if(widget == NULL) g_debug("no widget focused"); + if(widget == NULL) { + g_debug("no widget focused"); + GList *children = gtk_container_get_children(GTK_CONTAINER(container)); + + if(children != NULL) + widget = GTK_WIDGET(children->data); + } + return widget; -- 2.34.1