From a3c097a992e8a05d5e1db5a28dbebea5ddb73973 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Mon, 6 Jun 2011 11:10:00 +0200 Subject: [PATCH] Adjustments. Made transient the progress window. Sorted the combo with tables list. --- src/datasources.c | 1 + src/table.c | 45 +++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/datasources.c b/src/datasources.c index acc5a75..fb7d570 100644 --- a/src/datasources.c +++ b/src/datasources.c @@ -277,6 +277,7 @@ datasources_add_all_tables (Datasources *datasources) if (id_ds != 0) { dialog = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_progress")); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); /* updating meta store */ priv->update_metastore_datasource_id = id_ds; diff --git a/src/table.c b/src/table.c index 11b061a..2ceb37a 100644 --- a/src/table.c +++ b/src/table.c @@ -65,6 +65,7 @@ struct _TablePrivate GtkWidget *w; GtkListStore *lstore_fields; + GtkTreeModel *cb_model; gint id; @@ -131,9 +132,9 @@ Table error = NULL; gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile, g_strsplit ("lstore_tables" - "|lstore_fields" + "|lstore_fields" "|w_progress" - "|w_table", + "|w_table", "|", -1), &error); if (error != NULL) @@ -144,6 +145,7 @@ Table priv->w = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_table")); priv->lstore_fields = GTK_LIST_STORE (gtk_builder_get_object (priv->commons->gtkbuilder, "lstore_fields")); + priv->cb_model = gtk_combo_box_get_model (GTK_COMBO_BOX (gtk_builder_get_object (priv->commons->gtkbuilder, "combobox1"))); g_signal_connect (gtk_builder_get_object (priv->commons->gtkbuilder, "combobox1"), "changed", G_CALLBACK (table_on_cb_tables_changed), (gpointer *)a); @@ -273,11 +275,10 @@ table_load_db_tables (Table *table) TablePrivate *priv = TABLE_GET_PRIVATE (table); - model = gtk_combo_box_get_model (GTK_COMBO_BOX (gtk_builder_get_object (priv->commons->gtkbuilder, "combobox1"))); - - gtk_list_store_clear (GTK_LIST_STORE (model)); + gtk_list_store_clear (GTK_LIST_STORE (priv->cb_model)); dialog = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_progress")); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main"))); /* updating meta store */ priv->update_metastore_datasource_id = strtol (gtk_label_get_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label8"))), NULL, 10); @@ -286,25 +287,25 @@ table_load_db_tables (Table *table) error = NULL; thr = g_thread_create (table_update_metastore, - (gpointer)table, - FALSE, - &error); + (gpointer)table, + FALSE, + &error); if (thr == NULL || error != NULL) { gtk_widget_hide_all (dialog); dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - "Unable to update the metastore: %s", - error != NULL && error->message != NULL ? error->message : "no details"); + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Unable to update the metastore: %s", + error != NULL && error->message != NULL ? error->message : "no details"); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return; } gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label10")), - "Updating meta store"); + "Updating meta store"); gtk_widget_show_all (dialog); gtk_widget_show_now (dialog); @@ -319,10 +320,10 @@ table_load_db_tables (Table *table) { gtk_widget_hide_all (dialog); dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_builder_get_object (priv->commons->gtkbuilder, "w_main")), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - priv->error_update_metastore); + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + priv->error_update_metastore); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); return; @@ -343,13 +344,17 @@ table_load_db_tables (Table *table) if (!table_is_a_system_table (priv->commons, table_name)) { - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, + gtk_list_store_append (GTK_LIST_STORE (priv->cb_model), &iter); + gtk_list_store_set (GTK_LIST_STORE (priv->cb_model), &iter, 0, table_name, -1); } } g_object_unref (dm); + + model = gtk_tree_model_sort_new_with_model (priv->cb_model); + gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (model), 0, GTK_SORT_ASCENDING); + gtk_combo_box_set_model (GTK_COMBO_BOX (gtk_builder_get_object (priv->commons->gtkbuilder, "combobox1")), model); } else { -- 2.49.0