From 9882af4c39bf7901fb182cc12f151a88eab8f447 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 5 Mar 2011 17:48:57 +0100 Subject: [PATCH] Changed GUI. Added function GdaExQueryEditor::clean_choices. --- data/libgdaex/gui/libgdaex.ui | 889 +++++++++++++++++----------------- src/queryeditor.c | 169 +++++-- src/queryeditor.h | 3 +- tests/query_editor.c | 93 +++- 4 files changed, 644 insertions(+), 510 deletions(-) diff --git a/data/libgdaex/gui/libgdaex.ui b/data/libgdaex/gui/libgdaex.ui index 85edf0d..cbd0925 100644 --- a/data/libgdaex/gui/libgdaex.ui +++ b/data/libgdaex/gui/libgdaex.ui @@ -56,72 +56,149 @@ - - 5 - Query Editor - True - center-on-parent - 600 - True - normal - - + + + True - vertical - 5 + True + 4 + 200 + True - + True True - 200 - True + automatic + automatic + etched-in - + True True - automatic - automatic - etched-in + tstore_fields + False + 0 + 3 - + + Fields + + + + 2 + + + + + + + + + False + True + + + + + True + vertical + 5 + + + True + vertical + 5 + + True - True - tstore_fields - 3 + vertical - - Fields - - - - 2 - - + + + + + 0 + + + + + True + 5 + end + + + gtk-cancel + True + True + True + True + + False + False + 0 + + + + + gtk-save + True + True + True + True + + + False + False + 1 + + + 1 + - False - True + False + 0 - + True - vertical - 5 + True - - vertical + + True + 5 5 - + True - vertical + True + automatic + automatic + etched-in - + + True + True + lstore_show + False + 0 + + + Field + + + + 2 + + + + + @@ -129,13 +206,14 @@ - + True + vertical 5 - end + start - - gtk-cancel + + gtk-add True True True @@ -148,8 +226,8 @@ - - gtk-save + + gtk-remove True True True @@ -161,501 +239,400 @@ 1 + + + gtk-go-up + True + True + True + True + + + False + False + 2 + + + + + gtk-go-down + True + True + True + True + + + False + False + 3 + + + + + gtk-clear + True + True + True + True + + + False + False + 4 + + + False 1 + + + + True + Show + - 0 + False - + True - 0 + 5 + 5 - + True - 12 + True + automatic + automatic + etched-in - + True - 5 + True + tstore_where + False + 0 - - True - True - automatic - automatic - etched-in + + Field - - True - True - lstore_show - - - Field - - - - 2 - - - - - + + + 2 + - - 0 - - - True - vertical - 5 + + Not - - gtk-add - True - True - True - True - - - False - False - 0 - + + + 3 + + + + + + Condition - - gtk-remove - True - True - True - True - - - False - False - 1 - + + + 5 + + + + + + From - - gtk-go-up - True - True - True - True - - - False - False - 2 - + + + 6 + + + + + + To - - gtk-go-down - True - True - True - True - - - False - False - 3 - + + + 7 + - - False - 1 - + + 0 + - - + + True - <b>Show</b> - True + vertical + 5 + start + + + gtk-add + True + True + True + True + + + False + False + 0 + + + + + gtk-remove + True + True + True + True + + + False + False + 1 + + + + + gtk-go-up + True + True + True + True + + + False + False + 2 + + + + + gtk-go-down + True + True + True + True + + + False + False + 3 + + + + + gtk-clear + True + True + True + True + + + False + False + 4 + + + + False + 1 + 1 + + + True + Where + + + 1 + False + + - + True - 0 + 5 + 5 - + True - 12 + True + automatic + automatic + etched-in - + True - 5 + True + lstore_order + False + 0 - - True - True - automatic - automatic - etched-in + + Field - - True - True - tstore_where - - - Field - - - - 2 - - - - - - - Not - - - - 3 - - - - - - - Condition - - - - 5 - - - - - - - From - - - - 6 - - - - - - - To - - - - 7 - - - - - + + + 2 + - - 0 - - - True - vertical - 5 + + Order - - gtk-add - True - True - True - True - - - False - False - 0 - - - - - gtk-remove - True - True - True - True - - - False - False - 1 - - - - - gtk-go-up - True - True - True - True - - - False - False - 2 - - - - - gtk-go-down - True - True - True - True - - - False - False - 3 - + + + 3 + - - False - 1 - + + 0 + - - + + True - <b>Where</b> - True + vertical + 5 + start + + + gtk-add + True + True + True + True + + + False + False + 0 + + + + + gtk-remove + True + True + True + True + + + False + False + 1 + + + + + gtk-go-up + True + True + True + True + + + False + False + 2 + + + + + gtk-go-down + True + True + True + True + + + False + False + 3 + + + + + gtk-clear + True + True + True + True + + + False + False + 4 + + + + False + 1 + 2 - - + + True - 0 - - - True - 12 - - - True - 5 - - - True - True - automatic - automatic - etched-in - - - True - True - lstore_order - - - Field - - - - 2 - - - - - - - Order - - - - 3 - - - - - - - - - 0 - - - - - True - vertical - 5 - - - gtk-add - True - True - True - True - - - False - False - 0 - - - - - gtk-remove - True - True - True - True - - - False - False - 1 - - - - - gtk-go-up - True - True - True - True - - - False - False - 2 - - - - - gtk-go-down - True - True - True - True - - - False - False - 3 - - - - - False - 1 - - - - - - - - - True - <b>Order</b> - True - - + Order - 3 + 2 + False - True - True - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - True - - - False - False 1 - False - end - 0 + True + True - - button1 - button2 - diff --git a/src/queryeditor.c b/src/queryeditor.c index d5ba5d3..40289ea 100644 --- a/src/queryeditor.c +++ b/src/queryeditor.c @@ -64,6 +64,8 @@ static void gdaex_query_editor_refresh_gui_add_fields (GdaExQueryEditor *qe, GdaExQueryEditorTable *table, GtkTreeIter *iter_parent); +static void gdaex_query_editor_refill_always_show (GdaExQueryEditor *qe); + static void gdaex_query_editor_store_remove_iter (GdaExQueryEditor *qe, GtkTreeSelection *sel, GObject *store); @@ -98,6 +100,8 @@ static void gdaex_query_editor_on_btn_show_up_clicked (GtkButton *button, gpointer user_data); static void gdaex_query_editor_on_btn_show_down_clicked (GtkButton *button, gpointer user_data); +static void gdaex_query_editor_on_btn_show_clean_clicked (GtkButton *button, + gpointer user_data); static void gdaex_query_editor_on_sel_show_changed (GtkTreeSelection *treeselection, gpointer user_data); @@ -109,6 +113,8 @@ static void gdaex_query_editor_on_btn_where_up_clicked (GtkButton *button, gpointer user_data); static void gdaex_query_editor_on_btn_where_down_clicked (GtkButton *button, gpointer user_data); +static void gdaex_query_editor_on_btn_where_clean_clicked (GtkButton *button, + gpointer user_data); static void gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection, gpointer user_data); @@ -120,6 +126,8 @@ static void gdaex_query_editor_on_btn_order_up_clicked (GtkButton *button, gpointer user_data); static void gdaex_query_editor_on_btn_order_down_clicked (GtkButton *button, gpointer user_data); +static void gdaex_query_editor_on_btn_order_clean_clicked (GtkButton *button, + gpointer user_data); static void gdaex_query_editor_on_sel_order_changed (GtkTreeSelection *treeselection, gpointer user_data); @@ -132,7 +140,6 @@ struct _GdaExQueryEditorPrivate GtkBuilder *gtkbuilder; - GtkWidget *dialog; GtkWidget *hpaned_main; GtkWidget *vbx_values_container; @@ -219,7 +226,6 @@ gdaex_query_editor_init (GdaExQueryEditor *gdaex_query_editor) priv->tables = g_hash_table_new (g_str_hash, g_str_equal); - priv->dialog = NULL; priv->hpaned_main = NULL; priv->relations = NULL; @@ -259,7 +265,7 @@ GdaExQueryEditor "|lstore_show" "|tstore_where" "|lstore_order" - "|diag_query_editor", + "|hpaned_query_editor", "|", -1), &error); if (error != NULL) @@ -298,6 +304,8 @@ GdaExQueryEditor G_CALLBACK (gdaex_query_editor_on_btn_show_up_clicked), (gpointer)gdaex_query_editor); g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button6"), "clicked", G_CALLBACK (gdaex_query_editor_on_btn_show_down_clicked), (gpointer)gdaex_query_editor); + g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button1"), "clicked", + G_CALLBACK (gdaex_query_editor_on_btn_show_clean_clicked), (gpointer)gdaex_query_editor); g_signal_connect (priv->sel_show, "changed", G_CALLBACK (gdaex_query_editor_on_sel_show_changed), (gpointer)gdaex_query_editor); @@ -309,6 +317,8 @@ GdaExQueryEditor G_CALLBACK (gdaex_query_editor_on_btn_where_up_clicked), (gpointer)gdaex_query_editor); g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button10"), "clicked", G_CALLBACK (gdaex_query_editor_on_btn_where_down_clicked), (gpointer)gdaex_query_editor); + g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button2"), "clicked", + G_CALLBACK (gdaex_query_editor_on_btn_where_clean_clicked), (gpointer)gdaex_query_editor); g_signal_connect (priv->sel_where, "changed", G_CALLBACK (gdaex_query_editor_on_sel_where_changed), (gpointer)gdaex_query_editor); @@ -320,6 +330,8 @@ GdaExQueryEditor G_CALLBACK (gdaex_query_editor_on_btn_order_up_clicked), (gpointer)gdaex_query_editor); g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button14"), "clicked", G_CALLBACK (gdaex_query_editor_on_btn_order_down_clicked), (gpointer)gdaex_query_editor); + g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button17"), "clicked", + G_CALLBACK (gdaex_query_editor_on_btn_order_clean_clicked), (gpointer)gdaex_query_editor); g_signal_connect (priv->sel_order, "changed", G_CALLBACK (gdaex_query_editor_on_sel_order_changed), (gpointer)gdaex_query_editor); @@ -330,25 +342,6 @@ GdaExQueryEditor return gdaex_query_editor; } -GtkWidget -*gdaex_query_editor_get_dialog (GdaExQueryEditor *gdaex_query_editor) -{ - GdaExQueryEditorPrivate *priv; - - g_return_if_fail (GDAEX_IS_QUERY_EDITOR (gdaex_query_editor)); - - priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (gdaex_query_editor); - - if (priv->dialog == NULL) - { - priv->dialog = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "diag_query_editor")); - } - - gdaex_query_editor_refresh_gui (gdaex_query_editor); - - return priv->dialog; -} - GtkWidget *gdaex_query_editor_get_widget (GdaExQueryEditor *gdaex_query_editor) { @@ -360,7 +353,7 @@ GtkWidget if (priv->hpaned_main == NULL) { - priv->hpaned_main = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "hpaned1")); + priv->hpaned_main = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "hpaned_query_editor")); } gdaex_query_editor_refresh_gui (gdaex_query_editor); @@ -464,6 +457,24 @@ gdaex_query_editor_add_relation (GdaExQueryEditor *qe, return TRUE; } +void +gdaex_query_editor_clean_choices (GdaExQueryEditor *qe) +{ + GdaExQueryEditorPrivate *priv; + + g_return_if_fail (GDAEX_IS_QUERY_EDITOR (qe)); + + priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + + gtk_list_store_clear (priv->lstore_show); + gtk_tree_store_clear (priv->tstore_where); + gtk_list_store_clear (priv->lstore_order); + + gdaex_query_editor_refill_always_show (qe); + + gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->gtkbuilder, "button16"))); +} + const gchar *gdaex_query_editor_get_sql (GdaExQueryEditor *qe) { @@ -996,6 +1007,46 @@ gdaex_query_editor_refresh_gui_add_fields (GdaExQueryEditor *qe, } } +static void +gdaex_query_editor_refill_always_show (GdaExQueryEditor *qe) +{ + GdaExQueryEditorPrivate *priv; + + GtkTreeIter iter_table; + GtkTreeIter iter; + + gchar *table_name; + gchar *field_name; + + GdaExQueryEditorTable *table; + GdaExQueryEditorField *field; + + priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + + if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->tstore_fields), &iter_table)) + { + do + { + if (gtk_tree_model_iter_children (GTK_TREE_MODEL (priv->tstore_fields), &iter, &iter_table)) + { + do + { + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_fields), &iter, + COL_FIELDS_TABLE_NAME, &table_name, + COL_FIELDS_NAME, &field_name, + -1); + table = g_hash_table_lookup (priv->tables, table_name); + field = g_hash_table_lookup (table->fields, field_name); + if (field->always_showed) + { + gdaex_query_editor_show_add_iter (qe, &iter); + } + } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->tstore_fields), &iter)); + } + } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->tstore_fields), &iter_table)); + } +} + static void gdaex_query_editor_store_remove_iter (GdaExQueryEditor *qe, GtkTreeSelection *sel, @@ -1014,8 +1065,7 @@ gdaex_query_editor_store_remove_iter (GdaExQueryEditor *qe, if (gtk_tree_selection_get_selected (sel, NULL, &iter)) { - /* TODO if get_widget dialog isn't valid */ - dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, @@ -1036,8 +1086,7 @@ gdaex_query_editor_store_remove_iter (GdaExQueryEditor *qe, } else { - /* TODO if get_widget dialog isn't valid */ - dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -1100,8 +1149,7 @@ gdaex_query_editor_store_move_iter_up_down (GdaExQueryEditor *qe, } else { - /* TODO if get_widget dialog isn't valid */ - dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -1293,7 +1341,18 @@ gdaex_query_editor_on_btn_save_clicked (GtkButton *button, guint where_type; GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->cb_where_type)); - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->cb_where_type), &iter_val); + if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->cb_where_type), &iter_val)) + { + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "You must select a condition's type before."); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog); + return; + } + gtk_tree_model_get (model, &iter_val, 0, &where_type, -1); @@ -1376,8 +1435,7 @@ gdaex_query_editor_on_btn_show_add_clicked (GtkButton *button, } else { - /* TODO if get_widget dialog isn't valid */ - dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -1425,6 +1483,17 @@ gdaex_query_editor_on_btn_show_down_clicked (GtkButton *button, FALSE); } +static void +gdaex_query_editor_on_btn_show_clean_clicked (GtkButton *button, + gpointer user_data) +{ + GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data; + GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + + gtk_list_store_clear (priv->lstore_show); + gdaex_query_editor_refill_always_show (qe); +} + static void gdaex_query_editor_on_sel_show_changed (GtkTreeSelection *treeselection, gpointer user_data) @@ -1496,8 +1565,7 @@ gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button, } else { - /* TODO if get_widget dialog isn't valid */ - dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -1545,6 +1613,18 @@ gdaex_query_editor_on_btn_where_down_clicked (GtkButton *button, FALSE); } +static void +gdaex_query_editor_on_btn_where_clean_clicked (GtkButton *button, + gpointer user_data) +{ + GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data; + GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + + gtk_tree_store_clear (priv->tstore_where); + + gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->gtkbuilder, "button16"))); +} + static void gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection, gpointer user_data) @@ -1771,7 +1851,8 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection, gtk_box_pack_start (GTK_BOX (priv->vbx_values), priv->hbox, FALSE, FALSE, 0); - gtk_widget_show_all (priv->vbx_values_container); + gtk_widget_show_all (priv->vbx_values); + gtk_widget_show (priv->vbx_values_container); } } @@ -1816,8 +1897,7 @@ gdaex_query_editor_on_btn_order_add_clicked (GtkButton *button, } else { - /* TODO if get_widget dialog isn't valid */ - dialog = gtk_message_dialog_new (GTK_WINDOW (priv->dialog), + dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, @@ -1865,6 +1945,18 @@ gdaex_query_editor_on_btn_order_down_clicked (GtkButton *button, FALSE); } +static void +gdaex_query_editor_on_btn_order_clean_clicked (GtkButton *button, + gpointer user_data) +{ + GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data; + GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + + gtk_list_store_clear (priv->lstore_order); + + gtk_button_clicked (GTK_BUTTON (gtk_builder_get_object (priv->gtkbuilder, "button16"))); +} + static void gdaex_query_editor_on_sel_order_changed (GtkTreeSelection *treeselection, gpointer user_data) @@ -1915,6 +2007,7 @@ gdaex_query_editor_on_sel_order_changed (GtkTreeSelection *treeselection, gtk_box_pack_start (GTK_BOX (priv->vbx_values), priv->hbox, FALSE, FALSE, 0); - gtk_widget_show_all (priv->vbx_values_container); + gtk_widget_show_all (priv->vbx_values); + gtk_widget_show (priv->vbx_values_container); } } diff --git a/src/queryeditor.h b/src/queryeditor.h index 9193ce1..4de3443 100644 --- a/src/queryeditor.h +++ b/src/queryeditor.h @@ -55,7 +55,6 @@ GType gdaex_query_editor_get_type (void) G_GNUC_CONST; GdaExQueryEditor *gdaex_query_editor_new (GdaEx *gdaex); -GtkWidget *gdaex_query_editor_get_dialog (GdaExQueryEditor *gdaex_query_editor); GtkWidget *gdaex_query_editor_get_widget (GdaExQueryEditor *gdaex_query_editor); typedef enum @@ -114,6 +113,8 @@ gboolean gdaex_query_editor_add_relation (GdaExQueryEditor *qe, const gchar *table2, ...); +void gdaex_query_editor_clean_choices (GdaExQueryEditor *qe); + const gchar *gdaex_query_editor_get_sql (GdaExQueryEditor *qe); xmlNode *gdaex_query_editor_get_sql_as_xml (GdaExQueryEditor *qe); diff --git a/tests/query_editor.c b/tests/query_editor.c index c709bab..60a0d89 100644 --- a/tests/query_editor.c +++ b/tests/query_editor.c @@ -19,6 +19,44 @@ #include #include +GtkWidget *w; + +on_btn_clean_clicked (GtkButton *button, + gpointer user_data) +{ + gdaex_query_editor_clean_choices ((GdaExQueryEditor *)user_data); +} + +on_btn_get_sql_clicked (GtkButton *button, + gpointer user_data) +{ + xmlDoc *doc; + xmlNode *node; + xmlChar *buf; + gint size; + + GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + gdaex_query_editor_get_sql ((GdaExQueryEditor *)user_data)); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog);; + + doc = xmlNewDoc ("1.0"); + node = gdaex_query_editor_get_sql_as_xml ((GdaExQueryEditor *)user_data); + xmlDocSetRootElement (doc, node); + xmlDocDumpMemory (doc, &buf, &size); + + dialog = gtk_message_dialog_new (GTK_WINDOW (w), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + buf); + gtk_dialog_run (GTK_DIALOG (dialog)); + gtk_widget_destroy (dialog);; +} + int main (int argc, char *argv[]) { @@ -31,11 +69,16 @@ main (int argc, char *argv[]) GdaExQueryEditorField *field; - GtkWidget *dialog; + GtkWidget *vbox; + GtkWidget *widget_qe; + GtkWidget *hbtnbox; + GtkWidget *btn_clean; + GtkWidget *btn_get_sql; + GtkWidget *btn_ok; gtk_init (&argc, &argv); - gdaex = gdaex = gdaex_new_from_string (g_strdup_printf ("SQLite://DB_DIR=%s;DB_NAME=test_prefix.db", TESTSDIR)); + gdaex = gdaex_new_from_string (g_strdup_printf ("SQLite://DB_DIR=%s;DB_NAME=test_prefix.db", TESTSDIR)); if (gdaex == NULL) { g_error ("Error on GdaEx initialization."); @@ -123,22 +166,42 @@ main (int argc, char *argv[]) gdaex_query_editor_table_add_field (qe, "clients", *field); g_free (field); - dialog = gdaex_query_editor_get_dialog (qe); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); + w = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size (GTK_WINDOW (w), 610, 400); + gtk_window_set_modal (GTK_WINDOW (w), TRUE); + gtk_window_set_position (GTK_WINDOW (w), GTK_WIN_POS_CENTER); + g_signal_connect (G_OBJECT (w), "delete-event", + gtk_main_quit, NULL); - g_message (gdaex_query_editor_get_sql (qe)); + vbox = gtk_vbox_new (FALSE, 5); + gtk_container_add (GTK_CONTAINER (w), vbox); - xmlDoc *doc; - xmlNode *node; - xmlChar *buf; - gint size; + widget_qe = gdaex_query_editor_get_widget (qe); + gtk_box_pack_start (GTK_BOX (vbox), widget_qe, TRUE, TRUE, 5); - doc = xmlNewDoc ("1.0"); - node = gdaex_query_editor_get_sql_as_xml (qe); - xmlDocSetRootElement (doc, node); - xmlDocDumpMemory (doc, &buf, &size); - g_message (buf); + hbtnbox = gtk_hbutton_box_new (); + gtk_button_box_set_layout (GTK_BUTTON_BOX (hbtnbox), GTK_BUTTONBOX_END); + gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbtnbox), 5); + gtk_box_pack_start (GTK_BOX (vbox), hbtnbox, FALSE, FALSE, 5); + + btn_clean = gtk_button_new_from_stock ("gtk-clear"); + gtk_box_pack_start (GTK_BOX (hbtnbox), btn_clean, TRUE, TRUE, 5); + g_signal_connect (G_OBJECT (btn_clean), "clicked", + G_CALLBACK (on_btn_clean_clicked), qe); + + btn_get_sql = gtk_button_new_with_mnemonic ("Get _Sql"); + gtk_box_pack_start (GTK_BOX (hbtnbox), btn_get_sql, TRUE, TRUE, 5); + g_signal_connect (G_OBJECT (btn_get_sql), "clicked", + G_CALLBACK (on_btn_get_sql_clicked), qe); + + btn_ok = gtk_button_new_from_stock ("gtk-close"); + gtk_box_pack_start (GTK_BOX (hbtnbox), btn_ok, TRUE, TRUE, 5); + g_signal_connect (G_OBJECT (btn_ok), "clicked", + gtk_main_quit, NULL); + + gtk_widget_show_all (w); + + gtk_main (); return 0; } -- 2.49.0