libgnomedb r1771 - in trunk: . extra/demos libgnomedb libgnomedb-graph libgnomedb/data-entries
- From: vivien svn gnome org
- To: svn-commits-list gnome org
- Subject: libgnomedb r1771 - in trunk: . extra/demos libgnomedb libgnomedb-graph libgnomedb/data-entries
- Date: Mon, 23 Mar 2009 18:23:37 +0000 (UTC)
Author: vivien
Date: Mon Mar 23 18:23:36 2009
New Revision: 1771
URL: http://svn.gnome.org/viewvc/libgnomedb?rev=1771&view=rev
Log:
2009-03-23 Vivien Malerba <malerba gnome-db org>
* libgnomedb-graph/gnome-db-canvas.c: applied patch for bug #576045
thanks to GÃtz Waschk
* other files: make Libgnomedb compile again with latest Libgda, for bug
#575469
Added:
trunk/libgnomedb/gnome-db-set.c
trunk/libgnomedb/gnome-db-set.h
Modified:
trunk/ChangeLog
trunk/extra/demos/demo_db.db
trunk/libgnomedb-graph/gnome-db-canvas.c
trunk/libgnomedb/Makefile.am
trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.c
trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.h
trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.c
trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.h
trunk/libgnomedb/data-entries/gnome-db-entry-combo.c
trunk/libgnomedb/data-entries/gnome-db-entry-combo.h
trunk/libgnomedb/gnome-db-basic-form.c
trunk/libgnomedb/gnome-db-data-widget.h
trunk/libgnomedb/gnome-db-raw-grid.c
trunk/libgnomedb/utility.c
trunk/libgnomedb/utility.h
Modified: trunk/extra/demos/demo_db.db
==============================================================================
Binary files trunk/extra/demos/demo_db.db (original) and trunk/extra/demos/demo_db.db Mon Mar 23 18:23:36 2009 differ
Modified: trunk/libgnomedb-graph/gnome-db-canvas.c
==============================================================================
--- trunk/libgnomedb-graph/gnome-db-canvas.c (original)
+++ trunk/libgnomedb-graph/gnome-db-canvas.c Mon Mar 23 18:23:36 2009
@@ -32,6 +32,9 @@
#ifdef HAVE_GRAPHVIZ
#include <stddef.h>
#include <gvc.h>
+#ifndef ND_coord_i
+ #define ND_coord_i ND_coord
+#endif
static GVC_t* gvc = NULL;
#endif
#include <cairo.h>
Modified: trunk/libgnomedb/Makefile.am
==============================================================================
--- trunk/libgnomedb/Makefile.am (original)
+++ trunk/libgnomedb/Makefile.am Mon Mar 23 18:23:36 2009
@@ -51,6 +51,7 @@
gnome-db-raw-form.h \
gnome-db-raw-grid.h \
gnome-db-server-operation.h \
+ gnome-db-set.h \
gnome-db-stock.h \
gnome-db-tools.h \
gnome-db-transaction-status.h \
@@ -92,6 +93,7 @@
gnome-db-raw-form.c \
gnome-db-raw-grid.c \
gnome-db-server-operation.c \
+ gnome-db-set.c \
gnome-db-stock.c \
gnome-db-tools.c \
gnome-db-transaction-status.c \
Modified: trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.c
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.c (original)
+++ trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.c Mon Mar 23 18:23:36 2009
@@ -87,8 +87,8 @@
struct _GnomeDbDataCellRendererComboPrivate
{
- GdaSet *paramlist;
- GdaSetSource *source;
+ GnomeDbSet *paramlist;
+ GnomeDbSetSource *source;
guint focus_out_id;
guint attributes;
gboolean to_be_deleted;
@@ -299,7 +299,7 @@
/* if (gnome_db_data_model_get_status (datacell->priv->data_model) & */
/* GNOME_DB_DATA_MODEL_NEEDS_INIT_REFRESH) */
/* gnome_db_data_model_refresh (datacell->priv->data_model, NULL); */
- row = gda_data_model_get_row_from_values (datacell->priv->source->data_model,
+ row = gda_data_model_get_row_from_values (datacell->priv->source->source->data_model,
values,
datacell->priv->source->ref_cols_index);
if (row >= 0) {
@@ -310,7 +310,7 @@
for (i = 0; i < datacell->priv->source->shown_n_cols; i++) {
const GValue *value;
- value = gda_data_model_get_value_at (datacell->priv->source->data_model,
+ value = gda_data_model_get_value_at (datacell->priv->source->source->data_model,
datacell->priv->source->shown_cols_index [i],
row, NULL);
dsplay_values = g_list_append (dsplay_values, (GValue *) value);
@@ -369,14 +369,14 @@
if (datacell->priv->paramlist)
g_object_unref (datacell->priv->paramlist);
- datacell->priv->paramlist = GDA_SET(g_value_get_object(value));
+ datacell->priv->paramlist = GNOME_DB_SET (g_value_get_object(value));
if(datacell->priv->paramlist)
g_object_ref(datacell->priv->paramlist);
g_object_ref (G_OBJECT (datacell->priv->paramlist));
break;
case PROP_PARAMLISTSOURCE:
- datacell->priv->source = GDA_SET_SOURCE(g_value_get_pointer(value));
+ datacell->priv->source = GNOME_DB_SET_SOURCE (g_value_get_pointer(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -426,7 +426,7 @@
/**
* gnome_db_data_cell_renderer_combo_new
* @paramlist: a #GdaSet object
- * @source: a #GdaSetSource structure listed in @paramlist->sources_list
+ * @source: a #GnomeDbSetSource structure listed in @paramlist->sources_list
*
* Creates a new #GnomeDbDataCellRendererCombo which will fill the parameters listed in
* @source->nodes with values available from @source->data_model.
@@ -434,7 +434,7 @@
* Return value: the new cell renderer
**/
GtkCellRenderer *
-gnome_db_data_cell_renderer_combo_new (GdaSet *paramlist, GdaSetSource *source)
+gnome_db_data_cell_renderer_combo_new (GnomeDbSet *paramlist, GnomeDbSetSource *source)
{
GObject *obj;
@@ -557,7 +557,7 @@
if (cell_text->editable == FALSE)
return NULL;
- combo = gnome_db_combo_new_with_model (GDA_DATA_MODEL (datacell->priv->source->data_model),
+ combo = gnome_db_combo_new_with_model (GDA_DATA_MODEL (datacell->priv->source->source->data_model),
datacell->priv->source->shown_n_cols,
datacell->priv->source->shown_cols_index);
Modified: trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.h
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.h (original)
+++ trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-combo.h Mon Mar 23 18:23:36 2009
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <pango/pango.h>
#include <libgnomedb/gnome-db-decl.h>
+#include <libgnomedb/gnome-db-set.h>
#ifdef __cplusplus
extern "C" {
@@ -59,7 +60,7 @@
};
GType gnome_db_data_cell_renderer_combo_get_type (void) G_GNUC_CONST;
-GtkCellRenderer *gnome_db_data_cell_renderer_combo_new (GdaSet *paramlist, GdaSetSource *source);
+GtkCellRenderer *gnome_db_data_cell_renderer_combo_new (GnomeDbSet *paramlist, GnomeDbSetSource *source);
#ifdef __cplusplus
}
Modified: trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.c
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.c (original)
+++ trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.c Mon Mar 23 18:23:36 2009
@@ -74,16 +74,16 @@
PROP_VALUE_ATTRIBUTES,
PROP_EDITABLE,
PROP_TO_BE_DELETED,
- PROP_STORE,
- PROP_ITER,
- PROP_GROUP
+ PROP_STORE,
+ PROP_ITER,
+ PROP_GROUP
};
struct _GnomeDbDataCellRendererInfoPriv {
/* attributes valid for the while life of the object */
GnomeDbDataStore *store;
GdaDataModelIter *iter;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
/* attribute valid only for drawing */
gboolean active;
@@ -287,7 +287,7 @@
g_object_ref (G_OBJECT (cellinfo->priv->iter));
break;
case PROP_GROUP:
- cellinfo->priv->group = GDA_SET_GROUP(g_value_get_pointer(value));
+ cellinfo->priv->group = GNOME_DB_SET_GROUP (g_value_get_pointer(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -313,16 +313,16 @@
**/
GtkCellRenderer *
gnome_db_data_cell_renderer_info_new (GnomeDbDataStore *store,
- GdaDataModelIter *iter, GdaSetGroup *group)
+ GdaDataModelIter *iter, GnomeDbSetGroup *group)
{
GObject *obj;
g_return_val_if_fail (GNOME_DB_IS_DATA_STORE (store), NULL);
g_return_val_if_fail (GDA_IS_SET (iter), NULL);
- g_return_val_if_fail (group && g_slist_find (((GdaSet *) iter)->groups_list, group), NULL);
+ g_return_val_if_fail (group, NULL);
obj = g_object_new (GNOME_DB_TYPE_DATA_CELL_RENDERER_INFO,
- "store", store, "iter", iter, "group", group, NULL);
+ "store", store, "iter", iter, "group", group, NULL);
return (GtkCellRenderer *) obj;
}
@@ -469,7 +469,7 @@
gtk_tree_path_free (treepath);
/* we want the attributes */
- if (! cellinfo->priv->group->nodes_source) {
+ if (! cellinfo->priv->group->group->nodes_source) {
gint col;
GdaDataModel *proxied_model;
GdaDataProxy *proxy;
@@ -477,9 +477,9 @@
proxy = gnome_db_data_store_get_proxy (cellinfo->priv->store);
proxied_model = gda_data_proxy_get_proxied_model (proxy);
- g_assert (g_slist_length (cellinfo->priv->group->nodes) == 1);
+ g_assert (g_slist_length (cellinfo->priv->group->group->nodes) == 1);
col = g_slist_index (GDA_SET (cellinfo->priv->iter)->holders,
- GDA_SET_NODE (cellinfo->priv->group->nodes->data)->holder);
+ GDA_SET_NODE (cellinfo->priv->group->group->nodes->data)->holder);
gtk_tree_model_get (GTK_TREE_MODEL (cellinfo->priv->store), &iter,
gda_data_model_get_n_columns (proxied_model) + col,
@@ -487,9 +487,9 @@
}
else
attributes = gnome_db_utility_proxy_compute_attributes_for_group (cellinfo->priv->group,
- cellinfo->priv->store,
- cellinfo->priv->iter,
- &iter, NULL);
+ cellinfo->priv->store,
+ cellinfo->priv->iter,
+ &iter, NULL);
/* build the popup menu */
menu = gnome_db_utility_entry_build_actions_menu (G_OBJECT (cellinfo), attributes,
Modified: trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.h
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.h (original)
+++ trunk/libgnomedb/data-entries/gnome-db-data-cell-renderer-info.h Mon Mar 23 18:23:36 2009
@@ -26,6 +26,7 @@
#include <libgnomedb/gnome-db-decl.h>
#include <libgda/gda-enums.h>
#include <libgda/gda-decl.h>
+#include <libgnomedb/gnome-db-set.h>
G_BEGIN_DECLS
@@ -60,7 +61,7 @@
GType gnome_db_data_cell_renderer_info_get_type (void) G_GNUC_CONST;
GtkCellRenderer *gnome_db_data_cell_renderer_info_new (GnomeDbDataStore *store,
GdaDataModelIter *iter,
- GdaSetGroup *group);
+ GnomeDbSetGroup *group);
G_END_DECLS
#endif /* __GNOME_DB_DATA_CELL_RENDERER_INFO_H__ */
Modified: trunk/libgnomedb/data-entries/gnome-db-entry-combo.c
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-entry-combo.c (original)
+++ trunk/libgnomedb/data-entries/gnome-db-entry-combo.c Mon Mar 23 18:23:36 2009
@@ -55,6 +55,9 @@
static gboolean gnome_db_entry_combo_expand_in_layout (GnomeDbDataEntry *de);
static void gnome_db_entry_combo_grab_focus (GnomeDbDataEntry *de);
+static void _gnome_db_entry_combo_construct(GnomeDbEntryCombo* combo,
+ GnomeDbSet *paramlist, GnomeDbSetSource *source);
+
/* properties */
enum
{
@@ -78,8 +81,8 @@
GtkWidget *combo_entry;
GSList *combo_nodes; /* list of ComboNode structures */
- GdaSet *paramlist;
- GdaSetSource *source;
+ GnomeDbSet *paramlist; // useless?
+ GnomeDbSetSource *source;
gboolean data_valid;
gboolean null_forced;
@@ -213,8 +216,8 @@
/**
* gnome_db_entry_combo_new
- * @paramlist: a #GdaSet object
- * @source: a #GdaSetSource structure, part of @paramlist
+ * @paramlist: a #GnomeDbSet object
+ * @source: a #GnomeDbSetSource structure, part of @paramlist
*
* Creates a new #GnomeDbEntryCombo widget. The widget is a combo box which displays a
* selectable list of items (the items come from the 'source->data_model' data model)
@@ -225,7 +228,7 @@
* Returns: the new widget
*/
GtkWidget *
-gnome_db_entry_combo_new (GdaSet *paramlist, GdaSetSource *source)
+gnome_db_entry_combo_new (GnomeDbSet *paramlist, GnomeDbSetSource *source)
{
GObject *obj;
@@ -246,7 +249,7 @@
* TODO: This is just a work-around for language bindings. Ideally we would use construction
* properties instead.
*/
-void _gnome_db_entry_combo_construct (GnomeDbEntryCombo* combo, GdaSet *paramlist, GdaSetSource *source)
+void _gnome_db_entry_combo_construct (GnomeDbEntryCombo* combo, GnomeDbSet *paramlist, GnomeDbSetSource *source)
{
GSList *list;
GSList *values;
@@ -265,7 +268,7 @@
* and use the values provided by the parameters to display the correct row */
null_possible = TRUE;
values = NULL;
- list = source->nodes;
+ list = source->source->nodes;
while (list) {
ComboNode *cnode = g_new0 (ComboNode, 1);
@@ -282,7 +285,7 @@
combo->priv->null_possible = null_possible;
/* create the combo box itself */
- entry = gnome_db_combo_new_with_model (GDA_DATA_MODEL (source->data_model),
+ entry = gnome_db_combo_new_with_model (GDA_DATA_MODEL (source->source->data_model),
combo->priv->source->shown_n_cols,
combo->priv->source->shown_cols_index);
g_signal_connect (G_OBJECT (entry), "changed",
@@ -616,7 +619,7 @@
GdaColumn *attrs;
GType type=GDA_TYPE_NULL;
- attrs = gda_data_model_describe_column (combo->priv->source->data_model,
+ attrs = gda_data_model_describe_column (combo->priv->source->source->data_model,
COMBO_NODE (nodes->data)->node->source_column);
arg_value = (GValue*) (argptr->data);
Modified: trunk/libgnomedb/data-entries/gnome-db-entry-combo.h
==============================================================================
--- trunk/libgnomedb/data-entries/gnome-db-entry-combo.h (original)
+++ trunk/libgnomedb/data-entries/gnome-db-entry-combo.h Mon Mar 23 18:23:36 2009
@@ -24,6 +24,7 @@
#include <gtk/gtk.h>
#include "gnome-db-entry-shell.h"
#include <libgnomedb/gnome-db-data-entry.h>
+#include <libgnomedb/gnome-db-set.h>
G_BEGIN_DECLS
@@ -53,7 +54,7 @@
GType gnome_db_entry_combo_get_type (void) G_GNUC_CONST;
-GtkWidget *gnome_db_entry_combo_new (GdaSet *paramlist, GdaSetSource *source);
+GtkWidget *gnome_db_entry_combo_new (GnomeDbSet *paramlist, GnomeDbSetSource *source);
gboolean gnome_db_entry_combo_set_values (GnomeDbEntryCombo *combo, GSList *values);
GSList *gnome_db_entry_combo_get_values (GnomeDbEntryCombo *combo);
@@ -62,9 +63,6 @@
GSList *gnome_db_entry_combo_get_values_orig (GnomeDbEntryCombo *combo);
void gnome_db_entry_combo_set_values_default(GnomeDbEntryCombo *combo, GSList *values);
-void _gnome_db_entry_combo_construct(GnomeDbEntryCombo* combo,
- GdaSet *paramlist, GdaSetSource *source);
-
G_END_DECLS
#endif
Modified: trunk/libgnomedb/gnome-db-basic-form.c
==============================================================================
--- trunk/libgnomedb/gnome-db-basic-form.c (original)
+++ trunk/libgnomedb/gnome-db-basic-form.c Mon Mar 23 18:23:36 2009
@@ -28,6 +28,8 @@
#include "utility.h"
#include "gnome-db-data-entry.h"
#include <libgnomedb/data-entries/gnome-db-entry-combo.h>
+#include <libgnomedb/gnome-db-data-widget.h>
+#include <libgnomedb/gnome-db-raw-form.h>
static void gnome_db_basic_form_class_init (GnomeDbBasicFormClass * class);
static void gnome_db_basic_form_init (GnomeDbBasicForm *wid);
@@ -48,7 +50,7 @@
static void gnome_db_basic_form_clean (GnomeDbBasicForm *form);
static void get_rid_of_set (GdaSet *paramlist, GnomeDbBasicForm *form);
-static void paramlist_public_data_changed_cb (GdaSet *paramlist, GnomeDbBasicForm *form);
+static void paramlist_public_data_changed_cb (GnomeDbSet *paramlist, GnomeDbBasicForm *form);
static void paramlist_param_attr_changed_cb (GdaSet *paramlist, GdaHolder *param,
const gchar *att_name, const GValue *att_value, GnomeDbBasicForm *form);
@@ -79,6 +81,7 @@
struct _GnomeDbBasicFormPriv
{
GdaSet *set;
+ GnomeDbSet *set_info;
gulong *signal_ids; /* array of signal ids */
GSList *entries;/* list of GnomeDbDataEntry widgets */
@@ -307,7 +310,7 @@
form->priv->signal_ids = NULL;
/* unref the paramlist */
- g_signal_handlers_disconnect_by_func (paramlist,
+ g_signal_handlers_disconnect_by_func (form->priv->set_info,
G_CALLBACK (paramlist_public_data_changed_cb), form);
g_signal_handlers_disconnect_by_func (paramlist,
G_CALLBACK (paramlist_param_attr_changed_cb), form);
@@ -315,6 +318,11 @@
g_object_unref (form->priv->set);
form->priv->set = NULL;
+ if (form->priv->set_info) {
+ g_object_unref (form->priv->set_info);
+ form->priv->set_info = NULL;
+ }
+
/* render all the entries non sensitive */
list = form->priv->entries;
while (list) {
@@ -324,7 +332,7 @@
}
static void
-paramlist_public_data_changed_cb (GdaSet *paramlist, GnomeDbBasicForm *form)
+paramlist_public_data_changed_cb (GnomeDbSet *paramlist, GnomeDbBasicForm *form)
{
/* here we want to re-define all the data entry widgets */
gnome_db_basic_form_clean (form);
@@ -375,14 +383,14 @@
hidden_params = g_slist_prepend (hidden_params, param);
else {
/* multiple parameters, take the 1st param */
- GdaSetGroup *group;
- group = g_object_get_data (G_OBJECT (list->data), "group");
- hidden_params = g_slist_prepend (hidden_params, GDA_SET_NODE (group->nodes->data)->holder);
+ GnomeDbSetGroup *group;
+ group = g_object_get_data (G_OBJECT (list->data), "__gnome_db_group");
+ hidden_params = g_slist_prepend (hidden_params, GDA_SET_NODE (group->group->nodes->data)->holder);
}
}
/* re-create entries */
- paramlist_public_data_changed_cb (paramlist, form);
+ paramlist_public_data_changed_cb (form->priv->set_info, form);
/* hide entries which were hidden */
for (list = hidden_params; list; list = list->next)
@@ -427,7 +435,6 @@
g_return_if_fail (form && GNOME_DB_IS_BASIC_FORM (form));
g_return_if_fail (data && GTK_IS_TABLE(data));
- gchar *name = NULL;
gchar *title = NULL;
gchar *script = NULL;
gint sequence = 0;
@@ -561,11 +568,13 @@
/* text = g_value_get_string (value); */
/* else */
/* text = id; */
- GdaDataModel *model = gnome_db_data_widget_get_gda_model (form);
-
- const gchar *text;
- text = gda_utility_data_model_find_column_description (model, name);
- if (text == NULL)
+ const gchar *text = NULL;
+ if (GNOME_DB_IS_RAW_FORM (form)) {
+ GdaDataModel *model = gnome_db_data_widget_get_gda_model (GNOME_DB_DATA_WIDGET (form));
+ if (model && GDA_IS_DATA_SELECT (model))
+ text = gda_utility_data_model_find_column_description (GDA_DATA_SELECT (model), name);
+ }
+ if (! text)
text = gda_holder_get_id (holder);
GtkLabel *label = GTK_LABEL(gtk_label_new (text));
@@ -684,9 +693,9 @@
xmlFree (str);
}
- GtkVBox *vbox;
+ GtkWidget *vbox;
vbox = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (GTK_WIDGET(vbox));
+ gtk_widget_show (vbox);
gint n_columns, n_rows;
g_object_get (G_OBJECT(data), "n-columns", &n_columns, NULL);
@@ -696,7 +705,7 @@
col = 2 * ((sequence - 1) / n_rows);
row = (sequence - 1) % n_rows;
- gtk_table_attach (GTK_TABLE(data), GTK_WIDGET(vbox),
+ gtk_table_attach (GTK_TABLE (data), vbox,
col, col + 2, row, row + 1,
(GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0);
@@ -754,7 +763,6 @@
gchar *name = NULL;
gint sequence = 0;
- gint columns_count = 1;
gchar *title = NULL;
xmlChar *str;
@@ -790,9 +798,9 @@
/* gtk_widget_show (GTK_WIDGET(label)); */
/* gtk_label_set_use_markup (label, TRUE); */
- GtkNotebook *notebook;
+ GtkWidget *notebook;
notebook = gtk_notebook_new ();
- gtk_widget_show (GTK_WIDGET(notebook));
+ gtk_widget_show (notebook);
gint n_columns, n_rows;
g_object_get (G_OBJECT(data), "n-columns", &n_columns, NULL);
@@ -802,7 +810,7 @@
col = 2 * ((sequence - 1) / n_rows);
row = (sequence - 1) % n_rows;
- gtk_table_attach (GTK_TABLE(data), GTK_WIDGET(notebook),
+ gtk_table_attach (GTK_TABLE(data), notebook,
col, col + 2, row, row + 1,
(GtkAttachOptions) (GTK_FILL|GTK_EXPAND),
(GtkAttachOptions) (GTK_FILL|GTK_EXPAND), 0, 0);
@@ -1297,7 +1305,9 @@
g_return_if_fail (GDA_IS_SET (form->priv->set));
g_object_ref (form->priv->set);
- g_signal_connect (form->priv->set, "public_data_changed",
+ form->priv->set_info = gnome_db_set_new (GDA_SET (form->priv->set));
+
+ g_signal_connect (form->priv->set_info, "public_data_changed",
G_CALLBACK (paramlist_public_data_changed_cb), form);
g_signal_connect (form->priv->set, "holder-attr-changed",
G_CALLBACK (paramlist_param_attr_changed_cb), form);
@@ -1363,13 +1373,10 @@
gint i = 0;
if (form->priv->set) {
- list = form->priv->set->holders;
- while (list) {
+ for (i = 0, list = form->priv->set->holders;
+ list;
+ i++, list = list->next)
g_signal_handler_disconnect (G_OBJECT (list->data), form->priv->signal_ids[i]);
-
- list = g_slist_next (list);
- i++;
- }
g_free (form->priv->signal_ids);
form->priv->signal_ids = NULL;
}
@@ -1448,7 +1455,7 @@
gboolean form_expand = FALSE;
/* parameters list management */
- if (!form->priv->set || !form->priv->set->groups_list)
+ if (!form->priv->set || !form->priv->set_info->groups_list)
/* nothing to do */
return;
@@ -1457,13 +1464,12 @@
i = 0;
/* creating all the data entries, and putting them into the form->priv->entries list */
- list = form->priv->set->groups_list;
- while (list) {
- GdaSetGroup *group;
+ for (list = form->priv->set_info->groups_list; list; list = list->next) {
+ GnomeDbSetGroup *group;
GtkWidget *entry = NULL;
- group = GDA_SET_GROUP (list->data);
- if (! group->nodes_source) {
+ group = GNOME_DB_SET_GROUP (list->data);
+ if (! group->group->nodes_source) {
/* there is only one non-constrained parameter */
GdaHolder *param;
GType type;
@@ -1472,9 +1478,9 @@
const gchar *plugin = NULL;
const GValue *plugin_val;
- g_assert (g_slist_length (group->nodes) == 1);
+ g_assert (g_slist_length (group->group->nodes) == 1);
- param = GDA_HOLDER (GDA_SET_NODE (group->nodes->data)->holder);
+ param = GDA_HOLDER (GDA_SET_NODE (group->group->nodes->data)->holder);
val = gda_holder_get_value (param);
default_val = gda_holder_get_default_value (param);
@@ -1533,14 +1539,14 @@
GSList *plist;
gboolean nnul = TRUE;
- entry = gnome_db_entry_combo_new (form->priv->set, group->nodes_source);
- g_object_set_data (G_OBJECT (entry), "group", group);
+ entry = gnome_db_entry_combo_new (form->priv->set_info, group->source);
+ g_object_set_data (G_OBJECT (entry), "__gnome_db_group", group);
g_object_set_data (G_OBJECT (entry), "form", form);
form->priv->entries = g_slist_append (form->priv->entries, entry);
g_signal_connect (entry, "destroy", G_CALLBACK (entry_destroyed_cb), form);
/* connect to the parameter's changes */
- for (plist = group->nodes; plist; plist = plist->next) {
+ for (plist = group->group->nodes; plist; plist = plist->next) {
GdaHolder *param;
param = GDA_SET_NODE (plist->data)->holder;
@@ -1561,7 +1567,6 @@
G_CALLBACK (entry_contents_modified), form);
g_signal_connect (G_OBJECT (entry), "contents_activated",
G_CALLBACK (entry_contents_activated), form);
- list = g_slist_next (list);
}
@@ -1728,10 +1733,10 @@
GtkWidget *evbox;
gboolean nullok = TRUE;
GSList *params;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
- group = g_object_get_data (G_OBJECT (list->data), "group");
- for (params = group->nodes; params; params = params->next) {
+ group = g_object_get_data (G_OBJECT (list->data), "__gnome_db_group");
+ for (params = group->group->nodes; params; params = params->next) {
if (nullok && gda_holder_get_not_null (GDA_SET_NODE (params->data)->holder))
nullok = FALSE;
if (!title)
@@ -1740,7 +1745,7 @@
}
if (!title) {
- str = g_object_get_data (G_OBJECT (group->nodes_source->data_model),
+ str = g_object_get_data (G_OBJECT (group->group->nodes_source->data_model),
"name");
if (str)
title = g_strdup (str);
@@ -1763,7 +1768,7 @@
gtk_widget_show (label);
entry_label = evbox;
- title = g_object_get_data (G_OBJECT (group->nodes_source->data_model), "descr");
+ title = g_object_get_data (G_OBJECT (group->group->nodes_source->data_model), "descr");
if (title && *title)
gtk_tooltips_set_tip (form->priv->tooltips, evbox, title, NULL);
}
@@ -1894,15 +1899,14 @@
else { /* multiple parameters */
GSList *params;
GSList *values, *list;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
- group = g_object_get_data (G_OBJECT (entry), "group");
- params = group->nodes;
+ group = g_object_get_data (G_OBJECT (entry), "__gnome_db_group");
+ params = group->group->nodes;
values = gnome_db_entry_combo_get_values (GNOME_DB_ENTRY_COMBO (entry));
g_assert (g_slist_length (params) == g_slist_length (values));
- list = values;
- while (list) {
+ for (list = values; list; list = list->next, params = params->next) {
/* REM: if there is more than one value in 'params', then a
* signal is emitted for each param that is changed,
* and there is no way for the listener of that signal to know if it
@@ -1930,9 +1934,6 @@
else
TO_IMPLEMENT;
form->priv->forward_param_updates = TRUE;
-
- list = g_slist_next (list);
- params = g_slist_next (params);
}
g_slist_free (values);
@@ -1977,7 +1978,7 @@
parameter_changed_cb (GdaHolder *param, GnomeDbDataEntry *entry)
{
GnomeDbBasicForm *form = g_object_get_data (G_OBJECT (entry), "form");
- GdaSetGroup *group = g_object_get_data (G_OBJECT (entry), "group");
+ GnomeDbSetGroup *group = g_object_get_data (G_OBJECT (entry), "__gnome_db_group");
const GValue *value = gda_holder_get_value (param);
if (form->priv->forward_param_updates) {
@@ -2000,7 +2001,7 @@
}
if (group) {
GSList *values = NULL;
- GSList *list = group->nodes;
+ GSList *list = group->group->nodes;
gboolean allnull = TRUE;
while (list) {
@@ -2078,14 +2079,14 @@
g_return_if_fail (form->priv);
for (list = form->priv->entries; list; list = list->next) {
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
- group = g_object_get_data (G_OBJECT (list->data), "group");
+ group = g_object_get_data (G_OBJECT (list->data), "__gnome_db_group");
if (group) {
/* Combo entry */
GSList *values = NULL;
- GSList *params = group->nodes;
+ GSList *params = group->group->nodes;
gboolean allnull = TRUE;
while (params) {
@@ -2451,10 +2452,10 @@
else {
/* multiple parameters */
GSList *params;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
- group = g_object_get_data (G_OBJECT (entries->data), "group");
- for (params = group->nodes; params; params = params->next) {
+ group = g_object_get_data (G_OBJECT (entries->data), "__gnome_db_group");
+ for (params = group->group->nodes; params; params = params->next) {
if (GDA_SET_NODE (params->data)->holder == (gpointer) param) {
entry = GTK_WIDGET (entries->data);
break;
Modified: trunk/libgnomedb/gnome-db-data-widget.h
==============================================================================
--- trunk/libgnomedb/gnome-db-data-widget.h (original)
+++ trunk/libgnomedb/gnome-db-data-widget.h Mon Mar 23 18:23:36 2009
@@ -85,6 +85,8 @@
gboolean gnome_db_data_widget_set_write_mode (GnomeDbDataWidget *iface, GnomeDbDataWidgetWriteMode mode);
GnomeDbDataWidgetWriteMode gnome_db_data_widget_get_write_mode (GnomeDbDataWidget *iface);
+void gnome_db_data_widget_set_data_layout (GnomeDbDataWidget *iface, const gpointer data);
+
G_END_DECLS
#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 Mar 23 18:23:36 2009
@@ -1,6 +1,6 @@
/* gnome-db-raw-grid.c
*
- * Copyright (C) 2002 - 2008 Vivien Malerba
+ * Copyright (C) 2002 - 2009 Vivien Malerba
*
* This Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
@@ -50,7 +50,7 @@
static void proxy_sample_changed_cb (GdaDataProxy *proxy, gint sample_start, gint sample_end, GnomeDbRawGrid *grid);
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_public_data_changed_cb (GnomeDbSet *paramlist, 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);
@@ -72,7 +72,7 @@
static void gnome_db_raw_grid_set_data_layout (GnomeDbDataWidget *iface, gpointer data);
typedef struct {
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
GtkCellRenderer *data_cell;
GtkCellRenderer *info_cell;
gboolean info_shown;
@@ -82,12 +82,13 @@
#define COLUMN_DATA(x) ((ColumnData *)(x))
-static ColumnData *get_column_data (GnomeDbRawGrid *grid, GdaSetGroup *group);
+static ColumnData *get_column_data (GnomeDbRawGrid *grid, GnomeDbSetGroup *group);
struct _GnomeDbRawGridPriv
{
GdaDataModel *data_model; /* data model provided by set_model() */
GdaDataModelIter *iter; /* iterator for @store, used for its structure */
+ GnomeDbSet *iter_info;
GnomeDbDataStore *store; /* GtkTreeModel interface, using @proxy */
GdaDataProxy *proxy; /* proxy data model, proxying @data_model */
@@ -430,17 +431,18 @@
/* } */
//GdaHolder *holder = gda_set_get_holder (grid->priv->set, name);
- GdaHolder *holder = gda_set_get_holder (GDA_SET(grid->priv->iter), name);
+ GdaHolder *holder = gda_set_get_holder (GDA_SET (grid->priv->iter), name);
g_return_if_fail (holder != NULL);
- gint index = g_slist_index (GDA_SET(grid->priv->iter)->holders, holder);
+ gint index = g_slist_index (GDA_SET (grid->priv->iter)->holders, holder);
grid->priv->reordered_indexes = g_slist_insert (grid->priv->reordered_indexes,
GINT_TO_POINTER(index),
sequence - 1);
- GdaSetGroup *group = gda_set_get_group (GDA_SET(grid->priv->iter), holder);
- g_return_if_fail (group);
+ GnomeDbSetGroup *group = _gnome_db_set_get_group (grid->priv->iter_info, holder);
+ if (!group)
+ return;
ColumnData *column_data = get_column_data (grid, group);
g_return_if_fail (column_data);
@@ -448,16 +450,17 @@
column_data->tooltip_text = g_strdup ((const gchar *) data);
//g_print ("*** %s\n", column_data->tooltip_text);
- gint position = g_slist_index (GDA_SET(grid->priv->iter)->holders, holder);
- GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW(grid), position);
+ gint position = g_slist_index (GDA_SET (grid->priv->iter)->holders, holder);
+ GtkTreeViewColumn *column = gtk_tree_view_get_column (GTK_TREE_VIEW (grid), position);
g_return_if_fail (column != NULL);
// ((GdaDataSelect *) model)->prep_stmt
GdaDataModel *model = grid->priv->data_model;
- const gchar *text;
- text = gda_utility_data_model_find_column_description (model, name);
- if (text == NULL)
+ const gchar *text = NULL;
+ if (GDA_IS_DATA_SELECT (model))
+ text = gda_utility_data_model_find_column_description (GDA_DATA_SELECT (model), name);
+ if (!text)
text = gda_holder_get_id (holder);
gtk_tree_view_column_set_title (column, text);
@@ -655,7 +658,6 @@
GtkTooltip *tooltip,
gpointer data)
{
- GtkTreeIter iter;
GtkTreeView *tree_view = GTK_TREE_VIEW(widget);
if (!gtk_tree_view_get_tooltip_context (tree_view, &x, &y,
@@ -712,132 +714,130 @@
grid = GNOME_DB_RAW_GRID (object);
if (grid->priv) {
switch (param_id) {
- case PROP_MODEL:
- {
- GdaDataModel *model = GDA_DATA_MODEL (g_value_get_object (value));
- if (model)
- g_return_if_fail (GDA_IS_DATA_MODEL (model));
-
- gnome_db_raw_grid_clean (grid);
- if (!model)
- return;
-
- grid->priv->store = GNOME_DB_DATA_STORE (gnome_db_data_store_new (model));
- grid->priv->proxy = gnome_db_data_store_get_proxy (grid->priv->store);
- grid->priv->data_model = gda_data_proxy_get_proxied_model (grid->priv->proxy);
-
- g_object_ref (G_OBJECT (grid->priv->proxy));
- g_signal_connect (grid->priv->proxy, "sample_changed",
- G_CALLBACK (proxy_sample_changed_cb), grid);
- g_signal_connect (grid->priv->proxy, "row_updated",
- G_CALLBACK (proxy_row_updated_cb), grid);
- g_signal_connect (grid->priv->proxy, "reset",
- G_CALLBACK (proxy_reset_cb), grid);
+ case PROP_MODEL: {
+ GdaDataModel *model = GDA_DATA_MODEL (g_value_get_object (value));
+ if (model)
+ g_return_if_fail (GDA_IS_DATA_MODEL (model));
+
+ gnome_db_raw_grid_clean (grid);
+ if (!model)
+ return;
+
+ grid->priv->store = GNOME_DB_DATA_STORE (gnome_db_data_store_new (model));
+ grid->priv->proxy = gnome_db_data_store_get_proxy (grid->priv->store);
+ grid->priv->data_model = gda_data_proxy_get_proxied_model (grid->priv->proxy);
+
+ g_object_ref (G_OBJECT (grid->priv->proxy));
+ g_signal_connect (grid->priv->proxy, "sample_changed",
+ G_CALLBACK (proxy_sample_changed_cb), grid);
+ g_signal_connect (grid->priv->proxy, "row_updated",
+ G_CALLBACK (proxy_row_updated_cb), grid);
+ g_signal_connect (grid->priv->proxy, "reset",
+ G_CALLBACK (proxy_reset_cb), grid);
- grid->priv->iter = gda_data_model_create_iter (GDA_DATA_MODEL (grid->priv->proxy));
+ grid->priv->iter = gda_data_model_create_iter (GDA_DATA_MODEL (grid->priv->proxy));
+ grid->priv->iter_info = gnome_db_set_new (GDA_SET (grid->priv->iter));
- g_signal_connect (grid->priv->iter, "public_data_changed",
- G_CALLBACK (paramlist_public_data_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);
- g_signal_connect (grid->priv->iter, "validate-set",
- G_CALLBACK (iter_validate_set_cb), grid);
+ g_signal_connect (grid->priv->iter_info, "public_data_changed",
+ G_CALLBACK (paramlist_public_data_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);
+ g_signal_connect (grid->priv->iter, "validate-set",
+ G_CALLBACK (iter_validate_set_cb), grid);
- gda_data_model_iter_invalidate_contents (grid->priv->iter);
+ gda_data_model_iter_invalidate_contents (grid->priv->iter);
- gtk_tree_view_set_model ((GtkTreeView *) grid, GTK_TREE_MODEL (grid->priv->store));
- init_tree_view (grid);
+ gtk_tree_view_set_model ((GtkTreeView *) grid, GTK_TREE_MODEL (grid->priv->store));
+ init_tree_view (grid);
- g_signal_emit_by_name (object, "proxy_changed", grid->priv->proxy);
- g_signal_emit_by_name (object, "iter_changed", grid->priv->iter);
+ g_signal_emit_by_name (object, "proxy_changed", grid->priv->proxy);
+ g_signal_emit_by_name (object, "iter_changed", grid->priv->iter);
- break;
- }
+ break;
+ }
- case PROP_DATA_LAYOUT:
- {
- xmlNodePtr node = g_value_get_pointer (value);
-
- xmlNodePtr child;
- for (child = node->children; child != NULL; child = child->next) {
-
- if (child->type == XML_ELEMENT_NODE &&
- !xmlStrcmp (child->name, (const xmlChar *) "data_layout_groups")) {
- load_xml_data_layout_groups (grid, child, NULL);
- }
+ case PROP_DATA_LAYOUT: {
+ xmlNodePtr node = g_value_get_pointer (value);
+
+ xmlNodePtr child;
+ for (child = node->children; child != NULL; child = child->next) {
+
+ if (child->type == XML_ELEMENT_NODE &&
+ !xmlStrcmp (child->name, (const xmlChar *) "data_layout_groups")) {
+ load_xml_data_layout_groups (grid, child, NULL);
}
+ }
- if (grid->priv->reordered_indexes != NULL) {
- g_print ("Loaded XML file, reinit interface\n");
+ if (grid->priv->reordered_indexes != NULL) {
+ g_print ("Loaded XML file, reinit interface\n");
- GList *columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(grid));
+ GList *columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(grid));
- GtkTreeViewColumn *prev_column = NULL;
- GSList *columns_data = NULL;
+ GtkTreeViewColumn *prev_column = NULL;
+ GSList *columns_data = NULL;
- GSList *reordered_indexes = grid->priv->reordered_indexes;
- while (reordered_indexes != NULL) {
- gint position = GPOINTER_TO_INT(reordered_indexes->data);
+ GSList *reordered_indexes = grid->priv->reordered_indexes;
+ while (reordered_indexes != NULL) {
+ gint position = GPOINTER_TO_INT(reordered_indexes->data);
- GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN
- (g_list_nth (columns, position)->data);
+ GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN
+ (g_list_nth (columns, position)->data);
- gtk_tree_view_move_column_after (GTK_TREE_VIEW(grid),
- column, prev_column);
- prev_column = column;
-
- // Data columns are handled
- ColumnData *column_data = (ColumnData *)
- (g_slist_nth (grid->priv->columns_data, position)->data);
- columns_data = g_slist_append (columns_data, column_data);
+ gtk_tree_view_move_column_after (GTK_TREE_VIEW(grid),
+ column, prev_column);
+ prev_column = column;
- reordered_indexes = g_slist_next (reordered_indexes);
- }
- g_list_free (columns);
+ // Data columns are handled
+ ColumnData *column_data = (ColumnData *)
+ (g_slist_nth (grid->priv->columns_data, position)->data);
+ columns_data = g_slist_append (columns_data, column_data);
- g_slist_free (grid->priv->columns_data);
- grid->priv->columns_data = columns_data;
+ reordered_indexes = g_slist_next (reordered_indexes);
+ }
+ g_list_free (columns);
- // Remove unnecessary columns according layout
- columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(grid));
+ g_slist_free (grid->priv->columns_data);
+ grid->priv->columns_data = columns_data;
- gint num_columns = g_list_length (columns);
- gint num_reordered_indexes = g_slist_length (grid->priv->reordered_indexes);
- if (num_reordered_indexes < num_columns) {
- gint i;
- for (i = num_reordered_indexes; i < num_columns; ++i) {
- GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN
- (g_list_nth (columns, i)->data);
- gtk_tree_view_remove_column (GTK_TREE_VIEW(grid), column);
- }
- }
- g_list_free (columns);
+ // Remove unnecessary columns according layout
+ columns = gtk_tree_view_get_columns (GTK_TREE_VIEW(grid));
- g_object_set (G_OBJECT(grid), "has-tooltip", TRUE, NULL);
- g_signal_connect (G_OBJECT(grid), "query-tooltip",
- G_CALLBACK(gnome_db_raw_grid_query_tooltip), NULL);
+ gint num_columns = g_list_length (columns);
+ gint num_reordered_indexes = g_slist_length (grid->priv->reordered_indexes);
+ if (num_reordered_indexes < num_columns) {
+ gint i;
+ for (i = num_reordered_indexes; i < num_columns; ++i) {
+ GtkTreeViewColumn *column = GTK_TREE_VIEW_COLUMN
+ (g_list_nth (columns, i)->data);
+ gtk_tree_view_remove_column (GTK_TREE_VIEW(grid), column);
+ }
}
+ g_list_free (columns);
+ g_object_set (G_OBJECT(grid), "has-tooltip", TRUE, NULL);
+ g_signal_connect (G_OBJECT(grid), "query-tooltip",
+ G_CALLBACK(gnome_db_raw_grid_query_tooltip), NULL);
}
+ }
+
break;
- case PROP_INFO_CELL_VISIBLE:
- {
- GSList *list = grid->priv->columns_data;
- gboolean show = g_value_get_boolean (value);
- grid->priv->default_show_info_cell = show;
-
- while (list) {
- COLUMN_DATA (list->data)->info_shown = show;
- g_object_set (G_OBJECT (COLUMN_DATA (list->data)->info_cell), "visible",
- show, NULL);
- list = g_slist_next (list);
- }
+ case PROP_INFO_CELL_VISIBLE: {
+ GSList *list = grid->priv->columns_data;
+ gboolean show = g_value_get_boolean (value);
+ grid->priv->default_show_info_cell = show;
+
+ while (list) {
+ COLUMN_DATA (list->data)->info_shown = show;
+ g_object_set (G_OBJECT (COLUMN_DATA (list->data)->info_cell), "visible",
+ show, NULL);
+ list = g_slist_next (list);
}
+ }
break;
case PROP_GLOBAL_ACTIONS_VISIBLE:
@@ -970,16 +970,16 @@
tree_view = GTK_TREE_VIEW (grid);
/* Creation of the columns in the treeview, to fit the parameters in grid->priv->iter param list */
- list = GDA_SET (grid->priv->iter)->groups_list;
- i = 0;
- while (list) {
+ for (i = 0, list = grid->priv->iter_info->groups_list;
+ list;
+ i++, list = list->next) {
GdaHolder *param;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
ColumnData *column_data;
- group = GDA_SET_GROUP (list->data);
+ group = GNOME_DB_SET_GROUP (list->data);
/* update the list of columns data */
column_data = get_column_data (grid, group);
@@ -993,13 +993,13 @@
}
/* create renderers */
- if (group->nodes_source) {
+ if (group->source) {
/* parameters depending on a GdaDataModel */
gchar *title;
gboolean nullok = TRUE;
GSList *nodes;
- nodes = group->nodes;
+ nodes = group->group->nodes;
while (nodes && nullok) {
if (gda_holder_get_not_null (GDA_HOLDER (GDA_SET_NODE (nodes->data)->holder)))
nullok = FALSE;
@@ -1007,11 +1007,11 @@
}
/* determine title */
- if (g_slist_length (group->nodes) == 1)
- title = (gchar *) g_object_get_data (G_OBJECT (GDA_SET_NODE (group->nodes->data)->holder),
+ if (g_slist_length (group->group->nodes) == 1)
+ title = (gchar *) g_object_get_data (G_OBJECT (GDA_SET_NODE (group->group->nodes->data)->holder),
"name");
else
- title = (gchar *) g_object_get_data (G_OBJECT (group->nodes_source->data_model),
+ title = (gchar *) g_object_get_data (G_OBJECT (group->group->nodes_source->data_model),
"name");
if (title)
@@ -1022,7 +1022,7 @@
/* FIXME: if nullok is FALSE, then set the column title in bold */
- renderer = gnome_db_data_cell_renderer_combo_new (GDA_SET (grid->priv->iter), group->nodes_source);
+ renderer = gnome_db_data_cell_renderer_combo_new (grid->priv->iter_info, group->source);
column_data->data_cell = renderer;
gtk_tree_view_insert_column_with_data_func (tree_view, i, title, renderer,
(GtkTreeCellDataFunc) cell_renderer_value_set_attributes,
@@ -1033,7 +1033,7 @@
g_signal_connect (G_OBJECT (renderer), "changed",
G_CALLBACK (data_cell_values_changed), grid);
- g_object_set_data (G_OBJECT (column), "source", group->nodes_source);
+ g_object_set_data (G_OBJECT (column), "source", group->group->nodes_source);
}
else {
/* single direct parameter */
@@ -1042,7 +1042,7 @@
const GValue *plugin_val;
gchar *title;
- param = GDA_HOLDER (GDA_SET_NODE (group->nodes->data)->holder);
+ param = GDA_HOLDER (GDA_SET_NODE (group->group->nodes->data)->holder);
g_type = gda_holder_get_g_type (param);
g_object_get (G_OBJECT (param), "name", &title, NULL);
@@ -1080,8 +1080,8 @@
g_object_set (G_OBJECT (renderer), "editable", !column_data->data_locked, NULL);
if (g_object_class_find_property (G_OBJECT_GET_CLASS (renderer), "set_default_if_invalid"))
g_object_set (G_OBJECT (renderer), "set_default_if_invalid", TRUE, NULL);
- g_object_set_data (G_OBJECT (renderer), "group", group);
- g_object_set_data (G_OBJECT (column), "group", group);
+ g_object_set_data (G_OBJECT (renderer), "__gnome_db_group", group);
+ g_object_set_data (G_OBJECT (column), "__gnome_db_group", group);
/* Adding the GValue's information cell as another GtkCellRenderer */
renderer = gnome_db_data_cell_renderer_info_new (grid->priv->store, grid->priv->iter, group);
@@ -1093,15 +1093,12 @@
g_signal_connect (G_OBJECT (renderer), "status_changed",
G_CALLBACK (data_cell_status_changed), grid);
g_object_set (G_OBJECT (renderer), "visible", column_data->info_shown, NULL);
- g_object_set_data (G_OBJECT (renderer), "group", group);
+ g_object_set_data (G_OBJECT (renderer), "__gnome_db_group", group);
/* Sorting data */
gtk_tree_view_column_set_clickable (column, TRUE);
g_signal_connect (G_OBJECT (column), "clicked",
G_CALLBACK (treeview_column_clicked_cb), grid);
-
- list = g_slist_next (list);
- i++;
}
}
@@ -1115,15 +1112,15 @@
GtkTreeModel *tree_model,
GtkTreeIter *iter, GnomeDbRawGrid *grid)
{
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
guint attributes;
gboolean to_be_deleted = FALSE;
ColumnData *column_data;
- group = g_object_get_data (G_OBJECT (tree_column), "group");
+ group = g_object_get_data (G_OBJECT (tree_column), "__gnome_db_group");
column_data = get_column_data (grid, group);
- if (group->nodes_source) {
+ if (group->group->nodes_source) {
/* parameters depending on a GdaDataModel */
GList *values = NULL;
GdaSetSource *source;
@@ -1143,9 +1140,9 @@
* external events and we can't know when it has changed.
*/
attributes = gnome_db_utility_proxy_compute_attributes_for_group (group, grid->priv->store, grid->priv->iter,
- iter, &to_be_deleted);
+ iter, &to_be_deleted);
values = gnome_db_utility_proxy_compute_values_for_group (group, grid->priv->store, grid->priv->iter, iter,
- TRUE);
+ TRUE);
if (!values) {
values = gnome_db_utility_proxy_compute_values_for_group (group, grid->priv->store,
grid->priv->iter, iter, FALSE);
@@ -1186,9 +1183,9 @@
offset = gda_data_model_get_n_columns (gda_data_proxy_get_proxied_model (grid->priv->proxy));
- g_assert (g_slist_length (group->nodes) == 1);
+ g_assert (g_slist_length (group->group->nodes) == 1);
col = g_slist_index (((GdaSet *)grid->priv->iter)->holders,
- GDA_SET_NODE (group->nodes->data)->holder);
+ GDA_SET_NODE (group->group->nodes->data)->holder);
gtk_tree_model_get (GTK_TREE_MODEL (grid->priv->store), iter,
DATA_STORE_COL_TO_DELETE, &to_be_deleted,
DATA_STORE_COL_MODEL_ROW, &row,
@@ -1216,22 +1213,22 @@
GtkTreeModel *tree_model,
GtkTreeIter *iter, GnomeDbRawGrid *grid)
{
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
guint attributes;
gboolean to_be_deleted = FALSE;
ColumnData *column_data;
- group = g_object_get_data (G_OBJECT (tree_column), "group");
+ group = g_object_get_data (G_OBJECT (tree_column), "__gnome_db_group");
column_data = get_column_data (grid, group);
- if (group->nodes_source) {
+ if (group->group->nodes_source) {
/* parameters depending on a GdaDataModel */
GdaSetSource *source;
source = g_object_get_data (G_OBJECT (tree_column), "source");
attributes = gnome_db_utility_proxy_compute_attributes_for_group (group, grid->priv->store, grid->priv->iter,
- iter, &to_be_deleted);
+ iter, &to_be_deleted);
g_object_set (G_OBJECT (cell),
"editable", !column_data->data_locked && !(attributes & GDA_VALUE_ATTR_NO_MODIF),
"value_attributes", attributes,
@@ -1249,9 +1246,9 @@
offset = gda_data_model_get_n_columns (gda_data_proxy_get_proxied_model (grid->priv->proxy));
- g_assert (g_slist_length (group->nodes) == 1);
+ g_assert (g_slist_length (group->group->nodes) == 1);
col = g_slist_index (((GdaSet *)grid->priv->iter)->holders,
- GDA_SET_NODE (group->nodes->data)->holder);
+ GDA_SET_NODE (group->group->nodes->data)->holder);
gtk_tree_model_get (GTK_TREE_MODEL (grid->priv->store), iter,
DATA_STORE_COL_TO_DELETE, &to_be_deleted,
DATA_STORE_COL_MODEL_ROW, &row,
@@ -1278,15 +1275,15 @@
data_cell_value_changed (GtkCellRenderer *renderer, const gchar *path, const GValue *new_value, GnomeDbRawGrid *grid)
{
GtkTreeIter iter;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
- group = g_object_get_data (G_OBJECT (renderer), "group");
- g_assert (g_slist_length (group->nodes) == 1);
+ group = g_object_get_data (G_OBJECT (renderer), "__gnome_db_group");
+ g_assert (g_slist_length (group->group->nodes) == 1);
if (set_iter_from_path (grid, path, &iter)) {
gint col;
col = g_slist_index (((GdaSet *)grid->priv->iter)->holders,
- GDA_SET_NODE (group->nodes->data)->holder);
+ GDA_SET_NODE (group->group->nodes->data)->holder);
gnome_db_data_store_set_value (grid->priv->store, &iter, col, new_value);
}
}
@@ -1302,13 +1299,13 @@
GSList *new_values, GSList *all_new_values, GnomeDbRawGrid *grid)
{
GtkTreeIter iter;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
- group = g_object_get_data (G_OBJECT (renderer), "group");
- g_assert (group->nodes_source);
+ group = g_object_get_data (G_OBJECT (renderer), "__gnome_db_group");
+ g_assert (group->group->nodes_source);
if (new_values)
- g_return_if_fail (g_slist_length (group->nodes) == g_slist_length (new_values));
+ g_return_if_fail (g_slist_length (group->group->nodes) == g_slist_length (new_values));
else
/* the reason for not having any value is that the GnomeDbDataCellRendererCombo had no selected item */
return;
@@ -1320,7 +1317,7 @@
proxy_row = gnome_db_data_store_get_row_from_iter (grid->priv->store, &iter);
/* update the GnomeDbDataStore */
- for (params = group->nodes, list = new_values;
+ for (params = group->group->nodes, list = new_values;
list;
params = params->next, list = list->next) {
col = g_slist_index (((GdaSet *)grid->priv->iter)->holders,
@@ -1331,13 +1328,13 @@
#ifdef PROXY_STORE_EXTRA_VALUES
/* call gda_data_proxy_set_model_row_value() */
gint i;
- for (i = 0; i < group->nodes_source->shown_n_cols; i++) {
+ for (i = 0; i < group->source->shown_n_cols; i++) {
GValue *value;
col = group->nodes_source->shown_cols_index[i];
value = (GValue *) g_slist_nth_data (all_new_values, col);
gda_data_proxy_set_model_row_value (grid->priv->proxy,
- group->nodes_source->data_model,
+ group->group->nodes_source->data_model,
proxy_row, col, value);
}
#endif
@@ -1365,13 +1362,13 @@
static void
treeview_column_clicked_cb (GtkTreeViewColumn *tree_column, GnomeDbRawGrid *grid)
{
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
GSList *nodes;
- group = g_object_get_data (G_OBJECT (tree_column), "group");
+ group = g_object_get_data (G_OBJECT (tree_column), "__gnome_db_group");
g_assert (group);
- for (nodes = group->nodes; nodes; nodes = nodes->next) {
+ for (nodes = group->group->nodes; nodes; nodes = nodes->next) {
GdaHolder *param = ((GdaSetNode*) nodes->data)->holder;
gint pos;
g_assert (param);
@@ -1393,7 +1390,7 @@
{
GtkTreePath *treepath;
GtkTreeIter iter;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
GtkTreeModel *tree_model;
gint col;
gint offset;
@@ -1401,7 +1398,7 @@
offset = gda_data_model_get_n_columns (gda_data_proxy_get_proxied_model (grid->priv->proxy));
- group = g_object_get_data (G_OBJECT (renderer), "group");
+ group = g_object_get_data (G_OBJECT (renderer), "__gnome_db_group");
tree_model = GTK_TREE_MODEL (grid->priv->store);
treepath = gtk_tree_path_new_from_string (path);
@@ -1413,13 +1410,13 @@
gtk_tree_path_free (treepath);
g_value_set_uint (attribute = gda_value_new (G_TYPE_UINT), requested_action);
- if (group->nodes_source) {
+ if (group->group->nodes_source) {
/* parameters depending on a GdaDataModel */
gint proxy_row;
GSList *list;
proxy_row = gnome_db_data_store_get_row_from_iter (grid->priv->store, &iter);
- for (list = group->nodes; list; list = list->next) {
+ for (list = group->group->nodes; list; list = list->next) {
col = g_slist_index (((GdaSet *)grid->priv->iter)->holders,
GDA_SET_NODE (list->data)->holder);
gnome_db_data_store_set_value (grid->priv->store, &iter, offset + col, attribute);
@@ -1455,9 +1452,9 @@
/* single direct parameter */
gint col;
- g_assert (g_slist_length (group->nodes) == 1);
+ g_assert (g_slist_length (group->group->nodes) == 1);
col = g_slist_index (((GdaSet *)grid->priv->iter)->holders,
- GDA_SET_NODE (group->nodes->data)->holder);
+ GDA_SET_NODE (group->group->nodes->data)->holder);
gnome_db_data_store_set_value (grid->priv->store, &iter, offset + col, attribute);
}
gda_value_free (attribute);
@@ -2063,11 +2060,11 @@
list = columns;
while (list) {
if (gtk_tree_view_column_get_visible (GTK_TREE_VIEW_COLUMN (list->data))) {
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
GSList *params;
- group = g_object_get_data (G_OBJECT (list->data), "group");
- for (params = group->nodes; params; nb_cols ++, params = params->next)
+ group = g_object_get_data (G_OBJECT (list->data), "__gnome_db_group");
+ for (params = group->group->nodes; params; nb_cols ++, params = params->next)
cols [nb_cols] = g_slist_index (((GdaSet *)grid->priv->iter)->holders,
GDA_SET_NODE (params->data)->holder);
}
@@ -2300,18 +2297,15 @@
}
static ColumnData *
-get_column_data (GnomeDbRawGrid *grid, GdaSetGroup *group)
+get_column_data (GnomeDbRawGrid *grid, GnomeDbSetGroup *group)
{
- ColumnData *retval = NULL;
- GSList *list = grid->priv->columns_data;
- while (list && !retval) {
+ GSList *list;
+ for (list = grid->priv->columns_data; list; list = list->next) {
if (COLUMN_DATA (list->data)->group == group)
- retval = COLUMN_DATA (list->data);
-
- list = g_slist_next (list);
+ return COLUMN_DATA (list->data);
}
- return retval;
+ return NULL;
}
/**
@@ -2366,7 +2360,7 @@
GnomeDbRawGrid *grid;
GdaHolder *param;
ColumnData *column_data;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
g_return_if_fail (iface && GNOME_DB_IS_RAW_GRID (iface));
grid = GNOME_DB_RAW_GRID (iface);
@@ -2378,7 +2372,7 @@
param = gda_data_model_iter_get_holder_for_field (grid->priv->iter, column);
g_return_if_fail (param);
- group = gda_set_get_group (GDA_SET (grid->priv->iter), param);
+ group = _gnome_db_set_get_group (grid->priv->iter_info, param);
g_return_if_fail (group);
column_data = get_column_data (grid, group);
@@ -2402,14 +2396,14 @@
if (column >= 0) {
GdaHolder *param;
- GdaSetGroup *group;
+ GnomeDbSetGroup *group;
ColumnData *cdata;
/* setting applies only to the @column column */
param = gda_data_model_iter_get_holder_for_field (grid->priv->iter, column);
g_return_if_fail (param);
- group = gda_set_get_group (GDA_SET (grid->priv->iter), param);
+ group = _gnome_db_set_get_group (grid->priv->iter_info, param);
g_return_if_fail (group);
cdata = get_column_data (grid, group);
@@ -2500,7 +2494,7 @@
}
static void
-paramlist_public_data_changed_cb (GdaSet *paramlist, GnomeDbRawGrid *grid)
+paramlist_public_data_changed_cb (GnomeDbSet *info, GnomeDbRawGrid *grid)
{
GList *columns, *list;
@@ -2550,7 +2544,7 @@
g_list_free (cols);
/* re-create columns */
- paramlist_public_data_changed_cb (paramlist, grid);
+ paramlist_public_data_changed_cb (grid->priv->iter_info, grid);
/* hide columns which were hidden */
cols = gtk_tree_view_get_columns (GTK_TREE_VIEW (grid));
@@ -2707,7 +2701,7 @@
/* private data set */
if (grid->priv->iter) {
- g_signal_handlers_disconnect_by_func (grid->priv->iter,
+ g_signal_handlers_disconnect_by_func (grid->priv->iter_info,
G_CALLBACK (paramlist_public_data_changed_cb), grid);
g_signal_handlers_disconnect_by_func (grid->priv->iter,
G_CALLBACK (paramlist_param_attr_changed_cb), grid);
@@ -2716,7 +2710,9 @@
g_signal_handlers_disconnect_by_func (grid->priv->iter,
G_CALLBACK (iter_validate_set_cb), grid);
g_object_unref (grid->priv->iter);
+ g_object_unref (grid->priv->iter_info);
grid->priv->iter = NULL;
+ grid->priv->iter_info = NULL;
}
/* proxy */
Added: trunk/libgnomedb/gnome-db-set.c
==============================================================================
--- (empty file)
+++ trunk/libgnomedb/gnome-db-set.c Mon Mar 23 18:23:36 2009
@@ -0,0 +1,407 @@
+/* gnome-db-set.c
+ *
+ * Copyright (C) 2009 Vivien Malerba
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include <libgda/libgda.h>
+#include <libgnomedb/gnome-db-set.h>
+#include "marshal.h"
+
+static void gnome_db_set_class_init (GnomeDbSetClass * class);
+static void gnome_db_set_init (GnomeDbSet *wid);
+static void gnome_db_set_dispose (GObject *object);
+
+static void gnome_db_set_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gnome_db_set_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void wrapped_set_public_data_changed_cb (GdaSet *wset, GnomeDbSet *set);
+static void clean_public_data (GnomeDbSet *set);
+static void compute_public_data (GnomeDbSet *set);
+static void compute_shown_columns_index (GnomeDbSetSource *dsource);
+static void compute_ref_columns_index (GnomeDbSetSource *dsource);
+
+
+struct _GnomeDbSetPriv
+{
+ GdaSet *set;
+};
+
+/* get a pointer to the parents to be able to call their destructor */
+static GObjectClass *parent_class = NULL;
+
+/* properties */
+enum
+{
+ PROP_0,
+ PROP_SET
+};
+
+/* signals */
+enum
+{
+ PUBLIC_DATA_CHANGED,
+ LAST_SIGNAL
+};
+
+static gint gnome_db_set_signals[LAST_SIGNAL] = { 0 };
+
+GType
+gnome_db_set_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo info = {
+ sizeof (GnomeDbSetClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gnome_db_set_class_init,
+ NULL,
+ NULL,
+ sizeof (GnomeDbSet),
+ 0,
+ (GInstanceInitFunc) gnome_db_set_init
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT, "GnomeDbSet", &info, 0);
+ }
+
+ return type;
+}
+
+static void
+gnome_db_set_class_init (GnomeDbSetClass *class)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+ parent_class = g_type_class_peek_parent (class);
+ object_class->dispose = gnome_db_set_dispose;
+
+ /**
+ * GnomeDbSet::public-data-changed
+ * @set: the #GnomeDbSet
+ *
+ * Gets emitted when @set's public data (#GnomeDbSetGroup or #GnomeDbSetSource values) have changed
+ */
+ gnome_db_set_signals[PUBLIC_DATA_CHANGED] =
+ g_signal_new ("public-data-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GnomeDbSetClass, public_data_changed),
+ NULL, NULL,
+ gnome_db_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ class->public_data_changed = NULL;
+
+ /* Properties */
+ object_class->set_property = gnome_db_set_set_property;
+ object_class->get_property = gnome_db_set_get_property;
+ g_object_class_install_property (object_class, PROP_SET,
+ g_param_spec_object ("set", NULL, NULL,
+ GDA_TYPE_SET,
+ G_PARAM_READABLE | G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+}
+
+static void
+gnome_db_set_init (GnomeDbSet *set)
+{
+ set->priv = g_new0 (GnomeDbSetPriv, 1);
+ set->priv->set = NULL;
+}
+
+/**
+ * gnome_db_set_new
+ * @set: a #GdaSet
+ *
+ * Creates a new #GnomeDbSet which wraps @set's properties
+ *
+ * Returns: the new widget
+ */
+GnomeDbSet *
+gnome_db_set_new (GdaSet *set)
+{
+ g_return_val_if_fail (GDA_IS_SET (set), NULL);
+
+ return (GnomeDbSet *) g_object_new (GNOME_DB_TYPE_SET, "set", set, NULL);
+}
+
+static void
+gnome_db_set_dispose (GObject *object)
+{
+ GnomeDbSet *set;
+
+ g_return_if_fail (GNOME_DB_IS_SET (object));
+
+ set = GNOME_DB_SET (object);
+
+ if (set->priv) {
+ if (set->priv->set) {
+ g_signal_handlers_disconnect_by_func (G_OBJECT (set->priv->set),
+ G_CALLBACK (wrapped_set_public_data_changed_cb), set);
+ g_object_unref (set->priv->set);
+ set->priv->set = NULL;
+ }
+
+ clean_public_data (set);
+
+ g_free (set->priv);
+ set->priv = NULL;
+ }
+
+ /* for the parent class */
+ parent_class->dispose (object);
+}
+
+static void
+gnome_db_set_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GnomeDbSet *set;
+
+ set = GNOME_DB_SET (object);
+
+ switch (param_id) {
+ case PROP_SET:
+ set->priv->set = g_value_get_object (value);
+ if (set->priv->set) {
+ g_object_ref (set->priv->set);
+ compute_public_data (set);
+ g_signal_connect (set->priv->set, "public-data-changed",
+ G_CALLBACK (wrapped_set_public_data_changed_cb), set);
+ }
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+wrapped_set_public_data_changed_cb (GdaSet *wset, GnomeDbSet *set)
+{
+ clean_public_data (set);
+ compute_public_data (set);
+ g_signal_emit (set, gnome_db_set_signals[PUBLIC_DATA_CHANGED], 0);
+}
+
+static void
+clean_public_data (GnomeDbSet *set)
+{
+ TO_IMPLEMENT;
+ GSList *list;
+
+ for (list = set->sources_list; list; list = list->next) {
+ GnomeDbSetSource *dsource = (GnomeDbSetSource*) list->data;
+ g_free (dsource->shown_cols_index);
+ g_free (dsource->ref_cols_index);
+ g_free (dsource);
+ }
+ g_slist_free (set->sources_list);
+ set->sources_list = NULL;
+
+ for (list = set->groups_list; list; list = list->next) {
+ GnomeDbSetGroup *dgroup = (GnomeDbSetGroup*) list->data;
+ g_free (dgroup);
+ }
+ g_slist_free (set->groups_list);
+ set->groups_list = NULL;
+}
+
+static void
+compute_public_data (GnomeDbSet *set)
+{
+ GSList *list;
+ GdaSet *aset = GDA_SET (set->priv->set);
+ GHashTable *hash;
+
+ /* scan GdaSetSource list */
+ hash = g_hash_table_new (NULL, NULL);
+ for (list = aset->sources_list; list; list = list->next) {
+ GnomeDbSetSource *dsource;
+ dsource = g_new0 (GnomeDbSetSource, 1);
+ set->sources_list = g_slist_prepend (set->sources_list, dsource);
+ g_hash_table_insert (hash, list->data, dsource);
+
+ dsource->source = GDA_SET_SOURCE (list->data);
+ compute_shown_columns_index (dsource);
+ compute_ref_columns_index (dsource);
+ }
+ set->sources_list = g_slist_reverse (set->sources_list);
+
+ /* scan GdaSetGroup list */
+ for (list = aset->groups_list; list; list = list->next) {
+ GnomeDbSetGroup *dgroup;
+ dgroup = g_new0 (GnomeDbSetGroup, 1);
+ set->groups_list = g_slist_prepend (set->groups_list, dgroup);
+ dgroup->group = GDA_SET_GROUP (list->data);
+ dgroup->source = g_hash_table_lookup (hash, GDA_SET_GROUP (list->data)->nodes_source);
+ }
+ set->groups_list = g_slist_reverse (set->groups_list);
+
+ g_hash_table_destroy (hash);
+}
+
+static void
+compute_shown_columns_index (GnomeDbSetSource *dsource)
+{
+ gint ncols, nholders;
+ gint *mask = NULL, masksize = 0;
+
+ nholders = g_slist_length (dsource->source->nodes);
+ g_return_if_fail (nholders > 0);
+ ncols = gda_data_model_get_n_columns (GDA_DATA_MODEL (dsource->source->data_model));
+ g_return_if_fail (ncols > 0);
+
+ if (ncols > nholders) {
+ /* we only want columns which are not holders */
+ gint i, current = 0;
+
+ masksize = ncols - nholders;
+ mask = g_new0 (gint, masksize);
+ for (i = 0; i < ncols ; i++) {
+ GSList *list = dsource->source->nodes;
+ gboolean found = FALSE;
+ while (list && !found) {
+ if (GDA_SET_NODE (list->data)->source_column == i)
+ found = TRUE;
+ else
+ list = g_slist_next (list);
+ }
+ if (!found) {
+ mask[current] = i;
+ current ++;
+ }
+ }
+ masksize = current;
+ }
+ else {
+ /* we want all the columns */
+ gint i;
+
+ masksize = ncols;
+ mask = g_new0 (gint, masksize);
+ for (i=0; i<ncols; i++) {
+ mask[i] = i;
+ }
+ }
+
+ dsource->shown_n_cols = masksize;
+ dsource->shown_cols_index = mask;
+}
+
+void
+compute_ref_columns_index (GnomeDbSetSource *dsource)
+{
+ gint ncols, nholders;
+ gint *mask = NULL, masksize = 0;
+
+ nholders = g_slist_length (dsource->source->nodes);
+ g_return_if_fail (nholders > 0);
+ ncols = gda_data_model_get_n_columns (GDA_DATA_MODEL (dsource->source->data_model));
+ g_return_if_fail (ncols > 0);
+
+ if (ncols > nholders) {
+ /* we only want columns which are holders */
+ gint i, current = 0;
+
+ masksize = ncols - nholders;
+ mask = g_new0 (gint, masksize);
+ for (i=0; i<ncols ; i++) {
+ GSList *list = dsource->source->nodes;
+ gboolean found = FALSE;
+ while (list && !found) {
+ if (GDA_SET_NODE (list->data)->source_column == i)
+ found = TRUE;
+ else
+ list = g_slist_next (list);
+ }
+ if (found) {
+ mask[current] = i;
+ current ++;
+ }
+ }
+ masksize = current;
+ }
+ else {
+ /* we want all the columns */
+ gint i;
+
+ masksize = ncols;
+ mask = g_new0 (gint, masksize);
+ for (i=0; i<ncols; i++) {
+ mask[i] = i;
+ }
+ }
+
+ dsource->ref_n_cols = masksize;
+ dsource->ref_cols_index = mask;
+}
+
+
+static void
+gnome_db_set_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GnomeDbSet *set;
+
+ set = GNOME_DB_SET (object);
+
+ switch (param_id) {
+ case PROP_SET:
+ g_value_set_object (value, set->priv->set);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+/**
+ * _gnome_db_set_get_group
+ */
+GnomeDbSetGroup *
+_gnome_db_set_get_group (GnomeDbSet *dbset, GdaHolder *holder)
+{
+ GdaSetGroup *agroup;
+ GSList *list;
+ g_return_val_if_fail (GNOME_DB_IS_SET (dbset), NULL);
+ g_return_val_if_fail (GDA_IS_HOLDER (holder), NULL);
+
+ agroup = gda_set_get_group (dbset->priv->set, holder);
+ if (!agroup)
+ return NULL;
+
+ for (list = dbset->groups_list; list; list = list->next) {
+ if (GNOME_DB_SET_GROUP (list->data)->group == agroup)
+ return GNOME_DB_SET_GROUP (list->data);
+ }
+ return NULL;
+}
Added: trunk/libgnomedb/gnome-db-set.h
==============================================================================
--- (empty file)
+++ trunk/libgnomedb/gnome-db-set.h Mon Mar 23 18:23:36 2009
@@ -0,0 +1,104 @@
+/* gnome-db-set.h
+ *
+ * Copyright (C) 2009 Vivien Malerba
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef __GNOME_DB_SET__
+#define __GNOME_DB_SET__
+
+#include <gtk/gtk.h>
+#include <libgda/gda-decl.h>
+
+G_BEGIN_DECLS
+
+#define GNOME_DB_TYPE_SET (gnome_db_set_get_type())
+#define GNOME_DB_SET(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gnome_db_set_get_type(), GnomeDbSet)
+#define GNOME_DB_SET_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gnome_db_set_get_type (), GnomeDbSetClass)
+#define GNOME_DB_IS_SET(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gnome_db_set_get_type ())
+
+
+typedef struct _GnomeDbSet GnomeDbSet;
+typedef struct _GnomeDbSetClass GnomeDbSetClass;
+typedef struct _GnomeDbSetPriv GnomeDbSetPriv;
+
+typedef struct _GnomeDbSetGroup GnomeDbSetGroup;
+typedef struct _GnomeDbSetSource GnomeDbSetSource;
+
+struct _GnomeDbSetGroup {
+ GdaSetGroup *group;
+ GnomeDbSetSource *source; /* if NULL, then @group->nodes contains exactly one entry */
+
+ /* Padding for future expansion */
+ gpointer _gda_reserved1;
+ gpointer _gda_reserved2;
+};
+
+#define GNOME_DB_SET_GROUP(x) ((GnomeDbSetGroup*)(x))
+
+struct _GnomeDbSetSource {
+ GdaSetSource *source;
+
+ /* displayed columns in 'source->data_model' */
+ gint shown_n_cols;
+ gint *shown_cols_index;
+
+ /* columns used as a reference (corresponding to PK values) in 'source->data_model' */
+ gint ref_n_cols;
+ gint *ref_cols_index;
+
+ /* Padding for future expansion */
+ gpointer _gda_reserved1;
+ gpointer _gda_reserved2;
+ gpointer _gda_reserved3;
+ gpointer _gda_reserved4;
+};
+
+#define GNOME_DB_SET_SOURCE(x) ((GnomeDbSetSource*)(x))
+
+/* struct for the object's data */
+struct _GnomeDbSet
+{
+ GObject object;
+ GnomeDbSetPriv *priv;
+
+ /*< public >*/
+ GSList *sources_list; /* list of GnomeDbSetSource */
+ GSList *groups_list; /* list of GnomeDbSetGroup */
+};
+
+/* struct for the object's class */
+struct _GnomeDbSetClass
+{
+ GObjectClass parent_class;
+ void (*public_data_changed) (GnomeDbSet *set);
+};
+
+/*
+ * Generic widget's methods
+ */
+GType gnome_db_set_get_type (void) G_GNUC_CONST;
+
+GnomeDbSet *gnome_db_set_new (GdaSet *set);
+GnomeDbSetGroup *_gnome_db_set_get_group (GnomeDbSet *dbset, GdaHolder *holder);
+
+G_END_DECLS
+
+#endif
+
+
+
Modified: trunk/libgnomedb/utility.c
==============================================================================
--- trunk/libgnomedb/utility.c (original)
+++ trunk/libgnomedb/utility.c Mon Mar 23 18:23:36 2009
@@ -217,9 +217,9 @@
* Returns: the attributes
*/
guint
-gnome_db_utility_proxy_compute_attributes_for_group (GdaSetGroup *group, GnomeDbDataStore *store,
- GdaDataModelIter *model_iter, GtkTreeIter *tree_iter,
- gboolean *to_be_deleted)
+gnome_db_utility_proxy_compute_attributes_for_group (GnomeDbSetGroup *group, GnomeDbDataStore *store,
+ GdaDataModelIter *model_iter, GtkTreeIter *tree_iter,
+ gboolean *to_be_deleted)
{
guint attributes = GDA_VALUE_ATTR_IS_NULL | GDA_VALUE_ATTR_CAN_BE_NULL |
GDA_VALUE_ATTR_IS_DEFAULT | GDA_VALUE_ATTR_CAN_BE_DEFAULT |
@@ -234,14 +234,14 @@
proxy = gnome_db_data_store_get_proxy (store);
offset = gda_data_proxy_get_proxied_model_n_cols (proxy);
- /* list the values in proxy_model for each param in GDA_SET_NODE (group->nodes->data)->params */
+ /* list the values in proxy_model for each param in GDA_SET_NODE (group->group->nodes->data)->params */
attributes = 0;
- for (list = group->nodes; list; list = list->next) {
+ for (list = group->group->nodes; list; list = list->next) {
col = g_slist_index (((GdaSet*)model_iter)->holders, GDA_SET_NODE (list->data)->holder);
gtk_tree_model_get (GTK_TREE_MODEL (store), tree_iter,
DATA_STORE_COL_TO_DELETE, &local_to_del,
offset + col, &localattr, -1);
- if (list == group->nodes)
+ if (list == group->group->nodes)
attributes = localattr;
else
attributes &= localattr;
@@ -269,7 +269,7 @@
* freed.
*/
GList *
-gnome_db_utility_proxy_compute_values_for_group (GdaSetGroup *group, GnomeDbDataStore *store,
+gnome_db_utility_proxy_compute_values_for_group (GnomeDbSetGroup *group, GnomeDbDataStore *store,
GdaDataModelIter *model_iter,
GtkTreeIter *tree_iter, gboolean model_values)
{
@@ -283,7 +283,7 @@
GSList *list;
GValue *value;
- for (list = group->nodes; list; list = list->next) {
+ for (list = group->group->nodes; list; list = list->next) {
gint col;
col = g_slist_index (((GdaSet*)model_iter)->holders, GDA_SET_NODE (list->data)->holder);
@@ -293,13 +293,13 @@
}
else {
gint col, i, proxy_row;
- GdaSetSource *source;
+ GnomeDbSetSource *source;
const GValue *value;
gboolean slow_way = FALSE;
gboolean ret_null = FALSE;
proxy_row = gnome_db_data_store_get_row_from_iter (store, tree_iter);
- source = group->nodes_source;
+ source = group->source;
for (i = 0 ; (i < source->shown_n_cols) && !ret_null; i++) {
col = source->shown_cols_index[i];
#ifdef PROXY_STORE_EXTRA_VALUES
@@ -325,8 +325,8 @@
GSList *list;
gint j;
- cols_index = g_new0 (gint, g_slist_length (group->nodes));
- for (list = group->nodes, j = 0; list; list = list->next, j++) {
+ cols_index = g_new0 (gint, g_slist_length (group->group->nodes));
+ for (list = group->group->nodes, j = 0; list; list = list->next, j++) {
gint colno;
colno = g_slist_index (((GdaSet*)model_iter)->holders,
GDA_SET_NODE (list->data)->holder);
@@ -336,10 +336,10 @@
key_values = g_slist_append (key_values, (GValue *) value);
}
- row = gda_data_model_get_row_from_values (GDA_DATA_MODEL (source->data_model),
+ row = gda_data_model_get_row_from_values (GDA_DATA_MODEL (source->source->data_model),
key_values, cols_index);
if (row >= 0) {
- value = gda_data_model_get_value_at (GDA_DATA_MODEL (source->data_model),
+ value = gda_data_model_get_value_at (GDA_DATA_MODEL (source->source->data_model),
col, row, NULL);
retval = g_list_append (retval, (GValue *) value);
}
@@ -552,7 +552,7 @@
return;
}
- xmlNodePtr node, child;
+ xmlNodePtr node;
for (node = root_node->children; node != NULL; node = node->next) {
if (node->type == XML_ELEMENT_NODE &&
Modified: trunk/libgnomedb/utility.h
==============================================================================
--- trunk/libgnomedb/utility.h (original)
+++ trunk/libgnomedb/utility.h Mon Mar 23 18:23:36 2009
@@ -22,6 +22,7 @@
#include <libgda/gda-set.h>
#include "gnome-db-data-entry.h"
#include "gnome-db-data-store.h"
+#include "gnome-db-set.h"
/*
*
@@ -37,13 +38,13 @@
* corresponding to the columns for the parameters in @group (as described by @model_iter),
* at row pointed by @tree_iter
*/
-guint gnome_db_utility_proxy_compute_attributes_for_group (GdaSetGroup *group,
- GnomeDbDataStore *store, GdaDataModelIter *model_iter,
- GtkTreeIter *tree_iter,
- gboolean *to_be_deleted);
-GList *gnome_db_utility_proxy_compute_values_for_group (GdaSetGroup *group,
- GnomeDbDataStore *store, GdaDataModelIter *model_iter,
- GtkTreeIter *tree_iter, gboolean model_values);
+guint gnome_db_utility_proxy_compute_attributes_for_group (GnomeDbSetGroup *group,
+ GnomeDbDataStore *store, GdaDataModelIter *model_iter,
+ GtkTreeIter *tree_iter,
+ gboolean *to_be_deleted);
+GList *gnome_db_utility_proxy_compute_values_for_group (GnomeDbSetGroup *group,
+ GnomeDbDataStore *store, GdaDataModelIter *model_iter,
+ GtkTreeIter *tree_iter, gboolean model_values);
/*
* Some dialogs used by GnomeDbDataWidget widgets
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]