diff --git a/autogen.sh b/autogen.sh index 5d770a0..be57f3c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,5 +1,15 @@ -gtkdocize --copy -autoreconf -fi -glib-gettextize --force --copy +#!/bin/sh + +test -n "$srcdir" || srcdir=`dirname "$0"` +test -n "$srcdir" || srcdir=. + +builddir=`pwd` +mkdir -p $builddir/m4 + +cd $srcdir +gtkdocize --copy && +autoreconf -fi && +glib-gettextize --copy --force && intltoolize --copy --force --automake -automake --add-missing --copy + +exit $? diff --git a/configure.ac b/configure.ac index d3454e2..e757bc8 100644 --- a/configure.ac +++ b/configure.ac @@ -87,8 +87,6 @@ AM_CONDITIONAL(ENABLE_INSTALL, [test x"$ENABLE_INSTALL" = x"yes"]) if test x"$ENABLE_INSTALL" = x"yes"; then CFLAGS+=" -O3" -else - CFLAGS+=" -O0" fi AC_SUBST([CPPFLAGS]) @@ -117,7 +115,6 @@ AC_CONFIG_FILES([ module/Makefile module/src/Makefile module/data/Makefile - module/sql/Makefile main/Makefile main/vn-hedera.desktop vapi/Makefile diff --git a/module/data/example.ui b/module/data/example.ui index b290204..8b8fc78 100644 --- a/module/data/example.ui +++ b/module/data/example.ui @@ -5,6 +5,7 @@ + diff --git a/module/data/example.xml b/module/data/example.xml index 9729d1e..92190cd 100644 --- a/module/data/example.xml +++ b/module/data/example.xml @@ -33,5 +33,13 @@ accel="F5"> Customer +
+ Allocator +
diff --git a/module/src/Makefile.am b/module/src/Makefile.am index aed27ca..7230329 100644 --- a/module/src/Makefile.am +++ b/module/src/Makefile.am @@ -14,7 +14,9 @@ libexample_la_SOURCES = \ vn-users.h \ vn-users.c \ vn-customer.h \ - vn-customer.c + vn-customer.c \ + vn-allocator.h \ + vn-allocator.c install-data-hook: rm -f $(DESTDIR)$(module_libdir)/libexample.la diff --git a/sql/sql-batch.c b/sql/sql-batch.c index cbbe885..202961f 100644 --- a/sql/sql-batch.c +++ b/sql/sql-batch.c @@ -47,7 +47,7 @@ static void sql_batch_child_changed (SqlBatch * child, SqlBatch * obj) * sql_batch_is_ready: * @obj: a #SqlBatch * - * Checks if @obj and all of its elemens are ready to be rendered. + * Checks if @obj and all of its elements are ready to be rendered. * * Return value: %TRUE if ready, %FALSE otherwise. **/ diff --git a/sql/sql-holder.c b/sql/sql-holder.c index 13c3f33..12cae6b 100644 --- a/sql/sql-holder.c +++ b/sql/sql-holder.c @@ -45,6 +45,11 @@ static void sql_holder_render (SqlHolder * obj, SqlRender * render) sql_render_printf (render, "#%s", obj->id); } +static void sql_holder_find_holders (SqlHolder * obj, GQueue * holders) +{ + g_queue_push_tail (holders, obj->id); +} + //+++++++++++++++++++++++++++++++++++++++++++++++++++ Public /** @@ -116,6 +121,7 @@ static void sql_holder_class_init (SqlHolderClass * k) klass->set_property = (GObjectSetPropertyFunc) sql_holder_set_property; klass->get_property = (GObjectGetPropertyFunc) sql_holder_get_property; SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_holder_render; + SQL_OBJECT_CLASS (klass)->find_holders = (SqlObjectFindHoldersFunc) sql_holder_find_holders; g_object_class_install_property (klass, PROP_ID, g_param_spec_string ("id" diff --git a/sql/sql-list.c b/sql/sql-list.c index 0b52408..12d9011 100644 --- a/sql/sql-list.c +++ b/sql/sql-list.c @@ -35,7 +35,7 @@ static void sql_list_render (SqlList * obj, SqlRender * render) { GList * i; - for (i = obj->items.tail; i; i = i->next) + for (i = obj->items.head; i; i = i->next) { sql_render_add_object (render, i->data); @@ -48,13 +48,21 @@ static gboolean sql_list_is_ready (SqlList * obj) { GList * i; - for (i = obj->items.tail; i; i = i->next) + for (i = obj->items.head; i; i = i->next) if (!sql_object_is_ready (i->data)) return FALSE; return TRUE; } +static void sql_list_find_holders (SqlList * obj, GQueue * holders) +{ + GList * i; + + for (i = obj->items.head; i; i = i->next) + sql_object_get_holders (i->data, holders); +} + static void sql_list_item_changed (SqlObject * item, SqlObject * obj) { sql_object_changed (obj); @@ -93,7 +101,7 @@ void sql_list_insert (SqlList * obj, gpointer item, guint n) if (n > 0) g_queue_push_nth (&obj->items, g_object_ref_sink (item), n); else - g_queue_push_head (&obj->items, g_object_ref_sink (item)); + g_queue_push_tail (&obj->items, g_object_ref_sink (item)); g_signal_connect (item, "changed", G_CALLBACK (sql_list_item_changed), obj @@ -148,7 +156,7 @@ GList * sql_list_get_items (SqlList * obj) { g_return_val_if_fail (SQL_IS_LIST (obj), NULL); - return obj->items.tail; + return obj->items.head; } /** @@ -229,7 +237,7 @@ static void sql_list_finalize (SqlList * obj) { GList * i; - for (i = obj->items.tail; i; i = i->next) + for (i = obj->items.head; i; i = i->next) { g_signal_handlers_disconnect_by_func (i->data, sql_list_item_changed, obj); @@ -248,6 +256,7 @@ static void sql_list_class_init (SqlListClass * k) klass->get_property = (GObjectGetPropertyFunc) sql_list_get_property; SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_list_render; SQL_OBJECT_CLASS (klass)->is_ready = (SqlObjectIsReadyFunc) sql_list_is_ready; + SQL_OBJECT_CLASS (klass)->find_holders = (SqlObjectFindHoldersFunc) sql_list_find_holders; g_object_class_install_property (klass, PROP_LENGTH, g_param_spec_uint ("length" diff --git a/sql/sql-object.c b/sql/sql-object.c index 8715a88..6274227 100644 --- a/sql/sql-object.c +++ b/sql/sql-object.c @@ -41,6 +41,24 @@ static void sql_object_child_changed (SqlObject * child, SqlObject * obj) sql_object_changed (obj); } +static void sql_object_find_holders (SqlObject * obj, GQueue * holders) +{ + guint i; + guint nparams; + GParamSpec ** params; + + params = g_object_class_list_properties (G_OBJECT_GET_CLASS (obj), &nparams); + + for (i = 0; i < nparams; i++) + if (SQL_IS_PARAM_OBJECT (params[i]) || SQL_IS_PARAM_LIST (params[i])) + { + SqlObject * child = sql_object_get (obj, params[i]->name); + sql_object_get_holders (child, holders); + } + + g_free (params); +} + //+++++++++++++++++++++++++++++++++++++++++++++++++++ Protected /** @@ -177,6 +195,23 @@ void sql_object_remove_child (SqlObject * obj, const gchar * property, guint n) sql_list_remove (list, n); } +/** + * sql_object_get_holders: + * @obj: a #SqlObject + * @holders: a #GQueue + * + * Gets all identifiers of the contained holders. + **/ +void sql_object_get_holders (SqlObject * obj, GQueue * holders) +{ + if (!obj) + return; + + g_return_if_fail (SQL_IS_OBJECT (obj)); + + SQL_OBJECT_GET_CLASS (obj)->find_holders (obj, holders); +} + /** * sql_object_changed: * @obj: a #SqlObject @@ -200,6 +235,7 @@ static void sql_object_finalize (SqlObject * obj) static void sql_object_class_init (SqlObjectClass * klass) { G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) sql_object_finalize; + klass->find_holders = sql_object_find_holders; klass->is_ready = NULL; klass->render = NULL; diff --git a/sql/sql-object.h b/sql/sql-object.h index fa4694a..52f8911 100644 --- a/sql/sql-object.h +++ b/sql/sql-object.h @@ -31,7 +31,8 @@ typedef struct _SqlObject SqlObject; typedef struct _SqlObjectClass SqlObjectClass; -typedef gboolean (* SqlObjectIsReadyFunc) (SqlObject * obj); +typedef gboolean (* SqlObjectIsReadyFunc) (SqlObject * obj); +typedef void (* SqlObjectFindHoldersFunc) (SqlObject * obj, GQueue * holders); struct _SqlObject { @@ -44,6 +45,7 @@ struct _SqlObjectClass GInitiallyUnownedClass parent; gpointer /* SqlRenderFunc */ render; SqlObjectIsReadyFunc is_ready; + SqlObjectFindHoldersFunc find_holders; }; #include "sql-holder.h" @@ -53,6 +55,7 @@ struct _SqlObjectClass GType sql_object_get_type (); void sql_object_render (SqlObject * obj, SqlRender * render); gboolean sql_object_is_ready (SqlObject * obj); +void sql_object_get_holders (SqlObject * obj, GQueue * holders); void sql_object_set (SqlObject * obj, const gchar * property, SqlObject * set); SqlObject * sql_object_get (SqlObject * obj, const gchar * property); @@ -63,4 +66,4 @@ void sql_object_changed (SqlObject * obj); gpointer sql_object_add (gpointer obj, gpointer child); void sql_object_remove (gpointer obj, gpointer child); -#endif +#endif \ No newline at end of file diff --git a/sql/sql-param-list.h b/sql/sql-param-list.h index 0067b6f..3f6e210 100644 --- a/sql/sql-param-list.h +++ b/sql/sql-param-list.h @@ -21,8 +21,8 @@ #include "sql-object.h" #define SQL_TYPE_PARAM_LIST (sql_param_list_get_type ()) -#define SQL_PARAM_LIST(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SQL_TYPE_PARAM_LIST, SqlParamList)) - +#define SQL_PARAM_LIST(pspec) (G_TYPE_CHECK_INSTANCE_CAST (pspec, SQL_TYPE_PARAM_LIST, SqlParamList)) +#define SQL_IS_PARAM_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_PARAM_LIST)) typedef struct { diff --git a/sql/sql-param-object.h b/sql/sql-param-object.h index 72a5f07..a92e582 100644 --- a/sql/sql-param-object.h +++ b/sql/sql-param-object.h @@ -20,8 +20,9 @@ #include "sql-object.h" -#define SQL_TYPE_PARAM_OBJECT (sql_param_object_get_type ()) -#define SQL_PARAM_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), SQL_TYPE_PARAM_OBJECT, SqlParamObject)) +#define SQL_TYPE_PARAM_OBJECT (sql_param_object_get_type ()) +#define SQL_PARAM_OBJECT(pspec) (G_TYPE_CHECK_INSTANCE_CAST (pspec, SQL_TYPE_PARAM_OBJECT, SqlParamObject)) +#define SQL_IS_PARAM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_PARAM_OBJECT)) typedef struct { diff --git a/sql/sql-string.c b/sql/sql-string.c index 8dad5fb..4ecb697 100644 --- a/sql/sql-string.c +++ b/sql/sql-string.c @@ -59,6 +59,14 @@ static void sql_string_render (SqlString * obj, SqlRender * render) sql_render_append (render, ptr); } +static void sql_string_find_holders (SqlString * obj, GQueue * holders) +{ + GSList * i; + + for (i = obj->holders; i; i = i->next) + sql_object_get_holders (((HolderData *) i->data)->holder); +} + static void sql_string_free_holder_data (HolderData * holder_data) { g_object_unref (holder_data->holder); @@ -173,6 +181,7 @@ static void sql_string_class_init (SqlStringClass * k) klass->set_property = (GObjectSetPropertyFunc) sql_string_set_property; klass->get_property = (GObjectGetPropertyFunc) sql_string_get_property; SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_string_render; + SQL_OBJECT_CLASS (klass)->find_holders = (SqlObjectFindHoldersFunc) sql_string_find_holders; g_object_class_install_property (klass, PROP_SQL, g_param_spec_string ("sql"