From: Andrea Zagli Date: Thu, 25 Jun 2015 11:00:49 +0000 (+0200) Subject: Merged decoder branch. X-Git-Tag: 0.4.0 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=05968590b1ad92546bb785911f8d2d1514c33bd0;p=libgdaex Merged decoder branch. --- 05968590b1ad92546bb785911f8d2d1514c33bd0 diff --cc src/queryeditor.c index ebfa5ee,c690d9d..32a34b4 --- a/src/queryeditor.c +++ b/src/queryeditor.c @@@ -166,14 -147,12 +166,18 @@@ static void gdaex_query_editor_on_btn_o static void gdaex_query_editor_on_sel_order_changed (GtkTreeSelection *treeselection, gpointer user_data); + static void gdaex_query_editor_on_txt1_btn_browse_clicked (gpointer instance, gpointer user_data); + static void gdaex_query_editor_on_txt2_btn_browse_clicked (gpointer instance, gpointer user_data); + + #define GDAEX_QUERY_EDITOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GDAEX_QUERY_EDITOR, GdaExQueryEditorPrivate)) +typedef GtkWidget *(* GtkDateEntryNew) (const gchar *format, + const gchar *separator, + gboolean calendar_button_is_visible); +typedef void (* GtkDateEntrySetDateVisible) (gpointer gtkdateentry, gboolean visible); +typedef void (* GtkDateEntrySetTimeVisible) (gpointer gtkdateentry, gboolean visible); + typedef struct _GdaExQueryEditorPrivate GdaExQueryEditorPrivate; struct _GdaExQueryEditorPrivate { @@@ -3473,62 -2195,79 +3477,67 @@@ gdaex_query_editor_on_btn_save_clicked 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; - } + _("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); + gtk_tree_model_get (model, &iter_val, + 0, &where_type, + -1); - if (GTK_IS_DATE_ENTRY (priv->txt1)) - { - val1 = (gchar *)gtk_date_entry_get_strf (GTK_DATE_ENTRY (priv->txt1), gtk_date_entry_is_time_visible (GTK_DATE_ENTRY (priv->txt1)) ? "dmYHMS" : "dmY", NULL, NULL); - val1_sql = (gchar *)gtk_date_entry_get_sql (GTK_DATE_ENTRY (priv->txt1)); + val1 = (gchar *)gdaex_query_editor_iwidget_get_value (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt_from)); + val1_sql = (gchar *)gdaex_query_editor_iwidget_get_value_sql (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt_from)); + if (val1 == NULL) + { + val1 = g_strdup (""); + } + else + { + val1 = g_strdup (val1); + } + if (val1_sql == NULL) + { + val1_sql = g_strdup (""); + } + else + { + val1_sql = g_strdup (val1_sql); + } + + val2 = (gchar *)gdaex_query_editor_iwidget_get_value (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt_to)); + val2_sql = (gchar *)gdaex_query_editor_iwidget_get_value_sql (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt_to)); + if (val2 == NULL) + { + val2 = g_strdup (""); + } + else + { + val2 = g_strdup (val2); + } + if (val2_sql == NULL) + { + val2_sql = g_strdup (""); + } + else + { + val2_sql = g_strdup (val2_sql); + } } + else if (GTK_IS_FORM_DECODER (priv->txt1)) + { + val1 = (gchar *)gtk_form_decoder_get_decoded (GTK_FORM_DECODER (priv->txt1)); + val1_sql = (gchar *)gtk_form_decoder_get_key (GTK_FORM_DECODER (priv->txt1)); + } else { - val1 = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt1)); - val1_sql = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt1)); - } - if (val1 == NULL) - { + where_type = 0; val1 = g_strdup (""); - } - else - { - val1 = g_strdup (val1); - } - if (val1_sql == NULL) - { val1_sql = g_strdup (""); - } - else - { - val1_sql = g_strdup (val1_sql); - } - - if (GTK_IS_DATE_ENTRY (priv->txt2)) - { - val2 = (gchar *)gtk_date_entry_get_strf (GTK_DATE_ENTRY (priv->txt2), gtk_date_entry_is_time_visible (GTK_DATE_ENTRY (priv->txt2)) ? "dmYHMS" : "dmY", NULL, NULL); - val2_sql = (gchar *)gtk_date_entry_get_sql (GTK_DATE_ENTRY (priv->txt2)); - } - else if (GTK_IS_FORM_DECODER (priv->txt2)) - { - val2 = (gchar *)gtk_form_decoder_get_decoded (GTK_FORM_DECODER (priv->txt2)); - val2_sql = (gchar *)gtk_form_decoder_get_key (GTK_FORM_DECODER (priv->txt2)); - } - else - { - val2 = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt2)); - val2_sql = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt2)); - } - if (val2 == NULL) - { val2 = g_strdup (""); - } - else - { - val2 = g_strdup (val2); - } - if (val2_sql == NULL) - { val2_sql = g_strdup (""); } - else - { - val2_sql = g_strdup (val2_sql); - } gtk_tree_store_set (priv->tstore_where, &iter, COL_WHERE_LINK_TYPE, link_type, diff --cc tests/query_editor.c index d6a9fcc,c65f6fc..3a56de2 --- a/tests/query_editor.c +++ b/tests/query_editor.c @@@ -202,19 -146,9 +202,19 @@@ main (int argc, char *argv[] GtkWidget *btn_load_xml; GtkWidget *btn_ok; + gchar *xmlfile; + + xmlfile = NULL; + + GOptionEntry entries[] = + { + { "xml-file", 'x', 0, G_OPTION_ARG_FILENAME, &xmlfile, "Xml file", NULL }, + { NULL } + }; + gtk_init (&argc, &argv); - 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=query_editor.db", TESTSDIR)); if (gdaex == NULL) { g_error ("Error on GdaEx initialization.");