[libgda] Added an option to hide the favorites tab in GdaBrowser



commit 1b257ef7766df027369217dc50341b1bc6720055
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed Aug 4 19:23:10 2010 +0200

    Added an option to hide the favorites tab in GdaBrowser

 tools/browser/browser-window.c                     |    5 ++-
 .../data-manager/data-manager-perspective.c        |   37 ++++++++++++++++++-
 tools/browser/query-exec/query-exec-perspective.c  |   33 +++++++++++++++++
 .../schema-browser/schema-browser-perspective.c    |   34 +++++++++++++++++-
 4 files changed, 105 insertions(+), 4 deletions(-)
---
diff --git a/tools/browser/browser-window.c b/tools/browser/browser-window.c
index 24584a8..72ce748 100644
--- a/tools/browser/browser-window.c
+++ b/tools/browser/browser-window.c
@@ -235,6 +235,7 @@ static const GtkActionEntry ui_actions[] = {
         { "ConnectionClose", GTK_STOCK_CLOSE, "_Close connection", NULL, "Close this connection", G_CALLBACK (connection_close_cb)},
         { "Quit", GTK_STOCK_QUIT, "_Quit", NULL, "Quit", G_CALLBACK (quit_cb)},
         { "Edit", NULL, "_Edit", NULL, "Edit", NULL },
+        { "Display", NULL, "_Display", NULL, "Display", NULL },
         { "Perspective", NULL, "_Perspective", NULL, "Perspective", NULL },
         { "Window", NULL, "_Window", NULL, "Window", NULL },
         { "WindowNew", STOCK_NEW_WINDOW, "_New window", "<control>N", "Open a new window for current connection", G_CALLBACK (window_new_cb)},
@@ -274,6 +275,8 @@ static const gchar *ui_actions_info =
         "    </menu>"
         "    <menu name='Edit' action='Edit'>"
         "    </menu>"
+        "    <menu name='Display' action='Display'>"
+        "    </menu>"
         "    <menu name='Perspective' action='Perspective'>"
         "      <placeholder name='PersList'/>"
         "    </menu>"
@@ -565,7 +568,7 @@ perspective_toggle_cb (GtkRadioAction *action, GtkRadioAction *current, BrowserW
 		bwin->priv->perspectives = g_slist_prepend (bwin->priv->perspectives, pers);
 		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_show (GTK_WIDGET (pers->perspective_widget));
 
 		GtkActionGroup *actions;
 		actions = browser_perspective_get_actions_group (BROWSER_PERSPECTIVE (pers->perspective_widget));
diff --git a/tools/browser/data-manager/data-manager-perspective.c b/tools/browser/data-manager/data-manager-perspective.c
index 027ab79..31888bf 100644
--- a/tools/browser/data-manager/data-manager-perspective.c
+++ b/tools/browser/data-manager/data-manager-perspective.c
@@ -47,6 +47,8 @@ static GObjectClass  *parent_class = NULL;
 
 struct _DataManagerPerspectivePriv {
 	GtkWidget *notebook;
+	GtkWidget *favorites;
+	gboolean favorites_shown;
 	BrowserWindow *bwin;
         BrowserConnection *bcnc;
 };
@@ -119,6 +121,7 @@ static void
 data_manager_perspective_init (DataManagerPerspective *perspective)
 {
 	perspective->priv = g_new0 (DataManagerPerspectivePriv, 1);
+	perspective->priv->favorites_shown = TRUE;
 }
 
 static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
@@ -155,6 +158,7 @@ data_manager_perspective_new (BrowserWindow *bwin)
 			  G_CALLBACK (fav_selection_changed_cb), bpers);
         gtk_paned_pack1 (GTK_PANED (paned), wid, FALSE, TRUE);
 	gtk_paned_set_position (GTK_PANED (paned), DEFAULT_FAVORITES_SIZE);
+	perspective->priv->favorites = wid;
 
 	nb = gtk_notebook_new ();
         perspective->priv->notebook = nb;
@@ -185,6 +189,9 @@ data_manager_perspective_new (BrowserWindow *bwin)
 	gtk_box_pack_start (GTK_BOX (bpers), paned, TRUE, TRUE, 0);
 	gtk_widget_show_all (paned);
 
+	if (!perspective->priv->favorites_shown)
+		gtk_widget_hide (perspective->priv->favorites);
+
 	gtk_widget_grab_focus (page);
 
 	return bpers;
@@ -248,7 +255,7 @@ fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType f
 	
 	data_console_set_text (page_to_reuse, selection);
 	data_console_set_fav_id (page_to_reuse, fav_id, NULL);
-	gtk_widget_grab_focus (page_to_reuse);
+	gtk_widget_grab_focus ((GtkWidget*) page_to_reuse);
 }
 
 static void
