[libgda/LIBGDA_4.2] GdaBrowser: UI improvements



commit 7b1b159924a6206cf67926567a8869b82e774271
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Jul 19 22:26:52 2011 +0200

    GdaBrowser: UI improvements

 tools/browser/data-manager/data-console.c          |   20 ++++++++++++++++++++
 tools/browser/data-manager/data-console.h          |    1 +
 .../data-manager/data-manager-perspective.c        |   18 ++++--------------
 3 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/tools/browser/data-manager/data-console.c b/tools/browser/data-manager/data-console.c
index b29dfca..dfc081a 100644
--- a/tools/browser/data-manager/data-console.c
+++ b/tools/browser/data-manager/data-console.c
@@ -996,6 +996,26 @@ data_console_get_text (DataConsole *console)
 }
 
 /**
+ * data_console_is_unused
+ */
+gboolean
+data_console_is_unused (DataConsole *console)
+{
+	gchar *text;
+	gboolean retval = TRUE;
+	g_return_val_if_fail (IS_DATA_CONSOLE (console), FALSE);
+	text = data_console_get_text (console);
+	if (!text || !*text) {
+		g_free (text);
+		return TRUE;
+	}
+	if (strcmp (text, DEFAULT_XML))
+		retval = FALSE;
+	g_free (text);
+	return retval;
+}
+
+/**
  * data_console_execute
  * @console: a #DataConsole widget
  *
diff --git a/tools/browser/data-manager/data-console.h b/tools/browser/data-manager/data-console.h
index 9aaefd7..187e98d 100644
--- a/tools/browser/data-manager/data-console.h
+++ b/tools/browser/data-manager/data-console.h
@@ -49,6 +49,7 @@ GtkWidget               *data_console_new             (BrowserConnection *bcnc);
 GtkWidget               *data_console_new_with_fav_id (BrowserConnection *bcnc, gint fav_id);
 void                     data_console_set_text        (DataConsole *console, const gchar *text);
 gchar                   *data_console_get_text        (DataConsole *console);
+gboolean                 data_console_is_unused       (DataConsole *console);
 void                     data_console_execute         (DataConsole *console);
 void                     data_console_set_fav_id      (DataConsole *dconsole, gint fav_id,
 						       GError **error);
diff --git a/tools/browser/data-manager/data-manager-perspective.c b/tools/browser/data-manager/data-manager-perspective.c
index 28ff513..d805b5f 100644
--- a/tools/browser/data-manager/data-manager-perspective.c
+++ b/tools/browser/data-manager/data-manager-perspective.c
@@ -263,12 +263,9 @@ fav_selection_changed_cb (G_GNUC_UNUSED GtkWidget *widget, gint fav_id, BrowserF
 		page_contents = gtk_notebook_get_nth_page (GTK_NOTEBOOK (perspective->priv->notebook),
 							   current_page);
 		
-		if (IS_DATA_CONSOLE (page_contents)) {
-			gchar *text;
-			text = data_console_get_text (DATA_CONSOLE (page_contents));
-			if (!text || !*text)
-				page_to_reuse = DATA_CONSOLE (page_contents);
-		}
+		if (IS_DATA_CONSOLE (page_contents) &&
+		    data_console_is_unused (DATA_CONSOLE (page_contents)))
+			page_to_reuse = DATA_CONSOLE (page_contents);
 	}
 
 	if (! page_to_reuse)
@@ -403,15 +400,8 @@ data_manager_perspective_new_tab (DataManagerPerspective *dmp, const gchar *xml_
 	current = gtk_notebook_get_current_page (GTK_NOTEBOOK (dmp->priv->notebook));
 	if (current >= 0) {
 		page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (dmp->priv->notebook), current);
-		if (! IS_DATA_CONSOLE (page))
+		if (! IS_DATA_CONSOLE (page) || !data_console_is_unused (DATA_CONSOLE (page)))
 			page = NULL;
-		else {
-			gchar *text;
-			text = data_console_get_text (DATA_CONSOLE (page));
-			if (text && *text)
-				page = NULL;
-			g_free (text);
-		}
 	}
 
 	if (!page) {



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