libgnomedb r1750 - in trunk: . extra/demos libgnomedb
- From: vivien svn gnome org
- To: svn-commits-list gnome org
- Subject: libgnomedb r1750 - in trunk: . extra/demos libgnomedb
- Date: Mon, 6 Oct 2008 18:29:21 +0000 (UTC)
Author: vivien
Date: Mon Oct 6 18:29:20 2008
New Revision: 1750
URL: http://svn.gnome.org/viewvc/libgnomedb?rev=1750&view=rev
Log:
2008-10-06 Vivien Malerba <malerba gnome-db org>
* configure.in: set minimum libgda version to 3.99.5
* libgnomedb/gnome-db-basic-form.c:
* libgnomedb/gnome-db-raw-grid.c:
* libgnomedb/gnome-db-enums.h: adaptations to Libgda's API changes
* extra/demos/grid_pict.c:
* extra/demos/form_pict.c:
* extra/demos/data_model_dir.c: updates demo code
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/extra/demos/data_model_dir.c
trunk/extra/demos/form_pict.c
trunk/extra/demos/grid_pict.c
trunk/libgnomedb/gnome-db-basic-form.c
trunk/libgnomedb/gnome-db-enums.h
trunk/libgnomedb/gnome-db-raw-grid.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Mon Oct 6 18:29:20 2008
@@ -1,6 +1,6 @@
m4_define(major, 3)
m4_define(minor, 99)
-m4_define(micro, 4)
+m4_define(micro, 5)
AC_INIT(GNOME DB library, major.minor.micro, gnome-db-list gnome org,
libgnomedb)
@@ -152,7 +152,7 @@
dnl ******************************
GTK_MODULES="gtk+-2.0 >= 2.6.0 gthread-2.0"
-LIBGDA_MODULES="libgda-$GNOMEDB_ABI_MAJOR_VERSION.$GNOMEDB_ABI_MINOR_VERSION >= 3.99.4"
+LIBGDA_MODULES="libgda-$GNOMEDB_ABI_MAJOR_VERSION.$GNOMEDB_ABI_MINOR_VERSION >= 3.99.5"
LIBGNOMEDB_REQUIRES="$GTK_MODULES $LIBGDA_MODULES"
PKG_CHECK_MODULES(LIBGNOMEDB, $GTK_MODULES $LIBGDA_MODULES)
Modified: trunk/extra/demos/data_model_dir.c
==============================================================================
--- trunk/extra/demos/data_model_dir.c (original)
+++ trunk/extra/demos/data_model_dir.c Mon Oct 6 18:29:20 2008
@@ -47,6 +47,7 @@
GdaSet *data_set;
GdaHolder *param;
gchar *path;
+ GValue *value;
window = gtk_dialog_new_with_buttons ("GdaDataModelDir data model",
GTK_WINDOW (do_widget),
@@ -90,14 +91,19 @@
g_object_get (G_OBJECT (form), "raw_form", &raw, NULL);
data_set = gnome_db_basic_form_get_data_set (GNOME_DB_BASIC_FORM (raw));
param = gda_set_get_holder (data_set, "data");
- g_object_set (G_OBJECT (param), "plugin", "picture", NULL);
+
+ value = gda_value_new_from_string ("picture", G_TYPE_STRING);
+ gda_holder_set_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN, value);
gnome_db_data_widget_column_show_actions (GNOME_DB_DATA_WIDGET (raw), -1, TRUE);
g_object_get (G_OBJECT (grid), "raw_grid", &raw, NULL);
data_set = GDA_SET (gnome_db_data_widget_get_current_data (GNOME_DB_DATA_WIDGET (raw)));
param = gda_set_get_holder (data_set, "data");
- g_object_set (G_OBJECT (param), "plugin", "picture", NULL);
+
+ gda_holder_set_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN, value);
gnome_db_data_widget_column_show_actions (GNOME_DB_DATA_WIDGET (raw), -1, TRUE);
+
+ gda_value_free (value);
}
if (!GTK_WIDGET_VISIBLE (window))
Modified: trunk/extra/demos/form_pict.c
==============================================================================
--- trunk/extra/demos/form_pict.c (original)
+++ trunk/extra/demos/form_pict.c Mon Oct 6 18:29:20 2008
@@ -22,6 +22,7 @@
GnomeDbRawForm *raw_form;
GdaSet *data_set;
GdaHolder *param;
+ GValue *value;
window = gtk_dialog_new_with_buttons ("Form with the 'picture' plugin",
GTK_WINDOW (do_widget),
@@ -57,7 +58,10 @@
g_object_get (G_OBJECT (form), "raw_form", &raw_form, NULL);
data_set = gnome_db_basic_form_get_data_set (GNOME_DB_BASIC_FORM (raw_form));
param = gda_set_get_holder (data_set, "pict");
- g_object_set (G_OBJECT (param), "plugin", "picture", NULL);
+
+ value = gda_value_new_from_string ("picture", G_TYPE_STRING);
+ gda_holder_set_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN, value);
+ gda_value_free (value);
gtk_box_pack_start (GTK_BOX (vbox), form, TRUE, TRUE, 0);
Modified: trunk/extra/demos/grid_pict.c
==============================================================================
--- trunk/extra/demos/grid_pict.c (original)
+++ trunk/extra/demos/grid_pict.c Mon Oct 6 18:29:20 2008
@@ -22,6 +22,7 @@
GnomeDbRawGrid *raw_grid;
GdaSet *data_set;
GdaHolder *param;
+ GValue *value;
window = gtk_dialog_new_with_buttons ("Grid with the 'picture' plugin",
GTK_WINDOW (do_widget),
@@ -57,7 +58,10 @@
g_object_get (G_OBJECT (grid), "raw_grid", &raw_grid, NULL);
data_set = GDA_SET (gnome_db_data_widget_get_current_data (GNOME_DB_DATA_WIDGET (raw_grid)));
param = gda_set_get_holder (data_set, "pict");
- g_object_set (G_OBJECT (param), "plugin", "picture", NULL);
+
+ value = gda_value_new_from_string ("picture", G_TYPE_STRING);
+ gda_holder_set_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN, value);
+ gda_value_free (value);
gtk_box_pack_start (GTK_BOX (vbox), grid, TRUE, TRUE, 0);
Modified: trunk/libgnomedb/gnome-db-basic-form.c
==============================================================================
--- trunk/libgnomedb/gnome-db-basic-form.c (original)
+++ trunk/libgnomedb/gnome-db-basic-form.c Mon Oct 6 18:29:20 2008
@@ -21,6 +21,7 @@
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
+#include "gnome-db-enums.h"
#include "gnome-db-basic-form.h"
#include "gnome-db-tools.h"
#include "marshal.h"
@@ -48,8 +49,8 @@
static void get_rid_of_set (GdaSet *paramlist, GnomeDbBasicForm *form);
static void paramlist_public_data_changed_cb (GdaSet *paramlist, GnomeDbBasicForm *form);
-static void paramlist_param_plugin_changed_cb (GdaSet *paramlist, GdaHolder *param, GnomeDbBasicForm *form);
-static void paramlist_param_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, GnomeDbBasicForm *form);
+static void paramlist_param_attr_changed_cb (GdaSet *paramlist, GdaHolder *param,
+ const gchar *att_name, const GValue *att_value, GnomeDbBasicForm *form);
static void entry_contents_modified (GnomeDbDataEntry *entry, GnomeDbBasicForm *form);
static void entry_contents_activated (GnomeDbDataEntry *entry, GnomeDbBasicForm *form);
@@ -295,8 +296,6 @@
g_signal_handlers_disconnect_by_func (paramlist,
G_CALLBACK (paramlist_public_data_changed_cb), form);
g_signal_handlers_disconnect_by_func (paramlist,
- G_CALLBACK (paramlist_param_plugin_changed_cb), form);
- g_signal_handlers_disconnect_by_func (paramlist,
G_CALLBACK (paramlist_param_attr_changed_cb), form);
g_object_unref (form->priv->set);
@@ -319,41 +318,41 @@
}
static void
-paramlist_param_plugin_changed_cb (GdaSet *paramlist, GdaHolder *param, GnomeDbBasicForm *form)
-{
- /* TODO: be more specific and change only the entry corresponding to @param */
- paramlist_public_data_changed_cb (paramlist, form);
-}
-
-static void
-paramlist_param_attr_changed_cb (GdaSet *paramlist, GdaHolder *param, GnomeDbBasicForm *form)
+paramlist_param_attr_changed_cb (GdaSet *paramlist, GdaHolder *param,
+ const gchar *att_name, const GValue *att_value, GnomeDbBasicForm *form)
{
GtkWidget *entry;
- entry = gnome_db_basic_form_get_entry_widget (form, param);
- if (entry) {
- gboolean toset;
- guint attrs = 0;
- guint mask = 0;
- const GValue *defv;
-
- defv = gda_holder_get_default_value (param);
- attrs |= defv ? GDA_VALUE_ATTR_CAN_BE_DEFAULT : 0;
- mask |= GDA_VALUE_ATTR_CAN_BE_DEFAULT;
-
- toset = gda_holder_get_not_null (param);
- attrs |= toset ? 0 : GDA_VALUE_ATTR_CAN_BE_NULL;
- mask |= GDA_VALUE_ATTR_CAN_BE_NULL;
-
- g_object_get (G_OBJECT (param), "use-default-value", &toset, NULL);
- attrs |= toset ? GDA_VALUE_ATTR_IS_DEFAULT : 0;
- mask |= GDA_VALUE_ATTR_IS_DEFAULT;
-
- g_signal_handlers_block_by_func (G_OBJECT (entry),
- G_CALLBACK (entry_contents_modified), form);
- gnome_db_data_entry_set_attributes (GNOME_DB_DATA_ENTRY (entry), attrs, mask);
- g_signal_handlers_unblock_by_func (G_OBJECT (entry),
- G_CALLBACK (entry_contents_modified), form);
+ if (!strcmp (att_name, GDA_ATTRIBUTE_IS_DEFAULT)) {
+ entry = gnome_db_basic_form_get_entry_widget (form, param);
+ if (entry) {
+ gboolean toset;
+ guint attrs = 0;
+ guint mask = 0;
+ const GValue *defv;
+
+ defv = gda_holder_get_default_value (param);
+ attrs |= defv ? GDA_VALUE_ATTR_CAN_BE_DEFAULT : 0;
+ mask |= GDA_VALUE_ATTR_CAN_BE_DEFAULT;
+
+ toset = gda_holder_get_not_null (param);
+ attrs |= toset ? 0 : GDA_VALUE_ATTR_CAN_BE_NULL;
+ mask |= GDA_VALUE_ATTR_CAN_BE_NULL;
+
+ g_object_get (G_OBJECT (param), "use-default-value", &toset, NULL);
+ attrs |= toset ? GDA_VALUE_ATTR_IS_DEFAULT : 0;
+ mask |= GDA_VALUE_ATTR_IS_DEFAULT;
+
+ g_signal_handlers_block_by_func (G_OBJECT (entry),
+ G_CALLBACK (entry_contents_modified), form);
+ gnome_db_data_entry_set_attributes (GNOME_DB_DATA_ENTRY (entry), attrs, mask);
+ g_signal_handlers_unblock_by_func (G_OBJECT (entry),
+ G_CALLBACK (entry_contents_modified), form);
+ }
+ }
+ else if (!strcmp (att_name, GNOME_DB_ATTRIBUTE_PLUGIN)) {
+ /* TODO: be more specific and change only the cell renderer corresponding to @param */
+ paramlist_public_data_changed_cb (paramlist, form);
}
}
@@ -490,9 +489,7 @@
g_object_ref (form->priv->set);
g_signal_connect (form->priv->set, "public_data_changed",
G_CALLBACK (paramlist_public_data_changed_cb), form);
- g_signal_connect (form->priv->set, "holder_plugin_changed",
- G_CALLBACK (paramlist_param_plugin_changed_cb), form);
- g_signal_connect (form->priv->set, "holder_attr_changed",
+ g_signal_connect (form->priv->set, "holder-attr-changed",
G_CALLBACK (paramlist_param_attr_changed_cb), form);
#ifdef HAVE_LIBGLADE
@@ -640,7 +637,8 @@
GType type;
const GValue *val, *default_val, *value;
gboolean nnul;
- gchar *plugin = NULL;
+ const gchar *plugin = NULL;
+ const GValue *plugin_val;
g_assert (g_slist_length (group->nodes) == 1);
@@ -658,10 +656,15 @@
value = default_val;
/* create entry */
- g_object_get (G_OBJECT (param), "plugin", &plugin, NULL);
+ plugin_val = gda_holder_get_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN);
+ if (plugin_val) {
+ if (G_VALUE_TYPE (plugin_val) == G_TYPE_STRING)
+ plugin = g_value_get_string (plugin_val);
+ else
+ g_warning (_("The '%s' attribute should be a G_TYPE_STRING value"),
+ GNOME_DB_ATTRIBUTE_PLUGIN);
+ }
entry = GTK_WIDGET (gnome_db_util_new_data_entry (type, plugin));
- g_free(plugin);
-
/* set current value */
gnome_db_data_entry_set_value (GNOME_DB_DATA_ENTRY (entry), val);
Modified: trunk/libgnomedb/gnome-db-enums.h
==============================================================================
--- trunk/libgnomedb/gnome-db-enums.h (original)
+++ trunk/libgnomedb/gnome-db-enums.h Mon Oct 6 18:29:20 2008
@@ -56,6 +56,9 @@
GNOME_DB_ACTION_MOVE_LAST_CHUNCK
} GnomeDbAction;
+/* possible predefined attribute names for gda_holder_get_attribute() or gda_column_get_attribute() */
+#define GNOME_DB_ATTRIBUTE_PLUGIN "__gnomedb_attr_plugin" /* G_TYPE_STRING expected */
+
#endif
Modified: trunk/libgnomedb/gnome-db-raw-grid.c
==============================================================================
--- trunk/libgnomedb/gnome-db-raw-grid.c (original)
+++ trunk/libgnomedb/gnome-db-raw-grid.c Mon Oct 6 18:29:20 2008
@@ -51,7 +51,8 @@
static void proxy_row_updated_cb (GdaDataProxy *proxy, gint proxy_row, GnomeDbRawGrid *grid);
static void proxy_reset_cb (GdaDataProxy *proxy, GnomeDbRawGrid *grid);
static void paramlist_public_data_changed_cb (GdaSet *paramlist, GnomeDbRawGrid *grid);
-static void paramlist_param_plugin_changed_cb (GdaSet *paramlist, GdaHolder *param, GnomeDbRawGrid *grid);
+static void paramlist_param_attr_changed_cb (GdaSet *paramlist, GdaHolder *param,
+ const gchar *att_name, const GValue *att_value, GnomeDbRawGrid *grid);
static GError *iter_validate_set_cb (GdaDataModelIter *iter, GnomeDbRawGrid *grid);
static void iter_row_changed_cb (GdaDataModelIter *iter, gint row, GnomeDbRawGrid *grid);
@@ -393,8 +394,8 @@
g_signal_connect (grid->priv->iter, "public_data_changed",
G_CALLBACK (paramlist_public_data_changed_cb), grid);
- g_signal_connect (grid->priv->iter, "holder_plugin_changed",
- G_CALLBACK (paramlist_param_plugin_changed_cb), grid);
+ g_signal_connect (grid->priv->iter, "holder-attr-changed",
+ G_CALLBACK (paramlist_param_attr_changed_cb), grid);
g_signal_connect (grid->priv->iter, "row_changed",
G_CALLBACK (iter_row_changed_cb), grid);
@@ -626,7 +627,8 @@
else {
/* single direct parameter */
GType g_type;
- gchar *plugin = NULL;
+ const gchar *plugin = NULL;
+ const GValue *plugin_val;
gchar *title;
param = GDA_HOLDER (GDA_SET_NODE (group->nodes->data)->holder);
@@ -640,7 +642,14 @@
if (!title)
title = g_strdup (_("No title"));
- g_object_get (G_OBJECT (param), "plugin", &plugin, NULL);
+ plugin_val = gda_holder_get_attribute (param, GNOME_DB_ATTRIBUTE_PLUGIN);
+ if (plugin_val) {
+ if (G_VALUE_TYPE (plugin_val) == G_TYPE_STRING)
+ plugin = g_value_get_string (plugin_val);
+ else
+ g_warning (_("The '%s' attribute should be a G_TYPE_STRING value"),
+ GNOME_DB_ATTRIBUTE_PLUGIN);
+ }
renderer = gnome_db_util_new_cell_renderer (g_type, plugin);
column_data->data_cell = renderer;
if (! column_data->data_locked)
@@ -2143,10 +2152,13 @@
}
static void
-paramlist_param_plugin_changed_cb (GdaSet *paramlist, GdaHolder *param, GnomeDbRawGrid *grid)
+paramlist_param_attr_changed_cb (GdaSet *paramlist, GdaHolder *param,
+ const gchar *att_name, const GValue *att_value, GnomeDbRawGrid *grid)
{
- /* TODO: be more specific and change only the cell renderer corresponding to @param */
- paramlist_public_data_changed_cb (paramlist, grid);
+ if (!strcmp (att_name, GNOME_DB_ATTRIBUTE_PLUGIN)) {
+ /* TODO: be more specific and change only the cell renderer corresponding to @param */
+ paramlist_public_data_changed_cb (paramlist, grid);
+ }
}
static GError *
@@ -2295,7 +2307,7 @@
g_signal_handlers_disconnect_by_func (grid->priv->iter,
G_CALLBACK (paramlist_public_data_changed_cb), grid);
g_signal_handlers_disconnect_by_func (grid->priv->iter,
- G_CALLBACK (paramlist_param_plugin_changed_cb), grid);
+ G_CALLBACK (paramlist_param_attr_changed_cb), grid);
g_signal_handlers_disconnect_by_func (grid->priv->iter,
G_CALLBACK (iter_row_changed_cb), grid);
g_signal_handlers_disconnect_by_func (grid->priv->iter,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]