@@ -317,6 +324,23 @@ manager_new_cb (GtkAction *action, BrowserPerspective *bpers)
 	add_new_data_console (bpers, -1);
 }
 
+static void
+favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
+{
+	DataManagerPerspective *perspective;
+	perspective = DATA_MANAGER_PERSPECTIVE (bpers);
+	perspective->priv->favorites_shown = gtk_toggle_action_get_active (action);
+	if (perspective->priv->favorites_shown)
+		gtk_widget_show (perspective->priv->favorites);
+	else
+		gtk_widget_hide (perspective->priv->favorites);
+}
+
+static const GtkToggleActionEntry ui_toggle_actions [] =
+{
+        { "DataManagerFavoritesShow", NULL, N_("_Show favorites"), "F9", N_("Show or hide favorites"), G_CALLBACK (favorites_toggle_cb), FALSE}
+};
+
 static GtkActionEntry ui_actions[] = {
         { "DataManagerMenu", NULL, "_Manager", NULL, "ManagerMenu", NULL },
         { "NewDataManager", GTK_STOCK_NEW, "_New data manager", "<control>T", "New data manager",
@@ -326,6 +350,9 @@ static GtkActionEntry ui_actions[] = {
 static const gchar *ui_actions_info =
         "<ui>"
         "  <menubar name='MenuBar'>"
+        "    <menu name='Display' action='Display'>"
+        "      <menuitem name='DataManagerFavoritesShow' action='DataManagerFavoritesShow'/>"
+        "    </menu>"
 	"    <placeholder name='MenuExtension'>"
         "      <menu name='Data manager' action='DataManagerMenu'>"
         "        <menuitem name='NewDataManager' action= 'NewDataManager'/>"
@@ -344,7 +371,13 @@ data_manager_perspective_get_actions_group (BrowserPerspective *bpers)
 	GtkActionGroup *agroup;
 	agroup = gtk_action_group_new ("DataManagerActions");
 	gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), bpers);
-	
+	gtk_action_group_add_toggle_actions (agroup, ui_toggle_actions, G_N_ELEMENTS (ui_toggle_actions), bpers);
+
+	GtkAction *action;
+	action = gtk_action_group_get_action (agroup, "DataManagerFavoritesShow");
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+				      DATA_MANAGER_PERSPECTIVE (bpers)->priv->favorites_shown);
+
 	return agroup;
 }
 
diff --git a/tools/browser/query-exec/query-exec-perspective.c b/tools/browser/query-exec/query-exec-perspective.c
index c4f4f3f..8495017 100644
--- a/tools/browser/query-exec/query-exec-perspective.c
+++ b/tools/browser/query-exec/query-exec-perspective.c
@@ -51,6 +51,8 @@ static GObjectClass  *parent_class = NULL;
 
 struct _QueryExecPerspectivePrivate {
 	GtkWidget *notebook;
+	GtkWidget *favorites;
+	gboolean favorites_shown;
 	BrowserWindow *bwin;
 	BrowserConnection *bcnc;
 	
@@ -126,6 +128,7 @@ query_exec_perspective_init (QueryExecPerspective *perspective)
 {
 	perspective->priv = g_new0 (QueryExecPerspectivePrivate, 1);
 	perspective->priv->action_group = NULL;
+	perspective->priv->favorites_shown = TRUE;
 }
 
 static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
@@ -163,6 +166,7 @@ query_exec_perspective_new (BrowserWindow *bwin)
 			  G_CALLBACK (fav_selection_changed_cb), bpers);
 	gtk_paned_pack1 (GTK_PANED (paned), wid, FALSE, TRUE);
 	gtk_paned_set_position (GTK_PANED (paned), DEFAULT_FAVORITES_SIZE);
