]> saetta.ns0.it Git - libgdaex/commitdiff
In GdaExQueryEditor used GtkDateEntry if it is present/usable.
authorAndrea Zagli <azagli@libero.it>
Sat, 26 Nov 2011 09:31:09 +0000 (10:31 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 26 Nov 2011 09:31:09 +0000 (10:31 +0100)
.anjuta/session/anjuta.session
.anjuta/session/dock-layout.xml
.anjuta_sym_db.db
configure.ac
src/queryeditor.c

index 300bb0f925fc0a8b3e889a84bbc98a6223fe4fa9..9954397677de3d84144e8e3b8e5306f9d4cd6e45 100644 (file)
@@ -1,14 +1,14 @@
 
 [Anjuta]
 Maximized=1
-Geometry=1366x716+0+30
+Geometry=1366x745+0+1
 
 [Project Manager]
-Shortcut=libgdaex//libgdaex//src//libgdaex.la%%%libgdaex//libgdaex//tests//test_prefix%%%libgdaex//libgdaex//tests//grid%%%libgdaex//libgdaex//tests//query_editor
-Expand=libgdaex
+Shortcut=libgdaex//libgdaex//src//libgdaex.la%%%libgdaex//libgdaex//tests//grid%%%libgdaex//libgdaex//tests//query_editor%%%libgdaex//libgdaex//tests//select%%%libgdaex//libgdaex//tests//test_prefix
+Expand=libgdaex.la%%%libgdaex
 
 [File Loader]
-Files=file:///home/andreaz/files/c/libgdaex/src/queryeditor.c#15
+Files=file:///home/andreaz/files/c/libgdaex/src/queryeditor.c#668
 
 [Document Manager]
 bookmarks=<?xml version="1.0" encoding="UTF-8"?>\n<bookmarks/>\n
index d8c025d86e12bc0eb0cc0e120dd0b4b71fb718b2..17c0817b9c566f76722c56dc3fa190934601bffe 100644 (file)
@@ -1,2 +1,2 @@
 <?xml version="1.0"?>
-<dock-layout><layout name="__default__"><dock name="__dock_1" floating="no" width="-1" height="-1" floatx="0" floaty="0"><paned orientation="horizontal" locked="no" position="1019"><notebook orientation="vertical" locked="no" page="2"><item name="AnjutaDocumentManager" orientation="vertical" locked="no"/><item name="AnjutaDevhelpDisplay" orientation="vertical" locked="yes"/><item name="AnjutaTerminal" orientation="vertical" locked="yes"/></notebook><notebook orientation="vertical" locked="no" page="2"><item name="AnjutaFileManager" orientation="vertical" locked="no"/><item name="AnjutaProjectManager" orientation="vertical" locked="no"/><item name="AnjutaSymbolDB" orientation="vertical" locked="no"/><item name="AnjutaDevhelpIndex" orientation="vertical" locked="no"/></notebook></paned></dock></layout></dock-layout>
+<dock-layout><layout name="__default__"><dock name="__dock_1" floating="no" width="-1" height="-1" floatx="0" floaty="0"><paned orientation="horizontal" locked="no" position="1019"><notebook orientation="vertical" locked="no" page="0"><item name="AnjutaDocumentManager" orientation="vertical" locked="no"/><item name="AnjutaDevhelpDisplay" orientation="vertical" locked="yes"/><item name="AnjutaTerminal" orientation="vertical" locked="yes"/></notebook><notebook orientation="vertical" locked="no" page="1"><item name="AnjutaFileManager" orientation="vertical" locked="no"/><item name="AnjutaProjectManager" orientation="vertical" locked="no"/><item name="AnjutaSymbolDB" orientation="vertical" locked="no"/><item name="AnjutaDevhelpIndex" orientation="vertical" locked="no"/></notebook></paned></dock></layout></dock-layout>
index 722ad464cd0571eafa373a7d5401a81db0bd230d..60e368aaf52e5dbfba6aa892abae85b7cd99af56 100644 (file)
Binary files a/.anjuta_sym_db.db and b/.anjuta_sym_db.db differ
index 1dde28abe4a302e350d1bd6c7f3fcd63a20c6fa9..19df4b0ebe0370a5b62f5698e8ad04fcaf284065 100644 (file)
@@ -40,7 +40,8 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
 AM_GLIB_GNU_GETTEXT
 
 # Checks for libraries.
-PKG_CHECK_MODULES(GDAEX, [libgda-4.0 >= 4
+PKG_CHECK_MODULES(GDAEX, [gmodule-2.0 >= 2
+                          libgda-4.0 >= 4
                           gio-2.0 >= 2.24
                           gtk+-2.0 >= 2.20])
 
index af2191c02fa18ea1d15e82fb2bb74f871874583e..44c91829676d570a286d1a041e4166a37c1ca7e4 100644 (file)
@@ -159,7 +159,10 @@ static void gdaex_query_editor_on_sel_order_changed (GtkTreeSelection *treeselec
 
 #define GDAEX_QUERY_EDITOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_GDAEX_QUERY_EDITOR, GdaExQueryEditorPrivate))
 
-typedef GtkWidget *(* GtkDateEntryNew) (void);
+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;
@@ -167,6 +170,11 @@ struct _GdaExQueryEditorPrivate
        {
                GdaEx *gdaex;
 
+               GModule *gtk_date_entry_module;
+               GtkDateEntryNew gtk_date_entry_new;
+               GtkDateEntrySetDateVisible gtk_date_entry_set_date_visible;
+               GtkDateEntrySetTimeVisible gtk_date_entry_set_time_visible;
+
                GtkBuilder *gtkbuilder;
 
                GtkWidget *notebook;
@@ -308,6 +316,34 @@ GdaExQueryEditor
 
        priv->gdaex = gdaex;
 
+       /* test if we can use GtkDateEntry */
+       priv->gtk_date_entry_module = NULL;
+       priv->gtk_date_entry_new = NULL;
+       priv->gtk_date_entry_set_date_visible = NULL;
+       priv->gtk_date_entry_set_time_visible = NULL;
+       if (g_module_supported ())
+               {
+                       /* TODO it must be found in a better way */
+#ifdef G_OS_WIN32
+                       priv->gtk_date_entry_module = g_module_open (g_build_filename (g_win32_get_package_installation_directory_of_module (NULL), "libgtkdateentry-0.dll", NULL), G_MODULE_BIND_LAZY);
+#else
+                       priv->gtk_date_entry_module = g_module_open ("/usr/local/lib/libgtkdateentry.la", G_MODULE_BIND_LAZY);
+#endif
+                       if (priv->gtk_date_entry_module != NULL)
+                               {
+                                       if (!g_module_symbol (priv->gtk_date_entry_module, "gtk_date_entry_new", (gpointer *)&(priv->gtk_date_entry_new))
+                                           || !g_module_symbol (priv->gtk_date_entry_module, "gtk_date_entry_set_date_visible", (gpointer *)&(priv->gtk_date_entry_set_date_visible))
+                                           || !g_module_symbol (priv->gtk_date_entry_module, "gtk_date_entry_set_time_visible", (gpointer *)&(priv->gtk_date_entry_set_time_visible)))
+                                               {
+                                                       g_module_close (priv->gtk_date_entry_module);
+                                                       priv->gtk_date_entry_module = NULL;
+                                                       priv->gtk_date_entry_new = NULL;
+                                                       priv->gtk_date_entry_set_date_visible = NULL;
+                                                       priv->gtk_date_entry_set_time_visible = NULL;
+                                               }
+                               }
+               }
+
        priv->gtkbuilder = gdaex_get_gtkbuilder (priv->gdaex);
 
        error = NULL;
@@ -591,34 +627,80 @@ gdaex_query_editor_table_add_field (GdaExQueryEditor *qe,
 
        if (!GDAEX_QUERY_EDITOR_IS_IWIDGET (_field->iwidget_from))
                {
-                       _field->iwidget_from = GDAEX_QUERY_EDITOR_IWIDGET (gdaex_query_editor_entry_new ());
-                       if (_field->type == GDAEX_QE_FIELD_TYPE_DATE)
-                               {
-                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_from), 10);
-                               }
-                       else if (_field->type == GDAEX_QE_FIELD_TYPE_DATETIME)
+                       if (priv->gtk_date_entry_module != NULL
+                           && (_field->type == GDAEX_QE_FIELD_TYPE_DATE
+                               || _field->type == GDAEX_QE_FIELD_TYPE_DATETIME
+                               || _field->type == GDAEX_QE_FIELD_TYPE_TIME))
                                {
-                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_from), 19);
+                                       _field->iwidget_from = GDAEX_QUERY_EDITOR_IWIDGET (priv->gtk_date_entry_new (NULL, NULL, TRUE));
+                                       if (_field->type == GDAEX_QE_FIELD_TYPE_DATE)
+                                               {
+                                                       priv->gtk_date_entry_set_date_visible ((gpointer)_field->iwidget_from, TRUE);
+                                                       priv->gtk_date_entry_set_time_visible ((gpointer)_field->iwidget_from, FALSE);
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_DATETIME)
+                                               {
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_TIME)
+                                               {
+                                                       priv->gtk_date_entry_set_date_visible ((gpointer)_field->iwidget_from, FALSE);
+                                                       priv->gtk_date_entry_set_time_visible ((gpointer)_field->iwidget_from, TRUE);
+                                               }
                                }
-                       else if (_field->type == GDAEX_QE_FIELD_TYPE_TIME)
+                       else
                                {
-                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_from), 8);
+                                       _field->iwidget_from = GDAEX_QUERY_EDITOR_IWIDGET (gdaex_query_editor_entry_new ());
+                                       if (_field->type == GDAEX_QE_FIELD_TYPE_DATE)
+                                               {
+                                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_from), 10);
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_DATETIME)
+                                               {
+                                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_from), 19);
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_TIME)
+                                               {
+                                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_from), 8);
+                                               }
                                }
                }
        if (!GDAEX_QUERY_EDITOR_IS_IWIDGET (_field->iwidget_to))
                {
-                       _field->iwidget_to = GDAEX_QUERY_EDITOR_IWIDGET (gdaex_query_editor_entry_new ());
-                       if (_field->type == GDAEX_QE_FIELD_TYPE_DATE)
-                               {
-                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_to), 10);
-                               }
-                       else if (_field->type == GDAEX_QE_FIELD_TYPE_DATETIME)
+                       if (priv->gtk_date_entry_module != NULL
+                           && (_field->type == GDAEX_QE_FIELD_TYPE_DATE
+                               || _field->type == GDAEX_QE_FIELD_TYPE_DATETIME
+                               || _field->type == GDAEX_QE_FIELD_TYPE_TIME))
                                {
-                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_to), 19);
+                                       _field->iwidget_to = GDAEX_QUERY_EDITOR_IWIDGET (priv->gtk_date_entry_new (NULL, NULL, TRUE));
+                                       if (_field->type == GDAEX_QE_FIELD_TYPE_DATE)
+                                               {
+                                                       priv->gtk_date_entry_set_date_visible ((gpointer)_field->iwidget_to, TRUE);
+                                                       priv->gtk_date_entry_set_time_visible ((gpointer)_field->iwidget_to, FALSE);
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_DATETIME)
+                                               {
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_TIME)
+                                               {
+                                                       priv->gtk_date_entry_set_date_visible ((gpointer)_field->iwidget_to, FALSE);
+                                                       priv->gtk_date_entry_set_time_visible ((gpointer)_field->iwidget_to, TRUE);
+                                               }
                                }
-                       else if (_field->type == GDAEX_QE_FIELD_TYPE_TIME)
+                       else
                                {
-                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_to), 8);
+                                       _field->iwidget_to = GDAEX_QUERY_EDITOR_IWIDGET (gdaex_query_editor_entry_new ());
+                                       if (_field->type == GDAEX_QE_FIELD_TYPE_DATE)
+                                               {
+                                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_to), 10);
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_DATETIME)
+                                               {
+                                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_to), 19);
+                                               }
+                                       else if (_field->type == GDAEX_QE_FIELD_TYPE_TIME)
+                                               {
+                                                       gtk_entry_set_max_length (GTK_ENTRY (_field->iwidget_to), 8);
+                                               }
                                }
                }