]> saetta.ns0.it Git - libgdaex/commitdiff
Merged decoder branch. 0.4.0 gtk2
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 25 Jun 2015 11:00:49 +0000 (13:00 +0200)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Thu, 25 Jun 2015 11:01:04 +0000 (13:01 +0200)
1  2 
src/queryeditor.c
tests/query_editor.c

index ebfa5ee2946260c0759aad961134e2915a805fc5,c690d9daf65c5938af98311b35b7bce9c2b2c393..32a34b439161d2e69df6d304f5f5ae0ea7db98a2
@@@ -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,
index d6a9fcc6ccb3cdd121e54f9772fa8f42c7fe1981,c65f6fc0cc822f3144327e8ea48f2350bf22fb27..3a56de2b85914cd16f70f592e1105ee3bcfe6ff7
@@@ -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.");