+	perspective->priv->favorites = wid;
 
 	nb = gtk_notebook_new ();
 	perspective->priv->notebook = nb;
@@ -190,6 +194,8 @@ query_exec_perspective_new (BrowserWindow *bwin)
 	gtk_box_pack_start (GTK_BOX (bpers), paned, TRUE, TRUE, 0);
 	gtk_widget_show_all (paned);
 
+	if (!perspective->priv->favorites_shown)
+		gtk_widget_hide (perspective->priv->favorites);
 	gtk_widget_grab_focus (page);
 
 	/* signals to customize perspective */
@@ -315,6 +321,23 @@ query_exec_add_cb (GtkAction *action, BrowserPerspective *bpers)
 	gtk_widget_grab_focus (page);
 }
 
+static void
+favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
+{
+	QueryExecPerspective *perspective;
+	perspective = QUERY_EXEC_PERSPECTIVE (bpers);
+	perspective->priv->favorites_shown = gtk_toggle_action_get_active (action);
+	if (perspective->priv->favorites_shown)
+		gtk_widget_show (perspective->priv->favorites);
+	else
+		gtk_widget_hide (perspective->priv->favorites);
+}
+
+static const GtkToggleActionEntry ui_toggle_actions [] =
+{
+        { "QueryExecFavoritesShow", NULL, N_("_Show favorites"), "F9", N_("Show or hide favorites"), G_CALLBACK (favorites_toggle_cb), FALSE }
+};
+
 static GtkActionEntry ui_actions[] = {
         { "QueryExecMenu", NULL, N_("_Query"), NULL, "QueryExecMenu", NULL },
         { "QueryExecItem1", STOCK_CONSOLE, N_("_New editor"), "<control>T", N_("Open a new query editor"),
@@ -324,6 +347,9 @@ static GtkActionEntry ui_actions[] = {
 static const gchar *ui_actions_info =
         "<ui>"
         "  <menubar name='MenuBar'>"
+	"    <menu name='Display' action='Display'>"
+	"      <menuitem name='QueryExecFavoritesShow' action='QueryExecFavoritesShow'/>"
+        "    </menu>"
 	"    <placeholder name='MenuExtension'>"
         "      <menu name='QueryExec' action='QueryExecMenu'>"
         "        <menuitem name='QueryExecItem1' action= 'QueryExecItem1'/>"
@@ -347,6 +373,13 @@ query_exec_perspective_get_actions_group (BrowserPerspective *perspective)
 		agroup = gtk_action_group_new ("QueryExecActions");
 		gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), bpers);
 		bpers->priv->action_group = g_object_ref (agroup);
+
+		gtk_action_group_add_toggle_actions (agroup, ui_toggle_actions, G_N_ELEMENTS (ui_toggle_actions),
+						     bpers);
+		GtkAction *action;
+		action = gtk_action_group_get_action (agroup, "QueryExecFavoritesShow");
+		gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+					      QUERY_EXEC_PERSPECTIVE (bpers)->priv->favorites_shown);
 	}
 	
 	return bpers->priv->action_group;
diff --git a/tools/browser/schema-browser/schema-browser-perspective.c b/tools/browser/schema-browser/schema-browser-perspective.c
index c6104b8..c447ca4 100644
--- a/tools/browser/schema-browser/schema-browser-perspective.c
+++ b/tools/browser/schema-browser/schema-browser-perspective.c
@@ -51,6 +51,8 @@ static GObjectClass  *parent_class = NULL;
 
 struct _SchemaBrowserPerspectivePrivate {
 	GtkWidget *notebook;
+	GtkWidget *favorites;
+	gboolean favorites_shown;
 	BrowserWindow *bwin;
 };
 
