[libgda] GdaBrowser: data manager UI improvements



commit 87b192f0da31b8c7225bd49d4a1ccf077a671b97
Author: Vivien Malerba <malerba gnome-db org>
Date:   Tue Sep 7 18:31:16 2010 +0200

    GdaBrowser: data manager UI improvements

 tools/browser/data-manager/data-console.c   |   44 +++++++++++++++++++++++++--
 tools/browser/data-manager/ui-spec-editor.c |    6 ++--
 2 files changed, 44 insertions(+), 6 deletions(-)
---
diff --git a/tools/browser/data-manager/data-console.c b/tools/browser/data-manager/data-console.c
index 7dc6886..f45a6d4 100644
--- a/tools/browser/data-manager/data-console.c
+++ b/tools/browser/data-manager/data-console.c
@@ -734,6 +734,16 @@ add_source_mitem_activated_cb (GtkMenuItem *mitem, DataConsole *dconsole)
 	g_object_unref (source);
 }
 
+static gint
+dbo_sort (GdaMetaDbObject *dbo1, GdaMetaDbObject *dbo2)
+{
+	gint res;
+	res = g_strcmp0 (dbo1->obj_schema, dbo2->obj_schema);
+	if (res)
+		return - res;
+	return g_strcmp0 (dbo1->obj_name, dbo2->obj_name);
+}
+
 static void
 add_source_clicked_cb (GtkButton *button, DataConsole *dconsole)
 {
@@ -753,7 +763,7 @@ add_source_clicked_cb (GtkButton *button, DataConsole *dconsole)
 		return;
 	}
 
-	GtkWidget *menu, *mitem;
+	GtkWidget *menu, *mitem, *submenu = NULL;
 	menu = gtk_menu_new ();
 	mitem = gtk_menu_item_new_with_label (_("Data source from query"));
 	g_signal_connect (mitem, "activate",
@@ -764,7 +774,11 @@ add_source_clicked_cb (GtkButton *button, DataConsole *dconsole)
 	if (mstruct) {
 		gboolean sep_added = FALSE;
 		GSList *dbo_list, *list;
+		gchar *current_schema = NULL;
+
 		dbo_list = gda_meta_struct_get_all_db_objects (mstruct);
+		list = g_slist_sort (dbo_list, (GCompareFunc) dbo_sort);
+		dbo_list = list;
 		for (list = dbo_list; list; list = list->next) {
 			GdaMetaDbObject *dbo = GDA_META_DB_OBJECT (list->data);
 			gchar *str;
@@ -776,16 +790,40 @@ add_source_clicked_cb (GtkButton *button, DataConsole *dconsole)
 				gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);
 				sep_added = TRUE;
 			}
-			str = g_strdup_printf (_("For table: %s"), dbo->obj_short_name);
+
+			if (!strcmp (dbo->obj_short_name, dbo->obj_full_name)) {
+				gboolean schema_changed = TRUE;
+				if (!current_schema)
+					current_schema = g_strdup (dbo->obj_schema);
+				else if (strcmp (current_schema, dbo->obj_schema)) {
+					g_free (current_schema);
+					current_schema = g_strdup (dbo->obj_schema);
+				}
+				else
+					schema_changed = FALSE;
+
+				if (schema_changed) {
+					str = g_strdup_printf (_("In schema %s"), current_schema);
+					mitem = gtk_menu_item_new_with_label (str);
+					gtk_widget_show (mitem);
+					g_free (str);
+					gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);
+					submenu = gtk_menu_new ();
+					gtk_menu_item_set_submenu (GTK_MENU_ITEM (mitem), submenu);
+				}
+			}
+
+			str = g_strdup_printf (_("For table: %s"), dbo->obj_name);
 			mitem = gtk_menu_item_new_with_label (str);
 			g_object_set_data_full ((GObject*) mitem, "_table",
 						g_strdup (dbo->obj_short_name), g_free);
 			g_signal_connect (mitem, "activate",
 					  G_CALLBACK (add_source_mitem_activated_cb), dconsole);
 			gtk_widget_show (mitem);
-			gtk_menu_shell_append (GTK_MENU_SHELL (menu), mitem);			
+			gtk_menu_shell_append (GTK_MENU_SHELL (submenu ? submenu : menu), mitem);
 		}
 		g_slist_free (dbo_list);
+		g_free (current_schema);
 	}
 	dconsole->priv->add_source_menu_index = (gpointer) mstruct;
 	dconsole->priv->add_source_menu = menu;
diff --git a/tools/browser/data-manager/ui-spec-editor.c b/tools/browser/data-manager/ui-spec-editor.c
index 8272428..308907f 100644
--- a/tools/browser/data-manager/ui-spec-editor.c
+++ b/tools/browser/data-manager/ui-spec-editor.c
@@ -145,7 +145,7 @@ ui_spec_editor_init (UiSpecEditor *sped, UiSpecEditorClass *klass)
 	
 	GtkWidget *vbox;
 	vbox = gtk_vbox_new (FALSE, 0);
-	gtk_paned_add1 (GTK_PANED (hpaned), vbox);
+	gtk_paned_pack1 (GTK_PANED (hpaned), vbox, TRUE, FALSE);
 
 	GtkWidget *label;
 	gchar *str;
@@ -165,7 +165,7 @@ ui_spec_editor_init (UiSpecEditor *sped, UiSpecEditorClass *klass)
 
 	sped->priv->sources_tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (sped->priv->sources_model));
 	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (sped->priv->sources_tree), FALSE);
-	gtk_widget_set_size_request (sped->priv->sources_tree, 120, -1);
+	gtk_widget_set_size_request (sped->priv->sources_tree, 170, -1);
 
 	renderer = gtk_cell_renderer_pixbuf_new ();
 	column = gtk_tree_view_column_new ();
@@ -198,7 +198,7 @@ ui_spec_editor_init (UiSpecEditor *sped, UiSpecEditorClass *klass)
 	gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
 
 	vbox = gtk_vbox_new (FALSE, 0);
-	gtk_paned_add2 (GTK_PANED (hpaned), vbox);
+	gtk_paned_pack2 (GTK_PANED (hpaned), vbox, TRUE, FALSE);
 
 	label = gtk_label_new ("");
 	str = g_strdup_printf ("<b>%s</b>", _("Selected data source's properties:"));



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