{
GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe);
- GList *lw = gtk_container_get_children (GTK_CONTAINER (priv->vbx_values));
- if (lw != NULL && lw->data != NULL)
+ if (GTK_IS_HBOX (priv->hbox))
{
- gtk_container_remove (GTK_CONTAINER (priv->vbx_values), (GtkWidget *)lw->data);
+ gtk_container_remove (GTK_CONTAINER (priv->vbx_values), (GtkWidget *)priv->hbox);
}
}
{
gtk_date_entry_set_date_gdatetime (GTK_DATE_ENTRY (priv->txt1), NULL);
}
+ else if (GDAEX_QUERY_EDITOR_IS_IWIDGET (priv->txt1))
+ {
+ gdaex_query_editor_iwidget_set_value (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt1), "");
+ }
else
{
gtk_entry_set_text (GTK_ENTRY (priv->txt1), "");
{
gtk_date_entry_set_date_gdatetime (GTK_DATE_ENTRY (priv->txt2), NULL);
}
+ else if (GDAEX_QUERY_EDITOR_IS_IWIDGET (priv->txt2))
+ {
+ gdaex_query_editor_iwidget_set_value (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt2), "");
+ }
else
{
gtk_entry_set_text (GTK_ENTRY (priv->txt2), "");
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));
}
+ else if (GDAEX_QUERY_EDITOR_IS_IWIDGET (priv->txt1))
+ {
+ val1 = (gchar *)gdaex_query_editor_iwidget_get_value (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt1));
+ val1_sql = (gchar *)gdaex_query_editor_iwidget_get_value_sql (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt1));
+ }
else
{
val1 = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt1));
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 (GDAEX_QUERY_EDITOR_IS_IWIDGET (priv->txt2))
+ {
+ val2 = (gchar *)gdaex_query_editor_iwidget_get_value (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt2));
+ val2_sql = (gchar *)gdaex_query_editor_iwidget_get_value_sql (GDAEX_QUERY_EDITOR_IWIDGET (priv->txt2));
+ }
else
{
val2 = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt2));
GdaExQueryEditorField *field;
GtkWidget *lbl;
- GtkWidget *widget_val1;
- GtkWidget *widget_val2;
GtkTreeIter iter_cb;
GtkCellRenderer *renderer;
case GDAEX_QE_FIELD_TYPE_TEXT:
priv->txt1 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (priv->txt1), from == NULL ? "" : from);
- widget_val1 = priv->txt1;
priv->txt2 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (priv->txt2), to == NULL ? "" : to);
- widget_val2 = priv->txt2;
break;
case GDAEX_QE_FIELD_TYPE_INTEGER:
- priv->txt1 = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (priv->txt1), from == NULL ? "" : from);
- widget_val1 = priv->txt1;
+ if (GDAEX_QUERY_EDITOR_IS_IWIDGET (field->iwidget_from))
+ {
+ priv->txt1 = GTK_WIDGET (field->iwidget_from);
+ gdaex_query_editor_iwidget_set_value (field->iwidget_from, from_sql == NULL ? "0" : from_sql);
+ }
+ else
+ {
+ priv->txt2 = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (priv->txt2), to == NULL ? "" : to);
+ }
- priv->txt2 = gtk_entry_new ();
- gtk_entry_set_text (GTK_ENTRY (priv->txt2), to == NULL ? "" : to);
- widget_val2 = priv->txt2;
+ if (GDAEX_QUERY_EDITOR_IS_IWIDGET (field->iwidget_to))
+ {
+ priv->txt2 = GTK_WIDGET (field->iwidget_to);
+ gdaex_query_editor_iwidget_set_value (field->iwidget_to, to_sql == NULL ? "0" : to_sql);
+ }
+ else
+ {
+ priv->txt2 = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (priv->txt2), to == NULL ? "" : to);
+ }
break;
case GDAEX_QE_FIELD_TYPE_DOUBLE:
priv->txt1 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (priv->txt1), from == NULL ? "" : from);
- widget_val1 = priv->txt1;
priv->txt2 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (priv->txt2), to == NULL ? "" : to);
- widget_val2 = priv->txt2;
break;
case GDAEX_QE_FIELD_TYPE_DATE:
priv->txt1 = gtk_date_entry_new (NULL, NULL, TRUE);
gtk_date_entry_set_time_visible (GTK_DATE_ENTRY (priv->txt1), FALSE);
gtk_date_entry_set_date_strf (GTK_DATE_ENTRY (priv->txt1), from_sql == NULL ? g_date_time_format (g_date_time_new_now_local (), "%Y-%m-%d") : from_sql, "Ymd");
- widget_val1 = priv->txt1;
priv->txt2 = gtk_date_entry_new (NULL, NULL, TRUE);
gtk_date_entry_set_time_visible (GTK_DATE_ENTRY (priv->txt2), FALSE);
gtk_date_entry_set_date_strf (GTK_DATE_ENTRY (priv->txt2), to_sql == NULL ? g_date_time_format (g_date_time_new_now_local (), "%Y-%m-%d") : to_sql, "Ymd");
- widget_val2 = priv->txt2;
break;
case GDAEX_QE_FIELD_TYPE_DATETIME:
priv->txt1 = gtk_date_entry_new (NULL, NULL, TRUE);
gtk_date_entry_set_time_separator (GTK_DATE_ENTRY (priv->txt1), ".");
gtk_date_entry_set_date_strf (GTK_DATE_ENTRY (priv->txt1), from_sql == NULL ? g_date_time_format (g_date_time_new_now_local (), "%Y-%m-%d %H.%M.%S") : from_sql, "YmdHMS");
- widget_val1 = priv->txt1;
priv->txt2 = gtk_date_entry_new (NULL, NULL, TRUE);
gtk_date_entry_set_time_separator (GTK_DATE_ENTRY (priv->txt2), ".");
gtk_date_entry_set_date_strf (GTK_DATE_ENTRY (priv->txt2), to_sql == NULL ? g_date_time_format (g_date_time_new_now_local (), "%Y-%m-%d %H.%M.%S") : to_sql, "YmdHMS");
- widget_val2 = priv->txt2;
break;
case GDAEX_QE_FIELD_TYPE_TIME:
priv->txt1 = gtk_entry_new ();
gtk_entry_set_max_length (GTK_ENTRY (priv->txt1), 8);
gtk_entry_set_text (GTK_ENTRY (priv->txt1), from == NULL ? "" : from);
- widget_val1 = priv->txt1;
priv->txt2 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (priv->txt2), to == NULL ? "" : to);
- widget_val2 = priv->txt2;
break;
default:
break;
};
- gtk_table_attach (GTK_TABLE (priv->tbl), widget_val1, 4, 5, 1, 2, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
- gtk_table_attach (GTK_TABLE (priv->tbl), widget_val2, 4, 5, 2, 3, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (priv->tbl), priv->txt1, 4, 5, 1, 2, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
+ gtk_table_attach (GTK_TABLE (priv->tbl), priv->txt2, 4, 5, 2, 3, GTK_EXPAND | GTK_SHRINK | GTK_FILL, 0, 0, 0);
gtk_box_pack_start (GTK_BOX (priv->vbx_values), priv->hbox, FALSE, FALSE, 0);
--- /dev/null
+/*
+ * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include "queryeditor_widget_interface.h"
+
+typedef GdaExQueryEditorIWidgetIface GdaExQueryEditorIWidgetInterface;
+
+G_DEFINE_INTERFACE (GdaExQueryEditorIWidget, gdaex_query_editor_iwidget, G_TYPE_OBJECT)
+
+static void
+gdaex_query_editor_iwidget_default_init (GdaExQueryEditorIWidgetInterface *iface)
+{
+}
+
+const gchar
+*gdaex_query_editor_iwidget_get_value (GdaExQueryEditorIWidget *iwidget)
+{
+ GdaExQueryEditorIWidgetIface *iface;
+
+ gchar *ret;
+
+ ret = NULL;
+
+ g_return_val_if_fail (GDAEX_QUERY_EDITOR_IS_IWIDGET (iwidget), ret);
+
+ iface = GDAEX_QUERY_EDITOR_IWIDGET_GET_IFACE (iwidget);
+
+ if (iface->get_value)
+ {
+ ret = (gchar *)(* iface->get_value) (iwidget);
+ }
+
+ return ret;
+}
+
+const gchar
+*gdaex_query_editor_iwidget_get_value_sql (GdaExQueryEditorIWidget *iwidget)
+{
+ GdaExQueryEditorIWidgetIface *iface;
+
+ gchar *ret;
+
+ ret = NULL;
+
+ g_return_val_if_fail (GDAEX_QUERY_EDITOR_IS_IWIDGET (iwidget), ret);
+
+ iface = GDAEX_QUERY_EDITOR_IWIDGET_GET_IFACE (iwidget);
+
+ if (iface->get_value_sql)
+ {
+ ret = (gchar *)(* iface->get_value_sql) (iwidget);
+ }
+
+ return ret;
+}
+
+void
+gdaex_query_editor_iwidget_set_value (GdaExQueryEditorIWidget *iwidget,
+ const gchar *value)
+{
+ GdaExQueryEditorIWidgetIface *iface;
+
+ g_return_if_fail (GDAEX_QUERY_EDITOR_IS_IWIDGET (iwidget));
+
+ iface = GDAEX_QUERY_EDITOR_IWIDGET_GET_IFACE (iwidget);
+
+ if (iface->set_value)
+ {
+ (* iface->set_value) (iwidget, value);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __GDAEX_QUERY_EDITOR_IWIDGET_H__
+#define __GDAEX_QUERY_EDITOR_IWIDGET_H__
+
+#include <glib-object.h>
+
+
+G_BEGIN_DECLS
+
+
+#define GDAEX_QUERY_EDITOR_TYPE_IWIDGET (gdaex_query_editor_iwidget_get_type ())
+#define GDAEX_QUERY_EDITOR_IWIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDAEX_QUERY_EDITOR_TYPE_IWIDGET, GdaExQueryEditorIWidget))
+#define GDAEX_QUERY_EDITOR_IS_IWIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDAEX_QUERY_EDITOR_TYPE_IWIDGET))
+#define GDAEX_QUERY_EDITOR_IWIDGET_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDAEX_QUERY_EDITOR_TYPE_IWIDGET, GdaExQueryEditorIWidgetIface))
+
+
+typedef struct _GdaExQueryEditorIWidget GdaExQueryEditorIWidget;
+typedef struct _GdaExQueryEditorIWidgetIface GdaExQueryEditorIWidgetIface;
+
+struct _GdaExQueryEditorIWidgetIface
+ {
+ GTypeInterface g_iface;
+
+ const gchar *(*get_value) (GdaExQueryEditorIWidget *irole);
+ const gchar *(*get_value_sql) (GdaExQueryEditorIWidget *irole);
+ void (*set_value) (GdaExQueryEditorIWidget *irole, const gchar *value);
+ };
+
+GType gdaex_query_editor_irole_get_type (void) G_GNUC_CONST;
+
+const gchar *gdaex_query_editor_iwidget_get_value (GdaExQueryEditorIWidget *iwidget);
+const gchar *gdaex_query_editor_iwidget_get_value_sql (GdaExQueryEditorIWidget *iwidget);
+void gdaex_query_editor_iwidget_set_value (GdaExQueryEditorIWidget *iwidget, const gchar *value);
+
+
+G_END_DECLS
+
+
+#endif /* __GDAEX_QUERY_EDITOR_IWIDGET_H__ */