{
Commons *commons;
- GdaConnection *gdacon;
-
GtkWidget *w;
GtkListStore *lstore_fields;
gint id;
+
+ guint update_metastore_datasource_id;
+ gboolean update_metastore_ended;
+ gchar *error_update_metastore;
+
+ GdaConnection *gdacon;
};
G_DEFINE_TYPE (Table, table, G_TYPE_OBJECT)
error = NULL;
gtk_builder_add_objects_from_file (priv->commons->gtkbuilder, priv->commons->guifile,
- g_strsplit ("lstore_tables|lstore_fields|w_table", "|", -1),
+ g_strsplit ("lstore_tables"
+ "|lstore_fields"
+ "|w_progress"
+ "|w_table",
+ "|", -1),
&error);
if (error != NULL)
{
}
/* PRIVATE */
+static gpointer
+table_update_metastore (gpointer data)
+{
+ Table *table;
+ TablePrivate *priv;
+
+ GError *error;
+
+ GdaMetaContext mcontext = {"_tables", 0, NULL, NULL};
+
+ table = (Table *)data;
+ priv = TABLE_GET_PRIVATE (table);
+
+ error = NULL;
+ priv->gdacon = datasources_get_gdaconnection (priv->commons, priv->update_metastore_datasource_id, &error);
+ if (priv->gdacon == NULL || error != NULL)
+ {
+ priv->error_update_metastore = g_strdup_printf ("Unable to update metastore.\n%s",
+ (error != NULL && error->message != NULL ? error->message : "No details."));
+ priv->update_metastore_ended = TRUE;
+ return NULL;
+ }
+
+ error = NULL;
+ if (!gda_connection_update_meta_store (priv->gdacon, &mcontext, &error))
+ {
+ priv->error_update_metastore = g_strdup_printf ("Unable to update metastore.\n%s",
+ (error != NULL && error->message != NULL ? error->message : "No details."));
+ priv->update_metastore_ended = TRUE;
+ return NULL;
+ }
+
+ priv->update_metastore_ended = TRUE;
+}
+
static void
table_load_db_tables (Table *table)
{
GtkWidget *dialog;
- GError *error;
- GdaMetaContext mcontext = {"_tables", 0, NULL, NULL};
+ GError *error;
+ GThread *thr;
GdaStatement *stmt;
GdaDataModel *dm;
gtk_list_store_clear (GTK_LIST_STORE (model));
+ dialog = GTK_WIDGET (gtk_builder_get_object (priv->commons->gtkbuilder, "w_progress"));
+
+ /* 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);
+ priv->update_metastore_ended = FALSE;
+ priv->error_update_metastore = NULL;
+
error = NULL;
- priv->gdacon = datasources_get_gdaconnection (priv->commons,
- strtol (gtk_label_get_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label8"))), NULL, 10),
- &error);
- if (priv->gdacon == NULL || error != NULL)
+ thr = g_thread_create (table_update_metastore,
+ (gpointer)table,
+ FALSE,
+ &error);
+ if (thr == NULL || error != NULL)
{
- dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "Unable to get tables list.\n%s",
- (error != NULL && error->message != NULL ? error->message : "No details."));
+ 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_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return;
}
- error = NULL;
- if (!gda_connection_update_meta_store (priv->gdacon, &mcontext, &error))
+ gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (priv->commons->gtkbuilder, "label10")),
+ "Updating meta store");
+ gtk_widget_show_all (dialog);
+ gtk_widget_show_now (dialog);
+
+ while (!priv->update_metastore_ended)
{
- dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "Unable to get tables list.\n%s",
- (error != NULL && error->message != NULL ? error->message : "No details."));
+ while (gtk_events_pending ()) gtk_main_iteration ();
+ g_usleep (500000);
+ gtk_progress_bar_pulse (GTK_PROGRESS_BAR (gtk_builder_get_object (priv->commons->gtkbuilder, "progressbar1")));
+ }
+
+ if (priv->error_update_metastore != 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,
+ priv->error_update_metastore);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
return;
}
+ gtk_widget_hide_all (dialog);
error = NULL;
dm = gda_connection_get_meta_store_data (priv->gdacon,