@@ -112,6 +114,7 @@ static void
 schema_browser_perspective_init (SchemaBrowserPerspective *perspective)
 {
 	perspective->priv = g_new0 (SchemaBrowserPerspectivePrivate, 1);
+	perspective->priv->favorites_shown = TRUE;
 }
 
 static void fav_selection_changed_cb (GtkWidget *widget, gint fav_id, BrowserFavoritesType fav_type,
@@ -146,6 +149,7 @@ schema_browser_perspective_new (BrowserWindow *bwin)
 			  G_CALLBACK (fav_selection_changed_cb), bpers);
 	gtk_paned_add1 (GTK_PANED (paned), wid);
 	gtk_paned_set_position (GTK_PANED (paned), DEFAULT_FAVORITES_SIZE);
+	perspective->priv->favorites = wid;
 
 	nb = gtk_notebook_new ();
 	perspective->priv->notebook = nb;
@@ -170,6 +174,9 @@ schema_browser_perspective_new (BrowserWindow *bwin)
 	gtk_box_pack_start (GTK_BOX (bpers), paned, TRUE, TRUE, 0);
 	gtk_widget_show_all (paned);
 
+	if (!perspective->priv->favorites_shown)
+		gtk_widget_hide (perspective->priv->favorites);
+
 	return bpers;
 }
 
@@ -293,6 +300,22 @@ action_create_diagram_cb (GtkAction *action, SchemaBrowserPerspective *bpers)
 }
 #endif
 
+static void
+favorites_toggle_cb (GtkToggleAction *action, BrowserPerspective *bpers)
+{
+	SchemaBrowserPerspective *perspective;
+	perspective = SCHEMA_BROWSER_PERSPECTIVE (bpers);
+	perspective->priv->favorites_shown = gtk_toggle_action_get_active (action);
+	if (perspective->priv->favorites_shown)
+		gtk_widget_show (perspective->priv->favorites);
+	else
+		gtk_widget_hide (perspective->priv->favorites);
+}
+
+static const GtkToggleActionEntry ui_toggle_actions [] =
+{
+        { "SchemaBrowserFavoritesShow", NULL, N_("_Show favorites"), "F9", N_("Show or hide favorites"), G_CALLBACK (favorites_toggle_cb), FALSE }
+};
 
 static GtkActionEntry ui_actions[] = {
 #ifdef HAVE_GOOCANVAS
@@ -305,6 +328,9 @@ static GtkActionEntry ui_actions[] = {
 static const gchar *ui_actions_info =
         "<ui>"
         "  <menubar name='MenuBar'>"
+	"    <menu name='Display' action='Display'>"
+	"      <menuitem name='SchemaBrowserFavoritesShow' action='SchemaBrowserFavoritesShow'/>"
+        "    </menu>"
         "    <placeholder name='MenuExtension'>"
         "      <menu name='Schema' action='Schema'>"
         "        <menuitem name='NewDiagram' action= 'NewDiagram'/>"
@@ -319,7 +345,13 @@ schema_browser_perspective_get_actions_group (BrowserPerspective *bpers)
 	GtkActionGroup *agroup;
 	agroup = gtk_action_group_new ("SchemaBrowserActions");
 	gtk_action_group_add_actions (agroup, ui_actions, G_N_ELEMENTS (ui_actions), bpers);
-	
+	gtk_action_group_add_toggle_actions (agroup, ui_toggle_actions, G_N_ELEMENTS (ui_toggle_actions),
+					     bpers);
+	GtkAction *action;
+	action = gtk_action_group_get_action (agroup, "SchemaBrowserFavoritesShow");
+	gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action),
+				      SCHEMA_BROWSER_PERSPECTIVE (bpers)->priv->favorites_shown);	
+
 	return agroup;
 }
 



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