[libgda] GdaBrowser: improved default focus in editor



commit c9ffb1967a36292213ca69594d54760b563097ee
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Sep 15 20:06:51 2009 +0200

    GdaBrowser: improved default focus in editor

 tools/browser/browser-window.c                    |    1 +
 tools/browser/query-exec/query-console.c          |   11 +++++++++++
 tools/browser/query-exec/query-editor.c           |   11 +++++++++++
 tools/browser/query-exec/query-exec-perspective.c |   17 +++++++++++++++++
 4 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/tools/browser/browser-window.c b/tools/browser/browser-window.c
index 9d25db1..29e54f2 100644
--- a/tools/browser/browser-window.c
+++ b/tools/browser/browser-window.c
@@ -403,6 +403,7 @@ browser_window_new (BrowserConnection *bcnc, BrowserPerspectiveFactory *factory)
 	pers->page_number = gtk_notebook_append_page (bwin->priv->perspectives_nb,
 						      GTK_WIDGET (pers->perspective_widget), NULL);
         gtk_widget_show_all ((GtkWidget*) bwin->priv->perspectives_nb);
+	gtk_widget_grab_focus (GTK_WIDGET (pers->perspective_widget));
 
 	/* build the perspectives menu */
 	GtkActionGroup *agroup;
diff --git a/tools/browser/query-exec/query-console.c b/tools/browser/query-exec/query-console.c
index 9ae295d..c2c87d6 100644
--- a/tools/browser/query-exec/query-console.c
+++ b/tools/browser/query-exec/query-console.c
@@ -136,6 +136,7 @@ static void query_console_class_init (QueryConsoleClass *klass);
 static void query_console_init       (QueryConsole *tconsole, QueryConsoleClass *klass);
 static void query_console_dispose   (GObject *object);
 static void query_console_show_all (GtkWidget *widget);
+static void query_console_grab_focus (GtkWidget *widget);
 
 /* BrowserPage interface */
 static void                 query_console_page_init (BrowserPageIface *iface);
@@ -163,6 +164,7 @@ query_console_class_init (QueryConsoleClass *klass)
 
 	object_class->dispose = query_console_dispose;
 	GTK_WIDGET_CLASS (klass)->show_all = query_console_show_all;
+	GTK_WIDGET_CLASS (klass)->grab_focus = query_console_grab_focus;
 }
 
 static void
@@ -1051,3 +1053,12 @@ query_console_page_get_tab_label (BrowserPage *page, GtkWidget **out_close_butto
 						  STOCK_CONSOLE,
 						  out_close_button ? TRUE : FALSE, out_close_button);
 }
+
+static void
+query_console_grab_focus (GtkWidget *widget)
+{
+	QueryConsole *tconsole;
+
+	tconsole = QUERY_CONSOLE (widget);
+	gtk_widget_grab_focus (GTK_WIDGET (tconsole->priv->editor));
+}
diff --git a/tools/browser/query-exec/query-editor.c b/tools/browser/query-exec/query-editor.c
index 79bb52e..6735354 100644
--- a/tools/browser/query-exec/query-editor.c
+++ b/tools/browser/query-exec/query-editor.c
@@ -85,6 +85,8 @@ static void query_editor_init       (QueryEditor *editor, QueryEditorClass *klas
 static void query_editor_finalize   (GObject *object);
 
 static void query_editor_map       (GtkWidget *widget);
+static void query_editor_grab_focus (GtkWidget *widget);
+
 
 static GObjectClass *parent_class = NULL;
 static GHashTable *supported_languages = NULL;
@@ -193,6 +195,7 @@ query_editor_class_init (QueryEditorClass *klass)
 
 	object_class->finalize = query_editor_finalize;
 	GTK_WIDGET_CLASS (object_class)->map = query_editor_map;
+	GTK_WIDGET_CLASS (object_class)->grab_focus = query_editor_grab_focus;
 }
 
 static void
@@ -442,6 +445,14 @@ query_editor_map (GtkWidget *widget)
 	}
 }
 
+
+static void
+query_editor_grab_focus (GtkWidget *widget)
+{
+	gtk_widget_grab_focus (QUERY_EDITOR (widget)->priv->text);
+}
+
+
 static void
 hist_data_free_all (QueryEditor *editor)
 {
diff --git a/tools/browser/query-exec/query-exec-perspective.c b/tools/browser/query-exec/query-exec-perspective.c
index 89633e4..0550f7a 100644
--- a/tools/browser/query-exec/query-exec-perspective.c
+++ b/tools/browser/query-exec/query-exec-perspective.c
@@ -33,6 +33,8 @@ static void query_exec_perspective_class_init (QueryExecPerspectiveClass *klass)
 static void query_exec_perspective_init (QueryExecPerspective *stmt);
 static void query_exec_perspective_dispose (GObject *object);
 
+static void query_exec_perspective_grab_focus (GtkWidget *widget);
+
 /* BrowserPerspective interface */
 static void                 query_exec_perspective_perspective_init (BrowserPerspectiveIface *iface);
 static GtkActionGroup      *query_exec_perspective_get_actions_group (BrowserPerspective *perspective);
@@ -93,6 +95,17 @@ query_exec_perspective_class_init (QueryExecPerspectiveClass * klass)
 	parent_class = g_type_class_peek_parent (klass);
 
 	object_class->dispose = query_exec_perspective_dispose;
+	GTK_WIDGET_CLASS (object_class)->grab_focus = query_exec_perspective_grab_focus;
+}
+
+static void
+query_exec_perspective_grab_focus (GtkWidget *widget)
+{
+	GtkNotebook *nb;
+
+	nb = GTK_NOTEBOOK (QUERY_EXEC_PERSPECTIVE (widget)->priv->notebook);
+	gtk_widget_grab_focus (gtk_notebook_get_nth_page (nb,
+							  gtk_notebook_get_current_page (nb)));
 }
 
 static void
@@ -182,6 +195,8 @@ query_exec_perspective_new (BrowserWindow *bwin)
 	g_signal_connect (bcnc, "transaction-status-changed",
 			  G_CALLBACK (transaction_status_changed_cb), bpers);
 
+	gtk_widget_grab_focus (page);
+
 	return bpers;
 }
 
@@ -277,6 +292,8 @@ query_exec_add_cb (GtkAction *action, BrowserPerspective *bpers)
 
 	tlabel = browser_page_get_tab_label (BROWSER_PAGE (page), NULL);
 	gtk_notebook_set_menu_label (GTK_NOTEBOOK (perspective->priv->notebook), page, tlabel);
+
+	gtk_widget_grab_focus (page);
 }
 
 static void



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