[libgda/LIBGDA_5.0] GdauiLogin: focus on the entry which needs attention when focus is obtained



commit 92a8cbc6927a2b7aac3bfde55655a05d6f976681
Author: Vivien Malerba <malerba gnome-db org>
Date:   Mon Jan 2 22:14:22 2012 +0100

    GdauiLogin: focus on the entry which needs attention when focus is obtained

 libgda-ui/gdaui-login.c                         |    6 +++++
 libgda-ui/internal/gdaui-provider-auth-editor.c |   25 ++++++++++++++++------
 2 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/libgda-ui/gdaui-login.c b/libgda-ui/gdaui-login.c
index abcc6eb..a3eb6c9 100644
--- a/libgda-ui/gdaui-login.c
+++ b/libgda-ui/gdaui-login.c
@@ -474,6 +474,9 @@ dsn_entry_changed_cb (GdauiDsnSelector *sel, GdauiLogin *login)
 	_gdaui_provider_spec_editor_set_specs (GDAUI_PROVIDER_SPEC_EDITOR (login->priv->cnc_params_editor),
 					       info ? info->cnc_string : NULL);
 
+	if (login->priv->auth_widget)
+		gtk_widget_grab_focus (login->priv->auth_widget);
+
 	g_signal_emit (login, gdaui_login_signals [CHANGED], 0, settings_are_valid (login));
 }
 
@@ -493,6 +496,9 @@ prov_entry_changed_cb (GdauiProviderSelector *sel, GdauiLogin *login)
 	_gdaui_provider_auth_editor_set_provider (GDAUI_PROVIDER_AUTH_EDITOR (login->priv->auth_widget),
 						 prov);
 
+	if (login->priv->auth_widget)
+		gtk_widget_grab_focus (login->priv->auth_widget);
+
 	g_signal_emit (login, gdaui_login_signals [CHANGED], 0, settings_are_valid (login));
 }
 
diff --git a/libgda-ui/internal/gdaui-provider-auth-editor.c b/libgda-ui/internal/gdaui-provider-auth-editor.c
index 3d596ef..3e34db4 100644
--- a/libgda-ui/internal/gdaui-provider-auth-editor.c
+++ b/libgda-ui/internal/gdaui-provider-auth-editor.c
@@ -37,17 +37,19 @@ struct _GdauiProviderAuthEditorPrivate {
 
 static void gdaui_provider_auth_editor_class_init (GdauiProviderAuthEditorClass *klass);
 static void gdaui_provider_auth_editor_init       (GdauiProviderAuthEditor *auth,
-						      GdauiProviderAuthEditorClass *klass);
+						   GdauiProviderAuthEditorClass *klass);
 static void gdaui_provider_auth_editor_finalize   (GObject *object);
 
 static void gdaui_provider_auth_editor_set_property (GObject *object,
-							guint param_id,
-							const GValue *value,
-							GParamSpec *pspec);
+						     guint param_id,
+						     const GValue *value,
+						     GParamSpec *pspec);
 static void gdaui_provider_auth_editor_get_property (GObject *object,
-							guint param_id,
-							GValue *value,
-							GParamSpec *pspec);
+						     guint param_id,
+						     GValue *value,
+						     GParamSpec *pspec);
+
+static void gdaui_provider_auth_editor_grab_focus (GtkWidget *widget);
 
 enum {
 	PROP_0,
@@ -78,6 +80,7 @@ gdaui_provider_auth_editor_class_init (GdauiProviderAuthEditorClass *klass)
 	object_class->set_property = gdaui_provider_auth_editor_set_property;
 	object_class->get_property = gdaui_provider_auth_editor_get_property;
 	klass->changed = NULL;
+	GTK_WIDGET_CLASS (klass)->grab_focus = gdaui_provider_auth_editor_grab_focus;
 
 	g_object_class_install_property (object_class, PROP_PROVIDER,
 	                                 g_param_spec_string ("provider", NULL, NULL, NULL,
@@ -95,6 +98,14 @@ gdaui_provider_auth_editor_class_init (GdauiProviderAuthEditorClass *klass)
 }
 
 static void
+gdaui_provider_auth_editor_grab_focus (GtkWidget *widget)
+{
+	GdauiProviderAuthEditor *aed = GDAUI_PROVIDER_AUTH_EDITOR (widget);
+	if (aed->priv->auth_widget)
+		gdaui_basic_form_entry_grab_focus (GDAUI_BASIC_FORM (aed->priv->auth_widget), NULL);
+}
+
+static void
 auth_form_changed (G_GNUC_UNUSED GdauiBasicForm *form, G_GNUC_UNUSED GdaHolder *param, gboolean is_user_modif,
 		   GdauiProviderAuthEditor *auth)
 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]