This commit is contained in:
Juan Ferrer Toribio 2014-07-09 09:49:56 +02:00
parent 8418144ad8
commit b042af35db
15 changed files with 405 additions and 213 deletions

View File

@ -51,13 +51,16 @@ G_DEFINE_TYPE (DbCalc, db_calc, GVN_TYPE_PARAM);
* *
* Return value: a new #DbCalc * Return value: a new #DbCalc
**/ **/
DbCalc * db_calc_new (DbModel * model, DbCalcType type, gint col) DbCalc * db_calc_new (DbModel * model, DbCalcType type, const gchar * column_name)
{ {
g_return_val_if_fail (DB_IS_MODEL (model), NULL); g_return_val_if_fail (DB_IS_MODEL (model), NULL);
g_return_val_if_fail (0 <= col || col < db_model_get_ncols (model), NULL);
return g_object_new return g_object_new (DB_TYPE_CALC
(DB_TYPE_CALC, "model", model, "type", type, "col", col, NULL); ,"model", model
,"type", type
,"column-name", column_name
,NULL
);
} }
/** /**
@ -77,8 +80,13 @@ DbCalc * db_calc_new_with_func (DbModel * model, DbCalcType type, DbCalcFunc fun
g_return_val_if_fail (DB_IS_MODEL (model), NULL); g_return_val_if_fail (DB_IS_MODEL (model), NULL);
g_return_val_if_fail (func, NULL); g_return_val_if_fail (func, NULL);
return g_object_new return g_object_new (DB_TYPE_CALC
(DB_TYPE_CALC, "model", model, "type", type, "function", func, "data", data, NULL); ,"model", model
,"type", type
,"function", func
,"data", data
,NULL
);
} }
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private //+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
@ -111,108 +119,194 @@ static gdouble db_calc_value_to_double (const GValue * v)
} }
static void db_calc_internal_func static void db_calc_internal_func
(DbCalc * obj, DbIter * iter, GValue * out, gpointer data) (DbCalc * self, DbIter * iter, GValue * out, gpointer data)
{ {
const GValue * value = db_model_get_value (obj->model, iter, obj->col, NULL); const GValue * value;
g_value_copy (value, g_value_init (out, G_VALUE_TYPE (value)));
if (self->column_index != -1)
{
value = db_model_get_value (self->model, iter, self->column_index, NULL);
g_value_copy (value, g_value_init (out, G_VALUE_TYPE (value)));
}
else
g_value_init (out, GVN_TYPE_NULL);
} }
static void db_calc_before_unset (DbModel * model, DbIter * iter, DbCalc * obj) static void db_calc_reset (DbCalc * self)
{
g_free (self->column_name);
self->column_name = NULL;
self->column_index = -1;
self->func = db_calc_internal_func;
}
static void db_calc_refresh (DbCalc * self)
{
DbIter iter;
gdouble current = 0;
GValue val = G_VALUE_INIT;
DbModel * model = self->model;
self->count = 0;
if (model)
{
DbModelStatus status = db_model_get_status (model);
if (status == DB_MODEL_STATUS_READY && self->column_name)
self->column_index = db_model_get_column_index (model, self->column_name);
if (status == DB_MODEL_STATUS_READY
&& self->column_index != -1
&& db_model_get_iter_first (model, &iter))
{
do {
self->func (self, &iter, &val, self->data);
if (!gvn_value_is_null (&val))
{
current += db_calc_value_to_double (&val);
self->count++;
}
g_value_unset (&val);
}
while (db_model_iter_next (model, &iter));
if (self->type == DB_CALC_TYPE_AVG)
current = (self->count > 0) ? current / (gdouble) self->count : 0;
}
}
if (self->count > 0)
g_value_set_double (g_value_init (&val, G_TYPE_DOUBLE), current);
else
g_value_init (&val, GVN_TYPE_NULL);
GVN_PARAM_GET_CLASS (self)->put_value (GVN_PARAM (self), &val);
g_value_unset (&val);
}
static void db_calc_on_model_refresh (DbModel * model, DbModelStatus status, DbCalc * self)
{
db_calc_refresh (self);
}
static void db_calc_on_update (DbModel * model, DbIter * iter, DbCalc * self)
{ {
GValue value = G_VALUE_INIT; GValue value = G_VALUE_INIT;
obj->func (obj, iter, &value, obj->data); self->func (self, iter, &value, self->data);
if (!gvn_value_is_null (&value)) if (!gvn_value_is_null (&value))
{ {
gdouble current, old; gdouble current, old;
current = db_calc_value_to_double (gvn_param_get_value (GVN_PARAM (obj))); current = db_calc_value_to_double (gvn_param_get_value (GVN_PARAM (self)));
old = db_calc_value_to_double (&value); old = db_calc_value_to_double (&value);
if (obj->type == DB_CALC_TYPE_AVG) if (self->type == DB_CALC_TYPE_AVG)
{ {
if (obj->count != 1) if (self->count != 1)
current = (current * (gdouble) obj->count - old) / (gdouble) (obj->count - 1); current = (current * (gdouble) self->count - old) / (gdouble) (self->count - 1);
else else
current = 0; current = 0;
} }
else if (obj->type == DB_CALC_TYPE_SUM) else if (self->type == DB_CALC_TYPE_SUM)
current -= old; current -= old;
obj->count--; self->count--;
g_value_unset (&value); g_value_unset (&value);
g_value_set_double (g_value_init (&value, G_TYPE_DOUBLE), current); g_value_set_double (g_value_init (&value, G_TYPE_DOUBLE), current);
GVN_PARAM_GET_CLASS (obj)->put_value (GVN_PARAM (obj), &value); GVN_PARAM_GET_CLASS (self)->put_value (GVN_PARAM (self), &value);
} }
g_value_unset (&value); g_value_unset (&value);
} }
static void db_calc_before_delete (DbModel * model, gint path, DbCalc * obj) static void db_calc_on_update_after (DbModel * model, DbIter * iter, DbCalc * self)
{
DbIter iter;
db_model_get_iter (model, &iter, path);
db_calc_before_unset (model, &iter, obj);
}
static void db_calc_after_set (DbModel * model, DbIter * iter, DbCalc * obj)
{ {
GValue value = G_VALUE_INIT; GValue value = G_VALUE_INIT;
obj->func (obj, iter, &value, obj->data); self->func (self, iter, &value, self->data);
if (!gvn_value_is_null (&value)) if (!gvn_value_is_null (&value))
{ {
gdouble current, new; gdouble current, new;
current = db_calc_value_to_double (gvn_param_get_value (GVN_PARAM (obj))); current = db_calc_value_to_double (gvn_param_get_value (GVN_PARAM (self)));
new = db_calc_value_to_double (&value); new = db_calc_value_to_double (&value);
if (obj->type == DB_CALC_TYPE_AVG) if (self->type == DB_CALC_TYPE_AVG)
current = (current * (gdouble) obj->count + new) / (gdouble) (obj->count + 1); current = (current * (gdouble) self->count + new) / (gdouble) (self->count + 1);
else if (obj->type == DB_CALC_TYPE_SUM) else if (self->type == DB_CALC_TYPE_SUM)
current += new; current += new;
obj->count++; self->count++;
g_value_unset (&value); g_value_unset (&value);
g_value_set_double (g_value_init (&value, G_TYPE_DOUBLE), current); g_value_set_double (g_value_init (&value, G_TYPE_DOUBLE), current);
GVN_PARAM_GET_CLASS (obj)->put_value (GVN_PARAM (obj), &value); GVN_PARAM_GET_CLASS (self)->put_value (GVN_PARAM (self), &value);
} }
g_value_unset (&value); g_value_unset (&value);
} }
static void db_calc_refresh (DbModel * model, DbModelStatus status, DbCalc * obj) static void db_calc_on_delete (DbModel * model, gint path, DbCalc * self)
{ {
DbIter iter; DbIter iter;
gdouble current = 0; db_model_get_iter (model, &iter, path);
GValue val = G_VALUE_INIT; db_calc_on_update (model, &iter, self);
}
if (status != DB_MODEL_STATUS_READY) return; //+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
if (!db_model_get_iter_first (model, &iter)) return;
obj->count = 0; void db_calc_set_column_name (DbCalc * self, const gchar * name)
{
g_return_if_fail (DB_IS_CALC (self));
do { db_calc_reset (self);
obj->func (obj, &iter, &val, obj->data); self->column_name = g_strdup (name);
db_calc_refresh (self);
}
if (!gvn_value_is_null (&val)) void db_calc_set_column_index (DbCalc * self, gint index)
{ {
current += db_calc_value_to_double (&val); g_return_if_fail (DB_IS_CALC (self));
obj->count++;
}
g_value_unset (&val); db_calc_reset (self);
self->column_index = index;
db_calc_refresh (self);
}
void db_calc_set_model (DbCalc * self, DbModel * model)
{
g_return_if_fail (DB_IS_CALC (self));
g_return_if_fail (DB_IS_MODEL (model) || !model);
if (self->model)
{
g_object_disconnect (self->model
,"any_signal::line-updated", db_calc_on_update, self
,"any_signal::line-updated", db_calc_on_update_after, self
,"any_signal::line-deleted", db_calc_on_delete, self
,"any_signal::status-changed", db_calc_on_model_refresh, self
,NULL
);
g_clear_object (&self->model);
} }
while (db_model_iter_next (model, &iter)); if (model)
{
if (obj->type == DB_CALC_TYPE_AVG) self->model = g_object_ref (model);
current = (obj->count > 0) ? current / (gdouble) obj->count : 0; g_object_connect (self->model
,"signal::line-updated", db_calc_on_update, self
g_value_set_double (g_value_init (&val, G_TYPE_DOUBLE), current); ,"signal-after::line-updated", db_calc_on_update_after, self
GVN_PARAM_GET_CLASS (obj)->put_value (GVN_PARAM (obj), &val); ,"signal::line-deleted", db_calc_on_delete, self
g_value_unset (&val); ,"signal::status-changed", db_calc_on_model_refresh, self
,NULL
);
}
db_calc_refresh (self);
} }
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class //+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
@ -223,98 +317,91 @@ enum
,PROP_TYPE ,PROP_TYPE
,PROP_FUNC ,PROP_FUNC
,PROP_DATA ,PROP_DATA
,PROP_COL ,PROP_COLUMN_INDEX
,PROP_COLUMN_NAME
}; };
static void db_calc_set_property (DbCalc * obj, guint id, static void db_calc_set_property (DbCalc * self, guint id,
const GValue * value, GParamSpec * pspec) const GValue * value, GParamSpec * pspec)
{ {
switch (id) switch (id)
{ {
case PROP_MODEL: case PROP_MODEL:
obj->model = g_value_dup_object (value); db_calc_set_model (self, g_value_get_object (value));
if (obj->model)
g_object_connect (obj->model
,"signal::line-updated", db_calc_before_unset, obj
,"signal-after::line-updated", db_calc_after_set, obj
,"signal::line-deleted", db_calc_before_delete, obj
,"signal::status-changed", db_calc_refresh, obj
, NULL);
break; break;
case PROP_TYPE: case PROP_TYPE:
obj->type = g_value_get_int (value); self->type = g_value_get_enum (value);
db_calc_refresh (self);
break; break;
case PROP_FUNC: case PROP_FUNC:
db_calc_reset (self);
if (g_value_get_pointer (value)) if (g_value_get_pointer (value))
obj->func = g_value_get_pointer (value); self->func = g_value_get_pointer (value);
db_calc_refresh (self);
break; break;
case PROP_DATA: case PROP_DATA:
obj->data = g_value_get_pointer (value); self->data = g_value_get_pointer (value);
break; break;
case PROP_COL: case PROP_COLUMN_INDEX:
obj->col = g_value_get_int (value); db_calc_set_column_index (self, g_value_get_int (value));
break;
if (!obj->func) case PROP_COLUMN_NAME:
obj->func = db_calc_internal_func; db_calc_set_column_name (self, g_value_get_string (value));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
} }
} }
static void db_calc_get_property (DbCalc * obj, guint id, static void db_calc_get_property (DbCalc * self, guint id,
GValue * value, GParamSpec * pspec) GValue * value, GParamSpec * pspec)
{ {
switch (id) switch (id)
{ {
case PROP_MODEL: case PROP_MODEL:
g_value_set_object (value, obj->model); g_value_set_object (value, self->model);
break; break;
case PROP_TYPE: case PROP_TYPE:
g_value_set_int (value, obj->type); g_value_set_enum (value, self->type);
break; break;
case PROP_FUNC: case PROP_FUNC:
g_value_set_pointer (value, obj->func); g_value_set_pointer (value, self->func);
break; break;
case PROP_DATA: case PROP_DATA:
g_value_set_pointer (value, obj->data); g_value_set_pointer (value, self->data);
break; break;
case PROP_COL: case PROP_COLUMN_INDEX:
g_value_set_int (value, obj->col); g_value_set_int (value, self->column_index);
break;
case PROP_COLUMN_NAME:
g_value_set_string (value, self->column_name);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
} }
} }
static void db_calc_init (DbCalc * obj) static void db_calc_init (DbCalc * self)
{ {
GvnParamSpec * spec; GvnParamSpec * spec;
obj->model = NULL; self->model = NULL;
obj->type = 0; self->type = 0;
obj->func = NULL; self->func = NULL;
obj->data = NULL; self->data = NULL;
obj->col = 0; self->column_index = -1;
obj->count = 0; self->column_name = NULL;
self->count = 0;
spec = gvn_param_spec_new_with_attrs (G_TYPE_DOUBLE, FALSE, TRUE, NULL); spec = gvn_param_spec_new_with_attrs (G_TYPE_DOUBLE, FALSE, TRUE, NULL);
GVN_PARAM_GET_CLASS (obj)->set_spec (GVN_PARAM (obj), spec); GVN_PARAM_GET_CLASS (self)->set_spec (GVN_PARAM (self), spec);
} }
static void db_calc_finalize (DbCalc * obj) static void db_calc_finalize (DbCalc * self)
{ {
if (obj->model) db_calc_set_model (self, NULL);
{ g_free (self->column_name);
g_object_disconnect (obj->model G_OBJECT_CLASS (db_calc_parent_class)->finalize (G_OBJECT (self));
,"any_signal::line-updated", db_calc_before_unset, obj
,"any_signal::line-updated", db_calc_after_set, obj
,"any_signal::line-deleted", db_calc_before_delete, obj
,"any_signal::status-changed", db_calc_refresh, obj
,NULL
);
g_clear_object (&obj->model);
}
} }
static void db_calc_class_init (DbCalcClass * k) static void db_calc_class_init (DbCalcClass * k)
@ -355,13 +442,21 @@ static void db_calc_class_init (DbCalcClass * k)
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE) ,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)
); );
g_object_class_install_property (klass, PROP_COL g_object_class_install_property (klass, PROP_COLUMN_INDEX
,g_param_spec_int ("col" ,g_param_spec_int ("column-index"
,_("Column") ,_("Column index")
,_("A column to apply the operations over it") ,_("A column to apply the operations over it")
,0 ,-1
,G_MAXINT32 ,G_MAXINT
,0 ,-1
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)
);
g_object_class_install_property (klass, PROP_COLUMN_NAME
,g_param_spec_string ("column-name"
,_("Column name")
,_("A column name to apply the operations over it")
,NULL
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE) ,G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)
); );
} }

View File

@ -27,11 +27,11 @@
#define DB_CALC_LOG_DOMAIN (g_quark_from_string ("DbCalc")) #define DB_CALC_LOG_DOMAIN (g_quark_from_string ("DbCalc"))
#define DB_TYPE_CALC (db_calc_get_type ()) #define DB_TYPE_CALC (db_calc_get_type ())
#define DB_CALC(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, DB_TYPE_CALC, DbCalc)) #define DB_CALC(self) (G_TYPE_CHECK_INSTANCE_CAST (self, DB_TYPE_CALC, DbCalc))
#define DB_IS_CALC(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, DB_TYPE_CALC)) #define DB_IS_CALC(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, DB_TYPE_CALC))
#define DB_CALC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((obj), DB_TYPE_CALC, DbCalcClass)) #define DB_CALC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((self), DB_TYPE_CALC, DbCalcClass))
#define DB_IS_CALC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DB_TYPE_CLASS)) #define DB_IS_CALC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DB_TYPE_CLASS))
#define DB_CALC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DB_TYPE_CALC, DbCalcClass)) #define DB_CALC_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS ((self), DB_TYPE_CALC, DbCalcClass))
#define DB_TYPE_CALC_TYPE (db_calc_type_get_type ()) #define DB_TYPE_CALC_TYPE (db_calc_type_get_type ())
@ -40,7 +40,7 @@ typedef struct _DbCalcClass DbCalcClass;
/** /**
* DbCalcFunc: * DbCalcFunc:
* @obj: a #DbCalc * @self: a #DbCalc
* @iter: a #DbIter pointing to a row of the model * @iter: a #DbIter pointing to a row of the model
* @out: the return position for the resulting value * @out: the return position for the resulting value
* @user_data: (closure): the data passed to the function * @user_data: (closure): the data passed to the function
@ -49,7 +49,7 @@ typedef struct _DbCalcClass DbCalcClass;
* on more than one column or to perform additional operations to a column, * on more than one column or to perform additional operations to a column,
* previously to add them to the calculations performed by the @DbCalc itself. * previously to add them to the calculations performed by the @DbCalc itself.
**/ **/
typedef void (*DbCalcFunc) (DbCalc * obj, DbIter * iter, GValue * out, gpointer user_data); typedef void (*DbCalcFunc) (DbCalc * self, DbIter * iter, GValue * out, gpointer user_data);
/** /**
* DbCalcType: * DbCalcType:
@ -61,7 +61,7 @@ typedef void (*DbCalcFunc) (DbCalc * obj, DbIter * iter, GValue * out, gpointer
typedef enum typedef enum
{ {
DB_CALC_TYPE_SUM, DB_CALC_TYPE_SUM,
DB_CALC_TYPE_AVG DB_CALC_TYPE_AVG
} }
DbCalcType; DbCalcType;
@ -73,7 +73,8 @@ struct _DbCalc
DbCalcType type; DbCalcType type;
DbCalcFunc func; DbCalcFunc func;
gpointer data; gpointer data;
guint col; guint column_index;
gchar * column_name;
guint count; guint count;
}; };
@ -88,7 +89,7 @@ GType db_calc_type_get_type ();
DbCalc * db_calc_new (DbModel * model DbCalc * db_calc_new (DbModel * model
,DbCalcType type ,DbCalcType type
,gint col); ,const gchar * column_name);
DbCalc * db_calc_new_with_func (DbModel * model DbCalc * db_calc_new_with_func (DbModel * model
,DbCalcType type ,DbCalcType type
,DbCalcFunc func ,DbCalcFunc func

View File

@ -73,12 +73,18 @@ static void db_iterator_unref_param (DbIterator * obj, DbParam * param)
*/ */
static void db_iterator_row_num_changed (DbIterator * obj) static void db_iterator_row_num_changed (DbIterator * obj)
{ {
if (obj->row_selected) gint new_row = obj->row;
obj->row = db_model_get_path (obj->model, &obj->iter);
else if (obj->selected || !obj->remember_selection)
obj->row = -1;
g_signal_emit (obj, signals[ROW_NUM_CHANGED], 0); if (obj->row_selected)
new_row = db_model_get_path (obj->model, &obj->iter);
else if (obj->selected || !obj->remember_selection)
new_row = -1;
if (new_row != obj->row)
{
obj->row = new_row;
g_signal_emit (obj, signals[ROW_NUM_CHANGED], 0);
}
} }
/* /*
@ -918,6 +924,7 @@ static void db_iterator_set_property (DbIterator * obj, guint id,
break; break;
case PROP_REMEMBER_SELECTION: case PROP_REMEMBER_SELECTION:
obj->remember_selection = g_value_get_boolean (value); obj->remember_selection = g_value_get_boolean (value);
db_iterator_row_num_changed (obj);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);

View File

@ -1312,6 +1312,7 @@ const gchar * db_model_get_column_name (DbModel * self, gint col)
&& col < self->priv->result->ncols) && col < self->priv->result->ncols)
&& self->priv->column) && self->priv->column)
return self->priv->column[col].alias; return self->priv->column[col].alias;
return NULL; return NULL;
} }
@ -1327,12 +1328,15 @@ const gchar * db_model_get_column_name (DbModel * self, gint col)
**/ **/
gint db_model_get_column_index (DbModel * self, const gchar * name) gint db_model_get_column_index (DbModel * self, const gchar * name)
{ {
gpointer column;
g_return_val_if_fail (DB_IS_MODEL (self), -1); g_return_val_if_fail (DB_IS_MODEL (self), -1);
if (!name || !self->priv->column_index) if (name && self->priv->column_index
return -1; && g_hash_table_lookup_extended (self->priv->column_index, name, NULL, &column))
return GPOINTER_TO_INT (column);
return GPOINTER_TO_INT (g_hash_table_lookup (self->priv->column_index, name)); return -1;
} }
/** /**
@ -2292,7 +2296,7 @@ gboolean db_model_has_pending_operations (DbModel * self)
} }
static SqlObject * db_model_create_where (DbModel * self, static SqlObject * db_model_create_where (DbModel * self,
TableInfo * tinfo, DbOperation * operation, gboolean for_insert) TableInfo * tinfo, DbOperation * operation, gboolean use_new_values)
{ {
GSList * l; GSList * l;
DbUpdatedField * u; DbUpdatedField * u;
@ -2322,7 +2326,7 @@ static SqlObject * db_model_create_where (DbModel * self,
g_value = &row->value[col]; g_value = &row->value[col];
if (!for_insert) if (!use_new_values)
{ {
for (n = operation->updated; n && (u = n->data); n = n->next) for (n = operation->updated; n && (u = n->data); n = n->next)
if (u->column == col) if (u->column == col)
@ -2350,7 +2354,7 @@ static SqlObject * db_model_create_where (DbModel * self,
g_object_unref (g_object_ref_sink (where)); g_object_unref (g_object_ref_sink (where));
return NULL; return NULL;
} }
equal = sql_operation_new (SQL_OPERATION_TYPE_EQUAL); equal = sql_operation_new (SQL_OPERATION_TYPE_EQUAL);
sql_list_add (and_operands, equal); sql_list_add (and_operands, equal);

View File

@ -7,7 +7,7 @@ example_DATA = \
example-menu.xml \ example-menu.xml \
consulter.glade \ consulter.glade \
consulter-menu.xml consulter-menu.xml
# customer.glade customer.glade
# signer.glade # signer.glade
EXTRA_DIST = $(example_DATA) EXTRA_DIST = $(example_DATA)

View File

@ -4,11 +4,45 @@
<requires lib="gtk+" version="3.0"/> <requires lib="gtk+" version="3.0"/>
<requires lib="vn" version="0.0"/> <requires lib="vn" version="0.0"/>
<!-- interface-local-resource-path ../image --> <!-- interface-local-resource-path ../image -->
<object class="DbIterator" id="homes"> <object class="VnBatch" id="models">
<property name="sql">SELECT id, street, pc, city, province, ok, user_id FROM user_address WHERE #link ORDER BY id</property> <child>
<object class="VnModel" id="object-model">
<property name="sql">SELECT id, object FROM object</property>
</object>
</child>
<child>
<object class="VnModel" id="homes-model">
<property name="sql">SELECT id, street, pc, city, province, ok, user_id
FROM user_address WHERE #link ORDER BY id</property>
<property name="update_flags">DB_MODEL_INSERT | DB_MODEL_DELETE | DB_MODEL_UPDATE</property>
<links>
<link field="user_address.user_id" param="id-param" linked="True"/>
</links>
</object>
</child>
<child>
<object class="VnModel" id="info-model">
<property name="sql">SELECT id, name, credit, active, born, photo, object_id
FROM "user" ORDER BY id</property>
<property name="update_flags">DB_MODEL_INSERT | DB_MODEL_DELETE | DB_MODEL_UPDATE</property>
</object>
</child>
<child>
<object class="VnModel" id="searcher-model">
<property name="sql">SELECT id, #field FROM article WHERE #filter</property>
</object>
</child>
</object> </object>
<object class="DbIterator" id="info"> <object class="VnIterator" id="homes">
<property name="sql">SELECT id, name, credit, active, born, photo, object_id FROM "user" ORDER BY id</property> <property name="model">homes-model</property>
</object>
<object class="VnIterator" id="info">
<property name="model">info-model</property>
<child>
<object class="DbParam" id="id-param">
<property name="column_name">id</property>
</object>
</child>
</object> </object>
<object class="GtkBox" id="main"> <object class="GtkBox" id="main">
<property name="visible">True</property> <property name="visible">True</property>
@ -55,6 +89,7 @@
<object class="VnCompletion" id="searcher"> <object class="VnCompletion" id="searcher">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="model">searcher-model</property>
<property name="field">name</property> <property name="field">name</property>
</object> </object>
<packing> <packing>
@ -152,6 +187,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="iterator">info</property> <property name="iterator">info</property>
<property name="column_name">object_id</property> <property name="column_name">object_id</property>
<property name="model">object-model</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
@ -214,6 +250,7 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="iterator">info</property> <property name="iterator">info</property>
<property name="column_name">born</property> <property name="column_name">born</property>
<property name="show_time">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -234,7 +271,7 @@
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
@ -250,7 +287,6 @@
<object class="VnHandler" id="customer-handler"> <object class="VnHandler" id="customer-handler">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="layout_style">end</property>
<property name="iterator">info</property> <property name="iterator">info</property>
<property name="show_flags">VN_HANDLER_SHOW_REFRESH | VN_HANDLER_SHOW_UNDO | VN_HANDLER_SHOW_SAVE | VN_HANDLER_SHOW_REMOVE | VN_HANDLER_SHOW_ADD | VN_HANDLER_SHOW_SCROLL</property> <property name="show_flags">VN_HANDLER_SHOW_REFRESH | VN_HANDLER_SHOW_UNDO | VN_HANDLER_SHOW_SAVE | VN_HANDLER_SHOW_REMOVE | VN_HANDLER_SHOW_ADD | VN_HANDLER_SHOW_SCROLL</property>
</object> </object>
@ -364,7 +400,6 @@
<object class="VnHandler" id="address-handler"> <object class="VnHandler" id="address-handler">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="layout_style">end</property>
<property name="iterator">homes</property> <property name="iterator">homes</property>
<property name="show_flags">VN_HANDLER_SHOW_REFRESH | VN_HANDLER_SHOW_UNDO | VN_HANDLER_SHOW_SAVE | VN_HANDLER_SHOW_REMOVE | VN_HANDLER_SHOW_ADD</property> <property name="show_flags">VN_HANDLER_SHOW_REFRESH | VN_HANDLER_SHOW_UNDO | VN_HANDLER_SHOW_SAVE | VN_HANDLER_SHOW_REMOVE | VN_HANDLER_SHOW_ADD</property>
</object> </object>

View File

@ -8,5 +8,11 @@
icon="system-run"> icon="system-run">
Consulter Consulter
</form> </form>
<form
translatable="yes"
name="customer"
icon="system-run">
Customer
</form>
</form-group> </form-group>
</module> </module>

View File

@ -11,9 +11,9 @@ libexample_la_LDFLAGS = -avoid-version
libexample_la_LIBADD = $(top_builddir)/vn/libvn.la libexample_la_LIBADD = $(top_builddir)/vn/libvn.la
libexample_la_SOURCES = \ libexample_la_SOURCES = \
vn-consulter.h \ vn-consulter.h \
vn-consulter.c vn-consulter.c \
# vn-customer.h vn-customer.h \
# vn-customer.c vn-customer.c
example_querydir = $(module_querydir)/example example_querydir = $(module_querydir)/example
example_query_DATA = ../sql/example/consulter.sql example_query_DATA = ../sql/example/consulter.sql

View File

@ -41,17 +41,18 @@ SqlBatch * sql_batch_new ()
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private //+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void sql_batch_item_changed (SqlObject * item, SqlBatch * obj) static void sql_batch_item_changed (SqlObject * item, SqlBatch * self)
{ {
sql_batch_changed (obj); if (!self->frozen)
sql_batch_changed (self);
} }
static void sql_batch_free_item (SqlBatch * obj, SqlObject * item) static void sql_batch_free_item (SqlBatch * self, SqlObject * item)
{ {
if (item) if (item)
{ {
g_signal_handlers_disconnect_by_func (item, g_signal_handlers_disconnect_by_func (item,
sql_batch_item_changed, obj); sql_batch_item_changed, self);
g_object_unref (item); g_object_unref (item);
} }
} }
@ -60,20 +61,20 @@ static void sql_batch_free_item (SqlBatch * obj, SqlObject * item)
/** /**
* sql_batch_is_ready: * sql_batch_is_ready:
* @obj: a #SqlBatch * @self: a #SqlBatch
* *
* Checks if @obj and all of its elements are ready to be rendered. * Checks if @self and all of its elements are ready to be rendered.
* *
* Return value: %TRUE if ready, %FALSE otherwise. * Return value: %TRUE if ready, %FALSE otherwise.
**/ **/
gboolean sql_batch_is_ready (SqlBatch * obj) gboolean sql_batch_is_ready (SqlBatch * self)
{ {
gpointer item; gpointer item;
GHashTableIter iter; GHashTableIter iter;
g_return_val_if_fail (SQL_IS_BATCH (obj), FALSE); g_return_val_if_fail (SQL_IS_BATCH (self), FALSE);
g_hash_table_iter_init (&iter, obj->items); g_hash_table_iter_init (&iter, self->items);
while (g_hash_table_iter_next (&iter, NULL, &item)) while (g_hash_table_iter_next (&iter, NULL, &item))
if (!item || !sql_object_is_ready (item)) if (!item || !sql_object_is_ready (item))
@ -84,7 +85,7 @@ gboolean sql_batch_is_ready (SqlBatch * obj)
/** /**
* sql_batch_get: * sql_batch_get:
* @obj: a #SqlBatch * @self: a #SqlBatch
* @id: the id of the #SqlHolder * @id: the id of the #SqlHolder
* *
* Gets a held object by its id. * Gets a held object by its id.
@ -92,107 +93,108 @@ gboolean sql_batch_is_ready (SqlBatch * obj)
* Return value: (transfer none): the #SqlObject if an object with that id * Return value: (transfer none): the #SqlObject if an object with that id
* exists, %NULL otherwise * exists, %NULL otherwise
**/ **/
SqlObject * sql_batch_get (SqlBatch * obj, const gchar * id) SqlObject * sql_batch_get (SqlBatch * self, const gchar * id)
{ {
g_return_val_if_fail (SQL_IS_BATCH (obj), NULL); g_return_val_if_fail (SQL_IS_BATCH (self), NULL);
g_return_val_if_fail (id, NULL); g_return_val_if_fail (id, NULL);
if (obj->items) if (self->items)
return g_hash_table_lookup (obj->items, id); return g_hash_table_lookup (self->items, id);
return NULL; return NULL;
} }
/** /**
* sql_batch_add: * sql_batch_add:
* @obj: a #SqlBatch * @self: a #SqlBatch
* @id: the id of the #SqlHolder * @id: the id of the #SqlHolder
* @item: the #SqlObject * @item: the #SqlObject
* *
* Adds a new item to the batch. * Adds a new item to the batch.
**/ **/
void sql_batch_add (SqlBatch * obj, const gchar * id, SqlObject * item) void sql_batch_add (SqlBatch * self, const gchar * id, SqlObject * item)
{ {
g_return_if_fail (SQL_IS_BATCH (obj)); g_return_if_fail (SQL_IS_BATCH (self));
g_return_if_fail (id); g_return_if_fail (id);
g_return_if_fail (SQL_IS_OBJECT (item) || !item); g_return_if_fail (SQL_IS_OBJECT (item) || !item);
sql_batch_remove (obj, id); sql_batch_remove (self, id);
if (item) if (item)
{ {
g_object_ref_sink (item); g_object_ref_sink (item);
g_signal_connect (item, "changed", g_signal_connect (item, "changed",
G_CALLBACK (sql_batch_item_changed), obj); G_CALLBACK (sql_batch_item_changed), self);
} }
g_hash_table_replace (obj->items, g_strdup (id), item); g_hash_table_replace (self->items, g_strdup (id), item);
sql_batch_item_changed (NULL, self);
} }
/** /**
* sql_batch_add_from_param: * sql_batch_add_param:
* @obj: a #SqlBatch * @self: a #SqlBatch
* @id: the id assigned to the item * @id: the id assigned to the item
* @param: the parameter
**/ **/
void sql_batch_add_from_param (SqlBatch * obj, const gchar * id, GvnParam * param) void sql_batch_add_from_param (SqlBatch * self, const gchar * id, GvnParam * param)
{ {
g_return_if_fail (SQL_IS_BATCH (obj)); g_return_if_fail (SQL_IS_BATCH (self));
g_return_if_fail (id); g_return_if_fail (id);
g_return_if_fail (GVN_IS_PARAM (param)); g_return_if_fail (GVN_IS_PARAM (param));
sql_batch_add (obj, id, sql_value_new_with_param (param)); sql_batch_add (self, id, sql_value_new_with_param (param));
} }
/** /**
* sql_batch_add_from_value: * sql_batch_add_value:
* @obj: a #SqlBatch * @self: a #SqlBatch
* @id: the id assigned to the item * @id: the id assigned to the item
* @value: the value
**/ **/
void sql_batch_add_from_value (SqlBatch * obj, const gchar * id, GType type, gpointer content) void sql_batch_add_from_value (SqlBatch * self, const gchar * id, const GValue * value)
{ {
g_return_if_fail (SQL_IS_BATCH (obj)); g_return_if_fail (SQL_IS_BATCH (self));
g_return_if_fail (id); g_return_if_fail (id);
g_return_if_fail (G_IS_VALUE (value));
GValue gvalue = {0}; sql_batch_add (self, id, sql_value_new_with_value (value));
gvn_value_new_with_content (&gvalue, type, content);
sql_batch_add (obj, id, sql_value_new_with_value (&gvalue));
g_value_unset (&gvalue);
} }
/** /**
* sql_batch_remove: * sql_batch_remove:
* @obj: a #SqlBatch * @self: a #SqlBatch
* @id: the id of the #SqlHolder * @id: the id of the #SqlHolder
* *
* Removes a held object from the batch. * Removes a held object from the batch.
**/ **/
void sql_batch_remove (SqlBatch * obj, const gchar * id) void sql_batch_remove (SqlBatch * self, const gchar * id)
{ {
g_return_val_if_fail (SQL_IS_BATCH (obj), NULL); g_return_val_if_fail (SQL_IS_BATCH (self), NULL);
g_return_val_if_fail (id, NULL); g_return_val_if_fail (id, NULL);
SqlObject * item = sql_batch_get (obj, id); SqlObject * item = sql_batch_get (self, id);
if (item) if (item)
{ {
sql_batch_free_item (obj, item); sql_batch_free_item (self, item);
g_hash_table_remove (obj->items, id); g_hash_table_remove (self->items, id);
} }
} }
/** /**
* sql_batch_merge: * sql_batch_merge:
* @obj: a #SqlBatch * @self: a #SqlBatch
* @batch: a #SqlBatch * @batch: a #SqlBatch
* *
* Meges the batch with another batch. * Meges the batch with another batch.
**/ **/
void sql_batch_merge (SqlBatch * obj, SqlBatch * batch) void sql_batch_merge (SqlBatch * self, SqlBatch * batch)
{ {
GHashTableIter iter; GHashTableIter iter;
gpointer key, value; gpointer key, value;
g_return_if_fail (SQL_IS_BATCH (obj)); g_return_if_fail (SQL_IS_BATCH (self));
g_return_if_fail (SQL_IS_BATCH (batch) || !batch); g_return_if_fail (SQL_IS_BATCH (batch) || !batch);
if (!batch) if (!batch)
@ -201,47 +203,74 @@ void sql_batch_merge (SqlBatch * obj, SqlBatch * batch)
g_hash_table_iter_init (&iter, batch->items); g_hash_table_iter_init (&iter, batch->items);
while (g_hash_table_iter_next (&iter, &key, &value)) while (g_hash_table_iter_next (&iter, &key, &value))
sql_batch_add (obj, key, value); sql_batch_add (self, key, value);
} }
/** /**
* sql_batch_changed: * sql_batch_changed:
* @obj: a #SqlBatch * @self: a #SqlBatch
* *
* Emits the changed signal on #SqlBatch. * Emits the changed signal on #SqlBatch.
**/ **/
void sql_batch_changed (SqlBatch * obj) void sql_batch_changed (SqlBatch * self)
{ {
g_return_if_fail (SQL_IS_BATCH (obj)); g_return_if_fail (SQL_IS_BATCH (self));
g_signal_emit (obj, signals[CHANGED], 0); g_signal_emit (self, signals[CHANGED], 0);
}
/**
* sql_batch_freeze:
* @self: a #SqlBatch
*
* Freezes the changed signal on #SqlBatch.
**/
void sql_batch_freeze (SqlBatch * self)
{
g_return_if_fail (SQL_IS_BATCH (self));
self->frozen = TRUE;
}
/**
* sql_batch_unfreeze:
* @self: a #SqlBatch
*
* Unfreezes the changed signal on #SqlBatch.
**/
void sql_batch_unfreeze (SqlBatch * self)
{
g_return_if_fail (SQL_IS_BATCH (self));
self->frozen = FALSE;
} }
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class //+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_batch_init (SqlBatch * obj) static void sql_batch_init (SqlBatch * self)
{ {
obj->items = g_hash_table_new_full ( self->items = g_hash_table_new_full (
g_str_hash g_str_hash
,g_str_equal ,g_str_equal
,g_free ,g_free
,NULL ,NULL
); );
self->frozen = FALSE;
} }
static void sql_batch_finalize (SqlBatch * obj) static void sql_batch_finalize (SqlBatch * self)
{ {
gpointer item; gpointer item;
GHashTableIter iter; GHashTableIter iter;
g_hash_table_iter_init (&iter, obj->items); g_hash_table_iter_init (&iter, self->items);
while (g_hash_table_iter_next (&iter, NULL, &item)) while (g_hash_table_iter_next (&iter, NULL, &item))
sql_batch_free_item (obj, item); sql_batch_free_item (self, item);
g_hash_table_destroy (obj->items); g_hash_table_destroy (self->items);
G_OBJECT_CLASS (sql_batch_parent_class)->finalize (G_OBJECT (obj)); G_OBJECT_CLASS (sql_batch_parent_class)->finalize (G_OBJECT (self));
} }
static void sql_batch_class_init (SqlBatchClass * klass) static void sql_batch_class_init (SqlBatchClass * klass)
@ -250,7 +279,7 @@ static void sql_batch_class_init (SqlBatchClass * klass)
/** /**
* SqlBatch::changed: * SqlBatch::changed:
* @obj: the object which emit the signal. * @self: the object which emit the signal.
* *
* This signal is emitted every time the batch or one of its attributes * This signal is emitted every time the batch or one of its attributes
* is modified. * is modified.

View File

@ -21,10 +21,10 @@
#include <glib-object.h> #include <glib-object.h>
#define SQL_TYPE_BATCH (sql_batch_get_type ()) #define SQL_TYPE_BATCH (sql_batch_get_type ())
#define SQL_BATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_BATCH, SqlBatch)) #define SQL_BATCH(self) (G_TYPE_CHECK_INSTANCE_CAST (self, SQL_TYPE_BATCH, SqlBatch))
#define SQL_IS_BATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_BATCH)) #define SQL_IS_BATCH(self) (G_TYPE_CHECK_INSTANCE_TYPE (self, SQL_TYPE_BATCH))
#define SQL_BATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, SQL_TYPE_BATCH, SqlBatchClass)) #define SQL_BATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, SQL_TYPE_BATCH, SqlBatchClass))
#define SQL_BATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, SQL_TYPE_BATCH, SqlBatchClass)) #define SQL_BATCH_GET_CLASS(self) (G_TYPE_INSTANCE_GET_CLASS (self, SQL_TYPE_BATCH, SqlBatchClass))
typedef struct _SqlBatch SqlBatch; typedef struct _SqlBatch SqlBatch;
typedef struct _SqlBatchClass SqlBatchClass; typedef struct _SqlBatchClass SqlBatchClass;
@ -33,6 +33,7 @@ struct _SqlBatch
{ {
GInitiallyUnowned parent; GInitiallyUnowned parent;
GHashTable * items; GHashTable * items;
gboolean frozen;
}; };
struct _SqlBatchClass struct _SqlBatchClass
@ -45,13 +46,15 @@ struct _SqlBatchClass
GType sql_batch_get_type (); GType sql_batch_get_type ();
SqlBatch * sql_batch_new (); SqlBatch * sql_batch_new ();
gboolean sql_batch_is_ready (SqlBatch * obj); gboolean sql_batch_is_ready (SqlBatch * self);
SqlObject * sql_batch_get (SqlBatch * obj, const gchar * id); SqlObject * sql_batch_get (SqlBatch * self, const gchar * id);
void sql_batch_add (SqlBatch * obj, const gchar * id, SqlObject * item); void sql_batch_add (SqlBatch * self, const gchar * id, SqlObject * item);
void sql_batch_add_from_param (SqlBatch * obj, const gchar * id, GvnParam * param); void sql_batch_add_from_param (SqlBatch * self, const gchar * id, GvnParam * param);
void sql_batch_add_from_value (SqlBatch * obj, const gchar * id, GType type, gpointer content); void sql_batch_add_from_value (SqlBatch * self, const gchar * id, const GValue * value);
void sql_batch_remove (SqlBatch * obj, const gchar * id); void sql_batch_remove (SqlBatch * self, const gchar * id);
void sql_batch_merge (SqlBatch * obj, SqlBatch * batch); void sql_batch_merge (SqlBatch * self, SqlBatch * batch);
void sql_batch_changed (SqlBatch * obj); void sql_batch_changed (SqlBatch * self);
void sql_batch_freeze (SqlBatch * self);
void sql_batch_unfreeze (SqlBatch * self);
#endif #endif

View File

@ -63,7 +63,10 @@ static void sql_value_render (SqlValue * obj, SqlRender * render)
sql_render_printf (render, "'%c'", g_value_get_schar (value)); sql_render_printf (render, "'%c'", g_value_get_schar (value));
break; break;
case G_TYPE_INT: case G_TYPE_INT:
sql_render_printf (render, "%i", g_value_get_int (value)); sql_render_printf (render, "%d", g_value_get_int (value));
break;
case G_TYPE_INT64:
sql_render_printf (render, "%lld", g_value_get_int64 (value));
break; break;
case G_TYPE_UINT: case G_TYPE_UINT:
sql_render_printf (render, "%u", g_value_get_uint (value)); sql_render_printf (render, "%u", g_value_get_uint (value));

View File

@ -210,8 +210,14 @@ static void vn_column_spin_init (VnColumnSpin * obj)
{ {
GtkCellRenderer * cell = gtk_cell_renderer_spin_new (); GtkCellRenderer * cell = gtk_cell_renderer_spin_new ();
obj->adjustment = gtk_adjustment_new (0.0, G_MININT, G_MAXINT, 0.0, 1.0, 0.0); obj->adjustment = gtk_adjustment_new (0.0, G_MININT, G_MAXINT, 0.0, 1.0, 0.0);
g_object_set (cell, "adjustment", obj->adjustment, NULL);
g_object_set (cell
,"adjustment", obj->adjustment
,"xalign", 1.0
,"alignment", PANGO_ALIGN_RIGHT
,NULL
);
obj->format = NULL; obj->format = NULL;

View File

@ -93,7 +93,7 @@ static void vn_completion_cb_status_changed (DbModel * model,
static void vn_completion_cb_changed (GtkEditable * entry, VnCompletion * obj) static void vn_completion_cb_changed (GtkEditable * entry, VnCompletion * obj)
{ {
const gchar * text = gtk_entry_get_text (GTK_ENTRY (entry)); const gchar * text = gtk_entry_get_text (GTK_ENTRY (entry));
if (obj->invalid) if (obj->invalid)
{ {
obj->invalid = FALSE; obj->invalid = FALSE;
@ -124,7 +124,7 @@ static void vn_completion_cb_changed (GtkEditable * entry, VnCompletion * obj)
static void vn_completion_iter_changed (VnCompletion * obj, DbIter * iter) static void vn_completion_iter_changed (VnCompletion * obj, DbIter * iter)
{ {
const GValue * value = db_model_get_value (obj->model, iter, 0, NULL); const GValue * value = db_model_get_value (obj->model, iter, 0, NULL);
if (value) if (value)
VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), value); VN_FIELD_GET_CLASS (obj)->value_changed (VN_FIELD (obj), value);

View File

@ -76,7 +76,8 @@ static void vn_column_data_func (GtkTreeViewColumn * col, GtkCellRenderer * cell
else else
background = NULL; background = NULL;
g_object_set (cell, "cell-background-rgba", background, NULL); if (background)
g_object_set (cell, "cell-background-rgba", background, NULL);
if (obj->style_func) if (obj->style_func)
obj->style_func (VN_COLUMN (col), cell, iter, &value); obj->style_func (VN_COLUMN (col), cell, iter, &value);
@ -420,7 +421,7 @@ static void vn_column_set_property (VnColumn * obj, guint id,
case PROP_STYLE_FUNC: case PROP_STYLE_FUNC:
obj->style_func = g_value_get_pointer (value); obj->style_func = g_value_get_pointer (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
} }
} }

View File

@ -473,7 +473,9 @@ static void vn_handler_init (VnHandler * obj)
obj->buttons = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON_BOX obj->buttons = GTK_WIDGET (g_object_new (GTK_TYPE_BUTTON_BOX
,"layout-style", GTK_BUTTONBOX_EXPAND ,"layout-style", GTK_BUTTONBOX_EXPAND
,"homogeneous", FALSE ,"homogeneous", FALSE
,NULL)); ,"halign", GTK_ALIGN_END
,NULL
));
context = gtk_widget_get_style_context (obj->buttons); context = gtk_widget_get_style_context (obj->buttons);
provider = gtk_css_provider_get_default (); provider = gtk_css_provider_get_default ();