Plugin de Glade y otros cambios

This commit is contained in:
Alejandro T. Colombini Gómez 2013-10-14 14:08:06 +02:00
parent d23042fc1c
commit 7d39316267
118 changed files with 4727 additions and 3453 deletions

View File

@ -1,4 +1,3 @@
Alejandro Tomas Colombini Gomez
Juan Ferrer Toribio
Javier Gallego Ferris
Jordi Cuquerella

View File

@ -57,13 +57,13 @@ vn_datadir = $(hedera_datadir)/vn
vn_imagedir = $(vn_datadir)/image
vn_guidir = $(vn_datadir)/gui
module_querydir = $(hedera_datadir)/module/sql
if ENABLE_INSTALL
vn_xmldir = $(datadir)/xml/$(PACKAGE)
module_querydir = $(hedera_datadir)/module/sql
module_datadir = $(hedera_datadir)/module
else
vn_xmldir = $(vn_datadir)/schema
module_querydir = $(hedera_datadir)/module/sql
module_datadir = $(hedera_datadir)/module/data
endif

68
build/m4/vn-dev.m4 Normal file
View File

@ -0,0 +1,68 @@
dnl
dnl Copyright (C) 2012 - Juan Ferrer Toribio
dnl
dnl This program is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
dnl
# serial 2 vn-dev
AC_DEFUN([VN_BUILD_OPTIONS],
[
case $CFLAGS in
*-W*) ;;
*)CFLAGS+=" -Wall ";;
esac
# Check for debug mode
AC_MSG_CHECKING([whether to build with debug information...])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable debug data generation [default = no]])],
[ENABLE_DEBUG="$enableval"],
[ENABLE_DEBUG=no])
AC_MSG_RESULT([$ENABLE_DEBUG])
case $CFLAGS in
*-g*) ;;
*)
if test x"$ENABLE_DEBUG" = x"yes"; then
CFLAGS+=" -ggdb "
fi
;;
esac
# Check if the package must be configured to be installed
AC_MSG_CHECKING([whether to configure to install...])
AC_ARG_ENABLE([install],
[AS_HELP_STRING([--enable-install],
[Enable install configuration [default = yes]])],
[ENABLE_INSTALL="$enableval"],
[ENABLE_INSTALL=yes])
AC_MSG_RESULT([$installit])
AM_CONDITIONAL(ENABLE_INSTALL, [test x"$ENABLE_INSTALL" = x"yes"])
case $CFLAGS in
*-O*) ;;
*)
if test x"$ENABLE_INSTALL" = x"yes"; then
CFLAGS+=" -O3"
fi
;;
esac
AC_SUBST([ENABLE_DEBUG])
AC_SUBST([ENABLE_INSTALL])
AC_SUBST([CFLAGS])
])

View File

@ -1,5 +1,7 @@
AC_INIT([hedera], [1.0])
dnl Set compiler flags empty by default
: ${CFLAGS=''}
AC_CONFIG_AUX_DIR([build])
AC_CONFIG_MACRO_DIR([build/m4])
@ -8,17 +10,32 @@ LT_INIT([dlopen])
AC_PREREQ([2.69])
AM_SILENT_RULES([yes])
# Checks for programs
# Checks for the C compiler
AC_PROG_CC
# Check for additional packages
PKG_CHECK_MODULES([glib], [glib-2.0])
PKG_CHECK_MODULES([gdome], [gdome2])
PKG_CHECK_MODULES([gtk], [gtk+-3.0])
PKG_CHECK_MODULES([gladeui], gladeui-2.0)
PKG_CHECK_MODULES([gladeui], [gladeui-2.0])
PKG_CHECK_MODULES([gtksourceview], [gtksourceview-3.0]
,[SOURCEVIEW=yes]
,[echo $gtksourceview_PKG_ERRORS])
AM_CONDITIONAL(HAVE_SOURCEVIEW, [test -n $SOURCEVIEW])
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])
# Internationalization
IT_PROG_INTLTOOL([0.40.1], [no-xml])
GETTEXT_PACKAGE=hedera
AC_SUBST([GETTEXT_PACKAGE])
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [GETTEXT package name])
ALL_LINGUAS="es ca nl"
AM_GLIB_GNU_GETTEXT
AM_XGETTEXT_OPTION([-k_ -kQ_:1g -kN_ -kC_:1c,2 -kNC_:1c,2])
# Checks for Ragel State Machine Compiler
AC_PATH_PROG(RAGEL, [ragel], [no])
if test x"$RAGEL" = x"no" ; then
@ -49,51 +66,11 @@ fi
AM_CONDITIONAL(ENABLE_VALA, [test x"$ENABLE_VALA" = x"yes" -a x"$VAPIGEN" != x"no"])
# Internationalization
GETTEXT_PACKAGE=hedera
AC_SUBST([GETTEXT_PACKAGE])
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [GETTEXT package name])
ALL_LINGUAS="es ca nl"
AM_GLIB_GNU_GETTEXT
AM_XGETTEXT_OPTION([-k_ -kQ_:1g -kN_ -kC_:1c,2 -kNC_:1c,2])
# GSettings configuration
GLIB_GSETTINGS
CFLAGS=" -Wall"
# Check for debug mode
AC_MSG_CHECKING([whether to build with debug information...])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable debug data generation [default = no]])],
[ENABLE_DEBUG="$enableval"],
[ENABLE_DEBUG=no])
AC_MSG_RESULT([$ENABLE_DEBUG])
if test x"$ENABLE_DEBUG" = x"yes"; then
CFLAGS+=" -ggdb"
fi
# Check if it will be installed
AC_MSG_CHECKING([whether to configure to install...])
AC_ARG_ENABLE([install],
[AS_HELP_STRING([--enable-install],
[Enable install configuration [default = yes]])],
[ENABLE_INSTALL="$enableval"],
[ENABLE_INSTALL=yes])
AC_MSG_RESULT([$installit])
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])
AC_SUBST([CFLAGS])
AC_SUBST([LDFLAGS])
# Sets the default build options for Vn projects
VN_BUILD_OPTIONS
# Portability check disabled for GTK-DOC (can be changed if needed)
AM_INIT_AUTOMAKE([-Wno-portability])
@ -117,9 +94,9 @@ AC_CONFIG_FILES([
module/Makefile
module/src/Makefile
module/data/Makefile
module/sql/Makefile
main/Makefile
main/vn-hedera.desktop
main/vn-hedera-debug.desktop
vapi/Makefile
glade/Makefile
docs/Makefile

View File

@ -239,7 +239,7 @@ static void db_conn_add_request (DbConn * obj, DbRequest * request)
* @plugin: the plugin name
* @err: return address of a #GError or #NULL
*
* Tryes to load a plugin.
* Tries to load a plugin.
*
* Return vale: %TRUE if plugin was loaded successfully, %FALSE ortherwise
**/
@ -892,14 +892,15 @@ SqlString * db_conn_create_stmt_from_file (DbConn * obj, const gchar * query_fil
g_return_val_if_fail (DB_IS_CONN (obj), NULL);
g_return_val_if_fail (query_file, NULL);
file = g_strconcat (query_file, ".sql", NULL);
for (i = 0; obj->query_dirs &&obj->query_dirs[i] && !stmt; i++)
if (obj->query_dirs)
for (i = 0; obj->query_dirs[i] && !stmt; i++)
{
gchar * buffer;
gchar * path = g_build_filename (obj->query_dirs[i], file, NULL);
if (g_file_get_contents (path, &buffer, NULL, NULL))
{
stmt = sql_string_new (buffer);
@ -908,9 +909,9 @@ SqlString * db_conn_create_stmt_from_file (DbConn * obj, const gchar * query_fil
g_free (path);
}
if (!stmt)
g_warning ("DbConn: Can't create statement from file: %s", query_file);
g_warning ("DbConn: Can't create statement from file: %s", file);
g_free (file);
return stmt;

View File

@ -565,7 +565,7 @@ static void db_file_loader_cancel (DbFileLoader * obj, const gchar * name)
g_hash_table_iter_init (&iter, obj->priv->downloading);
while (g_hash_table_iter_next (&iter, (gpointer*) &file, NULL))
while (g_hash_table_iter_next (&iter, (gpointer *) &file, NULL))
if (!name || !g_strcmp0 (file->name, name))
{
g_cancellable_cancel (file->cancel);

View File

@ -16,6 +16,7 @@
*/
#include "db-iterator.h"
#include "db-model-holder.h"
#define IS_READY(obj) (obj->model && db_model_get_status (obj->model) == DB_MODEL_STATUS_READY)
@ -24,29 +25,16 @@
* @short_description: manages a iterator with its events
* @title: DbIterator
*
* The DbIterator manages a connection with a data base.
* There are different ways to create an DbIterator:
* <itemizedlist>
* <listitem>
* <para>
* db_iterator_new(): This constructor just needs a #DbModel object
* </para>
* </listitem>
* <listitem>
* <para>
* db_iterator_new_with_stmt(): This one needs a #DbConn with the connection and
* a #SqlStmt object
* </para>
* </listitem>
* <listitem>
* <para>
* db_iterator_new_with_sql(): This one needs a #DbConn with the connection and
* the sql string
* </para>
* </listitem>
*</itemizedlist>
* The #DbIterator manages a connection with a data base. The function
* db_iterator_new() creates a new #DbIterator.
*/
G_DEFINE_TYPE (DbIterator, db_iterator, G_TYPE_OBJECT);
static void db_iterator_model_holder_interface_init (DbModelHolderInterface * iface);
G_DEFINE_TYPE_WITH_CODE (DbIterator, db_iterator, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (DB_TYPE_MODEL_HOLDER,
db_iterator_model_holder_interface_init)
);
enum {
ITER_CHANGED
@ -72,48 +60,6 @@ DbIterator * db_iterator_new (DbModel * model)
return g_object_new (DB_TYPE_ITERATOR, "model", model, NULL);
}
/**
* db_iterator_new_with_stmt:
* @conn: the connection used to create the model.
* @stmt: the #SqlStmt statement used to create the model.
*
* Creates a new #DbIterator. #SqlStmt must be a #SqlSelect or a #SqlString
* object with a valid SELECT statement.
*
* Return value: a #DbIterator.
**/
DbIterator * db_iterator_new_with_stmt (DbConn * conn, SqlStmt * stmt)
{
DbIterator * obj;
DbModel * model;
g_return_val_if_fail (DB_IS_CONN (conn) || !conn, NULL);
g_return_val_if_fail (SQL_IS_STMT (stmt) || !stmt, NULL);
model = db_model_new (conn, stmt);
obj = g_object_new (DB_TYPE_ITERATOR, "model", model, NULL);
g_object_unref (model);
return obj;
}
/**
* db_iterator_new_with_sql:
* @conn: the connection used to create the model.
* @sql: the sql string used to create the model.
*
* Creates a new #DbIterator. sql must be a valid SELECT statement.
*
* Return value: a #DbIterator.
**/
DbIterator * db_iterator_new_with_sql (DbConn * conn, const gchar * sql)
{
g_return_val_if_fail (sql, NULL);
g_return_val_if_fail (DB_IS_CONN (conn) || !conn, NULL);
return g_object_new (DB_TYPE_ITERATOR, "sql", sql, "conn", conn, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void db_iterator_unref_param (DbIterator * obj, DbParam * param)
@ -183,7 +129,7 @@ static void db_iterator_on_model_line_updated_after (DbModel * model, DbIter * i
* Function called when row is deleted on the model.
*/
static void db_iterator_on_model_line_deleted (DbModel * model, gint row, DbIterator * obj)
{
{
if (obj->row_selected && row == obj->row)
{
DbIter iter;
@ -296,31 +242,6 @@ static gboolean db_iterator_check_row_selected (DbIterator * obj)
return FALSE;
}
/*
* Attempts to create a model, if have enough information, and assigns it to
* the iterator.
*/
static void db_iterator_try_create_model (DbIterator * obj)
{
DbModel * new_model = NULL;
if (obj->conn)
{
if (obj->sql)
{
if (obj->use_file)
new_model = db_model_new_with_file (obj->conn, obj->sql);
else
new_model = db_model_new_with_sql (obj->conn, obj->sql);
}
if (obj->stmt)
new_model = db_model_new (obj->conn, obj->stmt);
}
if (new_model)
db_iterator_set_model (obj, new_model);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
@ -356,40 +277,6 @@ DbModel * db_iterator_get_model (DbIterator * obj)
return obj->model;
}
/**
* db_iterator_get_conn:
* @obj: a #DbIterator
*
* Gets connection used by the @obj model.
*
* Return value: (transfer none): the #DbConn
**/
DbConn * db_iterator_get_conn (DbIterator * obj)
{
g_return_val_if_fail (DB_IS_ITERATOR (obj), NULL);
if (obj->model)
db_model_get_conn (obj->model);
return NULL;
}
/**
* db_iterator_set_conn:
* @obj: a #DbIterator
* @conn: the #DbConn
*
* Sets the connection used by the @obj model.
**/
void db_iterator_set_conn (DbIterator * obj, DbConn * conn)
{
g_return_if_fail (DB_IS_ITERATOR (obj));
g_return_if_fail (DB_IS_CONN (conn));
g_return_if_fail (obj->model);
db_model_set_conn (obj->model, conn);
}
/**
* db_iterator_is_ready:
* @obj: a #DbIterator
@ -948,10 +835,6 @@ enum
PROP_MODEL = 1
,PROP_MODE
,PROP_REMEMBER_SELECTION
,PROP_CONN
,PROP_STMT
,PROP_SQL
,PROP_USE_FILE
};
static void db_iterator_set_property (DbIterator * obj, guint id,
@ -968,25 +851,6 @@ static void db_iterator_set_property (DbIterator * obj, guint id,
case PROP_REMEMBER_SELECTION:
obj->remember_selection = g_value_get_boolean (value);
break;
case PROP_CONN:
g_clear_object (&obj->conn);
obj->conn = g_value_dup_object (value);
db_iterator_try_create_model (obj);
break;
case PROP_STMT:
g_clear_object (&obj->stmt);
obj->stmt = g_value_dup_object (value);
db_iterator_try_create_model (obj);
break;
case PROP_SQL:
g_free (obj->sql);
obj->sql = g_value_dup_string (value);
db_iterator_try_create_model (obj);
break;
case PROP_USE_FILE:
obj->use_file = g_value_get_boolean (value);
db_iterator_try_create_model (obj);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -1019,10 +883,6 @@ static void db_iterator_init (DbIterator * obj)
obj->params = NULL;
obj->row = 0;
obj->row_selected = FALSE;
obj->conn = NULL;
obj->stmt = NULL;
obj->sql = NULL;
obj->use_file = FALSE;
}
static void db_iterator_finalize (DbIterator * obj)
@ -1049,10 +909,6 @@ static void db_iterator_finalize (DbIterator * obj)
);
g_object_unref (obj->model);
}
g_clear_object (&obj->conn);
g_clear_object (&obj->stmt);
g_free (obj->sql);
G_OBJECT_CLASS (db_iterator_parent_class)->finalize (G_OBJECT (obj));
}
@ -1064,34 +920,66 @@ static void db_iterator_class_init (DbIteratorClass * klass)
k->get_property = (GObjectGetPropertyFunc) db_iterator_get_property;
k->finalize = (GObjectFinalizeFunc) db_iterator_finalize;
/**
* DbIterator::iter-changed:
* @iterator: the object on which the signal is emitted
* @iter: a #DbIter
*
* This signal is emitted when @iter moves over the @iterator model
*/
signals[ITER_CHANGED] = g_signal_new ("iter-changed",
DB_TYPE_ITERATOR, G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0
);
/**
* DbIterator::data-changed:
* @iterator: the object on which the signal is emitted
*
* This signal is emitted when the model changes its data
*/
signals[DATA_CHANGED] = g_signal_new ("data-changed",
DB_TYPE_ITERATOR, G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0
);
/**
* DbIterator::row-num-changed:
* @iterator: the object on which the signal is emitted
*
* This signal is emitted when the selected row changes
*/
signals[ROW_NUM_CHANGED] = g_signal_new ("row-num-changed",
DB_TYPE_ITERATOR, G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0
);
/**
* DbIterator::status-changed:
* @iterator: the object on which the signal is emitted
* @ready: #TRUE if @iterator is ready, #FALSE otherwise
*
* This signal is emitted when the status of the iterator changes
*/
signals[STATUS_CHANGED] = g_signal_new ("status-changed",
DB_TYPE_ITERATOR, G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN
);
/**
* DbIterator::operations-done:
* @iterator: the object on which the signal is emitted
*
* This signal is emitted when all pending operations are performed over the
* model of @iterator
*/
signals[OPERATIONS_DONE] = g_signal_new ("operations-done",
DB_TYPE_ITERATOR, G_SIGNAL_RUN_FIRST, 0, NULL, NULL,
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0
);
g_object_class_install_property (k, PROP_MODEL,
g_param_spec_object ("model"
,_("Model")
,_("The DbModel handled by the iterator")
,DB_TYPE_MODEL
,G_PARAM_READWRITE
));
g_object_class_override_property (k, PROP_MODEL, "model");
g_object_class_install_property (k, PROP_MODE,
g_param_spec_enum ("mode"
,_("Mode")
@ -1107,34 +995,12 @@ static void db_iterator_class_init (DbIteratorClass * klass)
,TRUE
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_CONN,
g_param_spec_object ("conn"
,_("Connection")
,_("The connection used by the model")
,DB_TYPE_CONN
,G_PARAM_WRITABLE
));
g_object_class_install_property (k, PROP_STMT,
g_param_spec_object ("stmt"
,_("Statement")
,_("The statement used to create the model")
,SQL_TYPE_STMT
,G_PARAM_WRITABLE
));
g_object_class_install_property (k, PROP_SQL,
g_param_spec_string ("sql"
,_("SQL")
,_("The SQL query used to create the model")
, NULL
,G_PARAM_WRITABLE
));
g_object_class_install_property (k, PROP_USE_FILE,
g_param_spec_boolean ("use-file"
,_("Use file")
,_("Wether to interpret the sql property as query file")
,FALSE
,G_PARAM_CONSTRUCT | G_PARAM_WRITABLE
));
}
static void db_iterator_model_holder_interface_init (DbModelHolderInterface * iface)
{
iface->get_model = (DbModelHolderGetModelFunc) db_iterator_get_model;
iface->set_model = (DbModelHolderSetModelFunc) db_iterator_set_model;
}
GType db_iterator_mode_get_type ()

View File

@ -81,11 +81,6 @@ struct _DbIterator
gint row;
gboolean row_selected;
gboolean remember_selection;
DbConn * conn;
SqlStmt * stmt;
gchar * sql;
gboolean use_file;
};
struct _DbIteratorClass
@ -98,11 +93,6 @@ GType db_iterator_get_type ();
GType db_iterator_mode_get_type () G_GNUC_CONST;
DbIterator * db_iterator_new (DbModel * model);
DbIterator * db_iterator_new_with_stmt (DbConn * conn, SqlStmt * stmt);
DbIterator * db_iterator_new_with_sql (DbConn * conn, const gchar * sql);
DbModel * db_iterator_get_model (DbIterator * obj);
DbConn * db_iterator_get_conn (DbIterator * obj);
void db_iterator_set_conn (DbIterator * obj, DbConn * conn);
gboolean db_iterator_is_ready (DbIterator * obj);
DbIteratorMode db_iterator_get_mode (DbIterator * obj);
void db_iterator_set_mode (DbIterator * obj, DbIteratorMode mode);

View File

@ -19,15 +19,17 @@
/**
* SECTION: db-model-holder
* @Short_description:
* @Short_description: interface for objects that use a model
* @Title: DbModelHolder
* @See_also: #DbModel
*
* This interface should be implemented from any class that uses a #DbModel as
* datasource.
* data source. This interface offers a #DbModel as a virtual property that has
* to be overwritten by the classes implementing it, as well as the
* db_model_holder_get_model() and db_model_holder_set_model() methods.
**/
G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_INTERFACE);
G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_INVALID);
/**
* db_model_holder_get_model:
@ -35,7 +37,7 @@ G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_INTERFACE);
*
* Gets the model used by holder.
*
* Return value: the #DbModel
* Return value:(transfer none): the #DbModel
**/
DbModel * db_model_holder_get_model (DbModelHolder * obj)
{
@ -45,7 +47,7 @@ DbModel * db_model_holder_get_model (DbModelHolder * obj)
}
/**
* db_model_holder_get_model:
* db_model_holder_set_model:
* @obj: a #DbModelHolder
* @model: the #DbModel
*
@ -54,18 +56,19 @@ DbModel * db_model_holder_get_model (DbModelHolder * obj)
void db_model_holder_set_model (DbModelHolder * obj, DbModel * model)
{
g_return_if_fail (DB_IS_MODEL_HOLDER (obj));
g_return_if_fail (DB_IS_MODEL (obj));
DB_MODEL_HOLDER_GET_INTERFACE (obj)->set_model (obj, model);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void db_model_holder_default_init (DbModelHolderInterface * klass)
{
g_object_interface_install_property (klass,
static void db_model_holder_default_init (DbModelHolderInterface * iface)
{
g_object_interface_install_property (iface,
g_param_spec_object ("model"
,"Model"
,"The model used by the holder"
,_("Model")
,_("The model used by the holder")
,DB_TYPE_MODEL
,G_PARAM_READWRITE
));

View File

@ -15,34 +15,34 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DB_MODEL_HOLDER_H
#define DB_MODEL_HOLDER_H
#ifndef DB_MODEL_HOLDER_H
#define DB_MODEL_HOLDER_H
#include "db-model.h"
#define DB_TYPE_MODEL_HOLDER (db_model_holder_get_type ())
#define DB_MODEL_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DB_TYPE_MODEL_HOLDER, DbModelHolder))
#define DB_IS_MODEL_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DB_TYPE_MODEL_HOLDER))
#define DB_TYPE_MODEL_HOLDER (db_model_holder_get_type ())
#define DB_MODEL_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DB_TYPE_MODEL_HOLDER, DbModelHolder))
#define DB_IS_MODEL_HOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DB_TYPE_MODEL_HOLDER))
#define DB_MODEL_HOLDER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), DB_TYPE_MODEL_HOLDER, DbModelHolderInterface))
typedef struct _DbModelHolder DbModelHolder;
typedef struct _DbModelHolder DbModelHolder;
typedef struct _DbModelHolderInterface DbModelHolderInterface;
typedef DbModel * (* DbModelHolderGetModelFunc) (DbModelHolder * obj);
typedef void (* DbModelHolderSetModelFunc) (DbModelHolder * obj, DbModel * sql);
struct _DbModelHolder {};
struct _DbModelHolderInterface
struct _DbModelHolder;
struct _DbModelHolderInterface
{
/* <private> */
/* <private> */
GTypeInterface parent;
DbModelHolderGetModelFunc get_model;
DbModelHolderSetModelFunc set_model;
};
};
GType db_model_holder_get_type ();
DbModel * db_model_holder_get_model (DbModelHolder * obj);
void db_model_holder_set_model (DbModelHolder * obj, DbModel * model);
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -206,6 +206,7 @@ void db_model_unset_update_flags (DbModel * obj
void db_model_set_mode (DbModel * obj, DbModelMode mode);
DbModelMode db_model_get_mode (DbModel * obj);
void db_model_toggle_mode (DbModel * obj);
void db_model_use_null_row (DbModel * obj, gboolean use);
gboolean db_model_get_last (DbModel * obj, DbIter * iter);
void db_model_get (DbModel * obj
,DbIter * iter
@ -248,12 +249,11 @@ void db_model_add_join_columns (DbModel * obj
void db_model_set_default_value_from_column (DbModel * obj
,const gchar * dst_field
,gint src_column);
void db_model_set_default_value_from_param (DbModel * obj
,const gchar * dst_field
,GvnParam * param
,const gchar * id);
,GvnParam * param);
void db_model_add_param (DbModel * obj
,const gchar * id
,GvnParam * param);
//GtkTreeModel-like methods

View File

@ -17,6 +17,14 @@
#include "db-param.h"
/**
* SECTION: db-param
* @Short_description: representation of the value of a field
* @Title: DbParam
*
* This class represents the value of a field in a #DbIterator.
**/
G_DEFINE_TYPE (DbParam, db_param, GVN_TYPE_PARAM);
/**

View File

@ -30,7 +30,7 @@ typedef struct _DbColumn DbColumn;
* DbResult:
* @nrows: Number of rows.
* @ncols: Number of columns.
* @data: Has a #GList.
* @data: (element-type DbRow): Has a #GList.
* @column: Has a #DbColumn.
*
* Has the information of a row.

View File

@ -20,6 +20,7 @@
#include <sql/sql.h>
#include "db-iter.h"
#include "db-model-holder.h"
#include "db-model.h"
#include "db-request.h"
#include "db-conn.h"

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
libhedera (1.0-1) stable; urgency=low
libhedera (1.0-6) stable; urgency=low
* Initial Release.

20
debian/control vendored
View File

@ -20,23 +20,25 @@ Description: Database access and widget provider library (runtime)
queries.
.
The library also has a modular system to add and remove the different widgets
in run time.
in run time. And includes Glade integration, to design the programs in an
easiest, graphical way.
.
This package contains the executable and data files.
Package: libhedera-dev
Section: libdevel
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, libhedera1 (= ${binary:Version})
Suggests: libgtk-3-doc, libgtk-3-dbg, devhelp, valac (>= 0.16)
Recommends: glade (>= 3.4), anjuta (>= 3.4)
Depends: ${shlibs:Depends}, ${misc:Depends}, libhedera1 (= ${binary:Version}),
libgtk-3-dev
Suggests: libgtk-3-doc, libgtk-3-0-dbg, devhelp, valac (>= 0.16)
Recommends: glade (>= 3.4), anjuta (>= 3.4), libgtksourceview-3.0-1
Description: Database access and widget provider library (development)
The hedera library provides and lets you create widgets bound to SQL queries
and manages the different operations made over the data retrieved from these
queries.
.
The library also has a modular system to add and remove the different widgets
in run time. And it includes Glade integration, to design the programs in an
in run time. And includes Glade integration, to design the programs in an
easiest, graphical way.
.
This package contains development files to compile C and Vala programs that
@ -46,14 +48,15 @@ Description: Database access and widget provider library (development)
Package: libhedera1
Section: libs
Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, libgtk-3-0, libgtk-3-dev
Depends: ${shlibs:Depends}, ${misc:Depends}, libgtk-3-0
Description: Database access and widget provider library (core)
The hedera library provides and lets you create widgets bound to SQL queries
and manages the different operations made over the data retrieved from these
queries.
.
The library also has a modular system to add and remove the different widgets
in run time.
in run time. And includes Glade integration, to design the programs in an
easiest, graphical way.
.
This package contains the core of the library. It also provides the plugins to
connect a PostgreSQL or MySQL database.
@ -68,6 +71,7 @@ Description: Database access and widget provider library (debug)
queries.
.
The library also has a modular system to add and remove the different widgets
in run time.
in run time. And includes Glade integration, to design the programs in an
easiest, graphical way.
.
This package contains the debugging symbols for hedera.

6
debian/hedera.dirs vendored
View File

@ -1,8 +1,8 @@
usr/bin
usr/lib/hedera/module
usr/share/hedera/vn/image
usr/share/hedera/vn
usr/share/hedera/vn/image
usr/share/hedera/module
usr/share/hedera/module/sql
usr/share/applications
usr/share/ca-certificates/verdnatura.es
usr/share/hedera/module/sql/example
usr/share/applications

View File

@ -1,7 +1,8 @@
usr/bin/*
usr/lib/hedera/module/*.so
usr/share/hedera/vn/image/*
usr/share/hedera/vn/*
usr/share/hedera/vn/image/*
usr/share/hedera/module/*
usr/share/applications/*
usr/share/ca-certificates/verdnatura.es/*
usr/share/hedera/module/sql/*
usr/share/hedera/module/sql/example/*
usr/share/applications/*

View File

@ -7,7 +7,7 @@ usr/include/hedera/vn/field
usr/include/hedera/vn/column
usr/lib/hedera
usr/lib/glade/modules
usr/lib/girepository-1.0
#usr/lib/girepository-1.0
usr/share/gir-1.0
usr/share/glade/catalogs
usr/share/pkgconfig

View File

@ -17,7 +17,7 @@ usr/lib/hedera/libvnfield.so
usr/lib/hedera/libvncolumn.a
usr/lib/hedera/libvncolumn.so
usr/lib/glade/modules/libgladevn.so
usr/lib/girepository-1.0/*
#usr/lib/girepository-1.0/*
usr/share/gir-1.0/*
usr/share/glade/catalogs/*
usr/share/pkgconfig/*

View File

@ -95,6 +95,7 @@
<title>DbLib</title>
<xi:include href="xml/db-conn.xml"/>
<xi:include href="xml/db-model.xml"/>
<xi:include href="xml/db-model-holder.xml"/>
<xi:include href="xml/db-iterator.xml"/>
<xi:include href="xml/db-iter.xml"/>
<xi:include href="xml/db-row.xml"/>

View File

@ -4,20 +4,31 @@ gladevn_lib_LTLIBRARIES = libgladevn.la
AM_CPPFLAGS = \
-I$(top_srcdir) \
$(gladeui_CFLAGS)
$(gladeui_CFLAGS) \
$(DEFINES) \
$(gtksourceview_CFLAGS)
libgladevn_la_LIBADD = \
$(top_builddir)/vn/libvn.la \
$(gladeui_LIBS)
$(gladeui_LIBS) \
$(gtksourceview_LIBS)
libgladevn_la_LDFLAGS = -avoid-version
libgladevn_la_SOURCES = \
glade-vn.h \
glade-vn.c \
glade-vn-batch.c
glade-vn-batch.c \
glade-db-sql.c \
glade-db-model.c
gladevn_data_DATA = vn.xml
if HAVE_SOURCEVIEW
DEFINES = -D_HAVE_GTKSOURCEVIEW
else
DEFINES =
endif
EXTRA_DIST = $(gladevn_data_DATA)
install-data-hook:
rm -f $(DESTDIR)$(gladevn_libdir)/libgladevn.la
rm -f $(DESTDIR)$(gladevn_libdir)/libgladevn.a
rm -f $(DESTDIR)$(gladevn_libdir)/libgladevn.a

364
glade/glade-db-model.c Normal file
View File

@ -0,0 +1,364 @@
/*
* Copyright (C) 2013 - Juan Ferrer Toribio
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "glade-vn.h"
//+++++++++++++++++++++++++++++++++++++++++++++++++ DbModel GladeEditorProperty
typedef struct
{
GladeEditorProperty parent;
GtkWidget * button;
GtkWidget * entry;
gboolean connected;
GladeWidget * widget;
}
GladeEPropModel;
GLADE_MAKE_EPROP (GladeEPropModel, glade_eprop_model)
#define GLADE_TYPE_EPROP_MODEL (glade_eprop_model_get_type())
#define GLADE_EPROP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EPROP_MODEL, GladeEPropModel))
#define GLADE_EPROP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EPROP_MODEL, GladeEPropModelClass))
#define GLADE_IS_EPROP_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_MODEL))
#define GLADE_IS_EPROP_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_MODEL))
#define GLADE_EPROP_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_EPROP_MODEL, GladeEPropModelClass))
static void glade_eprop_model_name_changed (GladeProject * project,
GladeWidget * widget, GladeEPropModel * obj)
{
if (widget && obj->widget)
{
gtk_entry_set_text (GTK_ENTRY (obj->entry),
glade_widget_get_name (widget));
}
}
static GladeWidget * glade_model_create (GladeProperty * prop)
{
gboolean use = FALSE;
VnBatch * batch;
GladeWidget * batch_w;
GladeProject * project = glade_widget_get_project (glade_property_get_widget (prop));
const GList * l, * n, * objects = glade_project_get_objects (project);
for (n = objects; n; n = n->next)
if (VN_IS_BATCH (n->data))
{
batch = n->data;
use = TRUE;
for (l = vn_batch_get_objects (batch); l; l = l->next)
if (!DB_IS_MODEL (l->data))
{
use = FALSE;
break;
}
if (use)
break;
}
if (!use)
batch_w = glade_command_create
(glade_widget_adaptor_get_by_type (VN_TYPE_BATCH), NULL, NULL, project);
else
batch_w = glade_widget_get_from_gobject (batch);
return glade_command_create
(glade_widget_adaptor_get_by_type (DB_TYPE_MODEL), batch_w, NULL, project);
}
/*
* glade_eprop_model_show_dialog:
* @button:(allow-none): a #GtkButton or @NULL
* @object: a #GladeEditorPropery or a #GladeWidget
*
* Opens a dialog to edit a #DbModel.
* Can be called by a #GladeEditorProperty or by the "edit" action of a
* #GladeWidgetAdaptor directly (in which case @button is %NULL and @obj is a
* #GladeWidget).
**/
static void glade_eprop_model_show_dialog (GtkButton * button, GObject * object)
{
gboolean created = FALSE;
GObject * o;
GtkWidget * box;
GtkDialog * dialog;
GladeWidget * widget;
GladeWidgetAdaptor * adaptor;
GladeEditable * editor;
GladeProperty * p = NULL;
GladeEditorProperty * eprop = NULL;
if (GLADE_IS_EDITOR_PROPERTY (object))
{
eprop = GLADE_EDITOR_PROPERTY (object);
p = glade_editor_property_get_property (eprop);
o = g_value_get_object (glade_property_inline_value (p));
if (o && DB_IS_MODEL (o))
widget = glade_widget_get_from_gobject (o);
else
{
GValue val = G_VALUE_INIT;
glade_command_push_group
(_("Create and set a model for a DbModelHolder"));
widget = glade_model_create (p);
created = TRUE;
g_value_init (&val, DB_TYPE_MODEL);
g_value_set_object (&val, glade_widget_get_object (widget));
glade_command_set_property_value (p, &val);
g_value_unset (&val);
glade_command_pop_group ();
glade_project_selection_set (glade_widget_get_project (widget),
glade_widget_get_object (glade_property_get_widget (p)),
TRUE);
if (!GLADE_EPROP_MODEL (eprop)->connected)
{
g_signal_connect (glade_widget_get_project
(glade_property_get_widget (p)), "widget-name-changed",
G_CALLBACK (glade_eprop_model_name_changed), eprop);
GLADE_EPROP_MODEL (eprop)->connected = TRUE;
}
}
}
else
widget = GLADE_WIDGET (object);
adaptor = glade_widget_get_adaptor (widget);
editor = glade_widget_adaptor_create_editable (adaptor, GLADE_PAGE_GENERAL);
glade_editable_load (editor, widget);
dialog = GTK_DIALOG (gtk_dialog_new_with_buttons
(eprop ? _("Model configuration") : _("DbModel properties configuration")
,GTK_WINDOW (glade_app_get_window ())
,GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT
,GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL
,GTK_STOCK_CLEAR, GTK_RESPONSE_REJECT
,GTK_STOCK_OK, GTK_RESPONSE_OK
,NULL
));
gtk_dialog_set_alternative_button_order (dialog,
GTK_RESPONSE_OK, GTK_RESPONSE_REJECT, GTK_RESPONSE_CANCEL, -1);
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300);
if (!eprop)
gtk_widget_hide (gtk_dialog_get_widget_for_response
(dialog, GTK_RESPONSE_REJECT));
box = gtk_alignment_new (0,0,1,1);
gtk_alignment_set_padding (GTK_ALIGNMENT (box), 8, 8, 8, 8);
gtk_container_add (GTK_CONTAINER (box), GTK_WIDGET (editor));
gtk_widget_show_all (box);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)),
box, TRUE, TRUE, 0);
switch (gtk_dialog_run (dialog))
{
case GTK_RESPONSE_OK:
{
if (eprop)
{
gtk_entry_set_text (GTK_ENTRY (GLADE_EPROP_MODEL (eprop)->entry),
glade_widget_get_name (widget));
GLADE_EPROP_MODEL (eprop)->widget = widget;
}
break;
}
case GTK_RESPONSE_REJECT:
{
if (eprop)
{
glade_command_set_property (p, NULL);
GLADE_EPROP_MODEL (eprop)->widget = NULL;
}
break;
}
case GTK_RESPONSE_CANCEL:
{
if (created)
{
GList * list = g_list_append (NULL, widget);
GladeWidget * batch = glade_widget_get_parent (widget);
if (vn_batch_get_length
VN_BATCH (glade_widget_get_object (batch)) == 1)
list = g_list_prepend (list, batch);
glade_command_delete (list);
g_list_free (list);
GLADE_EPROP_MODEL (eprop)->widget = NULL;
}
break;
}
default:
break;
}
gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void glade_eprop_model_show_object_dialog (GtkButton * button,
GladeEditorProperty * eprop)
{
GladeProperty * p = glade_editor_property_get_property (eprop);
// Widget to which the property belongs (e.g. Model Holder)
GladeWidget * widget = glade_property_get_widget (p);
GladeProject * project = glade_widget_get_project (widget);
GObject * object = g_value_get_object (glade_property_inline_value (p));
// Widget representing the property itself (i.e. DbModel)
widget = object ? glade_widget_get_from_gobject (object) : NULL;
GLADE_EPROP_MODEL (eprop)->widget = widget;
if (glade_editor_property_show_object_dialog (project,
_("Select a DbModel for the property"), NULL,
DB_TYPE_MODEL, NULL, &widget))
{
if (widget)
{
GValue val = G_VALUE_INIT;
g_value_init (&val, DB_TYPE_MODEL);
g_value_set_object (&val, glade_widget_get_object (widget));
glade_command_set_property_value (p, &val);
g_value_unset (&val);
}
else
glade_command_set_property (p, NULL);
}
}
static GtkWidget * glade_eprop_model_create_input (GladeEditorProperty * eprop)
{
GtkWidget * hbox, * box, * object_button;
GladeEPropModel * obj = GLADE_EPROP_MODEL (eprop);
obj->button = gtk_button_new_with_label (_("New Model"));
g_signal_connect (G_OBJECT (obj->button), "clicked",
G_CALLBACK (glade_eprop_model_show_dialog), eprop);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
obj->entry = gtk_entry_new ();
gtk_editable_set_editable (GTK_EDITABLE (obj->entry), FALSE);
gtk_widget_set_hexpand (obj->entry, TRUE);
gtk_container_add (GTK_CONTAINER (hbox), obj->entry);
object_button = gtk_button_new_with_label ("...");
gtk_container_add (GTK_CONTAINER (hbox), object_button);
g_signal_connect (G_OBJECT (object_button), "clicked",
G_CALLBACK (glade_eprop_model_show_object_dialog), eprop);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (box), hbox);
gtk_container_add (GTK_CONTAINER (box), obj->button);
gtk_widget_show_all (box);
obj->widget = NULL;
/* project = glade_widget_get_project (glade_property_get_widget
(glade_editor_property_get_property (eprop)));
*/
return box;
}
static void glade_eprop_model_load (GladeEditorProperty * eprop, GladeProperty * property)
{
gchar * label;
const gchar * text;
GObject * object;
GladeEditorPropertyClass * parent_class =
g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
parent_class->load (eprop, property);
if (property == NULL)
return;
if ((object = g_value_get_object (glade_property_inline_value (property))))
{
label = _("Edit Model");
text = glade_widget_get_name (glade_widget_get_from_gobject (object));
}
else
{
label = _("New Model");
text = "";
}
gtk_button_set_label (GTK_BUTTON (GLADE_EPROP_MODEL (eprop)->button), label);
gtk_entry_set_text (GTK_ENTRY (GLADE_EPROP_MODEL (eprop)->entry), text);
}
static void glade_eprop_model_finalize (GObject * object)
{
GObjectClass * parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
G_OBJECT_CLASS (parent_class)->finalize (object);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ DbModel Action Callback
void glade_db_model_action_activate (GladeWidgetAdaptor * adaptor,
DbModel * model, const gchar * path)
{
glade_eprop_model_show_dialog (NULL,
(GObject *) glade_widget_get_from_gobject (model));
}
//++++++++++++++++++++++++++++++++++++++++++++ DbModelHolder GladeWidgetAdaptor
GladeEditorProperty * glade_db_model_holder_create_eprop (GladeWidgetAdaptor * adaptor,
GladePropertyClass * klass, gboolean use_command)
{
GladeEditorProperty * eprop;
GParamSpec * pspec = glade_property_class_get_pspec (klass);
if (pspec->value_type == DB_TYPE_MODEL)
{
eprop = g_object_new (GLADE_TYPE_EPROP_MODEL,
"property-class", klass,
"use-command", use_command, NULL);
}
else
eprop = GWA_GET_CLASS (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
return eprop;
}
void glade_db_model_write_widget (GladeWidgetAdaptor * adaptor,
GladeWidget * widget, GladeXmlContext * context, GladeXmlNode * node)
{
GladeProperty * prop;
if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
return;
prop = glade_widget_get_property (widget, "use-file");
glade_property_write (prop, context, node);
prop = glade_widget_get_property (widget, "sql");
glade_property_write (prop, context, node);
GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
}

231
glade/glade-db-sql.c Normal file
View File

@ -0,0 +1,231 @@
/*
* Copyright (C) 2013 - Juan Ferrer Toribio
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "glade-vn.h"
#ifdef _HAVE_GTKSOURCEVIEW
#include <gtksourceview/gtksourceview.h>
#include <gtksourceview/gtksourcebuffer.h>
#include <gtksourceview/gtksourcelanguage.h>
#include <gtksourceview/gtksourcelanguagemanager.h>
#endif
#define NEW_SQL _("New SQL statement")
//+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeEPropSql
typedef struct
{
GladeEditorProperty parent;
GtkWidget * button;
GtkWidget * entry;
gint width;
gint height;
}
GladeEPropSql;
GLADE_MAKE_EPROP (GladeEPropSql, glade_eprop_sql)
#define GLADE_TYPE_EPROP_SQL (glade_eprop_sql_get_type())
#define GLADE_EPROP_SQL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EPROP_SQL, GladeEPropSql))
#define GLADE_EPROP_SQL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EPROP_SQL, GladeEPropSqlClass))
#define GLADE_IS_EPROP_SQL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_SQL))
#define GLADE_IS_EPROP_SQL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_SQL))
#define GLADE_EPROP_SQL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_EPROP_SQL, GladeEPropSqlClass))
static void glade_eprop_sql_show_dialog (GtkButton * button, GladeEditorProperty * eprop)
{
gpointer text, buffer;
const gchar * sql;
GladeEPropSql * obj = GLADE_EPROP_SQL (eprop);
PangoFontDescription * font;
GtkWidget * scroll;
GladeProperty * p = glade_editor_property_get_property (eprop);
GtkDialog * dialog = GTK_DIALOG (gtk_dialog_new_with_buttons
(_("SQL Editor")
,GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (eprop)))
,GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT
,GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL
,GTK_STOCK_CLEAR, GTK_RESPONSE_REJECT
,GTK_STOCK_OK, GTK_RESPONSE_OK
,NULL
));
gtk_dialog_set_alternative_button_order (dialog,
GTK_RESPONSE_OK, GTK_RESPONSE_REJECT, GTK_RESPONSE_CANCEL, -1);
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
gtk_window_set_default_size (GTK_WINDOW (dialog), obj->width, obj->height);
scroll = gtk_scrolled_window_new (gtk_adjustment_new (0,0,0,0,0,0),
gtk_adjustment_new (0,0,0,0,0,0));
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
gtk_widget_set_margin_top (scroll, 6);
gtk_widget_set_margin_right (scroll, 6);
gtk_widget_set_margin_bottom (scroll, 6);
gtk_widget_set_margin_left (scroll, 6);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)),
scroll, TRUE, TRUE, 6);
#ifdef _HAVE_GTKSOURCEVIEW
GtkSourceLanguageManager * lm = gtk_source_language_manager_new ();
GtkSourceLanguage * lang = gtk_source_language_manager_get_language (lm, "sql");
text = gtk_source_view_new ();
gtk_source_view_set_tab_width (text, 4);
gtk_source_view_set_show_line_numbers (text, TRUE);
gtk_source_view_set_highlight_current_line (text, TRUE);
buffer = gtk_text_view_get_buffer (text);
gtk_source_buffer_set_language (buffer, lang);
gtk_source_buffer_set_highlight_matching_brackets (buffer, TRUE);
#else
text = gtk_text_view_new ();
buffer = gtk_text_view_get_buffer (text);
#endif
font = pango_font_description_from_string ("Monospace");
gtk_widget_override_font (text, font);
pango_font_description_free (font);
sql = g_value_get_string (glade_property_inline_value (p));
if (sql)
gtk_text_buffer_set_text (buffer, sql, -1);
gtk_container_add (GTK_CONTAINER (scroll), text);
gtk_widget_show_all (scroll);
switch (gtk_dialog_run (dialog))
{
case GTK_RESPONSE_OK:
{
GValue val = G_VALUE_INIT;
GtkTextIter * start = g_new (GtkTextIter, 1),
* end = g_new (GtkTextIter, 1);
g_value_init (&val, G_TYPE_STRING);
gtk_text_buffer_get_bounds (buffer, start, end);
sql = gtk_text_buffer_get_text (buffer, start, end, TRUE);
g_value_set_string (&val, sql);
glade_command_set_property_value (p, &val);
g_value_unset (&val);
g_free (start);
g_free (end);
break;
}
case GTK_RESPONSE_REJECT:
{
GValue val = G_VALUE_INIT;
g_value_init (&val, G_TYPE_STRING);
g_value_set_string (&val, "");
glade_command_set_property_value (p, &val);
g_value_unset (&val);
break;
}
case GTK_RESPONSE_CANCEL:
default:
break;
}
obj->width = gtk_widget_get_allocated_width (GTK_WIDGET (dialog));
obj->height = gtk_widget_get_allocated_height (GTK_WIDGET (dialog));
gtk_widget_destroy (GTK_WIDGET (dialog));
}
static void glade_eprop_sql_entry_text_changed (GtkEntry * entry,
GladeEditorProperty * eprop)
{
const gchar * text = gtk_entry_get_text (entry);
GladeProperty * p = glade_editor_property_get_property (eprop);
if (text)
{
GValue val = G_VALUE_INIT;
g_value_init (&val, G_TYPE_STRING);
g_value_set_string (&val, text);
glade_command_set_property_value (p, &val);
g_value_unset (&val);
}
}
static GtkWidget * glade_eprop_sql_create_input (GladeEditorProperty * eprop)
{
GladeEPropSql * obj = GLADE_EPROP_SQL (eprop);
GtkWidget * box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
obj->entry = gtk_entry_new ();
gtk_widget_set_hexpand (obj->entry, TRUE);
g_signal_connect (obj->entry, "changed",
G_CALLBACK (glade_eprop_sql_entry_text_changed), obj);
gtk_container_add (GTK_CONTAINER (box), obj->entry);
obj->button = gtk_button_new_with_label ("...");
g_signal_connect (obj->button, "clicked",
G_CALLBACK (glade_eprop_sql_show_dialog), obj);
gtk_widget_set_tooltip_text (obj->button, _("Open the SQL Editor"));
gtk_container_add (GTK_CONTAINER (box), obj->button);
gtk_widget_show_all (box);
obj->width = 750;
obj->height = 550;
return box;
}
static void glade_eprop_sql_load (GladeEditorProperty * eprop, GladeProperty * property)
{
const gchar * sql;
GladeEPropSql * obj = GLADE_EPROP_SQL (eprop);
GladeEditorPropertyClass * parent_class =
g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
parent_class->load (eprop, property);
if (!property)
return;
if ((sql = g_value_get_string (glade_property_inline_value (property))))
gtk_entry_set_text (GTK_ENTRY (obj->entry), sql);
}
static void glade_eprop_sql_finalize (GObject * object)
{
GObjectClass * parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (object));
G_OBJECT_CLASS (parent_class)->finalize (object);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++ DbModel GladeWidgetAdaptor
GladeEditorProperty * glade_db_sql_create_eprop (GladeWidgetAdaptor * adaptor,
GladePropertyClass * klass, gboolean use_command)
{
GladeEditorProperty * eprop;
GParamSpec * pspec = glade_property_class_get_pspec (klass);
if (!g_strcmp0 (pspec->name, "sql"))
{
eprop = g_object_new (GLADE_TYPE_EPROP_SQL,
"property-class", klass,
"use-command", use_command, NULL);
}
else
eprop = GWA_GET_CLASS (G_TYPE_OBJECT)->create_eprop (adaptor, klass, use_command);
return eprop;
}

View File

@ -65,5 +65,5 @@ void glade_vn_batch_replace_child (GladeWidgetAdaptor * adaptor,
GList * glade_vn_batch_get_children (GladeWidgetAdaptor * adaptor,
VnBatch * group)
{
return vn_batch_get_objects (group);
return vn_batch_get_objects_list (group);
}

View File

@ -16,15 +16,28 @@
<glade-widget-class name="DbModel" generic-name="model" title="Data Model" icon-name="widget-gtk-liststore">
<properties>
<property id="conn" ignore="True" disabled="True"/>
<property id="sql" ignore="True"/>
<property id="stmt" ignore="True" disabled="True"/>
<property save="False" weight="1.2" id="use-file" ignore="True"/>
<property save="False" weight="1.3" id="sql" ignore="True"/>
</properties>
<actions>
<action stock="gtk-edit" important="True" id="launch_editor" name="Edit&#8230;"/>
</actions>
<action-activate-function>glade_db_model_action_activate</action-activate-function>
<create-editor-property-function>glade_db_sql_create_eprop</create-editor-property-function>
<write-widget-function>glade_db_model_write_widget</write-widget-function>
</glade-widget-class>
<glade-widget-class name="DbIterator" generic-name="iterator" title="Iterator" icon-name="widget-gtk-texttagtable">
<properties>
<property id="conn" ignore="True" disabled="True"/>
<property id="sql" ignore="True"/>
<property id="model" ignore="True">
<parameter-spec>
<type>GParamObject</type>
<value-type>DbModel</value-type>
</parameter-spec>
</property>
</properties>
<create-editor-property-function>glade_db_model_holder_create_eprop</create-editor-property-function>
</glade-widget-class>
<glade-widget-class name="DbParam" generic-name="param" toplevel="True" title="Iterator Parameter" icon-name="widget-gtk-texttag">
@ -47,27 +60,32 @@
<glade-widget-class name="VnGrid" generic-name="grid" title="Grid" icon-name="widget-gtk-treeview">
</glade-widget-class>
<glade-widget-class name="VnColumnCheck" generic-name="column-check" title="Column Check" icon-name="widget-gtk-checkbutton"/>
<glade-widget-class name="VnColumnEntry" generic-name="column-entry" title="Column Entry" icon-name="widget-gtk-entry"/>
<glade-widget-class name="VnColumnCheck" generic-name="column-check" title="Column Check" icon-name="widget-gtk-cellrenderertoggle"/>
<glade-widget-class name="VnColumnEntry" generic-name="column-entry" title="Column Entry" icon-name="widget-gtk-cellrenderertext"/>
<glade-widget-class name="VnColumnSpin" generic-name="column-Spin" title="Column Spin" icon-name="widget-gtk-spinbutton">
<glade-widget-class name="VnColumnSpin" generic-name="column-Spin" title="Column Spin" icon-name="widget-gtk-cellrendererspin">
<properties>
<property id="digits" ignore="True" disabled="True"/>
<property id="climb-rate" ignore="True" disabled="True"/>
</properties>
</glade-widget-class>
<glade-widget-class name="VnColumnCombo" generic-name="column-combo" title="Column Combo" icon-name="widget-gtk-combobox">
<glade-widget-class name="VnColumnCombo" generic-name="column-combo" title="Column Combo" icon-name="widget-gtk-cellrenderercombo">
<properties>
<property id="conn" ignore="True" disabled="True"/>
<property id="sql" ignore="True"/>
<property id="model" ignore="True">
<parameter-spec>
<type>GParamObject</type>
<value-type>DbModel</value-type>
</parameter-spec>
</property>
</properties>
<create-editor-property-function>glade_db_model_holder_create_eprop</create-editor-property-function>
</glade-widget-class>
<glade-widget-class name="VnColumnImage" generic-name="column-image" title="Column Image" icon-name="widget-gtk-image">
<glade-widget-class name="VnColumnImage" generic-name="column-image" title="Column Image" icon-name="widget-gtk-cellrendererpixbuf">
<properties>
<property id="host" ignore="True" weight="0"/>
<property id="path" ignore="True" weight="1"/>
<property id="host" ignore="True"/>
<property id="path" ignore="True"/>
</properties>
</glade-widget-class>
@ -79,17 +97,31 @@
<glade-widget-class name="VnCombo" generic-name="combo" title="Combo Box Field" icon-name="widget-gtk-combobox">
<properties>
<property id="conn" ignore="True" disabled="True"/>
<property id="sql" ignore="True"/>
<property id="model" ignore="True">
<parameter-spec>
<type>GParamObject</type>
<value-type>DbModel</value-type>
</parameter-spec>
</property>
<!-- This is used to avoid weird error about this unexisting property -->
<property id="accelerator" disabled="True"/>
</properties>
<create-editor-property-function>glade_db_model_holder_create_eprop</create-editor-property-function>
</glade-widget-class>
<glade-widget-class name="VnCompletion" generic-name="completion" title="Completion Field" icon-name="widget-gtk-entry">
<properties>
<property id="conn" ignore="True" disabled="True"/>
<property id="sql" ignore="True"/>
<property id="model" ignore="True">
<parameter-spec>
<type>GParamObject</type>
<value-type>DbModel</value-type>
</parameter-spec>
</property>
<property id="field" ignore="True"/>
<!-- This is used to avoid weird error about this unexisting property -->
<property id="accelerator" disabled="True"/>
</properties>
<create-editor-property-function>glade_db_model_holder_create_eprop</create-editor-property-function>
</glade-widget-class>
<glade-widget-class name="VnHttpImage" generic-name="http-image" title="Image retrieved by HTTP" icon-name="widget-gtk-image">
@ -105,7 +137,7 @@
<glade-widget-class name="VnImage" generic-name="image" title="Image Field" icon-name="widget-gtk-image"/>
<glade-widget-class name="VnCalendar" generic-name="calendar" title="Date Field" icon-name="widget-gtk-calendar"/>
<glade-widget-class name="VnDateChooser" generic-name="date-chooser" title="Date Chooser" icon-name="widget-gtk-calendar"/>
<glade-widget-class name="VnBatch" generic-name="batch" toplevel="True" title="Group of objects" icon-name="widget-gtk-vbuttonbox">
<add-child-verify-function>glade_vn_batch_add_verify</add-child-verify-function>
<add-child-function>glade_vn_batch_add_child</add-child-function>
@ -117,7 +149,6 @@
</glade-widget-classes>
<glade-widget-group name="db-toplevels" title="Data Handling">
<glade-widget-class-ref name="VnBatch"/>
<glade-widget-class-ref name="GvnParam"/>
<glade-widget-class-ref name="DbModel"/>
<glade-widget-class-ref name="DbIterator"/>
@ -125,7 +156,7 @@
<glade-widget-class-ref name="DbFileLoader"/>
</glade-widget-group>
<glade-widget-group name="vn-toplevels" title="Grid and Columns">
<glade-widget-group name="vn-toplevels" title="Grid and Columns" weight="1000">
<glade-widget-class-ref name="VnGrid"/>
<glade-widget-class-ref name="VnColumnCheck"/>
<glade-widget-class-ref name="VnColumnCombo"/>
@ -134,7 +165,8 @@
<glade-widget-class-ref name="VnColumnSpin"/>
</glade-widget-group>
<glade-widget-group name="vn-toplevels" title="Data Widgets">
<glade-widget-group name="vn-toplevels" title="Data Widgets" weight="0">
<glade-widget-class-ref name="VnBatch"/>
<glade-widget-class-ref name="VnHandler"/>
<glade-widget-class-ref name="VnEntry"/>
<glade-widget-class-ref name="VnCheck"/>

View File

@ -9,6 +9,7 @@ AM_CPPFLAGS = \
hedera_bin_LDFLAGS = -Wl,--export-dynamic
hedera_bin_SOURCES = main.c
hedera_bin_LDADD = \
$(gtk_LIBS) \
$(top_builddir)/gvn/libgvn.la \
$(top_builddir)/db/libdb.la \
$(top_builddir)/vn/libvn.la
@ -21,12 +22,9 @@ $(hedera_bin_SCRIPTS): $(SCRIPT)
pkgconfig_DATA = hedera.pc
desktop_DATA = vn-hedera.desktop
HOST=verdnatura.es
certdir = $(datadir)/ca-certificates/$(HOST)
cert_DATA = cacert.pem
syscertdir = $(sysconfdir)/ssl/certs
desktop_DATA = \
vn-hedera.desktop \
vn-hedera-debug.desktop
man_MANS = hedera.1
@ -37,9 +35,5 @@ EXTRA_DIST = \
DISTCLEANFILES = \
$(hedera_bin_SCRIPTS) \
hedera.pc \
vn-hedera.desktop
install-data-hook:
mkdir -p $(DESTDIR)$(syscertdir)
(cd $(DESTDIR)$(syscertdir) && \
$(LN_S) -f $(DESTDIR)$(certdir)/$(cert_DATA) $(HOST).pem)
vn-hedera.desktop \
vn-hedera-debug.desktop

View File

@ -7,9 +7,13 @@ hedera \- modular management system
.SH SYNOPSIS
.B hedera
.\"RI [ options ]
.RB [\-\-lib-dir|\-l
.IR path \|]
.RB [\-\-data-dir|\-l
.IR path \|]
.RB [\-\-query-dir|\-l
.IR path \|]
.br
.SH DESCRIPTION
.B hedera
is an enterprise management and administration application. It features modular
@ -26,9 +30,12 @@ will look for the modules in /usr/lib/hedera/module and for its corresponding
data (GUI files, configuration...) in /usr/share/hedera/module but more
directories can be added by setting
.B VN_MODULE_LIB_PATH
(for the binaries) and
(for the binaries),
.B VN_MODULE_DATA_PATH
(for the additional data). These environment variables are intended for testing
(for the additional data) and
.B VN_MODULE_QUERY_PATH
(for SQL query files) that can also be set automatically passing the
corresponding options. These environment variables are intended for testing
during the developement and the expected is to use the modules installed.
.PP
The format for the configuration files for the modules and some information on
@ -37,7 +44,25 @@ for
.B hedera.
.SH OPTIONS
.TP
.BI \-l\ path ,\ \-\-lib-dir\ path
Sets the value of the
.B VN_MODULE_LIB_PATH
variable. This option can be used mutiple times to specify more than one search
path for the module libraries.
.TP
.BI \-d\ path ,\ \-\-data-dir\ path
Sets the value of the
.B VN_MODULE_DATA_PATH
variable. This option can be used mutiple times to specify more than one search
path for the module data files.
.TP
.BI \-q\ path ,\ \-\-query-dir\ path
Sets the value of the
.B VN_MODULE_QUERY_PATH
variable. This option can be used mutiple times to specify more than one search
path for the module query files.
.br
.SH EXAMPLE
Given a module project in the home directory,
.B hedera
@ -47,4 +72,4 @@ should be called like this to load the module without installing it:
.SH AUTHORS
Copyright (C) 2012 Juan Ferrer Toribio <juan@verdnauta.es>.
.PP
Manual page written by Alejandro T. Colombini.
Manual page written by Alejandro T. Colombini.

View File

@ -1,10 +1,26 @@
#!/bin/bash
if [ -x @bindir@/vn-updater-gui ]
UPDATE=1
while getopts ":u" OPTION
do
case $OPTION in
u)
UPDATE=0
;;
\?|:)
echo "Usage: $0 [-u]"
exit 1
;;
esac
done
if [ "$UPDATE" -eq "1" -a -x @bindir@/vn-updater-gui ]
then
echo "Running updater..."
@bindir@/vn-updater-gui
fi
export LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN=1
exec @bindir@/hedera-bin
exec hedera-bin

View File

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Hedera (Development)
GenericName=Office Tool
Comment=Runtime for the Hedera system (Development)
Exec=hedera -u
Icon=@prefix@/share/@PACKAGE@/vn/image/icon-debug.svg
Terminal=true
Type=Application
Categories=GNOME;GTK;Development;
StartupNotify=true
Version=@VERSION@

View File

@ -3,7 +3,7 @@ Name=Hedera
GenericName=Office Tool
Comment=Runtime for the Hedera system
Exec=hedera
Icon=@prefix@/share/hedera/vn/image/icon.svg
Icon=@prefix@/share/@PACKAGE@/vn/image/icon.svg
Terminal=false
Type=Application
Categories=GNOME;GTK;Office;

View File

@ -1,5 +1,5 @@
include $(top_srcdir)/Makefile.decl
SUBDIRS = \
src \
data \
sql
data

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-requires vn 0.0 -->
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-local-resource-path ../image -->
<object class="GtkActionGroup" id="actions">
<child>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-requires vn 0.0 -->
<!-- interface-requires gtk+ 3.0 -->
<!-- interface-local-resource-path ../image -->
<object class="DbIterator" id="homes">
<property name="sql">SELECT id, street, pc, city, province, ok FROM user_address WHERE #p ORDER BY id</property>
@ -19,7 +19,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
@ -308,7 +307,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkBox" id="box2">
<property name="visible">True</property>

View File

@ -1,13 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires vn 0.0 -->
<!-- interface-requires gtk+ 3.0 -->
<object class="DbIterator" id="account">
<property name="sql">SELECT user_id, group_id, uid, last_change, expire FROM account WHERE #p</property>
<property name="mode">on-iter</property>
</object>
<object class="DbIterator" id="alias">
<property name="sql">SELECT mail_alias_id, user_id FROM mail_alias_account WHERE #p</property>
<!-- interface-requires vn 0.0 -->
<object class="VnBatch" id="iterators">
<child>
<object class="DbIterator" id="account">
<property name="model">account-model</property>
<property name="mode">on-iter</property>
</object>
</child>
<child>
<object class="DbIterator" id="alias">
<property name="model">alias-model</property>
</object>
</child>
<child>
<object class="DbIterator" id="sip">
<property name="model">sip-model</property>
<property name="mode">on-iter</property>
</object>
</child>
<child>
<object class="DbIterator" id="users">
<property name="model">users-model</property>
</object>
</child>
</object>
<object class="GtkBox" id="main">
<property name="visible">True</property>
@ -15,66 +32,6 @@
<property name="border_width">6</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">30</property>
<child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">User name:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="VnEntry" id="entry-search">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="param">search-user</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Search&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
@ -277,9 +234,9 @@
<object class="VnCombo" id="combo1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">user-combo-model</property>
<property name="iterator">users</property>
<property name="column_name">mysql_user_id</property>
<property name="sql">SELECT id, user FROM mysql_user</property>
</object>
<packing>
<property name="left_attach">1</property>
@ -344,9 +301,9 @@
<object class="VnCombo" id="combo2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="model">account-combo-model</property>
<property name="iterator">account</property>
<property name="column_name">group_id</property>
<property name="sql">SELECT id, name FROM `group`</property>
</object>
<packing>
<property name="left_attach">1</property>
@ -518,9 +475,9 @@
<child>
<object class="VnColumnCombo" id="column-combo1">
<property name="title" translatable="yes">Alias</property>
<property name="model">alias-combo-model</property>
<property name="column_name">mail_alias_id</property>
<property name="editable">True</property>
<property name="sql">SELECT id, alias FROM mail_alias</property>
</object>
</child>
</object>
@ -739,6 +696,54 @@
</packing>
</child>
</object>
<object class="VnBatch" id="models">
<child>
<object class="DbModel" id="users-model">
<property name="sql">SELECT u.id, u.name, u.mysql_user_id, m.user, u.active
FROM `user` u
JOIN mysql_user m ON u.mysql_user_id = m.id</property>
</object>
</child>
<child>
<object class="DbModel" id="sip-model">
<property name="sql">SELECT user_id, extension, secret, callerid, callgroup
FROM account_sip
WHERE #p</property>
</object>
</child>
<child>
<object class="DbModel" id="alias-combo-model">
<property name="sql">SELECT id, alias FROM mail_alias</property>
<property name="update_flags"/>
</object>
</child>
<child>
<object class="DbModel" id="user-combo-model">
<property name="sql">SELECT id, user FROM mysql_user</property>
<property name="update_flags"/>
</object>
</child>
<child>
<object class="DbModel" id="alias-model">
<property name="sql">SELECT mail_alias_id, user_id
FROM mail_alias_account
WHERE #p</property>
</object>
</child>
<child>
<object class="DbModel" id="account-model">
<property name="sql">SELECT user_id, group_id, uid, last_change, expire
FROM account
WHERE #p</property>
</object>
</child>
<child>
<object class="DbModel" id="account-combo-model">
<property name="sql">SELECT id, name FROM `group`</property>
<property name="update_flags"/>
</object>
</child>
</object>
<object class="GtkDialog" id="password-dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@ -898,11 +903,4 @@
</child>
</object>
<object class="DbParam" id="search-user"/>
<object class="DbIterator" id="sip">
<property name="sql">SELECT user_id, extension, secret, callerid, callgroup FROM account_sip WHERE #p</property>
<property name="mode">on-iter</property>
</object>
<object class="DbIterator" id="users">
<property name="sql">SELECT u.id, u.name, u.mysql_user_id, m.user, u.active FROM `user` u JOIN mysql_user m ON u.mysql_user_id = m.id</property>
</object>
</interface>

28
module/sql/.svn/entries Normal file
View File

@ -0,0 +1,28 @@
10
dir
309
svn://www.verdnatura.es/hedera/trunk/module/sql
svn://www.verdnatura.es/hedera
2013-07-05T08:50:39.387803Z
307
juan
d9127786-647a-4bcf-81f6-65b2d4e6f3ab

View File

@ -0,0 +1 @@
SELECT name, color, id FROM item;

View File

@ -5,7 +5,8 @@ example_lib_LTLIBRARIES = libexample.la
AM_CPPFLAGS = \
-I$(top_srcdir) \
$(gtk_CFLAGS)
$(gtk_CFLAGS) \
$(DEFINES)
libexample_la_LDFLAGS = -avoid-version
libexample_la_LIBADD = $(top_builddir)/vn/libvn.la
libexample_la_SOURCES = \
@ -16,6 +17,11 @@ libexample_la_SOURCES = \
vn-customer.h \
vn-customer.c
example_querydir = $(module_querydir)/example
example_query_DATA = ../sql/example/consulter.sql
DEFINES = -D_QUERY_PATH=\"$(module_querydir)\"
install-data-hook:
rm -f $(DESTDIR)$(module_libdir)/libexample.la
rm -f $(DESTDIR)$(module_libdir)/libexample.a

View File

@ -20,6 +20,8 @@
G_DEFINE_TYPE (VnConsulter, vn_consulter, VN_TYPE_FORM);
#define FILE_KW "sql://"
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
void vn_consulter_clean_clicked (GtkButton * button, VnConsulter * obj)
@ -63,11 +65,14 @@ static void vn_consulter_model_status_changed (DbModel * model,
DbModelStatus status, VnConsulter * obj)
{
GList * n;
GtkTreeView * tv = GTK_TREE_VIEW (obj->tree);
GtkTreeView * tv = GTK_TREE_VIEW (obj->grid);
GList * cols = gtk_tree_view_get_columns (tv);
for (n = cols; n; n = n->next)
gtk_tree_view_remove_column (tv, n->data);
{
GtkTreeViewColumn * col = n->data;
gtk_tree_view_remove_column (tv, col);
}
g_list_free (cols);
@ -76,9 +81,8 @@ static void vn_consulter_model_status_changed (DbModel * model,
case DB_MODEL_STATUS_READY:
{
gint i;
gint cols = db_model_get_ncols (model);
for (i = 0; i < cols; i++)
for (i = 0; i < db_model_get_ncols (model); i++)
{
VnColumn * column;
GType col_type, type = db_model_get_column_type (model, i);
@ -92,7 +96,7 @@ static void vn_consulter_model_status_changed (DbModel * model,
if (i == 7) col_type = VN_TYPE_COLUMN_IMAGE;
column = vn_grid_append_column (obj->tree, i
column = vn_grid_append_column (obj->grid, i
,db_model_get_column_name (model, i)
,col_type
,TRUE, FALSE
@ -135,14 +139,23 @@ void vn_consulter_send (GtkButton * button, VnConsulter * obj)
vn_consulter_set_message (obj, sql);
model = db_model_new_with_sql (VN_FORM (obj)->conn, sql);
if (g_str_has_prefix (sql, FILE_KW))
{
const gchar * filename = sql + g_utf8_strlen (FILE_KW, -1);
db_conn_set_query_path (VN_FORM (obj)->conn, _QUERY_PATH);
model = db_model_new_with_file (VN_FORM (obj)->conn, filename);
g_message ("VnConsulter: query loaded from \"%s/%s.sql\"", _QUERY_PATH, filename);
}
else
model = db_model_new_with_sql (VN_FORM (obj)->conn, sql);
g_signal_connect (model, "status-changed",
G_CALLBACK (vn_consulter_model_status_changed), obj);
iterator = db_iterator_new (model);
iterator->mode = DB_ITERATOR_MODE_ON_DEMAND;
vn_handler_set_iterator (obj->handler, iterator);
vn_grid_set_iterator (obj->tree, iterator);
vn_grid_set_iterator (obj->grid, iterator);
vn_consulter_mode_toggled (GTK_TOGGLE_BUTTON (obj->mode), obj);
@ -159,7 +172,7 @@ static void vn_consulter_open (VnConsulter * obj)
gchar * queries[] =
{
//MySQL (kk schema)
"/*my*/SELECT id, name, item_id, item_id2, amount, item.price "
"/*my*/SELECT id, name, item_id, item_id2, amount, item.price "
"FROM movement JOIN item USING (item_id, item_id2)"
,"/*my*/SELECT item_id,item_id2, i.name, m.id, m.amount, m.price "
"FROM item i LEFT JOIN movement m USING (item_id, item_id2)"
@ -170,7 +183,7 @@ static void vn_consulter_open (VnConsulter * obj)
"FROM item i LEFT JOIN movement m ON i.id = m.item_id"
,"/*pg*/SELECT m.id, amount, item_id, name, color "
"FROM movement m JOIN item ON m.item_id = item.id"
,"/*pg*/SELECT * FROM item"
,FILE_KW"example/consulter"
,"/*pg*/ SELECT id1, id2, name, ok, date, number, floating, image "
"FROM prueben"
,NULL
@ -180,10 +193,10 @@ static void vn_consulter_open (VnConsulter * obj)
obj->combo = vn_form_get (form, "query");
obj->tv = vn_form_get (form, "treeview");
obj->mode = vn_form_get (form, "mode");
obj->tree = vn_form_get (form, "consulter");
obj->grid = vn_form_get (form, "consulter");
obj->handler = vn_form_get (form, "handler");
gtk_entry_set_placeholder_text (vn_form_get (form, "combo-entry"),
_("Write your query here or select one from the list"));
_("Type or select a query"));
gtk_tree_view_insert_column_with_attributes (obj->tv, -1, "Mensaje",
gtk_cell_renderer_text_new (), "text", 0, NULL);

View File

@ -30,13 +30,11 @@ typedef struct _VnConsulterClass VnConsulterClass;
struct _VnConsulter
{
VnForm parent;
GtkButton * connect;
GtkListStore * model;
GtkCheckButton * mode;
GtkComboBoxText * combo;
GtkTreeView * tv;
GtkContainer * box;
VnGrid * tree;
VnGrid * grid;
VnHandler * handler;
};

View File

@ -57,7 +57,7 @@ static void vn_users_on_password_changed (DbRequest * request, VnUsers * obj)
if (g_value_get_int (&value) != -1)
gtk_widget_hide (GTK_WIDGET (obj->password_dialog));
else
vn_users_reset_dialog (obj, _("The password is too week."));
vn_users_reset_dialog (obj, _("The password is too weak."));
g_value_unset (&value);
}
@ -78,12 +78,10 @@ void vn_users_on_dialog_response (GtkDialog * dialog, gint response_id, VnUsers
else
{
SqlString * query;
query = sql_string_new ("SELECT user_set_password (#user, #password)"
,"user", GVN_TYPE_PARAM, obj->user_id
,"password", G_TYPE_STRING, password
,NULL
);
query = sql_string_new ("SELECT user_set_password (#p, #p)");
sql_string_add_param (query, obj->user_id);
sql_string_add_value (query, G_TYPE_STRING, password);
db_conn_query_with_stmt_async (VN_FORM (obj)->conn
,SQL_STMT (query)

View File

@ -16,7 +16,16 @@
*/
#include <libpq-fe.h>
#include <postgres_fe.h>
//#include <postgres_fe.h>
// Replaces postgres_fe.h until it gets fixed
#ifndef FRONTEND
#define FRONTEND 1
#endif
#include "c.h"
// end of the "fix"
#include <catalog/pg_type.h>
// Macros to avoid redefinition warnings for constants
#undef PACKAGE_BUGREPORT
@ -332,6 +341,7 @@ static DbResultSet * __db_pg_query
switch (PQresultStatus (res))
{
case PGRES_COMMAND_OK:
case PGRES_SINGLE_TUPLE:
case PGRES_TUPLES_OK:
{
gchar ** q_t = NULL;
@ -674,9 +684,9 @@ static DbResultSet * __db_pg_query
{// Serial fields
GValue * v = g_new0 (GValue, 1);
gchar ** split = g_strsplit_set (pg_val, "(':)", G_MAXINT8);
SqlObject * function = sql_function_new ("currval", NULL);
SqlFunction * function = sql_function_new ("currval", NULL);
g_value_set_string (g_value_init (v, G_TYPE_STRING), split[2]);
sql_object_add_child (function, "params", sql_value_new_with_value (v));
sql_function_add_param (function, sql_value_new_with_value (v));
g_value_unset (v);
g_free (v);
g_value_take_object (g_value_init (&def[j], SQL_TYPE_FUNCTION),

View File

@ -13,6 +13,7 @@ plugin/pg/db-pg.c
db/db-iterator.c
db/db-model.c
db/db-model-holder.c
db/db-calc.c
db/db-param.c
db/db-conn.c
@ -44,4 +45,11 @@ vn/gui/main.glade
vn/gui/child-window.glade
vn/gui/actions.glade
glade/glade-db-model.c
glade/glade-db-sql.c
module/data/example.xml
module/data/users.glade
module/src/vn-users.c
module/data/consulter.glade
module/src/vn-consulter.c

View File

@ -1,11 +1,9 @@
module/data/example.xml
module/data/consulter.glade
module/data/customer.glade
module/data/signer.glade
module/src/vn-consulter.c
module/src/vn-customer.c
module/src/vn-signer.c
module/src/vn-users.c
template/lib-object.c

378
po/ca.po
View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: hedera 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-07-10 11:56+0200\n"
"POT-Creation-Date: 2013-10-08 09:59+0200\n"
"PO-Revision-Date: 2013-06-04 13:38+0200\n"
"Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n"
"Language-Team: Catalan\n"
@ -132,7 +132,7 @@ msgstr ""
msgid "The master GvnParam of this parameter"
msgstr ""
#: ../gvn/gvn-param.c:457 ../db/db-iterator.c:1070
#: ../gvn/gvn-param.c:457 ../db/db-iterator.c:985
msgid "Mode"
msgstr ""
@ -164,7 +164,7 @@ msgstr ""
msgid "The type of the value"
msgstr ""
#: ../gvn/gvn-param.c:485 ../vn/vn-field.c:553 ../vn/vn-column.c:354
#: ../gvn/gvn-param.c:485 ../vn/vn-field.c:553 ../vn/vn-column.c:401
msgid "Editable"
msgstr ""
@ -172,7 +172,7 @@ msgstr ""
msgid "Whether the param value can be modified"
msgstr ""
#: ../gvn/gvn-param.c:492 ../vn/vn-field.c:560
#: ../gvn/gvn-param.c:492 ../vn/vn-field.c:560 ../vn/vn-column.c:408
msgid "Null"
msgstr ""
@ -213,9 +213,7 @@ msgstr ""
msgid "The value"
msgstr ""
#: ../sql/sql-string.c:198 ../db/db-iterator.c:1063 ../db/db-model.c:3411
#: ../db/db-request.c:466 ../vn/field/vn-combo.c:356
#: ../vn/field/vn-completion.c:315 ../vn/column/vn-column-combo.c:297
#: ../sql/sql-string.c:198 ../db/db-model.c:3459 ../db/db-request.c:461
msgid "SQL"
msgstr ""
@ -223,111 +221,91 @@ msgstr ""
msgid "An arbitrary SQL string"
msgstr ""
#: ../plugin/mysql/db-mysql.c:68 ../plugin/pg/db-pg.c:76
#: ../plugin/mysql/db-mysql.c:68 ../plugin/pg/db-pg.c:85
#, c-format
msgid "Can't allocate the needed memory"
msgstr ""
#: ../db/db-iterator.c:284
msgid "DbIterator: Can't reassign the 'model' property"
msgstr ""
#: ../db/db-iterator.c:942
msgid "DbIterator: Can't set the 'conn' property because model isn't set"
msgstr ""
#: ../db/db-iterator.c:1049 ../db/db-calc.c:329 ../vn/field/vn-combo.c:342
#: ../vn/column/vn-column-combo.c:283
msgid "Model"
msgstr ""
#: ../db/db-iterator.c:1050
msgid "The DbModel handled by the iterator"
msgstr ""
#: ../db/db-iterator.c:1056 ../db/db-model.c:3395 ../db/db-request.c:459
#: ../vn/vn-gui.c:1531 ../vn/vn-form.c:241 ../vn/field/vn-combo.c:349
#: ../vn/field/vn-completion.c:308 ../vn/column/vn-column-combo.c:290
msgid "Connection"
msgstr ""
#: ../db/db-iterator.c:1057 ../vn/field/vn-combo.c:350
#: ../vn/field/vn-completion.c:309 ../vn/column/vn-column-combo.c:291
msgid "The connection used by the model"
msgstr ""
#: ../db/db-iterator.c:1064 ../vn/field/vn-combo.c:357
#: ../vn/field/vn-completion.c:316 ../vn/column/vn-column-combo.c:298
msgid "The SQL query used to create the model"
msgstr ""
#: ../db/db-iterator.c:1071
#: ../db/db-iterator.c:986
msgid "The mode in which the iterator is working"
msgstr ""
#: ../db/db-iterator.c:1078
#: ../db/db-iterator.c:993
#, fuzzy
msgid "Remember selection"
msgstr "Recordar"
#: ../db/db-iterator.c:1079
#: ../db/db-iterator.c:994
msgid "Wether to rememeber the selection when model is refreshed"
msgstr ""
#: ../db/db-model.c:3396
#: ../db/db-model.c:3443 ../db/db-request.c:454 ../vn/vn-gui.c:1531
#: ../vn/vn-form.c:235
msgid "Connection"
msgstr ""
#: ../db/db-model.c:3444
msgid "The DbConn that manages the connection to the database"
msgstr ""
#: ../db/db-model.c:3403 ../db/db-request.c:473
#: ../db/db-model.c:3451 ../db/db-request.c:468
msgid "Statement"
msgstr ""
#: ../db/db-model.c:3404
#: ../db/db-model.c:3452
msgid "The statement which retrieves the data"
msgstr ""
#: ../db/db-model.c:3412
#: ../db/db-model.c:3460
msgid ""
"Depending on the \"use-file\" property this will be the path to a file with "
"queries for the model or a SQL string"
msgstr ""
#: ../db/db-model.c:3421
#: ../db/db-model.c:3469
msgid "Use file"
msgstr ""
#: ../db/db-model.c:3422
#: ../db/db-model.c:3470
msgid ""
"If this is set to TRUE, the \"sql\" property will hold the name of a file "
"containing a query, if set to FALSE, \"sql\" is used as an SQL string"
msgstr ""
#: ../db/db-model.c:3431
#: ../db/db-model.c:3479
msgid "Main Table"
msgstr ""
#: ../db/db-model.c:3432
#: ../db/db-model.c:3480
msgid "The main table of the model"
msgstr ""
#: ../db/db-model.c:3439
#: ../db/db-model.c:3487
msgid "Update flags"
msgstr ""
#: ../db/db-model.c:3440
#: ../db/db-model.c:3488
msgid "The flags that indicate how a model can be modified"
msgstr ""
#: ../db/db-model.c:3448
#: ../db/db-model.c:3496
msgid "Result position"
msgstr ""
#: ../db/db-model.c:3449
#: ../db/db-model.c:3497
msgid ""
"The position where the query that will fill the model will be placed in a "
"multi-query"
msgstr ""
#: ../db/db-model-holder.c:70 ../db/db-calc.c:329
msgid "Model"
msgstr ""
#: ../db/db-model-holder.c:71
msgid "The model used by the holder"
msgstr ""
#: ../db/db-calc.c:330
msgid "The model where the operations will be applied"
msgstr ""
@ -364,121 +342,121 @@ msgstr ""
msgid "A column to apply the operations over it"
msgstr ""
#: ../db/db-param.c:243 ../vn/vn-grid.c:349 ../vn/vn-field.c:532
#: ../db/db-param.c:251 ../vn/vn-grid.c:357 ../vn/vn-field.c:532
msgid "Iterator"
msgstr ""
#: ../db/db-param.c:244
#: ../db/db-param.c:252
msgid "The iterator owner of param"
msgstr ""
#: ../db/db-param.c:250 ../vn/vn-column.c:340
#: ../db/db-param.c:258 ../vn/vn-column.c:387
msgid "Column index"
msgstr ""
#: ../db/db-param.c:251
#: ../db/db-param.c:259
msgid "The referenced column index"
msgstr ""
#: ../db/db-param.c:257 ../vn/vn-field.c:539 ../vn/vn-column.c:347
#: ../db/db-param.c:265 ../vn/vn-field.c:539 ../vn/vn-column.c:394
msgid "Column name"
msgstr "Nom de la columna"
#: ../db/db-param.c:258 ../vn/vn-column.c:348
#: ../db/db-param.c:266 ../vn/vn-column.c:395
msgid "The referenced column name"
msgstr "Nom de la columna referenciada"
#: ../db/db-conn.c:279 ../db/db-conn.c:284
#: ../db/db-conn.c:282 ../db/db-conn.c:287
#, c-format
msgid "Can't load DbPlugin '%s': %s"
msgstr ""
#: ../db/db-conn.c:297
#: ../db/db-conn.c:300
#, c-format
msgid "Plugin can't be loaded"
msgstr ""
#: ../db/db-conn.c:413
#: ../db/db-conn.c:416
#, c-format
msgid "Can't open a new connection, it's already open."
msgstr ""
#: ../db/db-conn.c:555
#: ../db/db-conn.c:558
#, c-format
msgid "The query is empty."
msgstr ""
#: ../db/db-conn.c:1060
#: ../db/db-conn.c:1037
msgid "Plugin"
msgstr ""
#: ../db/db-conn.c:1061
#: ../db/db-conn.c:1038
msgid "The name of the plugin"
msgstr ""
#: ../db/db-conn.c:1067
#: ../db/db-conn.c:1044
msgid "Query path"
msgstr ""
#: ../db/db-conn.c:1068
#: ../db/db-conn.c:1045
msgid "The path where query files are located"
msgstr ""
#: ../db/db-conn.c:1074 ../db/db-file-loader.c:724
#: ../vn/column/vn-column-image.c:475
#: ../db/db-conn.c:1051 ../db/db-file-loader.c:724
#: ../vn/column/vn-column-image.c:477
msgid "Host"
msgstr ""
#: ../db/db-conn.c:1075
#: ../db/db-conn.c:1052
msgid "The host name to connect to"
msgstr ""
#: ../db/db-conn.c:1081 ../module/data/users.glade.h:4
#: ../db/db-conn.c:1058 ../module/data/users.glade.h:2
msgid "User"
msgstr "Usuari"
#: ../db/db-conn.c:1082
#: ../db/db-conn.c:1059
msgid "The user name"
msgstr "Nom d'usuari"
#: ../db/db-conn.c:1088
#: ../db/db-conn.c:1065
msgid "DB name"
msgstr ""
#: ../db/db-conn.c:1089
#: ../db/db-conn.c:1066
msgid "The default schema"
msgstr ""
#: ../db/db-request.c:315
#: ../db/db-request.c:311
#, c-format
msgid "The request was canceled"
msgstr ""
#: ../db/db-request.c:460
#: ../db/db-request.c:455
msgid "The connection used to render and execute the query"
msgstr ""
#: ../db/db-request.c:467
#: ../db/db-request.c:462
msgid "The SQL query to execute"
msgstr ""
#: ../db/db-request.c:474
#: ../db/db-request.c:469
msgid "The statement to execute"
msgstr ""
#: ../db/db-request.c:480
#: ../db/db-request.c:475
msgid "Result"
msgstr ""
#: ../db/db-request.c:481
#: ../db/db-request.c:476
msgid "The result data of the query"
msgstr ""
#: ../db/db-request.c:487
#: ../db/db-request.c:482
msgid "Error"
msgstr ""
#: ../db/db-request.c:488
#: ../db/db-request.c:483
msgid "The GError, if an error ocurred"
msgstr ""
@ -492,11 +470,11 @@ msgstr ""
msgid "Unknown content length of file %s"
msgstr ""
#: ../db/db-file-loader.c:725 ../vn/column/vn-column-image.c:476
#: ../db/db-file-loader.c:725 ../vn/column/vn-column-image.c:478
msgid "The host web server name to get the images"
msgstr ""
#: ../db/db-file-loader.c:732 ../vn/column/vn-column-image.c:483
#: ../db/db-file-loader.c:732 ../vn/column/vn-column-image.c:485
msgid "Path"
msgstr ""
@ -558,7 +536,7 @@ msgstr ""
msgid "Connection closed"
msgstr ""
#: ../vn/vn-gui.c:987 ../vn/field/vn-http-image.c:118
#: ../vn/vn-gui.c:987 ../vn/field/vn-http-image.c:116
msgid "Loading"
msgstr ""
@ -578,17 +556,17 @@ msgstr ""
msgid "The application handler for the entire program"
msgstr ""
#: ../vn/vn-model.c:303
#: ../vn/vn-model.c:317
#, c-format
msgid "Function vn_model_set_sort_func not implemented"
msgstr "Funció vn_model_set_sort_func no implementada"
#: ../vn/vn-model.c:310
#: ../vn/vn-model.c:324
#, c-format
msgid "Function vn_model_set_default_sort_func not implemented"
msgstr "Funció vn_model_set_default_sort_func no implementada"
#: ../vn/vn-grid.c:350
#: ../vn/vn-grid.c:358
msgid "The iterator used by VnGrid"
msgstr ""
@ -652,48 +630,48 @@ msgstr ""
msgid "Sets if it is used to handle a iterator with a single record"
msgstr ""
#: ../vn/vn-form.c:227
#: ../vn/vn-form.c:221
msgid "Name"
msgstr ""
#: ../vn/vn-form.c:228
#: ../vn/vn-form.c:222
msgid "The form name"
msgstr ""
#: ../vn/vn-form.c:234
#: ../vn/vn-form.c:228
msgid "Gui"
msgstr ""
#: ../vn/vn-form.c:235
#: ../vn/vn-form.c:229
msgid "The Gui object"
msgstr ""
#: ../vn/vn-form.c:242
#: ../vn/vn-form.c:236
msgid "The connection used by the module"
msgstr ""
#: ../vn/vn-form.c:248
#: ../vn/vn-form.c:242
msgid "Module"
msgstr ""
#: ../vn/vn-form.c:249
#: ../vn/vn-form.c:243
msgid "The module"
msgstr ""
#: ../vn/vn-login.c:276 ../vn/vn-login.c:278
#: ../vn/vn-login.c:290 ../vn/vn-login.c:292
msgid "Login error"
msgstr ""
#: ../vn/vn-login.c:336
#: ../vn/vn-login.c:348
#, c-format
msgid "Bad connection settings, please check it."
msgstr ""
#: ../vn/vn-login.c:457
#: ../vn/vn-login.c:477
msgid "Application id"
msgstr ""
#: ../vn/vn-login.c:458
#: ../vn/vn-login.c:478
msgid "The application identifier"
msgstr ""
@ -721,7 +699,7 @@ msgstr ""
msgid "Whether the field value is user editable"
msgstr ""
#: ../vn/vn-field.c:561
#: ../vn/vn-field.c:561 ../vn/vn-column.c:409
msgid "Whether the field value can be of type GVN_TYPE_NULL"
msgstr ""
@ -735,31 +713,27 @@ msgstr ""
msgid "The number of decimal places to display."
msgstr ""
#: ../vn/field/vn-combo.c:328 ../vn/column/vn-column-combo.c:269
#: ../vn/field/vn-combo.c:286 ../vn/column/vn-column-combo.c:300
msgid "Index column"
msgstr ""
#: ../vn/field/vn-combo.c:329 ../vn/column/vn-column-combo.c:270
#: ../vn/field/vn-combo.c:287 ../vn/column/vn-column-combo.c:301
msgid "The column index of the model"
msgstr ""
#: ../vn/field/vn-combo.c:335 ../vn/column/vn-column-combo.c:276
#: ../vn/field/vn-combo.c:293 ../vn/column/vn-column-combo.c:307
msgid "Show column"
msgstr ""
#: ../vn/field/vn-combo.c:336 ../vn/column/vn-column-combo.c:277
#: ../vn/field/vn-combo.c:294 ../vn/column/vn-column-combo.c:308
msgid "The column of the model shown by combo"
msgstr ""
#: ../vn/field/vn-combo.c:343 ../vn/column/vn-column-combo.c:284
msgid "The model from which the combo takes the values shown in the list"
msgstr ""
#: ../vn/field/vn-completion.c:322
#: ../vn/field/vn-completion.c:325
msgid "Field"
msgstr ""
#: ../vn/field/vn-completion.c:323
#: ../vn/field/vn-completion.c:326
msgid "The name of the field used for the search"
msgstr ""
@ -776,49 +750,49 @@ msgstr ""
msgid "Select the image"
msgstr ""
#: ../vn/field/vn-http-image.c:69
#: ../vn/field/vn-http-image.c:70
msgid "Undefined error"
msgstr ""
#: ../vn/field/vn-http-image.c:145
#: ../vn/field/vn-http-image.c:142
msgid "File loader already set"
msgstr ""
#. Se usará para subir imagenes y cambiar nombres, o abrir un menu contextual
#. g_signal_connect (obj, "event", G_CALLBACK (vn_http_image_cb_event), obj);
#: ../vn/field/vn-http-image.c:184
#: ../vn/field/vn-http-image.c:181
msgid "No image set"
msgstr ""
#: ../vn/field/vn-http-image.c:210
#: ../vn/field/vn-http-image.c:207
msgid "File loader"
msgstr ""
#: ../vn/field/vn-http-image.c:211
#: ../vn/field/vn-http-image.c:208
msgid "A DbFileLoader, used to download the files"
msgstr ""
#: ../vn/field/vn-http-image.c:218
#: ../vn/field/vn-http-image.c:215
msgid "File path"
msgstr ""
#: ../vn/field/vn-http-image.c:219
#: ../vn/field/vn-http-image.c:216
msgid "The relative path to the image from file loader path"
msgstr ""
#: ../vn/field/vn-http-image.c:226
#: ../vn/field/vn-http-image.c:223
msgid "Image bytes"
msgstr ""
#: ../vn/field/vn-http-image.c:227
#: ../vn/field/vn-http-image.c:224
msgid "A GBytes structure with the image data"
msgstr ""
#: ../vn/vn-column.c:341
#: ../vn/vn-column.c:388
msgid "The column index in the model"
msgstr ""
#: ../vn/vn-column.c:355
#: ../vn/vn-column.c:402
msgid "Whether the column values are editable"
msgstr ""
@ -830,25 +804,25 @@ msgstr ""
msgid "The acceleration rate when you hold down a button."
msgstr ""
#: ../vn/column/vn-column-image.c:484
#: ../vn/column/vn-column-image.c:486
msgid "Base path from the host where the images will be downloaded"
msgstr ""
#: ../vn/column/vn-column-image.c:491
#: ../vn/column/vn-column-image.c:493
msgid "Tooltip path"
msgstr ""
#: ../vn/column/vn-column-image.c:492
#: ../vn/column/vn-column-image.c:494
msgid ""
"Prefix for the path of the images to be shown in the tooltip. Starting after "
"the path of the column and appending the name on each cell"
msgstr ""
#: ../vn/column/vn-column-image.c:501
#: ../vn/column/vn-column-image.c:503
msgid "Tooltip size"
msgstr ""
#: ../vn/column/vn-column-image.c:502
#: ../vn/column/vn-column-image.c:504
msgid ""
"Size of the bigger side of the tooltip images, the another side will be "
"scaled accordingly and smaller images won't be scaled"
@ -889,7 +863,7 @@ msgstr "Accés"
msgid "User:"
msgstr "Usuari:"
#: ../vn/gui/login.glade.h:9 ../module/data/users.glade.h:8
#: ../vn/gui/login.glade.h:9 ../module/data/users.glade.h:6
msgid "Password:"
msgstr "Contrasenya:"
@ -989,87 +963,179 @@ msgctxt "View menu option"
msgid "Tool_bar"
msgstr ""
#: ../module/data/users.glade.h:1
#, fuzzy
msgid "User name:"
msgstr "Nom d'usuari"
#: ../module/data/users.glade.h:2
msgid "<b>Search</b>"
#: ../glade/glade-db-model.c:121
msgid "Create and set a model for a DbModelHolder"
msgstr ""
#: ../module/data/users.glade.h:3
#: ../glade/glade-db-model.c:153
msgid "Model configuration"
msgstr ""
#: ../glade/glade-db-model.c:153
msgid "DbModel properties configuration"
msgstr ""
#: ../glade/glade-db-model.c:238
msgid "Select a DbModel for the property"
msgstr ""
#: ../glade/glade-db-model.c:259 ../glade/glade-db-model.c:306
msgid "New Model"
msgstr ""
#: ../glade/glade-db-model.c:301
msgid "Edit Model"
msgstr ""
#: ../glade/glade-db-sql.c:27
msgid "New SQL statement"
msgstr ""
#: ../glade/glade-db-sql.c:59
msgid "SQL Editor"
msgstr ""
#: ../glade/glade-db-sql.c:174
msgid "Open the SQL Editor"
msgstr ""
#: ../module/data/users.glade.h:1
msgid "Identifier"
msgstr ""
#: ../module/data/users.glade.h:5
#: ../module/data/users.glade.h:3
msgid "MySQL User"
msgstr ""
#: ../module/data/users.glade.h:6
#: ../module/data/users.glade.h:4
msgid "Enabled"
msgstr ""
#: ../module/data/users.glade.h:7
#: ../module/data/users.glade.h:5
msgid "Name:"
msgstr ""
#: ../module/data/users.glade.h:9
#: ../module/data/users.glade.h:7
msgid "MySQL user:"
msgstr ""
#: ../module/data/users.glade.h:10
#: ../module/data/users.glade.h:8
msgid "Enabled:"
msgstr ""
#: ../module/data/users.glade.h:11
#: ../module/data/users.glade.h:9
msgid "Identifier:"
msgstr ""
#: ../module/data/users.glade.h:12
#: ../module/data/users.glade.h:10
msgid "UID:"
msgstr ""
#: ../module/data/users.glade.h:13
#: ../module/data/users.glade.h:11
msgid "Main group:"
msgstr ""
#: ../module/data/users.glade.h:14
#: ../module/data/users.glade.h:12
msgid "Last change:"
msgstr ""
#: ../module/data/users.glade.h:15
#: ../module/data/users.glade.h:13
msgid "Expires:"
msgstr ""
#: ../module/data/users.glade.h:16
#: ../module/data/users.glade.h:14
msgid "Account"
msgstr ""
#: ../module/data/users.glade.h:17
#: ../module/data/users.glade.h:15
msgid "Alias"
msgstr ""
#: ../module/data/users.glade.h:18
#: ../module/data/users.glade.h:16
msgid "Mail alias"
msgstr ""
#: ../module/data/users.glade.h:19
#: ../module/data/users.glade.h:17
msgid "Extension:"
msgstr ""
#: ../module/data/users.glade.h:20
#: ../module/data/users.glade.h:18
msgid "Secret:"
msgstr ""
#: ../module/data/users.glade.h:21
#: ../module/data/users.glade.h:19
msgid "Call group:"
msgstr ""
#: ../module/data/users.glade.h:22
#: ../module/data/users.glade.h:20
msgid "SIP"
msgstr ""
#: ../module/data/users.glade.h:23
#: ../module/data/users.glade.h:21
#, fuzzy
msgid "Change password"
msgstr "Repetir contrasenya:"
#: ../module/data/users.glade.h:22
msgid "Repeat password:"
msgstr "Repetir contrasenya:"
#: ../module/src/vn-users.c:60
msgid "The password is too weak."
msgstr ""
#: ../module/src/vn-users.c:75
msgid "The password can't be empty."
msgstr ""
#: ../module/src/vn-users.c:77
msgid "Passwords do not match."
msgstr ""
#: ../module/data/consulter.glade.h:1
msgid "Send"
msgstr ""
#: ../module/data/consulter.glade.h:2
msgid "Send the current query"
msgstr ""
#: ../module/data/consulter.glade.h:3
msgid "Clean"
msgstr ""
#: ../module/data/consulter.glade.h:4
msgid "Clean the messages"
msgstr ""
#: ../module/data/consulter.glade.h:5
msgid "_Consulter"
msgstr ""
#: ../module/data/consulter.glade.h:6
msgid "Query:"
msgstr ""
#: ../module/data/consulter.glade.h:7
msgid "Immediate changes"
msgstr ""
#: ../module/data/consulter.glade.h:8
msgid "Start"
msgstr ""
#: ../module/data/consulter.glade.h:9
msgid "Commit"
msgstr ""
#: ../module/data/consulter.glade.h:10
msgid "Rollback"
msgstr ""
#: ../module/src/vn-consulter.c:199
msgid "Type or select a query"
msgstr ""
#, fuzzy
#~ msgid "User name:"
#~ msgstr "Nom d'usuari"

394
po/es.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: hedera 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-07-10 11:56+0200\n"
"POT-Creation-Date: 2013-10-08 09:59+0200\n"
"PO-Revision-Date: 2013-06-04 13:36+0200\n"
"Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n"
"Language-Team: Spanish\n"
@ -134,7 +134,7 @@ msgstr "Maestro"
msgid "The master GvnParam of this parameter"
msgstr "El GvnParam maestro de este parámetro"
#: ../gvn/gvn-param.c:457 ../db/db-iterator.c:1070
#: ../gvn/gvn-param.c:457 ../db/db-iterator.c:985
msgid "Mode"
msgstr "Modo"
@ -166,7 +166,7 @@ msgstr "Tipo Glib"
msgid "The type of the value"
msgstr "El tipo del valor"
#: ../gvn/gvn-param.c:485 ../vn/vn-field.c:553 ../vn/vn-column.c:354
#: ../gvn/gvn-param.c:485 ../vn/vn-field.c:553 ../vn/vn-column.c:401
msgid "Editable"
msgstr "Editable"
@ -174,7 +174,7 @@ msgstr "Editable"
msgid "Whether the param value can be modified"
msgstr "Indica si el parámetro puede modificarse"
#: ../gvn/gvn-param.c:492 ../vn/vn-field.c:560
#: ../gvn/gvn-param.c:492 ../vn/vn-field.c:560 ../vn/vn-column.c:408
msgid "Null"
msgstr "Nulo"
@ -215,9 +215,7 @@ msgstr "El parametro al cual está vinculado"
msgid "The value"
msgstr "Valor"
#: ../sql/sql-string.c:198 ../db/db-iterator.c:1063 ../db/db-model.c:3411
#: ../db/db-request.c:466 ../vn/field/vn-combo.c:356
#: ../vn/field/vn-completion.c:315 ../vn/column/vn-column-combo.c:297
#: ../sql/sql-string.c:198 ../db/db-model.c:3459 ../db/db-request.c:461
msgid "SQL"
msgstr "SQL"
@ -225,72 +223,42 @@ msgstr "SQL"
msgid "An arbitrary SQL string"
msgstr "Una cadena SQL arbitraria"
#: ../plugin/mysql/db-mysql.c:68 ../plugin/pg/db-pg.c:76
#: ../plugin/mysql/db-mysql.c:68 ../plugin/pg/db-pg.c:85
#, c-format
msgid "Can't allocate the needed memory"
msgstr "No es posible asignar la memoria necesaria"
#: ../db/db-iterator.c:284
msgid "DbIterator: Can't reassign the 'model' property"
msgstr "DbIterator: No puedo reasignarse la propiedad 'model'"
#: ../db/db-iterator.c:942
msgid "DbIterator: Can't set the 'conn' property because model isn't set"
msgstr ""
"DbIterator: No se pudo configurar la propiedad porque 'model' no está "
"configurado"
#: ../db/db-iterator.c:1049 ../db/db-calc.c:329 ../vn/field/vn-combo.c:342
#: ../vn/column/vn-column-combo.c:283
msgid "Model"
msgstr "Modelo"
#: ../db/db-iterator.c:1050
msgid "The DbModel handled by the iterator"
msgstr "El DbModel manejado por el iterador"
#: ../db/db-iterator.c:1056 ../db/db-model.c:3395 ../db/db-request.c:459
#: ../vn/vn-gui.c:1531 ../vn/vn-form.c:241 ../vn/field/vn-combo.c:349
#: ../vn/field/vn-completion.c:308 ../vn/column/vn-column-combo.c:290
msgid "Connection"
msgstr "Conexión"
#: ../db/db-iterator.c:1057 ../vn/field/vn-combo.c:350
#: ../vn/field/vn-completion.c:309 ../vn/column/vn-column-combo.c:291
msgid "The connection used by the model"
msgstr "La conexión empleada por el modelo"
#: ../db/db-iterator.c:1064 ../vn/field/vn-combo.c:357
#: ../vn/field/vn-completion.c:316 ../vn/column/vn-column-combo.c:298
msgid "The SQL query used to create the model"
msgstr "La consulta SQL usada para crear el modelo"
#: ../db/db-iterator.c:1071
#: ../db/db-iterator.c:986
msgid "The mode in which the iterator is working"
msgstr "El modo en el que está trabajando el iterador"
msgstr "El modo en el que está trabajando el Iterator"
#: ../db/db-iterator.c:1078
#: ../db/db-iterator.c:993
msgid "Remember selection"
msgstr "Recordar fila seleccionada"
#: ../db/db-iterator.c:1079
#: ../db/db-iterator.c:994
msgid "Wether to rememeber the selection when model is refreshed"
msgstr ""
"Si se recordará o no la fila seleccionado cuando se refresque el modelo"
#: ../db/db-model.c:3396
#: ../db/db-model.c:3443 ../db/db-request.c:454 ../vn/vn-gui.c:1531
#: ../vn/vn-form.c:235
msgid "Connection"
msgstr "Conexión"
#: ../db/db-model.c:3444
msgid "The DbConn that manages the connection to the database"
msgstr "La DbConn que controla la conexión a la base de datos"
#: ../db/db-model.c:3403 ../db/db-request.c:473
#: ../db/db-model.c:3451 ../db/db-request.c:468
msgid "Statement"
msgstr "Consulta"
#: ../db/db-model.c:3404
#: ../db/db-model.c:3452
msgid "The statement which retrieves the data"
msgstr "La consulta que recupera los datos"
#: ../db/db-model.c:3412
#: ../db/db-model.c:3460
msgid ""
"Depending on the \"use-file\" property this will be the path to a file with "
"queries for the model or a SQL string"
@ -298,39 +266,39 @@ msgstr ""
"Dependiendo de la propiedad \"use-file\", esta propiedad será la ruta a un "
"fichero con consultas para el modelo o una cadena SQL"
#: ../db/db-model.c:3421
#: ../db/db-model.c:3469
msgid "Use file"
msgstr "Usa fichero"
#: ../db/db-model.c:3422
#: ../db/db-model.c:3470
msgid ""
"If this is set to TRUE, the \"sql\" property will hold the name of a file "
"containing a query, if set to FALSE, \"sql\" is used as an SQL string"
msgstr ""
"Si está puesto a TRUE, la propiedad \"sql\" contiene el nombre de un "
"archivo, si es falso, \"sql\" se usa como una cadena SQL"
"Si es TRUE, la propiedad \"sql\" contiene el nombre de un archivo, si es "
"falso, \"sql\" se usa como una cadena SQL"
#: ../db/db-model.c:3431
#: ../db/db-model.c:3479
msgid "Main Table"
msgstr "Tabla principal"
#: ../db/db-model.c:3432
#: ../db/db-model.c:3480
msgid "The main table of the model"
msgstr "La tabla principal del modelo"
#: ../db/db-model.c:3439
#: ../db/db-model.c:3487
msgid "Update flags"
msgstr "Flags de actualización"
#: ../db/db-model.c:3440
#: ../db/db-model.c:3488
msgid "The flags that indicate how a model can be modified"
msgstr "Indican como se puede modificar el modelo"
#: ../db/db-model.c:3448
#: ../db/db-model.c:3496
msgid "Result position"
msgstr "Posición del resultado"
#: ../db/db-model.c:3449
#: ../db/db-model.c:3497
msgid ""
"The position where the query that will fill the model will be placed in a "
"multi-query"
@ -338,6 +306,14 @@ msgstr ""
"La posición en la que se situa la consulta que pone datos en el modelo en "
"una consulta múltiple"
#: ../db/db-model-holder.c:70 ../db/db-calc.c:329
msgid "Model"
msgstr "Modelo"
#: ../db/db-model-holder.c:71
msgid "The model used by the holder"
msgstr "La conexión empleada por el objeto"
#: ../db/db-calc.c:330
msgid "The model where the operations will be applied"
msgstr "El modelo en el que se aplicarán las operaciones"
@ -374,123 +350,123 @@ msgstr "Columna"
msgid "A column to apply the operations over it"
msgstr "Una columna sobre la que se aplicarán las operaciones"
#: ../db/db-param.c:243 ../vn/vn-grid.c:349 ../vn/vn-field.c:532
#: ../db/db-param.c:251 ../vn/vn-grid.c:357 ../vn/vn-field.c:532
msgid "Iterator"
msgstr "Iterator"
#: ../db/db-param.c:244
#: ../db/db-param.c:252
msgid "The iterator owner of param"
msgstr "El iterador dueño del parámetro"
msgstr "El Iterator dueño del parámetro"
#: ../db/db-param.c:250 ../vn/vn-column.c:340
#: ../db/db-param.c:258 ../vn/vn-column.c:387
msgid "Column index"
msgstr "Columna usada como índice"
msgstr "Posición"
#: ../db/db-param.c:251
#: ../db/db-param.c:259
msgid "The referenced column index"
msgstr "El índice de la columna referenciada"
msgstr "La posición de la columna en el Grid"
#: ../db/db-param.c:257 ../vn/vn-field.c:539 ../vn/vn-column.c:347
#: ../db/db-param.c:265 ../vn/vn-field.c:539 ../vn/vn-column.c:394
msgid "Column name"
msgstr "Nombre de la columna"
#: ../db/db-param.c:258 ../vn/vn-column.c:348
#: ../db/db-param.c:266 ../vn/vn-column.c:395
msgid "The referenced column name"
msgstr ""
"El nombre del campo en el Iterator vinculado al Grid al que pretenece la "
"columna"
#: ../db/db-conn.c:279 ../db/db-conn.c:284
#: ../db/db-conn.c:282 ../db/db-conn.c:287
#, c-format
msgid "Can't load DbPlugin '%s': %s"
msgstr "No se puede cargar el DbPlugin '%s': %s"
#: ../db/db-conn.c:297
#: ../db/db-conn.c:300
#, c-format
msgid "Plugin can't be loaded"
msgstr "No se puede cargar el plug-in"
#: ../db/db-conn.c:413
#: ../db/db-conn.c:416
#, c-format
msgid "Can't open a new connection, it's already open."
msgstr "No se puede abrir una nueva conexión, ya está abierta"
#: ../db/db-conn.c:555
#: ../db/db-conn.c:558
#, c-format
msgid "The query is empty."
msgstr "La consulta está vacía."
#: ../db/db-conn.c:1060
#: ../db/db-conn.c:1037
msgid "Plugin"
msgstr "Plugin"
#: ../db/db-conn.c:1061
#: ../db/db-conn.c:1038
msgid "The name of the plugin"
msgstr "El nombre del plugin"
#: ../db/db-conn.c:1067
#: ../db/db-conn.c:1044
msgid "Query path"
msgstr "Ruta de consultas"
#: ../db/db-conn.c:1068
#: ../db/db-conn.c:1045
msgid "The path where query files are located"
msgstr "La ruta donde se encuentran los archivos de consultas"
#: ../db/db-conn.c:1074 ../db/db-file-loader.c:724
#: ../vn/column/vn-column-image.c:475
#: ../db/db-conn.c:1051 ../db/db-file-loader.c:724
#: ../vn/column/vn-column-image.c:477
msgid "Host"
msgstr "Host"
#: ../db/db-conn.c:1075
#: ../db/db-conn.c:1052
msgid "The host name to connect to"
msgstr "El nombre del host al que se conectará"
#: ../db/db-conn.c:1081 ../module/data/users.glade.h:4
#: ../db/db-conn.c:1058 ../module/data/users.glade.h:2
msgid "User"
msgstr "Usuario"
#: ../db/db-conn.c:1082
#: ../db/db-conn.c:1059
msgid "The user name"
msgstr "El nombre de usuario"
#: ../db/db-conn.c:1088
#: ../db/db-conn.c:1065
msgid "DB name"
msgstr "Nombre de la BD"
#: ../db/db-conn.c:1089
#: ../db/db-conn.c:1066
msgid "The default schema"
msgstr "El esquema por defecto"
#: ../db/db-request.c:315
#: ../db/db-request.c:311
#, c-format
msgid "The request was canceled"
msgstr "Se ha cancelado la petición"
#: ../db/db-request.c:460
#: ../db/db-request.c:455
msgid "The connection used to render and execute the query"
msgstr "La conexión empleada por el módulo"
#: ../db/db-request.c:467
#: ../db/db-request.c:462
msgid "The SQL query to execute"
msgstr "La consulta SQL a ejecutar"
#: ../db/db-request.c:474
#: ../db/db-request.c:469
msgid "The statement to execute"
msgstr "La instrucción a ejecutar"
#: ../db/db-request.c:480
#: ../db/db-request.c:475
msgid "Result"
msgstr "Result"
#: ../db/db-request.c:481
#: ../db/db-request.c:476
msgid "The result data of the query"
msgstr "Los datos resultantes de la consulta"
#: ../db/db-request.c:487
#: ../db/db-request.c:482
msgid "Error"
msgstr "Error"
#: ../db/db-request.c:488
#: ../db/db-request.c:483
msgid "The GError, if an error ocurred"
msgstr "El GError, si ha habido algún error"
@ -504,11 +480,11 @@ msgstr "No se ha guardado %s en la cache"
msgid "Unknown content length of file %s"
msgstr "Longitud del contenido del archivo %s desconocida"
#: ../db/db-file-loader.c:725 ../vn/column/vn-column-image.c:476
#: ../db/db-file-loader.c:725 ../vn/column/vn-column-image.c:478
msgid "The host web server name to get the images"
msgstr "El nombre del servidor web al que se conectará"
#: ../db/db-file-loader.c:732 ../vn/column/vn-column-image.c:483
#: ../db/db-file-loader.c:732 ../vn/column/vn-column-image.c:485
msgid "Path"
msgstr "Ruta"
@ -572,7 +548,7 @@ msgstr "Conexión perdida"
msgid "Connection closed"
msgstr "Conexión cerrada"
#: ../vn/vn-gui.c:987 ../vn/field/vn-http-image.c:118
#: ../vn/vn-gui.c:987 ../vn/field/vn-http-image.c:116
msgid "Loading"
msgstr "Cargando"
@ -592,19 +568,19 @@ msgstr "Aplicación"
msgid "The application handler for the entire program"
msgstr "El manejador de la aplicación para todo el programa"
#: ../vn/vn-model.c:303
#: ../vn/vn-model.c:317
#, c-format
msgid "Function vn_model_set_sort_func not implemented"
msgstr "Función vn_model_set_sort_func no implementada"
#: ../vn/vn-model.c:310
#: ../vn/vn-model.c:324
#, c-format
msgid "Function vn_model_set_default_sort_func not implemented"
msgstr "Función vn_model_set_default_sort_func no implementada"
#: ../vn/vn-grid.c:350
#: ../vn/vn-grid.c:358
msgid "The iterator used by VnGrid"
msgstr "El iterador empleado por VnGrid"
msgstr "El Iterator empleado por VnGrid"
#: ../vn/vn-handler.c:65
msgid "Are you sure you want to delete the selected record?"
@ -666,48 +642,48 @@ msgstr "Registro simple"
msgid "Sets if it is used to handle a iterator with a single record"
msgstr "Indica si se utiliza para manejar solo un registro"
#: ../vn/vn-form.c:227
#: ../vn/vn-form.c:221
msgid "Name"
msgstr "Nombre"
#: ../vn/vn-form.c:228
#: ../vn/vn-form.c:222
msgid "The form name"
msgstr "El nombre del form"
#: ../vn/vn-form.c:234
#: ../vn/vn-form.c:228
msgid "Gui"
msgstr "Gui"
#: ../vn/vn-form.c:235
#: ../vn/vn-form.c:229
msgid "The Gui object"
msgstr "El objeto Gui"
#: ../vn/vn-form.c:242
#: ../vn/vn-form.c:236
msgid "The connection used by the module"
msgstr "La conexión empleada por el módulo"
#: ../vn/vn-form.c:248
#: ../vn/vn-form.c:242
msgid "Module"
msgstr "Módulo"
#: ../vn/vn-form.c:249
#: ../vn/vn-form.c:243
msgid "The module"
msgstr "El módulo"
#: ../vn/vn-login.c:276 ../vn/vn-login.c:278
#: ../vn/vn-login.c:290 ../vn/vn-login.c:292
msgid "Login error"
msgstr "Error de identificación"
#: ../vn/vn-login.c:336
#: ../vn/vn-login.c:348
#, c-format
msgid "Bad connection settings, please check it."
msgstr "Conexión mal configurado, compruébelo por favor"
#: ../vn/vn-login.c:457
#: ../vn/vn-login.c:477
msgid "Application id"
msgstr "Id de la aplicación"
#: ../vn/vn-login.c:458
#: ../vn/vn-login.c:478
msgid "The application identifier"
msgstr "El identificador de la aplicación"
@ -725,17 +701,17 @@ msgstr "El parámetro en el que el campo escribe/lee su valor"
#: ../vn/vn-field.c:533
msgid "The iterator used to get the field param"
msgstr "El iterador con el que se obtiene el parámetro"
msgstr "El Iterator con el que se obtiene el parámetro"
#: ../vn/vn-field.c:540
msgid "The column name on the iterator"
msgstr "El nombre de la columna en el iterador"
msgstr "El nombre de la columna en el Iterator"
#: ../vn/vn-field.c:554
msgid "Whether the field value is user editable"
msgstr "Si el valor de campo puede ser editado por el usuario"
#: ../vn/vn-field.c:561
#: ../vn/vn-field.c:561 ../vn/vn-column.c:409
msgid "Whether the field value can be of type GVN_TYPE_NULL"
msgstr "Si el campo puede ser del tipo GVN_TYPE_NULL"
@ -749,31 +725,27 @@ msgstr "Dígitos"
msgid "The number of decimal places to display."
msgstr "El número de posiciones decimales que se muestran"
#: ../vn/field/vn-combo.c:328 ../vn/column/vn-column-combo.c:269
#: ../vn/field/vn-combo.c:286 ../vn/column/vn-column-combo.c:300
msgid "Index column"
msgstr "Columna índice"
#: ../vn/field/vn-combo.c:329 ../vn/column/vn-column-combo.c:270
#: ../vn/field/vn-combo.c:287 ../vn/column/vn-column-combo.c:301
msgid "The column index of the model"
msgstr "El índice de columna del modelo"
#: ../vn/field/vn-combo.c:335 ../vn/column/vn-column-combo.c:276
#: ../vn/field/vn-combo.c:293 ../vn/column/vn-column-combo.c:307
msgid "Show column"
msgstr "Mostrar columna"
#: ../vn/field/vn-combo.c:336 ../vn/column/vn-column-combo.c:277
#: ../vn/field/vn-combo.c:294 ../vn/column/vn-column-combo.c:308
msgid "The column of the model shown by combo"
msgstr "La columna del modelo que se mostrará en el combo"
#: ../vn/field/vn-combo.c:343 ../vn/column/vn-column-combo.c:284
msgid "The model from which the combo takes the values shown in the list"
msgstr "El modelo del cual el combo tomará los valores mostrados en la lista"
#: ../vn/field/vn-completion.c:322
#: ../vn/field/vn-completion.c:325
msgid "Field"
msgstr "Campo"
#: ../vn/field/vn-completion.c:323
#: ../vn/field/vn-completion.c:326
msgid "The name of the field used for the search"
msgstr "El nombre del campo usado para la búsqueda"
@ -790,49 +762,49 @@ msgstr "Cambiar fecha"
msgid "Select the image"
msgstr "Selecciona la imagen"
#: ../vn/field/vn-http-image.c:69
#: ../vn/field/vn-http-image.c:70
msgid "Undefined error"
msgstr "Error indefinido"
#: ../vn/field/vn-http-image.c:145
#: ../vn/field/vn-http-image.c:142
msgid "File loader already set"
msgstr "Ya se ha especificado un cargador de archivos"
#. Se usará para subir imagenes y cambiar nombres, o abrir un menu contextual
#. g_signal_connect (obj, "event", G_CALLBACK (vn_http_image_cb_event), obj);
#: ../vn/field/vn-http-image.c:184
#: ../vn/field/vn-http-image.c:181
msgid "No image set"
msgstr "Sin imagen"
#: ../vn/field/vn-http-image.c:210
#: ../vn/field/vn-http-image.c:207
msgid "File loader"
msgstr "Cargador de archivos"
#: ../vn/field/vn-http-image.c:211
#: ../vn/field/vn-http-image.c:208
msgid "A DbFileLoader, used to download the files"
msgstr "Un DbFileLoader que se usará para descargar los archivos"
#: ../vn/field/vn-http-image.c:218
#: ../vn/field/vn-http-image.c:215
msgid "File path"
msgstr "Ruta del archivo"
#: ../vn/field/vn-http-image.c:219
#: ../vn/field/vn-http-image.c:216
msgid "The relative path to the image from file loader path"
msgstr "La ruta relativa a la imagen desde la del cargador de archivos"
#: ../vn/field/vn-http-image.c:226
#: ../vn/field/vn-http-image.c:223
msgid "Image bytes"
msgstr "Bytes"
#: ../vn/field/vn-http-image.c:227
#: ../vn/field/vn-http-image.c:224
msgid "A GBytes structure with the image data"
msgstr "Una estructura GBytes con los datos de la imágen"
#: ../vn/vn-column.c:341
#: ../vn/vn-column.c:388
msgid "The column index in the model"
msgstr "El índice de la columna en el modelo"
#: ../vn/vn-column.c:355
#: ../vn/vn-column.c:402
msgid "Whether the column values are editable"
msgstr "Si el valor de campo puede ser editado por el usuario"
@ -844,15 +816,15 @@ msgstr "Tasa de subida"
msgid "The acceleration rate when you hold down a button."
msgstr "La tasa de aceleración cuando se mantiene apretado el botón."
#: ../vn/column/vn-column-image.c:484
#: ../vn/column/vn-column-image.c:486
msgid "Base path from the host where the images will be downloaded"
msgstr "La ruta base del servidor desde donde se descargarán las imágenes."
#: ../vn/column/vn-column-image.c:491
#: ../vn/column/vn-column-image.c:493
msgid "Tooltip path"
msgstr "Ruta del tooltip"
#: ../vn/column/vn-column-image.c:492
#: ../vn/column/vn-column-image.c:494
msgid ""
"Prefix for the path of the images to be shown in the tooltip. Starting after "
"the path of the column and appending the name on each cell"
@ -861,11 +833,11 @@ msgstr ""
"Empezando desde la ruta de la columna y añadiendo después el nombre de cada "
"celda"
#: ../vn/column/vn-column-image.c:501
#: ../vn/column/vn-column-image.c:503
msgid "Tooltip size"
msgstr "Tamaño del tooltip"
#: ../vn/column/vn-column-image.c:502
#: ../vn/column/vn-column-image.c:504
msgid ""
"Size of the bigger side of the tooltip images, the another side will be "
"scaled accordingly and smaller images won't be scaled"
@ -908,7 +880,7 @@ msgstr "Acceso"
msgid "User:"
msgstr "Usuario:"
#: ../vn/gui/login.glade.h:9 ../module/data/users.glade.h:8
#: ../vn/gui/login.glade.h:9 ../module/data/users.glade.h:6
msgid "Password:"
msgstr "Clave:"
@ -1022,86 +994,174 @@ msgctxt "View menu option"
msgid "Tool_bar"
msgstr "_Barra de herramientas"
#: ../glade/glade-db-model.c:121
msgid "Create and set a model for a DbModelHolder"
msgstr "Crear y configurar un modelo para un DbModelHolder"
#: ../glade/glade-db-model.c:153
msgid "Model configuration"
msgstr "Configuración del Model"
#: ../glade/glade-db-model.c:153
msgid "DbModel properties configuration"
msgstr "Configuración de propiedades de DbModelo"
#: ../glade/glade-db-model.c:238
msgid "Select a DbModel for the property"
msgstr "Selecciona un DbModel para la propiedad"
#: ../glade/glade-db-model.c:259 ../glade/glade-db-model.c:306
msgid "New Model"
msgstr "Nuevo Modelo"
#: ../glade/glade-db-model.c:301
msgid "Edit Model"
msgstr "Editar Modelo"
#: ../glade/glade-db-sql.c:27
msgid "New SQL statement"
msgstr "Nueva consulta SQL"
#: ../glade/glade-db-sql.c:59
msgid "SQL Editor"
msgstr "Editor SQL"
#: ../glade/glade-db-sql.c:174
msgid "Open the SQL Editor"
msgstr "Abrir el Editor SQL"
#: ../module/data/users.glade.h:1
msgid "User name:"
msgstr "Nombre de usuario:"
#: ../module/data/users.glade.h:2
msgid "<b>Search</b>"
msgstr "<b>Buscar</b>"
#: ../module/data/users.glade.h:3
msgid "Identifier"
msgstr "Identificador"
#: ../module/data/users.glade.h:5
#: ../module/data/users.glade.h:3
msgid "MySQL User"
msgstr "Usuario MySQL"
#: ../module/data/users.glade.h:6
#: ../module/data/users.glade.h:4
msgid "Enabled"
msgstr "Habilitado"
#: ../module/data/users.glade.h:7
#: ../module/data/users.glade.h:5
msgid "Name:"
msgstr "Nombre:"
#: ../module/data/users.glade.h:9
#: ../module/data/users.glade.h:7
msgid "MySQL user:"
msgstr "Usuario MySQL:"
#: ../module/data/users.glade.h:10
#: ../module/data/users.glade.h:8
msgid "Enabled:"
msgstr "Habilitado:"
#: ../module/data/users.glade.h:11
#: ../module/data/users.glade.h:9
msgid "Identifier:"
msgstr "Identificador:"
#: ../module/data/users.glade.h:12
#: ../module/data/users.glade.h:10
msgid "UID:"
msgstr "UID:"
#: ../module/data/users.glade.h:13
#: ../module/data/users.glade.h:11
msgid "Main group:"
msgstr "Grupo principal:"
#: ../module/data/users.glade.h:14
#: ../module/data/users.glade.h:12
msgid "Last change:"
msgstr "Último cambio:"
#: ../module/data/users.glade.h:15
#: ../module/data/users.glade.h:13
msgid "Expires:"
msgstr "Expira:"
#: ../module/data/users.glade.h:16
#: ../module/data/users.glade.h:14
msgid "Account"
msgstr "Cuenta"
#: ../module/data/users.glade.h:17
#: ../module/data/users.glade.h:15
msgid "Alias"
msgstr "Alias"
#: ../module/data/users.glade.h:18
#: ../module/data/users.glade.h:16
msgid "Mail alias"
msgstr "Alias de correo"
#: ../module/data/users.glade.h:19
#: ../module/data/users.glade.h:17
msgid "Extension:"
msgstr "Extensión:"
#: ../module/data/users.glade.h:20
#: ../module/data/users.glade.h:18
msgid "Secret:"
msgstr "Clave:"
#: ../module/data/users.glade.h:21
#: ../module/data/users.glade.h:19
msgid "Call group:"
msgstr "Call group:"
#: ../module/data/users.glade.h:22
#: ../module/data/users.glade.h:20
msgid "SIP"
msgstr "SIP"
#: ../module/data/users.glade.h:23
#: ../module/data/users.glade.h:21
msgid "Change password"
msgstr "Cambiar contraseña"
#: ../module/data/users.glade.h:22
msgid "Repeat password:"
msgstr "Repetir contraseña:"
#: ../module/src/vn-users.c:60
msgid "The password is too weak."
msgstr "La contraseña es demasiado débil."
#: ../module/src/vn-users.c:75
msgid "The password can't be empty."
msgstr "La contraseña no puede estar vacía."
#: ../module/src/vn-users.c:77
msgid "Passwords do not match."
msgstr "Las contraseñas no coinciden."
#: ../module/data/consulter.glade.h:1
msgid "Send"
msgstr "Enviar"
#: ../module/data/consulter.glade.h:2
msgid "Send the current query"
msgstr "Enviar la consulta actual"
#: ../module/data/consulter.glade.h:3
msgid "Clean"
msgstr "Limpiar"
#: ../module/data/consulter.glade.h:4
msgid "Clean the messages"
msgstr "Limpia los mensajes"
#: ../module/data/consulter.glade.h:5
msgid "_Consulter"
msgstr "_Consultor"
#: ../module/data/consulter.glade.h:6
msgid "Query:"
msgstr "Consulta:"
#: ../module/data/consulter.glade.h:7
msgid "Immediate changes"
msgstr "Cambios inmediatos"
#: ../module/data/consulter.glade.h:8
msgid "Start"
msgstr "Empezar"
#: ../module/data/consulter.glade.h:9
msgid "Commit"
msgstr "Efectuar"
#: ../module/data/consulter.glade.h:10
msgid "Rollback"
msgstr "Deshacer"
#: ../module/src/vn-consulter.c:199
msgid "Type or select a query"
msgstr "Escribe o selecciona la consulta"

374
po/nl.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: hedera 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2013-07-10 11:56+0200\n"
"POT-Creation-Date: 2013-10-08 09:59+0200\n"
"PO-Revision-Date: 2012-10-09 11:38+0200\n"
"Last-Translator: Alejandro T. Colombini Gómez <atcolombini@verdnatura.es>\n"
"Language-Team: Dutch\n"
@ -134,7 +134,7 @@ msgstr ""
msgid "The master GvnParam of this parameter"
msgstr ""
#: ../gvn/gvn-param.c:457 ../db/db-iterator.c:1070
#: ../gvn/gvn-param.c:457 ../db/db-iterator.c:985
msgid "Mode"
msgstr ""
@ -166,7 +166,7 @@ msgstr ""
msgid "The type of the value"
msgstr ""
#: ../gvn/gvn-param.c:485 ../vn/vn-field.c:553 ../vn/vn-column.c:354
#: ../gvn/gvn-param.c:485 ../vn/vn-field.c:553 ../vn/vn-column.c:401
msgid "Editable"
msgstr ""
@ -174,7 +174,7 @@ msgstr ""
msgid "Whether the param value can be modified"
msgstr ""
#: ../gvn/gvn-param.c:492 ../vn/vn-field.c:560
#: ../gvn/gvn-param.c:492 ../vn/vn-field.c:560 ../vn/vn-column.c:408
msgid "Null"
msgstr ""
@ -215,9 +215,7 @@ msgstr ""
msgid "The value"
msgstr ""
#: ../sql/sql-string.c:198 ../db/db-iterator.c:1063 ../db/db-model.c:3411
#: ../db/db-request.c:466 ../vn/field/vn-combo.c:356
#: ../vn/field/vn-completion.c:315 ../vn/column/vn-column-combo.c:297
#: ../sql/sql-string.c:198 ../db/db-model.c:3459 ../db/db-request.c:461
msgid "SQL"
msgstr ""
@ -225,110 +223,90 @@ msgstr ""
msgid "An arbitrary SQL string"
msgstr ""
#: ../plugin/mysql/db-mysql.c:68 ../plugin/pg/db-pg.c:76
#: ../plugin/mysql/db-mysql.c:68 ../plugin/pg/db-pg.c:85
#, c-format
msgid "Can't allocate the needed memory"
msgstr ""
#: ../db/db-iterator.c:284
msgid "DbIterator: Can't reassign the 'model' property"
msgstr ""
#: ../db/db-iterator.c:942
msgid "DbIterator: Can't set the 'conn' property because model isn't set"
msgstr ""
#: ../db/db-iterator.c:1049 ../db/db-calc.c:329 ../vn/field/vn-combo.c:342
#: ../vn/column/vn-column-combo.c:283
msgid "Model"
msgstr ""
#: ../db/db-iterator.c:1050
msgid "The DbModel handled by the iterator"
msgstr ""
#: ../db/db-iterator.c:1056 ../db/db-model.c:3395 ../db/db-request.c:459
#: ../vn/vn-gui.c:1531 ../vn/vn-form.c:241 ../vn/field/vn-combo.c:349
#: ../vn/field/vn-completion.c:308 ../vn/column/vn-column-combo.c:290
msgid "Connection"
msgstr ""
#: ../db/db-iterator.c:1057 ../vn/field/vn-combo.c:350
#: ../vn/field/vn-completion.c:309 ../vn/column/vn-column-combo.c:291
msgid "The connection used by the model"
msgstr ""
#: ../db/db-iterator.c:1064 ../vn/field/vn-combo.c:357
#: ../vn/field/vn-completion.c:316 ../vn/column/vn-column-combo.c:298
msgid "The SQL query used to create the model"
msgstr ""
#: ../db/db-iterator.c:1071
#: ../db/db-iterator.c:986
msgid "The mode in which the iterator is working"
msgstr ""
#: ../db/db-iterator.c:1078
#: ../db/db-iterator.c:993
msgid "Remember selection"
msgstr ""
#: ../db/db-iterator.c:1079
#: ../db/db-iterator.c:994
msgid "Wether to rememeber the selection when model is refreshed"
msgstr ""
#: ../db/db-model.c:3396
#: ../db/db-model.c:3443 ../db/db-request.c:454 ../vn/vn-gui.c:1531
#: ../vn/vn-form.c:235
msgid "Connection"
msgstr ""
#: ../db/db-model.c:3444
msgid "The DbConn that manages the connection to the database"
msgstr ""
#: ../db/db-model.c:3403 ../db/db-request.c:473
#: ../db/db-model.c:3451 ../db/db-request.c:468
msgid "Statement"
msgstr ""
#: ../db/db-model.c:3404
#: ../db/db-model.c:3452
msgid "The statement which retrieves the data"
msgstr ""
#: ../db/db-model.c:3412
#: ../db/db-model.c:3460
msgid ""
"Depending on the \"use-file\" property this will be the path to a file with "
"queries for the model or a SQL string"
msgstr ""
#: ../db/db-model.c:3421
#: ../db/db-model.c:3469
msgid "Use file"
msgstr ""
#: ../db/db-model.c:3422
#: ../db/db-model.c:3470
msgid ""
"If this is set to TRUE, the \"sql\" property will hold the name of a file "
"containing a query, if set to FALSE, \"sql\" is used as an SQL string"
msgstr ""
#: ../db/db-model.c:3431
#: ../db/db-model.c:3479
msgid "Main Table"
msgstr ""
#: ../db/db-model.c:3432
#: ../db/db-model.c:3480
msgid "The main table of the model"
msgstr ""
#: ../db/db-model.c:3439
#: ../db/db-model.c:3487
msgid "Update flags"
msgstr ""
#: ../db/db-model.c:3440
#: ../db/db-model.c:3488
msgid "The flags that indicate how a model can be modified"
msgstr ""
#: ../db/db-model.c:3448
#: ../db/db-model.c:3496
msgid "Result position"
msgstr ""
#: ../db/db-model.c:3449
#: ../db/db-model.c:3497
msgid ""
"The position where the query that will fill the model will be placed in a "
"multi-query"
msgstr ""
#: ../db/db-model-holder.c:70 ../db/db-calc.c:329
msgid "Model"
msgstr ""
#: ../db/db-model-holder.c:71
msgid "The model used by the holder"
msgstr ""
#: ../db/db-calc.c:330
msgid "The model where the operations will be applied"
msgstr ""
@ -365,121 +343,121 @@ msgstr ""
msgid "A column to apply the operations over it"
msgstr ""
#: ../db/db-param.c:243 ../vn/vn-grid.c:349 ../vn/vn-field.c:532
#: ../db/db-param.c:251 ../vn/vn-grid.c:357 ../vn/vn-field.c:532
msgid "Iterator"
msgstr ""
#: ../db/db-param.c:244
#: ../db/db-param.c:252
msgid "The iterator owner of param"
msgstr ""
#: ../db/db-param.c:250 ../vn/vn-column.c:340
#: ../db/db-param.c:258 ../vn/vn-column.c:387
msgid "Column index"
msgstr ""
#: ../db/db-param.c:251
#: ../db/db-param.c:259
msgid "The referenced column index"
msgstr ""
#: ../db/db-param.c:257 ../vn/vn-field.c:539 ../vn/vn-column.c:347
#: ../db/db-param.c:265 ../vn/vn-field.c:539 ../vn/vn-column.c:394
msgid "Column name"
msgstr ""
#: ../db/db-param.c:258 ../vn/vn-column.c:348
#: ../db/db-param.c:266 ../vn/vn-column.c:395
msgid "The referenced column name"
msgstr ""
#: ../db/db-conn.c:279 ../db/db-conn.c:284
#: ../db/db-conn.c:282 ../db/db-conn.c:287
#, c-format
msgid "Can't load DbPlugin '%s': %s"
msgstr ""
#: ../db/db-conn.c:297
#: ../db/db-conn.c:300
#, c-format
msgid "Plugin can't be loaded"
msgstr ""
#: ../db/db-conn.c:413
#: ../db/db-conn.c:416
#, c-format
msgid "Can't open a new connection, it's already open."
msgstr ""
#: ../db/db-conn.c:555
#: ../db/db-conn.c:558
#, c-format
msgid "The query is empty."
msgstr ""
#: ../db/db-conn.c:1060
#: ../db/db-conn.c:1037
msgid "Plugin"
msgstr ""
#: ../db/db-conn.c:1061
#: ../db/db-conn.c:1038
msgid "The name of the plugin"
msgstr ""
#: ../db/db-conn.c:1067
#: ../db/db-conn.c:1044
msgid "Query path"
msgstr ""
#: ../db/db-conn.c:1068
#: ../db/db-conn.c:1045
msgid "The path where query files are located"
msgstr ""
#: ../db/db-conn.c:1074 ../db/db-file-loader.c:724
#: ../vn/column/vn-column-image.c:475
#: ../db/db-conn.c:1051 ../db/db-file-loader.c:724
#: ../vn/column/vn-column-image.c:477
msgid "Host"
msgstr ""
#: ../db/db-conn.c:1075
#: ../db/db-conn.c:1052
msgid "The host name to connect to"
msgstr ""
#: ../db/db-conn.c:1081 ../module/data/users.glade.h:4
#: ../db/db-conn.c:1058 ../module/data/users.glade.h:2
msgid "User"
msgstr ""
#: ../db/db-conn.c:1082
#: ../db/db-conn.c:1059
msgid "The user name"
msgstr ""
#: ../db/db-conn.c:1088
#: ../db/db-conn.c:1065
msgid "DB name"
msgstr ""
#: ../db/db-conn.c:1089
#: ../db/db-conn.c:1066
msgid "The default schema"
msgstr ""
#: ../db/db-request.c:315
#: ../db/db-request.c:311
#, c-format
msgid "The request was canceled"
msgstr ""
#: ../db/db-request.c:460
#: ../db/db-request.c:455
msgid "The connection used to render and execute the query"
msgstr ""
#: ../db/db-request.c:467
#: ../db/db-request.c:462
msgid "The SQL query to execute"
msgstr ""
#: ../db/db-request.c:474
#: ../db/db-request.c:469
msgid "The statement to execute"
msgstr ""
#: ../db/db-request.c:480
#: ../db/db-request.c:475
msgid "Result"
msgstr ""
#: ../db/db-request.c:481
#: ../db/db-request.c:476
msgid "The result data of the query"
msgstr ""
#: ../db/db-request.c:487
#: ../db/db-request.c:482
msgid "Error"
msgstr ""
#: ../db/db-request.c:488
#: ../db/db-request.c:483
msgid "The GError, if an error ocurred"
msgstr ""
@ -493,11 +471,11 @@ msgstr ""
msgid "Unknown content length of file %s"
msgstr ""
#: ../db/db-file-loader.c:725 ../vn/column/vn-column-image.c:476
#: ../db/db-file-loader.c:725 ../vn/column/vn-column-image.c:478
msgid "The host web server name to get the images"
msgstr ""
#: ../db/db-file-loader.c:732 ../vn/column/vn-column-image.c:483
#: ../db/db-file-loader.c:732 ../vn/column/vn-column-image.c:485
msgid "Path"
msgstr ""
@ -559,7 +537,7 @@ msgstr ""
msgid "Connection closed"
msgstr ""
#: ../vn/vn-gui.c:987 ../vn/field/vn-http-image.c:118
#: ../vn/vn-gui.c:987 ../vn/field/vn-http-image.c:116
msgid "Loading"
msgstr ""
@ -579,17 +557,17 @@ msgstr ""
msgid "The application handler for the entire program"
msgstr ""
#: ../vn/vn-model.c:303
#: ../vn/vn-model.c:317
#, c-format
msgid "Function vn_model_set_sort_func not implemented"
msgstr ""
#: ../vn/vn-model.c:310
#: ../vn/vn-model.c:324
#, c-format
msgid "Function vn_model_set_default_sort_func not implemented"
msgstr ""
#: ../vn/vn-grid.c:350
#: ../vn/vn-grid.c:358
msgid "The iterator used by VnGrid"
msgstr ""
@ -653,48 +631,48 @@ msgstr ""
msgid "Sets if it is used to handle a iterator with a single record"
msgstr ""
#: ../vn/vn-form.c:227
#: ../vn/vn-form.c:221
msgid "Name"
msgstr ""
#: ../vn/vn-form.c:228
#: ../vn/vn-form.c:222
msgid "The form name"
msgstr ""
#: ../vn/vn-form.c:234
#: ../vn/vn-form.c:228
msgid "Gui"
msgstr ""
#: ../vn/vn-form.c:235
#: ../vn/vn-form.c:229
msgid "The Gui object"
msgstr ""
#: ../vn/vn-form.c:242
#: ../vn/vn-form.c:236
msgid "The connection used by the module"
msgstr ""
#: ../vn/vn-form.c:248
#: ../vn/vn-form.c:242
msgid "Module"
msgstr ""
#: ../vn/vn-form.c:249
#: ../vn/vn-form.c:243
msgid "The module"
msgstr ""
#: ../vn/vn-login.c:276 ../vn/vn-login.c:278
#: ../vn/vn-login.c:290 ../vn/vn-login.c:292
msgid "Login error"
msgstr ""
#: ../vn/vn-login.c:336
#: ../vn/vn-login.c:348
#, c-format
msgid "Bad connection settings, please check it."
msgstr ""
#: ../vn/vn-login.c:457
#: ../vn/vn-login.c:477
msgid "Application id"
msgstr ""
#: ../vn/vn-login.c:458
#: ../vn/vn-login.c:478
msgid "The application identifier"
msgstr ""
@ -722,7 +700,7 @@ msgstr ""
msgid "Whether the field value is user editable"
msgstr ""
#: ../vn/vn-field.c:561
#: ../vn/vn-field.c:561 ../vn/vn-column.c:409
msgid "Whether the field value can be of type GVN_TYPE_NULL"
msgstr ""
@ -736,31 +714,27 @@ msgstr ""
msgid "The number of decimal places to display."
msgstr ""
#: ../vn/field/vn-combo.c:328 ../vn/column/vn-column-combo.c:269
#: ../vn/field/vn-combo.c:286 ../vn/column/vn-column-combo.c:300
msgid "Index column"
msgstr ""
#: ../vn/field/vn-combo.c:329 ../vn/column/vn-column-combo.c:270
#: ../vn/field/vn-combo.c:287 ../vn/column/vn-column-combo.c:301
msgid "The column index of the model"
msgstr ""
#: ../vn/field/vn-combo.c:335 ../vn/column/vn-column-combo.c:276
#: ../vn/field/vn-combo.c:293 ../vn/column/vn-column-combo.c:307
msgid "Show column"
msgstr ""
#: ../vn/field/vn-combo.c:336 ../vn/column/vn-column-combo.c:277
#: ../vn/field/vn-combo.c:294 ../vn/column/vn-column-combo.c:308
msgid "The column of the model shown by combo"
msgstr ""
#: ../vn/field/vn-combo.c:343 ../vn/column/vn-column-combo.c:284
msgid "The model from which the combo takes the values shown in the list"
msgstr ""
#: ../vn/field/vn-completion.c:322
#: ../vn/field/vn-completion.c:325
msgid "Field"
msgstr ""
#: ../vn/field/vn-completion.c:323
#: ../vn/field/vn-completion.c:326
msgid "The name of the field used for the search"
msgstr ""
@ -777,49 +751,49 @@ msgstr ""
msgid "Select the image"
msgstr ""
#: ../vn/field/vn-http-image.c:69
#: ../vn/field/vn-http-image.c:70
msgid "Undefined error"
msgstr ""
#: ../vn/field/vn-http-image.c:145
#: ../vn/field/vn-http-image.c:142
msgid "File loader already set"
msgstr ""
#. Se usará para subir imagenes y cambiar nombres, o abrir un menu contextual
#. g_signal_connect (obj, "event", G_CALLBACK (vn_http_image_cb_event), obj);
#: ../vn/field/vn-http-image.c:184
#: ../vn/field/vn-http-image.c:181
msgid "No image set"
msgstr ""
#: ../vn/field/vn-http-image.c:210
#: ../vn/field/vn-http-image.c:207
msgid "File loader"
msgstr ""
#: ../vn/field/vn-http-image.c:211
#: ../vn/field/vn-http-image.c:208
msgid "A DbFileLoader, used to download the files"
msgstr ""
#: ../vn/field/vn-http-image.c:218
#: ../vn/field/vn-http-image.c:215
msgid "File path"
msgstr ""
#: ../vn/field/vn-http-image.c:219
#: ../vn/field/vn-http-image.c:216
msgid "The relative path to the image from file loader path"
msgstr ""
#: ../vn/field/vn-http-image.c:226
#: ../vn/field/vn-http-image.c:223
msgid "Image bytes"
msgstr ""
#: ../vn/field/vn-http-image.c:227
#: ../vn/field/vn-http-image.c:224
msgid "A GBytes structure with the image data"
msgstr ""
#: ../vn/vn-column.c:341
#: ../vn/vn-column.c:388
msgid "The column index in the model"
msgstr ""
#: ../vn/vn-column.c:355
#: ../vn/vn-column.c:402
msgid "Whether the column values are editable"
msgstr ""
@ -831,25 +805,25 @@ msgstr ""
msgid "The acceleration rate when you hold down a button."
msgstr ""
#: ../vn/column/vn-column-image.c:484
#: ../vn/column/vn-column-image.c:486
msgid "Base path from the host where the images will be downloaded"
msgstr ""
#: ../vn/column/vn-column-image.c:491
#: ../vn/column/vn-column-image.c:493
msgid "Tooltip path"
msgstr ""
#: ../vn/column/vn-column-image.c:492
#: ../vn/column/vn-column-image.c:494
msgid ""
"Prefix for the path of the images to be shown in the tooltip. Starting after "
"the path of the column and appending the name on each cell"
msgstr ""
#: ../vn/column/vn-column-image.c:501
#: ../vn/column/vn-column-image.c:503
msgid "Tooltip size"
msgstr ""
#: ../vn/column/vn-column-image.c:502
#: ../vn/column/vn-column-image.c:504
msgid ""
"Size of the bigger side of the tooltip images, the another side will be "
"scaled accordingly and smaller images won't be scaled"
@ -889,7 +863,7 @@ msgstr ""
msgid "User:"
msgstr ""
#: ../vn/gui/login.glade.h:9 ../module/data/users.glade.h:8
#: ../vn/gui/login.glade.h:9 ../module/data/users.glade.h:6
msgid "Password:"
msgstr ""
@ -989,86 +963,174 @@ msgctxt "View menu option"
msgid "Tool_bar"
msgstr ""
#: ../glade/glade-db-model.c:121
msgid "Create and set a model for a DbModelHolder"
msgstr ""
#: ../glade/glade-db-model.c:153
msgid "Model configuration"
msgstr ""
#: ../glade/glade-db-model.c:153
msgid "DbModel properties configuration"
msgstr ""
#: ../glade/glade-db-model.c:238
msgid "Select a DbModel for the property"
msgstr ""
#: ../glade/glade-db-model.c:259 ../glade/glade-db-model.c:306
msgid "New Model"
msgstr ""
#: ../glade/glade-db-model.c:301
msgid "Edit Model"
msgstr ""
#: ../glade/glade-db-sql.c:27
msgid "New SQL statement"
msgstr ""
#: ../glade/glade-db-sql.c:59
msgid "SQL Editor"
msgstr ""
#: ../glade/glade-db-sql.c:174
msgid "Open the SQL Editor"
msgstr ""
#: ../module/data/users.glade.h:1
msgid "User name:"
msgstr ""
#: ../module/data/users.glade.h:2
msgid "<b>Search</b>"
msgstr ""
#: ../module/data/users.glade.h:3
msgid "Identifier"
msgstr ""
#: ../module/data/users.glade.h:5
#: ../module/data/users.glade.h:3
msgid "MySQL User"
msgstr ""
#: ../module/data/users.glade.h:6
#: ../module/data/users.glade.h:4
msgid "Enabled"
msgstr ""
#: ../module/data/users.glade.h:7
#: ../module/data/users.glade.h:5
msgid "Name:"
msgstr ""
#: ../module/data/users.glade.h:9
#: ../module/data/users.glade.h:7
msgid "MySQL user:"
msgstr ""
#: ../module/data/users.glade.h:10
#: ../module/data/users.glade.h:8
msgid "Enabled:"
msgstr ""
#: ../module/data/users.glade.h:11
#: ../module/data/users.glade.h:9
msgid "Identifier:"
msgstr ""
#: ../module/data/users.glade.h:12
#: ../module/data/users.glade.h:10
msgid "UID:"
msgstr ""
#: ../module/data/users.glade.h:13
#: ../module/data/users.glade.h:11
msgid "Main group:"
msgstr ""
#: ../module/data/users.glade.h:14
#: ../module/data/users.glade.h:12
msgid "Last change:"
msgstr ""
#: ../module/data/users.glade.h:15
#: ../module/data/users.glade.h:13
msgid "Expires:"
msgstr ""
#: ../module/data/users.glade.h:16
#: ../module/data/users.glade.h:14
msgid "Account"
msgstr ""
#: ../module/data/users.glade.h:17
#: ../module/data/users.glade.h:15
msgid "Alias"
msgstr ""
#: ../module/data/users.glade.h:18
#: ../module/data/users.glade.h:16
msgid "Mail alias"
msgstr ""
#: ../module/data/users.glade.h:19
#: ../module/data/users.glade.h:17
msgid "Extension:"
msgstr ""
#: ../module/data/users.glade.h:20
#: ../module/data/users.glade.h:18
msgid "Secret:"
msgstr ""
#: ../module/data/users.glade.h:21
#: ../module/data/users.glade.h:19
msgid "Call group:"
msgstr ""
#: ../module/data/users.glade.h:22
#: ../module/data/users.glade.h:20
msgid "SIP"
msgstr ""
#: ../module/data/users.glade.h:23
#: ../module/data/users.glade.h:21
msgid "Change password"
msgstr ""
#: ../module/data/users.glade.h:22
msgid "Repeat password:"
msgstr ""
#: ../module/src/vn-users.c:60
msgid "The password is too weak."
msgstr ""
#: ../module/src/vn-users.c:75
msgid "The password can't be empty."
msgstr ""
#: ../module/src/vn-users.c:77
msgid "Passwords do not match."
msgstr ""
#: ../module/data/consulter.glade.h:1
msgid "Send"
msgstr ""
#: ../module/data/consulter.glade.h:2
msgid "Send the current query"
msgstr ""
#: ../module/data/consulter.glade.h:3
msgid "Clean"
msgstr ""
#: ../module/data/consulter.glade.h:4
msgid "Clean the messages"
msgstr ""
#: ../module/data/consulter.glade.h:5
msgid "_Consulter"
msgstr ""
#: ../module/data/consulter.glade.h:6
msgid "Query:"
msgstr ""
#: ../module/data/consulter.glade.h:7
msgid "Immediate changes"
msgstr ""
#: ../module/data/consulter.glade.h:8
msgid "Start"
msgstr ""
#: ../module/data/consulter.glade.h:9
msgid "Commit"
msgstr ""
#: ../module/data/consulter.glade.h:10
msgid "Rollback"
msgstr ""
#: ../module/src/vn-consulter.c:199
msgid "Type or select a query"
msgstr ""

View File

@ -5,23 +5,15 @@ SUBDIRS = parser
sql_lib_LTLIBRARIES = libsql.la
sql_include_HEADERS = \
sql.h \
sql-object.h \
sql-param-object.h \
sql-param-list.h \
sql-holder.h \
sql-list.h \
sql-set.h \
sql-multi-stmt.h \
sql-string.h \
sql-target.h \
sql-expr.h \
sql-insert.h \
sql-object.h \
sql-select.h \
sql-select-field.h \
sql-select-order.h \
sql-subquery.h \
sql-update.h \
sql-update-set.h \
sql-delete.h \
sql-field.h \
sql-join.h \
@ -42,20 +34,12 @@ libsql_la_LIBADD = \
$(top_builddir)/gvn/libgvn.la
libsql_la_SOURCES = \
$(sql_include_HEADERS) \
sql-object.c \
sql-param-object.c \
sql-param-list.c \
sql-holder.c \
sql-list.c \
sql-set.c \
sql-expr.c \
sql-insert.c \
sql-object.c \
sql-select.c \
sql-select-field.c \
sql-select-order.c \
sql-subquery.c \
sql-update.c \
sql-update-set.c \
sql-delete.c \
sql-field.c \
sql-join.c \
@ -69,7 +53,7 @@ libsql_la_SOURCES = \
sql-string.c \
sql-target.c \
sql-render.c \
$(top_builddir)/sql/sql-parser.c
$(top_srcdir)/sql/sql-parser.c
pkgconfig_DATA = sql.pc

View File

@ -1,6 +1,6 @@
include $(top_srcdir)/Makefile.decl
PARSER = $(top_builddir)/sql/sql-parser.c
PARSER = $(top_srcdir)/sql/sql-parser.c
DIR = $(top_srcdir)/sql/parser
TMPL = $(DIR)/lempar-tmpl.c

File diff suppressed because it is too large Load Diff

View File

@ -251,7 +251,7 @@ SqlObject * sql_parser_parse (gchar * sql)
if (state->error)
{
if (state->object && G_IS_OBJECT (state->object))
g_object_unref (g_object_ref_sink (state->object));
g_object_unref (state->object);
object = NULL;
}
else

View File

@ -26,7 +26,7 @@
**/
G_DEFINE_TYPE (SqlDelete, sql_delete, SQL_TYPE_DML);
SqlObject * sql_delete_new ()
SqlDelete * sql_delete_new ()
{
return g_object_new (SQL_TYPE_DELETE, NULL);
}
@ -36,75 +36,40 @@ SqlObject * sql_delete_new ()
static void sql_delete_render (SqlDelete * obj, SqlRender * render)
{
sql_render_add_token (render, "DELETE");
sql_render_add_list (render, TRUE, NULL, obj->tables, ",");
sql_render_add_object (render, obj->table);
if (SQL_DML (obj)->targets)
if (SQL_DML (obj)->target)
{
sql_render_add_list (render, TRUE, "FROM", SQL_DML (obj)->targets, ",");
sql_render_add_item (render, FALSE, "WHERE", SQL_DML (obj)->where);
sql_render_add_list (render, T, "FROM", SQL_DML (obj)->target, ",");
sql_render_add_item (render, F, "WHERE", SQL_DML (obj)->where);
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
enum
void sql_delete_add_table (SqlDelete * obj, SqlTable * table)
{
PROP_TABLES = 1
};
static void sql_delete_set_property (SqlDelete * obj, guint id,
const GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_TABLES:
sql_object_remove (obj, obj->tables);
obj->tables = sql_object_add (obj, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
static void sql_delete_get_property (SqlDelete * obj, guint id,
GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_TABLES:
g_value_set_object (value, obj->tables);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
g_return_if_fail (SQL_IS_DELETE (obj));
g_return_if_fail (SQL_IS_TABLE (table));
obj->table = g_slist_append (obj->table, g_object_ref_sink (table));
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_delete_init (SqlDelete * obj)
{
obj->tables = NULL;
obj->table = NULL;
}
static void sql_delete_finalize (SqlDelete * obj)
{
sql_object_remove (obj, obj->tables);
g_slist_free_full (obj->table, g_object_unref);
G_OBJECT_CLASS (sql_delete_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_delete_class_init (SqlDeleteClass * klass)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_delete_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_delete_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_delete_get_property;
G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) sql_delete_finalize;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_delete_render;
g_object_class_install_property (k, PROP_TABLES,
sql_param_list ("tables"
,"Tables"
,"A list of tables"
,SQL_TYPE_TABLE
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
}

View File

@ -35,7 +35,7 @@ typedef struct _SqlDeleteClass SqlDeleteClass;
struct _SqlDelete
{
SqlDml parent;
SqlList * tables;
GSList * table;
};
struct _SqlDeleteClass
@ -45,6 +45,7 @@ struct _SqlDeleteClass
};
GType sql_delete_get_type ();
SqlObject * sql_delete_new ();
SqlDelete * sql_delete_new ();
void sql_delete_add_table (SqlDelete * obj, SqlTable * table);
#endif

View File

@ -28,21 +28,42 @@ G_DEFINE_ABSTRACT_TYPE (SqlDml, sql_dml, SQL_TYPE_STMT);
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
* sql_dml_add_target:
* @obj: a #SqlDml
* @target: a #SqlTarget
*
* Add a target to the DML statement.
**/
void sql_dml_add_target (SqlDml * obj, SqlTarget * target)
{
g_return_if_fail (SQL_IS_DML (obj));
g_return_if_fail (SQL_IS_TARGET (target));
obj->target = g_slist_append (obj->target, g_object_ref_sink (target));
}
/**
* sql_dml_set_where:
* @obj: a #SqlDml
* @expr: a #SqlExpr
*
* Sets the where expression of an DML statement.
**/
void sql_dml_set_where (SqlDml * obj, SqlExpr * where)
{
g_return_if_fail (SQL_IS_DML (obj));
g_return_if_fail (SQL_IS_EXPR (where) || SQL_IS_HOLDER (where) || !where);
g_return_if_fail (SQL_IS_EXPR (where));
sql_object_remove (obj, obj->where);
obj->where = sql_object_add (obj, where);
g_clear_object (&obj->where);
obj->where = g_object_ref_sink (where);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
{
PROP_TARGETS = 1
,PROP_WHERE
PROP_WHERE = 1
};
static void sql_dml_set_property (SqlDml * obj, guint id,
@ -50,10 +71,6 @@ static void sql_dml_set_property (SqlDml * obj, guint id,
{
switch (id)
{
case PROP_TARGETS:
sql_object_remove (obj, obj->targets);
obj->targets = sql_object_add (obj, g_value_get_object (value));
break;
case PROP_WHERE:
sql_dml_set_where (obj, g_value_get_object (value));
break;
@ -67,9 +84,6 @@ static void sql_dml_get_property (SqlDml * obj, guint id,
{
switch (id)
{
case PROP_TARGETS:
g_value_set_object (value, obj->targets);
break;
case PROP_WHERE:
g_value_set_object (value, obj->where);
break;
@ -80,37 +94,30 @@ static void sql_dml_get_property (SqlDml * obj, guint id,
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_dml_init (SqlDml * obj)
{
obj->targets = NULL;
obj->where = NULL;
}
static void sql_dml_finalize (SqlDml * obj)
{
sql_object_remove (obj, obj->targets);
sql_object_remove (obj, obj->where);
g_clear_object (&obj->where);
g_slist_free_full (obj->target, g_object_unref);
G_OBJECT_CLASS (sql_dml_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_dml_class_init (SqlDmlClass * klass)
static void sql_dml_init (SqlDml * obj)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_dml_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_dml_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_dml_get_property;
obj->target = NULL;
obj->where = NULL;
}
g_object_class_install_property (k, PROP_TARGETS,
sql_param_list ("targets"
,"Targets"
,"A list of targets"
,SQL_TYPE_TARGET
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
g_object_class_install_property (k, PROP_WHERE,
sql_param_object ("where"
static void sql_dml_class_init (SqlDmlClass * k)
{
GObjectClass * klass = G_OBJECT_CLASS (k);
klass->finalize = (GObjectFinalizeFunc) sql_dml_finalize;
klass->set_property = (GObjectSetPropertyFunc) sql_dml_set_property;
klass->get_property = (GObjectGetPropertyFunc) sql_dml_get_property;
g_object_class_install_property (klass, PROP_WHERE,
g_param_spec_object ("where"
,"Where"
,"The WHERE section of an statement"
,"The expression used to filter rows, it's the WHERE section of an statement"
,SQL_TYPE_EXPR
,G_PARAM_READWRITE
));

View File

@ -37,7 +37,7 @@ typedef struct _SqlDmlClass SqlDmlClass;
struct _SqlDml
{
SqlStmt parent;
SqlList * targets;
GSList * target;
SqlExpr * where;
};
@ -48,6 +48,7 @@ struct _SqlDmlClass
};
GType sql_dml_get_type ();
void sql_dml_add_target (SqlDml * obj, SqlTarget * target);
void sql_dml_set_where (SqlDml * obj, SqlExpr * expr);
#endif

View File

@ -28,6 +28,11 @@
**/
G_DEFINE_ABSTRACT_TYPE (SqlExpr, sql_expr, SQL_TYPE_OBJECT);
SqlExpr * sql_expr_new ()
{
return g_object_new (SQL_TYPE_EXPR, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_expr_init (SqlExpr * obj) {}

View File

@ -36,14 +36,13 @@ G_DEFINE_TYPE (SqlField, sql_field, SQL_TYPE_EXPR);
*
* Return value: an #SqlExpr
*/
SqlObject * sql_field_new (const gchar * name, const gchar * target, const gchar * schema)
SqlExpr * sql_field_new (const gchar * name, const gchar * target, const gchar * schema)
{
return g_object_new (SQL_TYPE_FIELD
,"name", name
,"target", target
,"schema", schema
,NULL
);
,NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
@ -97,7 +96,8 @@ static void sql_field_set_property (SqlField * obj, guint id,
switch (id)
{
case PROP_NAME:
sql_field_set_name (obj, g_value_get_string (value));
g_free (obj->name);
obj->name = g_value_dup_string (value);
break;
case PROP_TARGET:
g_free (obj->target);
@ -145,6 +145,7 @@ static void sql_field_finalize (SqlField * obj)
g_free (obj->name);
g_free (obj->target);
g_free (obj->schema);
G_OBJECT_CLASS (sql_field_parent_class)->finalize (G_OBJECT (obj));
}

View File

@ -43,7 +43,7 @@ struct _SqlFieldClass
};
GType sql_field_get_type ();
SqlObject * sql_field_new (const gchar * name
SqlExpr * sql_field_new (const gchar * name
,const gchar * target
,const gchar * schema);
void sql_field_set_name (SqlField * obj, const gchar * name);

View File

@ -46,18 +46,27 @@ static void sql_function_render (SqlFunction * obj, SqlRender * render)
if (obj->name)
{
sql_render_append (render, "(");
sql_render_add_list (render, FALSE, NULL, obj->params, ",");
sql_render_add_list (render, F, NULL, obj->param, ",");
sql_render_append (render, ")");
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
void sql_function_add_param (SqlFunction * obj, SqlExpr * param)
{
g_return_if_fail (SQL_IS_FUNCTION (obj));
g_return_if_fail (SQL_IS_EXPR (param));
obj->param = g_slist_append (obj->param, g_object_ref_sink (param));
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
{
PROP_NAME = 1
,PROP_SCHEMA
,PROP_PARAMS
};
static void sql_function_set_property (SqlFunction * obj, guint id,
@ -73,10 +82,6 @@ static void sql_function_set_property (SqlFunction * obj, guint id,
g_free (obj->schema);
obj->schema = g_value_dup_string (value);
break;
case PROP_PARAMS:
sql_object_remove (obj, obj->params);
obj->params = sql_object_add (obj, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -93,9 +98,6 @@ static void sql_function_get_property (SqlFunction * obj, guint id,
case PROP_SCHEMA:
g_value_set_string (value, obj->schema);
break;
case PROP_PARAMS:
g_value_set_object (value, obj->params);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -107,14 +109,14 @@ static void sql_function_init (SqlFunction * obj)
{
obj->name = NULL;
obj->schema = NULL;
obj->params = NULL;
obj->param = NULL;
}
static void sql_function_finalize (SqlFunction * obj)
{
g_free (obj->name);
g_free (obj->schema);
sql_object_remove (obj, obj->params);
g_slist_free_full (obj->param, g_object_unref);
G_OBJECT_CLASS (sql_function_parent_class)->finalize (G_OBJECT (obj));
}
@ -133,6 +135,7 @@ static void sql_function_class_init (SqlFunctionClass * klass)
,NULL
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_SCHEMA,
g_param_spec_string ("schema"
,"Schema"
@ -140,11 +143,4 @@ static void sql_function_class_init (SqlFunctionClass * klass)
,NULL
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_PARAMS,
sql_param_list ("params"
,"Parameters"
,"The function parameters"
,SQL_TYPE_EXPR
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
}

View File

@ -37,7 +37,7 @@ struct _SqlFunction
SqlExpr parent;
gchar * schema;
gchar * name;
SqlList * params; // List of SqlExpr
GSList * param; // Parameters for the function, list of SqlExpr
};
struct _SqlFunctionClass
@ -48,5 +48,6 @@ struct _SqlFunctionClass
GType sql_function_get_type ();
SqlFunction * sql_function_new (const gchar * name, const gchar * schema);
void sql_function_add_param (SqlFunction * obj, SqlExpr * param);
#endif

View File

@ -26,27 +26,51 @@
**/
G_DEFINE_TYPE (SqlInsert, sql_insert, SQL_TYPE_STMT);
SqlObject * sql_insert_new ()
SqlInsert * sql_insert_new ()
{
return g_object_new (SQL_TYPE_INSERT, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void sql_insert_expr_free (SqlExpr * expr)
{
if (expr)
g_object_unref (expr);
}
static void sql_insert_render_expr (SqlExpr * obj, SqlRender * render)
{
if (obj)
sql_render_add_object (render, obj);
else
sql_render_add_token (render, "DEFAULT");
}
static void sql_insert_render_row (GSList * obj, SqlRender * render)
{
sql_render_add_espace (render);
sql_render_append (render, "(");
sql_render_add_list_with_func (render, T, NULL, obj, ",",
(SqlRenderFunc) sql_insert_render_expr);
sql_render_append (render, ")");
}
static void sql_insert_render (SqlInsert * obj, SqlRender * render)
{
sql_render_add_item (render, TRUE, "INSERT INTO", obj->table);
sql_render_add_item (render, T, "INSERT INTO", obj->table);
if (obj->table)
{
if (obj->values)
if (obj->expr)
{
sql_render_add_espace (render);
sql_render_append (render, "(");
sql_render_add_list (render, FALSE, NULL, obj->fields, ",");
sql_render_add_list (render, F, NULL, obj->field, ",");
sql_render_append (render, ")");
sql_render_add_token (render, "VALUES");
sql_render_add_list (render, FALSE, NULL, obj->values, ",");
sql_render_add_list_with_func (render, F, NULL, obj->expr, ",",
(SqlRenderFunc) sql_insert_render_row);
}
else
sql_render_add_token (render, "DEFAULT VALUES");
@ -55,19 +79,56 @@ static void sql_insert_render (SqlInsert * obj, SqlRender * render)
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
void sql_insert_set_table_from_name (SqlInsert * obj, const gchar * table)
void sql_insert_set_table (SqlInsert * obj, SqlTable * table)
{
g_return_if_fail (SQL_IS_INSERT (obj));
g_return_if_fail (table);
sql_object_remove (obj, obj->table);
obj->table = sql_object_add (obj, sql_table_new (table));
g_return_if_fail (SQL_IS_TABLE (table));
g_clear_object (&obj->table);
obj->table = g_object_ref_sink (table);
}
void sql_insert_add_row (SqlInsert * obj)
{
g_return_if_fail (SQL_IS_INSERT (obj));
obj->iter = g_slist_alloc ();
obj->expr = g_slist_concat (obj->expr, obj->iter);
}
void sql_insert_add_field (SqlInsert * obj, SqlField * field)
{
g_return_if_fail (SQL_IS_INSERT (obj));
g_return_if_fail (SQL_IS_FIELD (field));
obj->field = g_slist_append (obj->field, g_object_ref_sink (field));
}
void sql_insert_add_expr (SqlInsert * obj, SqlExpr * expr)
{
g_return_if_fail (SQL_IS_INSERT (obj));
g_return_if_fail (SQL_IS_EXPR (expr) || !expr);
if (!obj->iter)
sql_insert_add_row (obj);
if (expr)
g_object_ref_sink (expr);
obj->iter->data = g_slist_append (obj->iter->data, expr);
}
void sql_insert_clean (SqlInsert * obj)
{
GSList * n;
g_return_if_fail (SQL_IS_INSERT (obj));
g_slist_free_full (obj->field, g_object_unref);
for (n = obj->expr; n; n = n->next)
g_slist_free_full (n->data, (GDestroyNotify) sql_insert_expr_free);
g_slist_free (obj->expr);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
@ -75,8 +136,6 @@ void sql_insert_add_expr (SqlInsert * obj, SqlExpr * expr)
enum
{
PROP_TABLE = 1
,PROP_FIELDS
,PROP_VALUES
};
static void sql_insert_set_property (SqlInsert * obj, guint id,
@ -85,16 +144,7 @@ static void sql_insert_set_property (SqlInsert * obj, guint id,
switch (id)
{
case PROP_TABLE:
sql_object_remove (obj, obj->table);
obj->table = sql_object_add (obj, g_value_get_object (value));
break;
case PROP_FIELDS:
sql_object_remove (obj, obj->fields);
obj->fields = sql_object_add (obj, g_value_get_object (value));
break;
case PROP_VALUES:
sql_object_remove (obj, obj->values);
obj->values = sql_object_add (obj, g_value_get_object (value));
sql_insert_set_table (obj, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
@ -109,12 +159,6 @@ static void sql_insert_get_property (SqlInsert * obj, guint id,
case PROP_TABLE:
g_value_set_object (value, obj->table);
break;
case PROP_FIELDS:
g_value_set_object (value, obj->fields);
break;
case PROP_VALUES:
g_value_set_object (value, obj->values);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -125,15 +169,15 @@ static void sql_insert_get_property (SqlInsert * obj, guint id,
static void sql_insert_init (SqlInsert * obj)
{
obj->table = NULL;
obj->fields = NULL;
obj->values = NULL;
obj->field = NULL;
obj->expr = NULL;
obj->iter = NULL;
}
static void sql_insert_finalize (SqlInsert * obj)
{
sql_object_remove (obj, obj->table);
sql_object_remove (obj, obj->fields);
sql_object_remove (obj, obj->values);
sql_insert_clean (obj);
g_clear_object (&obj->table);
G_OBJECT_CLASS (sql_insert_parent_class)->finalize (G_OBJECT (obj));
}
@ -146,24 +190,10 @@ static void sql_insert_class_init (SqlInsertClass * klass)
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_insert_render;
g_object_class_install_property (k, PROP_TABLE,
sql_param_object ("table"
g_param_spec_object ("table"
,"Table"
,"The table where the row is inserted"
,SQL_TYPE_TABLE
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_FIELDS,
sql_param_list ("fields"
,"Fields"
,"The list of fields"
,SQL_TYPE_FIELD
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
g_object_class_install_property (k, PROP_VALUES,
sql_param_list ("values"
,"Values"
,"The list of values"
,SQL_TYPE_SET
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
}

View File

@ -18,15 +18,14 @@
#ifndef SQL_INSERT_H
#define SQL_INSERT_H
#define SQL_TYPE_INSERT (sql_insert_get_type ())
#define SQL_INSERT(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_INSERT, SqlInsert))
#define SQL_IS_INSERT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_INSERT))
#define SQL_TYPE_INSERT (sql_insert_get_type ())
#define SQL_INSERT(object) (G_TYPE_CHECK_INSTANCE_CAST (object, SQL_TYPE_INSERT, SqlInsert))
#define SQL_IS_INSERT(object) (G_TYPE_CHECK_INSTANCE_TYPE (object, SQL_TYPE_INSERT))
#include "sql-stmt.h"
#include "sql-field.h"
#include "sql-value.h"
#include "sql-table.h"
#include "sql-set.h"
typedef struct _SqlInsert SqlInsert;
typedef struct _SqlInsertClass SqlInsertClass;
@ -41,8 +40,9 @@ struct _SqlInsert
{
SqlStmt parent;
SqlTable * table;
SqlList * fields; // List of SqlField
SqlList * values; // List of SqlSet
GSList * field; // List of SqlField
GSList * expr; // List of GSList of SqlExpr
GSList * iter;
};
struct _SqlInsertClass
@ -51,8 +51,12 @@ struct _SqlInsertClass
SqlStmtClass parent;
};
GType sql_insert_get_type ();
SqlObject * sql_insert_new ();
void sql_insert_set_table_from_name (SqlInsert * obj, const gchar * table);
GType sql_insert_get_type ();
SqlInsert * sql_insert_new ();
void sql_insert_set_table (SqlInsert * obj, SqlTable * table);
void sql_insert_add_row (SqlInsert * obj);
void sql_insert_add_field (SqlInsert * obj, SqlField * field);
void sql_insert_add_expr (SqlInsert * obj, SqlExpr * expr);
void sql_insert_clean (SqlInsert * obj);
#endif

View File

@ -16,7 +16,6 @@
*/
#include "sql-join.h"
#include "sql-field.h"
/**
* SECTION: sql-join
@ -48,20 +47,11 @@ static const gchar * SQL_JOIN_TYPE[] =
static void sql_join_render (SqlJoin * obj, SqlRender * render)
{
sql_render_add_item (render, TRUE, NULL, obj->target_left);
sql_render_add_item (render, T, NULL, obj->target_left);
sql_render_add_token (render, SQL_JOIN_TYPE[obj->type]);
sql_render_add_token (render, "JOIN");
sql_render_add_item (render, TRUE, NULL, obj->target_right);
if (obj->has_using)
{
sql_render_add_token (render, "USING");
sql_render_append (render, "(");
sql_render_add_list (render, TRUE, NULL, obj->using_fields, ",");
sql_render_append (render, ")");
}
else
sql_render_add_item (render, FALSE, "ON", obj->condition);
sql_render_add_item (render, T, NULL, obj->target_right);
sql_render_add_item (render, F, "ON", obj->condition);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
@ -69,28 +59,28 @@ static void sql_join_render (SqlJoin * obj, SqlRender * render)
void sql_join_set_target_left (SqlJoin * obj, SqlTarget * target)
{
g_return_if_fail (SQL_IS_JOIN (obj));
g_return_if_fail (SQL_IS_TARGET (target) || SQL_IS_HOLDER (target) || !target);
g_return_if_fail (SQL_IS_TARGET (target));
sql_object_remove (obj, obj->target_left);
obj->target_left = sql_object_add (obj, target);
g_clear_object (&obj->target_left);
obj->target_left = g_object_ref_sink (target);
}
void sql_join_set_target_right (SqlJoin * obj, SqlTarget * target)
{
g_return_if_fail (SQL_IS_JOIN (obj));
g_return_if_fail (SQL_IS_TARGET (target) || SQL_IS_HOLDER (target) || !target);
g_return_if_fail (SQL_IS_TARGET (target));
sql_object_remove (obj, obj->target_right);
obj->target_right = sql_object_add (obj, target);
g_clear_object (&obj->target_right);
obj->target_right = g_object_ref_sink (target);
}
void sql_join_set_condition (SqlJoin * obj, SqlExpr * condition)
{
g_return_if_fail (SQL_IS_JOIN (obj));
g_return_if_fail (SQL_IS_EXPR (condition) || SQL_IS_HOLDER (condition) || !condition);
g_return_if_fail (SQL_IS_EXPR (condition));
sql_object_remove (obj, obj->condition);
obj->condition = sql_object_add (obj, condition);
g_clear_object (&obj->condition);
obj->condition = g_object_ref_sink (condition);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
@ -101,8 +91,6 @@ enum
,PROP_TARGET_RIGHT
,PROP_TYPE
,PROP_CONDITION
,PROP_HAS_USING
,PROP_USING_FIELDS
};
static void sql_join_set_property (SqlJoin * obj, guint id,
@ -117,19 +105,12 @@ static void sql_join_set_property (SqlJoin * obj, guint id,
sql_join_set_target_right (obj, g_value_get_object (value));
break;
case PROP_TYPE:
obj->type = g_value_get_enum (value);
obj->type = g_value_get_int (value);
break;
case PROP_CONDITION:
sql_join_set_condition (obj, g_value_get_object (value));
break;
case PROP_HAS_USING:
obj->has_using = g_value_get_boolean (value);
break;
case PROP_USING_FIELDS:
sql_object_remove (obj, obj->using_fields);
obj->using_fields = sql_object_add (obj, g_value_get_object (value));
break;
default:
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
@ -146,17 +127,11 @@ static void sql_join_get_property (SqlJoin * obj, guint id,
g_value_set_object (value, obj->target_right);
break;
case PROP_TYPE:
g_value_set_enum (value, obj->type);
g_value_set_int (value, obj->type);
break;
case PROP_CONDITION:
g_value_set_object (value, obj->condition);
break;
case PROP_HAS_USING:
g_value_set_boolean (value, obj->has_using);
break;
case PROP_USING_FIELDS:
g_value_set_object (value, obj->using_fields);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -169,15 +144,13 @@ static void sql_join_init (SqlJoin * obj)
obj->target_left = NULL;
obj->target_right = NULL;
obj->condition = NULL;
obj->using_fields = NULL;
}
static void sql_join_finalize (SqlJoin * obj)
{
sql_object_remove (obj, obj->target_left);
sql_object_remove (obj, obj->target_right);
sql_object_remove (obj, obj->condition);
sql_object_remove (obj, obj->using_fields);
g_clear_object (&obj->target_left);
g_clear_object (&obj->target_right);
g_clear_object (&obj->condition);
G_OBJECT_CLASS (sql_join_parent_class)->finalize (G_OBJECT (obj));
}
@ -190,67 +163,31 @@ static void sql_join_class_init (SqlJoinClass * klass)
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_join_render;
g_object_class_install_property (k, PROP_TARGET_LEFT,
sql_param_list ("target-left"
g_param_spec_object ("target-left"
,"Left target"
,"The left target in the join"
,SQL_TYPE_TARGET
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_TARGET_RIGHT,
sql_param_list ("target-right"
g_param_spec_object ("target-right"
,"Right target"
,"The right target in the join"
,SQL_TYPE_TARGET
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_TYPE,
g_param_spec_enum ("join-type"
g_param_spec_int ("join-type"
,"Type"
,"The type of join"
,SQL_TYPE_JOIN_TYPE
,SQL_JOIN_TYPE_INNER
,0, SQL_JOIN_TYPE_COUNT - 1, SQL_JOIN_TYPE_INNER
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_CONDITION,
sql_param_list ("condition"
g_param_spec_object ("condition"
,"Condition"
,"The condition used for the join"
,SQL_TYPE_EXPR
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_HAS_USING,
g_param_spec_boolean ("has-using"
,"Has using"
,"Wether the condition is a USING"
,FALSE
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
g_object_class_install_property (k, PROP_CONDITION,
sql_param_list ("using-fields"
,"Using fields"
,"The list of fields of the USING"
,SQL_TYPE_FIELD
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
}
GType sql_join_type_get_type ()
{
static GType type = 0;
if (type == 0)
{
static const GEnumValue values[] =
{
{SQL_JOIN_TYPE_INNER ,"SQL_JOIN_TYPE_INNER" ,"inner"
},{SQL_JOIN_TYPE_LEFT ,"SQL_JOIN_TYPE_LEFT" ,"left"
},{SQL_JOIN_TYPE_RIGHT ,"SQL_JOIN_TYPE_RIGHT" ,"right"
},{0, NULL, NULL}
};
type = g_enum_register_static
(g_intern_static_string ("SqlJoinType"), values);
}
return type;
}

View File

@ -22,10 +22,8 @@
#include "sql-expr.h"
#define SQL_TYPE_JOIN (sql_join_get_type ())
#define SQL_IS_JOIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_JOIN))
#define SQL_JOIN(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_JOIN, SqlJoin))
#define SQL_TYPE_JOIN_TYPE (sql_join_type_get_type ())
#define SQL_IS_JOIN(object) (G_TYPE_CHECK_INSTANCE_TYPE (object, SQL_TYPE_JOIN))
#define SQL_JOIN(object) (G_TYPE_CHECK_INSTANCE_CAST (object, SQL_TYPE_JOIN, SqlJoin))
typedef struct _SqlJoin SqlJoin;
typedef struct _SqlJoinClass SqlJoinClass;
@ -46,8 +44,6 @@ struct _SqlJoin
SqlTarget * target_right;
SqlJoinType type;
SqlExpr * condition;
gboolean has_using;
SqlList * using_fields;
};
struct _SqlJoinClass
@ -57,8 +53,6 @@ struct _SqlJoinClass
};
GType sql_join_get_type ();
GType sql_join_type_get_type ();
SqlTarget * sql_join_new (SqlTarget * left, SqlTarget * right, SqlJoinType type);
void sql_join_set_condition (SqlJoin * obj, SqlExpr * condition);
void sql_join_set_target_right (SqlJoin * obj, SqlTarget * target);

View File

@ -35,69 +35,34 @@ SqlMultiStmt * sql_multi_stmt_new ()
static void sql_multi_stmt_render (SqlMultiStmt * obj, SqlRender * render)
{
sql_render_add_list (render, TRUE, NULL, obj->stmts, ";");
sql_render_add_list (render, T, NULL, obj->stmt, ";");
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
enum
void sql_multi_stmt_add_stmt (SqlMultiStmt * obj, SqlStmt * stmt)
{
PROP_STMTS = 1
};
g_return_if_fail (SQL_IS_MULTI_STMT (obj));
g_return_if_fail (SQL_IS_STMT (stmt));
static void sql_mutli_stmt_set_property (SqlMultiStmt * obj, guint id,
const GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_STMTS:
sql_object_remove (obj, obj->stmts);
obj->stmts = sql_object_add (obj, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
static void sql_mutli_stmt_get_property (SqlMultiStmt * obj, guint id,
GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_STMTS:
g_value_set_object (value, obj->stmts);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
obj->stmt = g_slist_append (obj->stmt, g_object_ref_sink (stmt));
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_multi_stmt_init (SqlMultiStmt * obj)
{
obj->stmts = NULL;
obj->stmt = NULL;
}
static void sql_multi_stmt_finalize (SqlMultiStmt * obj)
{
sql_object_remove (obj, obj->stmts);
g_slist_free_full (obj->stmt, g_object_unref);
G_OBJECT_CLASS (sql_multi_stmt_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_multi_stmt_class_init (SqlMultiStmtClass * klass)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_multi_stmt_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_mutli_stmt_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_mutli_stmt_get_property;
G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) sql_multi_stmt_finalize;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_multi_stmt_render;
g_object_class_install_property (k, PROP_STMTS,
sql_param_list ("stmts"
,"Statements"
,"The list of statements"
,SQL_TYPE_STMT
,G_PARAM_READWRITE | G_PARAM_CONSTRUCT
));
}

View File

@ -22,7 +22,7 @@
#define SQL_TYPE_MULTI_STMT (sql_multi_stmt_get_type ())
#define SQL_MULTI_STMT(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_MULTI_STMT, SqlMultiStmt))
#define SQL_IS_MULTI_STMT(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_MULTI_STMT))
#define SQL_IS_MULTI_STMT(object) (G_TYPE_CHECK_INSTANCE_TYPE (object, SQL_TYPE_MULTI_STMT))
typedef struct _SqlMultiStmt SqlMultiStmt;
typedef struct _SqlMultiStmtClass SqlMultiStmtClass;
@ -34,7 +34,7 @@ typedef struct _SqlMultiStmtClass SqlMultiStmtClass;
struct _SqlMultiStmt
{
SqlStmt parent;
SqlList * stmts;
GSList * stmt;
};
struct _SqlMultiStmtClass
@ -45,5 +45,6 @@ struct _SqlMultiStmtClass
GType sql_multi_stmt_get_type ();
SqlMultiStmt * sql_multi_stmt_new ();
void sql_multi_stmt_add_stmt (SqlMultiStmt * obj, SqlStmt * stmt);
#endif

View File

@ -35,49 +35,65 @@ static guint signals[LAST_SIGNAL] = {0};
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void sql_object_child_changed (SqlObject * child, SqlObject * obj)
static void sql_object_list_changed (SqlObject * sub, SqlObject * obj)
{
sql_object_changed (obj);
g_signal_emit (obj, signals[CHANGED], 0);
}
static gboolean sql_object_is_ready_default (SqlObject * obj)
{
return TRUE;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Protected
/**
* sql_object_add:
* @obj: #SqlObject where the new item will be added
* @child: #SqlObject the object is added
* sql_object_list_add:
* @obj: #SqlObject where the new item will be appended
* @list: (element-type Sql.Object): #GSList where @sub is appened
* @sub: #SqlObject the object is appended
*
* Appends an item into a list of @obj. This function was created to perform an
* action very common in all objects that inherit from this class.
*
* Note that this function is considered a protected method and should only
* be used in classes that inherit from #SqlObjectClass.
* be used in classes that inherit from #SqlObjectClass. Only this function
* should be able to modify @list. To release the list you can use
* sql_object_list_free().
**/
gpointer sql_object_add (gpointer obj, gpointer child)
void sql_object_list_add (SqlObject * obj, GSList ** list, SqlObject * sub)
{
if (child)
{
g_object_ref_sink (child);
g_signal_connect (child, "changed",
G_CALLBACK (sql_object_child_changed), obj);
}
return child;
*list = g_slist_append (*list, g_object_ref_sink (sub));
g_signal_connect (sub, "changed",
G_CALLBACK (sql_object_list_changed), obj
);
}
/**
* sql_object_remove:
* @obj: #SqlObject where the new item will be added
* @child: #SqlObject the object is added
* sql_object_list_free:
* @obj: #SqlObject where the item will be removed
* @list: (element-type Sql.Object): #GSList to release
*
* Releases a list of items, also disconnects its changed handler
* and calls g_object_unref() on every item.
*
* Note that this function is considered a protected method and should only
* be used in classes that inherit from #SqlObjectClass.
* be used in classes that inherit from #SqlObjectClass and whose list has only
* been handled by the function sql_object_list_add().
**/
void sql_object_remove (gpointer obj, gpointer child)
void sql_object_list_free (SqlObject * obj, GSList * list)
{
if (child)
GSList * n;
for (n = list; n; n = n->next)
{
g_signal_handlers_disconnect_by_func (child,
sql_object_child_changed, obj);
g_object_unref (child);
g_signal_handlers_disconnect_by_func (n->data,
G_CALLBACK (sql_object_list_changed), obj
);
g_object_unref (n->data);
}
g_slist_free (list);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
@ -94,7 +110,7 @@ void sql_object_render (SqlObject * obj, SqlRender * render)
g_return_if_fail (SQL_IS_OBJECT (obj));
g_return_if_fail (SQL_IS_RENDER (render));
// SQL_OBJECT_GET_CLASS (obj)->render (obj, render);
return SQL_OBJECT_GET_CLASS (obj)->render (obj, render);
}
/**
@ -106,157 +122,29 @@ void sql_object_render (SqlObject * obj, SqlRender * render)
* Return value: %TRUE if ready, %FALSE otherwise.
**/
gboolean sql_object_is_ready (SqlObject * obj)
{
SqlObjectClass * klass = SQL_OBJECT_GET_CLASS (obj);
{
g_return_val_if_fail (SQL_IS_OBJECT (obj), FALSE);
if (obj->held_objects)
{
GList * i;
GList * held_objects = g_hash_table_get_values (obj->held_objects);
gboolean is_ready = TRUE;
for (i = held_objects; i; i = i->next)
if (!sql_object_is_ready (i->data))
{
is_ready = FALSE;
break;
}
g_list_free (held_objects);
if (!is_ready)
return FALSE;
}
if (klass->is_ready)
return klass->is_ready (obj);
else
return TRUE;
}
void sql_object_set (SqlObject * obj, const gchar * property, SqlObject * value)
{
g_return_if_fail (SQL_IS_OBJECT (obj));
g_return_if_fail (SQL_IS_OBJECT (value));
g_object_set (obj, property, value, NULL);
}
SqlObject * sql_object_get (SqlObject * obj, const gchar * property)
{
SqlObject * value;
g_return_val_if_fail (SQL_IS_OBJECT (obj), NULL);
g_object_get (obj, property, &value, NULL);
return value;
}
void sql_object_add_child (SqlObject * obj, const gchar * property, SqlObject * child)
{
SqlList * list;
g_return_if_fail (SQL_IS_OBJECT (obj));
g_return_if_fail (SQL_IS_OBJECT (child));
g_object_get (obj, property, &list, NULL);
sql_list_add (list, child);
}
void sql_object_remove_child (SqlObject * obj, const gchar * property, guint n)
{
SqlList * list;
g_return_if_fail (SQL_IS_OBJECT (obj));
g_object_get (obj, property, &list, NULL);
sql_list_remove (list, n);
}
/**
* sql_object_add_held_object:
* @obj: a #SqlObject
* @id: the id of the #SqlHolder
* @held_object: the held object
*
* Adds a held object.
**/
void sql_object_add_held_object (SqlObject * obj, const gchar * id, SqlObject * held_object)
{
g_return_if_fail (SQL_IS_OBJECT (obj));
g_return_if_fail (id);
if (!obj->held_objects)
obj->held_objects = g_hash_table_new_full (
g_str_hash
,g_str_equal
,g_free
,g_object_unref
);
g_signal_connect (held_object, "changed",
G_CALLBACK (sql_object_child_changed), obj
);
g_hash_table_replace (obj->held_objects,
g_strdup (id), g_object_ref_sink (held_object));
}
/**
* sql_object_get_held_object:
* @obj: a #SqlObject
* @id: the id of the #SqlHolder
*
* Gets a held object by its id.
*
* Return value: the #SqlObject if an object with that id exists, %NULL otherwise
**/
SqlObject * sql_object_get_held_object (SqlObject * obj, const gchar * id)
{
g_return_val_if_fail (SQL_IS_OBJECT (obj), NULL);
g_return_val_if_fail (id, NULL);
if (obj->held_objects)
return g_hash_table_lookup (obj->held_objects, id);
return NULL;
}
/**
* sql_object_changed:
* @obj: a #SqlObject
*
* Emits the changed signal on #SqlObject.
**/
void sql_object_changed (SqlObject * obj)
{
g_signal_emit (obj, signals[CHANGED], 0);
return SQL_OBJECT_GET_CLASS (obj)->is_ready (obj);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_object_init (SqlObject * obj)
{
obj->child_groups = NULL;
obj->held_objects = NULL;
obj->sql = NULL;
}
static void sql_object_finalize (SqlObject * obj)
static void sql_object_finalize (GObject * obj)
{
if (obj->child_groups)
g_hash_table_destroy (obj->child_groups);
if (obj->held_objects)
g_hash_table_destroy (obj->held_objects);
G_OBJECT_CLASS (sql_object_parent_class)->finalize (G_OBJECT (obj));
g_free (SQL_OBJECT (obj)->sql);
G_OBJECT_CLASS (sql_object_parent_class)->finalize (obj);
}
static void sql_object_class_init (SqlObjectClass * klass)
{
G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) sql_object_finalize;
klass->is_ready = NULL;
G_OBJECT_CLASS (klass)->finalize = sql_object_finalize;
klass->is_ready = sql_object_is_ready_default;
klass->render = NULL;
/**

View File

@ -19,8 +19,6 @@
#define SQL_OBJECT_H
#include <gvn/gvn.h>
#include "sql-param-object.h"
#include "sql-param-list.h"
#define SQL_TYPE_OBJECT (sql_object_get_type ())
#define SQL_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_OBJECT, SqlObject))
@ -31,41 +29,28 @@
typedef struct _SqlObject SqlObject;
typedef struct _SqlObjectClass SqlObjectClass;
#include "sql-render.h"
typedef gboolean (* SqlObjectIsReadyFunc) (SqlObject * obj);
struct _SqlObject
{
GInitiallyUnowned parent;
GHashTable * child_groups;
GHashTable * held_objects;
gchar * sql;
};
struct _SqlObjectClass
{
/* <private> */
GInitiallyUnownedClass parent;
gpointer /* SqlRenderFunc */ render;
SqlRenderFunc render;
SqlObjectIsReadyFunc is_ready;
};
#include "sql-holder.h"
#include "sql-list.h"
#include "sql-render.h"
GType sql_object_get_type ();
void sql_object_render (SqlObject * obj, SqlRender * render);
gboolean sql_object_is_ready (SqlObject * obj);
void sql_object_set (SqlObject * obj, const gchar * property, SqlObject * set);
SqlObject * sql_object_get (SqlObject * obj, const gchar * property);
void sql_object_add_child (SqlObject * obj, const gchar * property, SqlObject * child);
void sql_object_remove_child (SqlObject * obj, const gchar * property, guint n);
void sql_object_add_held_object (SqlObject * obj, const gchar * id, SqlObject * held_object);
SqlObject * sql_object_get_held_object (SqlObject * obj, const gchar * id);
void sql_object_changed (SqlObject * obj);
gpointer sql_object_add (gpointer obj, gpointer child);
void sql_object_remove (gpointer obj, gpointer child);
GType sql_object_get_type ();
void sql_object_render (SqlObject * obj, SqlRender * render);
gboolean sql_object_is_ready (SqlObject * obj);
void sql_object_list_add (SqlObject * obj, GSList ** list, SqlObject * sub);
void sql_object_list_free (SqlObject * obj, GSList * list);
#endif

View File

@ -29,7 +29,7 @@
**/
G_DEFINE_TYPE (SqlOperation, sql_operation, SQL_TYPE_EXPR);
SqlObject * sql_operation_new (SqlOperationType type)
SqlOperation * sql_operation_new (SqlOperationType type)
{
return g_object_new (SQL_TYPE_OPERATION, "type", type, NULL);
}
@ -38,14 +38,11 @@ SqlObject * sql_operation_new (SqlOperationType type)
static const gchar * SQL_OPERATION_TYPE[] =
{
"NOT"
,"-"
,"+"
,"*"
"*"
,"/"
,"+"
,"-"
,"NOT"
,"IS"
,"="
,"!="
@ -57,25 +54,51 @@ static const gchar * SQL_OPERATION_TYPE[] =
,"AND"
,"OR"
,"XOR"
,"%"
,"IN"
};
static void sql_operation_render (SqlOperation * obj, SqlRender * render)
{
sql_render_add_espace (render);
sql_render_append (render, "(");
sql_render_add_list (render, TRUE, NULL, obj->operators,
sql_render_add_list (render, T, NULL, obj->expr,
SQL_OPERATION_TYPE[obj->type]);
sql_render_append (render, ")");
}
static gboolean sql_operation_is_ready (SqlOperation * obj)
{
GSList * n;
for (n = obj->expr; n; n = n->next)
if (!sql_object_is_ready (n->data))
return FALSE;
return TRUE;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
* sql_operation_add_expr:
* @obj: an #SqlOperation.
* @expr: an #SqlExpr.
*
* Adds an expression to an existing operation.
**/
void sql_operation_add_expr (SqlOperation * obj, SqlExpr * expr)
{
g_return_if_fail (SQL_IS_OPERATION (obj));
g_return_if_fail (SQL_IS_EXPR (expr));
sql_object_list_add (SQL_OBJECT (obj), &obj->expr, SQL_OBJECT (expr));
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
{
PROP_TYPE = 1
,PROP_OPERATORS
,PROP_COUNT
};
static void sql_operation_set_property (SqlOperation * obj, guint id,
@ -84,11 +107,7 @@ static void sql_operation_set_property (SqlOperation * obj, guint id,
switch (id)
{
case PROP_TYPE:
obj->type = g_value_get_enum (value);
break;
case PROP_OPERATORS:
sql_object_remove (obj, obj->operators);
obj->operators = sql_object_add (obj, g_value_get_object (value));
obj->type = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
@ -101,10 +120,7 @@ static void sql_operation_get_property (SqlOperation * obj, guint id,
switch (id)
{
case PROP_TYPE:
g_value_set_enum (value, obj->type);
break;
case PROP_OPERATORS:
g_value_set_object (value, obj->operators);
g_value_set_int (value, obj->type);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
@ -115,12 +131,12 @@ static void sql_operation_get_property (SqlOperation * obj, guint id,
static void sql_operation_init (SqlOperation * obj)
{
obj->operators = NULL;
obj->expr = NULL;
}
static void sql_operation_finalize (SqlOperation * obj)
{
sql_object_remove (obj, obj->operators);
sql_object_list_free (SQL_OBJECT (obj), obj->expr);
G_OBJECT_CLASS (sql_operation_parent_class)->finalize (G_OBJECT (obj));
}
@ -131,58 +147,13 @@ static void sql_operation_class_init (SqlOperationClass * klass)
k->set_property = (GObjectSetPropertyFunc) sql_operation_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_operation_get_property;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_operation_render;
SQL_OBJECT_CLASS (klass)->is_ready = (SqlObjectIsReadyFunc) sql_operation_is_ready;
g_object_class_install_property (k, PROP_TYPE,
g_param_spec_enum ("type"
g_param_spec_int ("type"
,"Type"
,"The type of the operation"
,SQL_TYPE_OPERATION_TYPE
,SQL_OPERATION_TYPE_AND
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_OPERATORS,
sql_param_list ("operators"
,"Operators"
,"The list of operators"
,SQL_TYPE_EXPR
,0, SQL_OPERATION_TYPE_COUNT, 0
,G_PARAM_READWRITE
));
}
GType sql_operation_type_get_type ()
{
static GType type = 0;
if (type == 0)
{
static const GEnumValue values[] =
{
{SQL_OPERATION_TYPE_NOT ,"SQL_OPERATION_TYPE_NOT" ,"not"
},{SQL_OPERATION_TYPE_MINUS ,"SQL_OPERATION_TYPE_MINUS" ,"minus"
},{SQL_OPERATION_TYPE_PLUS ,"SQL_OPERATION_TYPE_PLUS" ,"plus"
},{SQL_OPERATION_TYPE_MULTIPLICATION ,"SQL_OPERATION_TYPE_MULTIPLICATION" ,"multiplication"
},{SQL_OPERATION_TYPE_DIVISION ,"SQL_OPERATION_TYPE_DIVISION" ,"division"
},{SQL_OPERATION_TYPE_SUM ,"SQL_OPERATION_TYPE_SUM" ,"sum"
},{SQL_OPERATION_TYPE_SUBTRACTION ,"SQL_OPERATION_TYPE_SUBTRACTION" ,"subtraction"
},{SQL_OPERATION_TYPE_IS ,"SQL_OPERATION_TYPE_IS" ,"is"
},{SQL_OPERATION_TYPE_EQUAL ,"SQL_OPERATION_TYPE_EQUAL" ,"equal"
},{SQL_OPERATION_TYPE_NOT_EQUAL ,"SQL_OPERATION_TYPE_NOT_EQUAL" ,"not-equal"
},{SQL_OPERATION_TYPE_GREATER_EQUAL ,"SQL_OPERATION_TYPE_GREATER_EQUAL" ,"greater-equal"
},{SQL_OPERATION_TYPE_GREATER ,"SQL_OPERATION_TYPE_GREATER" ,"greater"
},{SQL_OPERATION_TYPE_LOWER_EQUAL ,"SQL_OPERATION_TYPE_LOWER_EQUAL" ,"lower-equal"
},{SQL_OPERATION_TYPE_LOWER ,"SQL_OPERATION_TYPE_LOWER" ,"lower"
},{SQL_OPERATION_TYPE_LIKE ,"SQL_OPERATION_TYPE_LIKE" ,"like"
},{SQL_OPERATION_TYPE_AND ,"SQL_OPERATION_TYPE_AND" ,"and"
},{SQL_OPERATION_TYPE_OR ,"SQL_OPERATION_TYPE_OR" ,"or"
},{SQL_OPERATION_TYPE_XOR ,"SQL_OPERATION_TYPE_XOR" ,"xor"
},{SQL_OPERATION_TYPE_MOD ,"SQL_OPERATION_TYPE_MOD" ,"mod"
},{SQL_OPERATION_TYPE_IN ,"SQL_OPERATION_TYPE_IN" ,"in"
},{0, NULL, NULL}
};
type = g_enum_register_static
(g_intern_static_string ("SqlOperationType"), values);
}
return type;
}

View File

@ -24,23 +24,16 @@
#define SQL_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_OPERATION, SqlOperation))
#define SQL_IS_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_OPERATION))
#define SQL_TYPE_OPERATION_TYPE (sql_operation_type_get_type ())
typedef struct _SqlOperation SqlOperation;
typedef struct _SqlOperationClass SqlOperationClass;
typedef enum
{
// Unary
SQL_OPERATION_TYPE_NOT
,SQL_OPERATION_TYPE_MINUS
,SQL_OPERATION_TYPE_PLUS
// Binary
,SQL_OPERATION_TYPE_MULTIPLICATION
SQL_OPERATION_TYPE_MULTIPLICATION
,SQL_OPERATION_TYPE_DIVISION
,SQL_OPERATION_TYPE_SUM
,SQL_OPERATION_TYPE_SUBTRACTION
,SQL_OPERATION_TYPE_REST
,SQL_OPERATION_TYPE_NOT
,SQL_OPERATION_TYPE_IS
,SQL_OPERATION_TYPE_EQUAL
,SQL_OPERATION_TYPE_NOT_EQUAL
@ -52,8 +45,6 @@ typedef enum
,SQL_OPERATION_TYPE_AND
,SQL_OPERATION_TYPE_OR
,SQL_OPERATION_TYPE_XOR
,SQL_OPERATION_TYPE_MOD
,SQL_OPERATION_TYPE_IN
,SQL_OPERATION_TYPE_COUNT
}
SqlOperationType;
@ -66,7 +57,7 @@ SqlOperationType;
struct _SqlOperation
{
SqlExpr parent;
SqlList * operators; // List of SqlExpr
GSList * expr; // List of SqlExpr pointers
SqlOperationType type;
};
@ -76,9 +67,8 @@ struct _SqlOperationClass
SqlExprClass parent;
};
GType sql_operation_get_type ();
GType sql_operation_type_get_type ();
SqlObject * sql_operation_new (SqlOperationType type);
GType sql_operation_get_type ();
SqlOperation * sql_operation_new (SqlOperationType type);
void sql_operation_add_expr (SqlOperation * obj, SqlExpr * expr);
#endif

View File

@ -66,7 +66,6 @@ gchar * sql_render_get_string (SqlRender * obj, gpointer object, gpointer data,
obj->data = data;
obj->object = g_object_ref (object);
obj->buffer = g_string_sized_new (SQL_BUFFER_SIZE);
obj->ancestors = NULL;
sql_render_add_object (obj, object);
@ -82,10 +81,8 @@ gchar * sql_render_get_string (SqlRender * obj, gpointer object, gpointer data,
}
else
sql = g_string_free (obj->buffer, FALSE);
g_clear_object (&obj->object);
g_slist_free (obj->ancestors);
obj->ancestors = NULL;
obj->buffer = NULL;
obj->data = NULL;
return sql;
@ -104,23 +101,7 @@ void sql_render_register_function (SqlRender * obj, GType type, SqlRenderFunc fu
{
g_return_if_fail (SQL_IS_RENDER (obj));
g_hash_table_insert (obj->custom_renderers, GUINT_TO_POINTER (type), function);
}
/**
* sql_render_get_ancestors:
* @obj: the #SqlRender
*
* Obtains a list of parents of the currently rendered object, including it.
*
* Return value: (transfer none): the #GSList with the parents, the list should
* not be edited or freed.
**/
GSList * sql_render_get_ancestors (SqlRender * obj)
{
g_return_val_if_fail (SQL_IS_RENDER (obj), NULL);
return obj->ancestors;
g_hash_table_insert (obj->symbol_table, GUINT_TO_POINTER (type), function);
}
/**
@ -139,16 +120,13 @@ void sql_render_add_object (SqlRender * obj, gpointer object)
if (object)
{
function = g_hash_table_lookup (obj->custom_renderers,
function = g_hash_table_lookup (obj->symbol_table,
GUINT_TO_POINTER (G_OBJECT_TYPE (object)));
obj->ancestors = g_slist_prepend (obj->ancestors, object);
if (function)
function (object, obj);
else
sql_object_render (object, obj);
obj->ancestors = g_slist_delete_link (obj->ancestors, obj->ancestors);
}
}
@ -302,17 +280,16 @@ void sql_render_add_item (SqlRender * obj, gboolean required, const gchar * toke
*
**/
void sql_render_add_list (SqlRender * obj, gboolean required, const gchar * token,
SqlList * list, const gchar * separator)
GSList * list, const gchar * separator)
{
g_return_if_fail (SQL_IS_RENDER (obj));
g_return_if_fail (SQL_IS_LIST (list));
if (list)
{
GList * n;
GSList * n;
sql_render_add_token (obj, token);
for (n = sql_list_get_items (list); n; n = n->next)
for (n = list; n; n = n->next)
{
sql_render_add_object (obj, n->data);
@ -336,17 +313,16 @@ void sql_render_add_list (SqlRender * obj, gboolean required, const gchar * toke
*
**/
void sql_render_add_list_with_func (SqlRender * obj, gboolean required, const gchar * token,
SqlList * list, const gchar * separator, SqlRenderFunc function)
GSList * list, const gchar * separator, SqlRenderFunc function)
{
g_return_if_fail (SQL_IS_RENDER (obj));
g_return_if_fail (SQL_IS_LIST (list));
if (list)
{
GList * n;
GSList * n;
sql_render_add_token (obj, token);
for (n = sql_list_get_items (list); n; n = n->next)
for (n = list; n; n = n->next)
{
function (n->data, obj);
@ -413,7 +389,7 @@ static void sql_render_init (SqlRender * obj)
{
obj->buffer = NULL;
obj->error = NULL;
obj->custom_renderers = g_hash_table_new (
obj->symbol_table = g_hash_table_new (
g_direct_hash
,g_direct_equal
);
@ -421,7 +397,7 @@ static void sql_render_init (SqlRender * obj)
static void sql_render_finalize (SqlRender * obj)
{
g_hash_table_unref (obj->custom_renderers);
g_hash_table_unref (obj->symbol_table);
G_OBJECT_CLASS (sql_render_parent_class)->finalize (G_OBJECT (obj));
}

View File

@ -26,6 +26,8 @@
#define SQL_RENDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_RENDER, SqlRender))
#define SQL_IS_RENDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, SQL_TYPE_RENDER))
#define T TRUE
#define F FALSE
#define SQL_BUFFER_SIZE 500
typedef struct _SqlRender SqlRender;
@ -37,7 +39,7 @@ typedef void (* SqlRenderFunc) (gpointer obj, SqlRender * render);
/**
* SqlRender:
* @custom_renderers: (element-type GType Sql.RenderFunc):
* @symbol_table: (element-type GType Sql.RenderFunc):
**/
struct _SqlRender
{
@ -45,9 +47,8 @@ struct _SqlRender
GError * error;
GString * buffer;
gpointer object;
GSList * ancestors;
gpointer data;
GHashTable * custom_renderers;
GHashTable * symbol_table;
gint8 delimiter;
};
@ -73,7 +74,6 @@ GType sql_render_get_type ();
SqlRender * sql_render_new (gchar delimiter);
gchar * sql_render_get_string (SqlRender * obj, gpointer object, gpointer data, GError ** err);
void sql_render_register_function (SqlRender * obj, GType type, SqlRenderFunc function);
GSList * sql_render_get_ancestors (SqlRender * obj);
void sql_render_add_espace (SqlRender * obj);
void sql_render_printf (SqlRender * obj, const gchar * string, ...);
void sql_render_append (SqlRender * obj, const gchar * string);
@ -82,8 +82,8 @@ void sql_render_add_token (SqlRender * obj, const gchar * token);
void sql_render_add_identifier (SqlRender * obj, const gchar * identifier);
void sql_render_add_object (SqlRender * obj, gpointer object);
void sql_render_add_item (SqlRender * obj, gboolean required, const gchar * token, gpointer item);
void sql_render_add_list (SqlRender * obj, gboolean required, const gchar * token, SqlList * list, const gchar * separator);
void sql_render_add_list_with_func (SqlRender * obj, gboolean required, const gchar * token, SqlList * list, const gchar * separator, SqlRenderFunc function);
void sql_render_add_list (SqlRender * obj, gboolean required, const gchar * token, GSList * list, const gchar * separator);
void sql_render_add_list_with_func (SqlRender * obj, gboolean required, const gchar * token, GSList * list, const gchar * separator, SqlRenderFunc function);
void sql_render_set_error (SqlRender * obj);
#endif

View File

@ -24,35 +24,84 @@
*
* This object represents a SELECT SQL statement
**/
typedef struct
{
SqlExpr * expr;
gchar * alias;
}
SqlSelectAlias;
typedef struct
{
SqlExpr * expr;
SqlOrderWay way;
}
SqlOrder;
G_DEFINE_TYPE (SqlSelect, sql_select, SQL_TYPE_DML);
SqlObject * sql_select_new ()
SqlSelect * sql_select_new ()
{
return g_object_new (SQL_TYPE_SELECT, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
/*
static const char * SQL_SELECT_TYPE[] =
{
""
NULL
,"UNION ALL"
,"UNION ANY"
,"INTERSECT"
,"EXCEPT"
};
*/
static void sql_select_render_order (SqlOrder * order, SqlRender * render)
{
sql_render_add_object (render, order->expr);
if (order->way == SQL_ORDER_DESC)
sql_render_add_token (render, "DESC");
}
static void sql_select_render (SqlSelect * obj, SqlRender * render)
{
sql_render_add_list (render, TRUE, "SELECT", obj->fields, ",");
sql_render_add_list (render, FALSE, "FROM", SQL_DML (obj)->targets, ",");
if (SQL_DML (obj)->targets)
if (obj->alias)
{
sql_render_add_item (render, FALSE, "WHERE", SQL_DML (obj)->where);
sql_render_add_list (render, FALSE, "GROUP BY", obj->group, ",");
sql_render_add_item (render, FALSE, "HAVING", obj->having);
sql_render_add_list (render, FALSE, "ORDER", obj->order, ",");
GSList * n;
sql_render_add_token (render, "SELECT");
for (n = obj->expr; n; n = n->next)
{
GSList * l;
sql_render_add_object (render, n->data);
for (l = obj->alias; l; l = l->next)
if (((SqlSelectAlias *) l->data)->expr == n->data)
{
sql_render_add_identifier (render,
((SqlSelectAlias *) l->data)->alias);
}
if (n->next)
sql_render_append (render, " ,");
}
}
else
sql_render_add_list (render, T, "SELECT", obj->expr, ",");
sql_render_add_list (render, F, "FROM", SQL_DML (obj)->target, ",");
if (SQL_DML (obj)->target)
{
sql_render_add_item (render, F, "WHERE", SQL_DML (obj)->where);
sql_render_add_list (render, F, "GROUP BY", obj->group, ",");
sql_render_add_item (render, F, "HAVING", obj->having);
sql_render_add_list_with_func (render, F, "ORDER", obj->order, ",",
(SqlRenderFunc) sql_select_render_order);
if (obj->limit_count)
sql_render_printf (render, "LIMIT %u OFFSET %u"
@ -60,9 +109,18 @@ static void sql_select_render (SqlSelect * obj, SqlRender * render)
,obj->limit_offset
);
}
if (obj->next)
sql_render_add_item (render, FALSE, SQL_SELECT_TYPE[obj->type], obj->next);
}
static void sql_order_free (SqlOrder * obj)
{
g_object_unref (obj->expr);
g_free (obj);
}
static void sql_select_alias_free (SqlSelectAlias * obj)
{
g_free (obj->alias);
g_free (obj);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
@ -71,27 +129,54 @@ void sql_select_add_expr (SqlSelect * obj, SqlExpr * expr)
{
g_return_if_fail (SQL_IS_SELECT (obj));
g_return_if_fail (SQL_IS_EXPR (expr));
obj->expr = g_slist_append (obj->expr, g_object_ref_sink (expr));
}
void sql_select_set_alias (SqlSelect * obj, SqlExpr * expr, const gchar * alias)
{
GSList * list;
g_return_if_fail (SQL_IS_SELECT (obj));
list = g_slist_find (obj->expr, expr);
if (list)
{
SqlSelectAlias * as = g_new (SqlSelectAlias, 1);
as->alias = g_strdup (alias);
as->expr = expr;
obj->alias = g_slist_append (obj->alias, as);
}
}
void sql_select_add_group (SqlSelect * obj, SqlExpr * expr)
{
g_return_if_fail (SQL_IS_SELECT (obj));
g_return_if_fail (SQL_IS_EXPR (expr));
obj->group = g_slist_append (obj->group, g_object_ref_sink (expr));
}
void sql_select_set_having (SqlSelect * obj, SqlExpr * having)
{
g_return_if_fail (SQL_IS_SELECT (obj));
g_return_if_fail (SQL_IS_EXPR (having) || having);
sql_object_remove (obj, obj->having);
obj->having = sql_object_add (obj, having);
}
void sql_select_add_order (SqlSelect * obj, SqlExpr * expr, SqlSelectOrderWay way)
void sql_select_set_having (SqlSelect * obj, SqlExpr * expr)
{
g_return_if_fail (SQL_IS_SELECT (obj));
g_return_if_fail (SQL_IS_EXPR (expr));
g_clear_object (&obj->having);
obj->having = g_object_ref_sink (expr);
}
void sql_select_add_order (SqlSelect * obj, SqlExpr * expr, SqlOrderWay way)
{
g_return_if_fail (SQL_IS_SELECT (obj));
g_return_if_fail (SQL_IS_EXPR (expr));
SqlOrder * order = g_new (SqlOrder, 1);
order->expr = g_object_ref_sink (expr);
order->way = way;
obj->order = g_slist_append (obj->order, order);
}
void sql_select_set_distinct (SqlSelect * obj, gboolean distinct)
@ -114,9 +199,15 @@ void sql_select_set_next (SqlSelect * obj, SqlSelect * next, SqlSelectType type)
g_return_if_fail (SQL_IS_SELECT (obj));
g_return_if_fail (SQL_IS_SELECT (next) || !next);
sql_object_remove (obj, obj->next);
obj->next = sql_object_add (obj, next);
obj->type = next ? type : SQL_SELECT_NONE;
g_clear_object (&obj->next);
if (next)
{
obj->next = g_object_ref (next);
obj->type = type;
}
else
obj->type = SQL_SELECT_NONE;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
@ -124,12 +215,9 @@ void sql_select_set_next (SqlSelect * obj, SqlSelect * next, SqlSelectType type)
enum
{
PROP_DISTINCT = 1
,PROP_FIELDS
,PROP_GROUP
,PROP_HAVING
,PROP_ORDER
,PROP_LIMIT_COUNT
,PROP_LIMIT_OFFSET
,PROP_HAVING
,PROP_TYPE
,PROP_NEXT
};
@ -142,33 +230,21 @@ static void sql_select_set_property (SqlSelect * obj, guint id,
case PROP_DISTINCT:
obj->distinct = g_value_get_boolean (value);
break;
case PROP_FIELDS:
sql_object_remove (obj, obj->fields);
obj->fields = sql_object_add (obj, g_value_get_object (value));
break;
case PROP_GROUP:
sql_object_remove (obj, obj->group);
obj->group = sql_object_add (obj, g_value_get_object (value));
break;
case PROP_HAVING:
sql_select_set_having (obj, g_value_get_object (value));
break;
case PROP_ORDER:
sql_object_remove (obj, obj->order);
obj->order = sql_object_add (obj, g_value_get_object (value));
break;
case PROP_LIMIT_COUNT:
obj->limit_count = g_value_get_uint (value);
break;
case PROP_LIMIT_OFFSET:
obj->limit_offset = g_value_get_uint (value);
break;
case PROP_NEXT:
sql_select_set_next (obj, g_value_get_object (value), obj->type);
case PROP_HAVING:
sql_select_set_having (obj, g_value_get_object (value));
break;
case PROP_TYPE:
obj->type = g_value_get_int (value);
break;
case PROP_NEXT:
sql_select_set_next (obj, g_value_get_object (value), obj->type);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -182,30 +258,21 @@ static void sql_select_get_property (SqlSelect * obj, guint id,
case PROP_DISTINCT:
g_value_set_boolean (value, obj->distinct);
break;
case PROP_FIELDS:
g_value_set_object (value, obj->fields);
break;
case PROP_GROUP:
g_value_set_object (value, obj->group);
break;
case PROP_HAVING:
g_value_set_object (value, obj->having);
break;
case PROP_ORDER:
g_value_set_object (value, obj->order);
break;
case PROP_LIMIT_COUNT:
g_value_set_uint (value, obj->limit_count);
break;
case PROP_LIMIT_OFFSET:
g_value_set_uint (value, obj->limit_offset);
break;
case PROP_NEXT:
g_value_set_object (value, obj->next);
case PROP_HAVING:
g_value_set_object (value, obj->having);
break;
case PROP_TYPE:
g_value_set_int (value, obj->type);
break;
case PROP_NEXT:
g_value_set_object (value, obj->next);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -216,7 +283,8 @@ static void sql_select_get_property (SqlSelect * obj, guint id,
static void sql_select_init (SqlSelect * obj)
{
obj->distinct = FALSE;
obj->fields = NULL;
obj->expr = NULL;
obj->alias = NULL;
obj->group = NULL;
obj->having = NULL;
obj->order = NULL;
@ -226,83 +294,62 @@ static void sql_select_init (SqlSelect * obj)
static void sql_select_finalize (SqlSelect * obj)
{
g_object_unref (obj->group);
g_object_unref (obj->order);
sql_object_remove (obj, obj->fields);
sql_object_remove (obj, obj->having);
sql_object_remove (obj, obj->next);
g_clear_object (&obj->having);
g_clear_object (&obj->next);
g_slist_free_full (obj->expr, g_object_unref);
g_slist_free_full (obj->group, g_object_unref);
g_slist_free_full (obj->alias, (GFreeFunc) sql_select_alias_free);
g_slist_free_full (obj->order, (GFreeFunc) sql_order_free);
G_OBJECT_CLASS (sql_select_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_select_class_init (SqlSelectClass * klass)
static void sql_select_class_init (SqlSelectClass * k)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_select_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_select_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_select_get_property;
SQL_OBJECT_CLASS (k)->render = (SqlRenderFunc) sql_select_render;
GObjectClass * klass = G_OBJECT_CLASS (k);
klass->finalize = (GObjectFinalizeFunc) sql_select_finalize;
klass->set_property = (GObjectSetPropertyFunc) sql_select_set_property;
klass->get_property = (GObjectGetPropertyFunc) sql_select_get_property;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_select_render;
g_object_class_install_property (k, PROP_LIMIT_COUNT,
g_object_class_install_property (klass, PROP_LIMIT_COUNT,
g_param_spec_boolean ("distinct"
,"Distinct"
,"Determines if the #SqlSelect uses the DISTINCT clause"
,FALSE
,G_PARAM_READWRITE
,FALSE, G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_FIELDS,
sql_param_list ("fields"
,"Fields"
,"The list of fields"
,SQL_TYPE_EXPR
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_GROUP,
sql_param_object ("group"
,"Group"
,"The GROUP BY section"
,SQL_TYPE_EXPR
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_HAVING,
sql_param_object ("having"
,"Having"
,"The HAVING clause"
,SQL_TYPE_EXPR
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_ORDER,
sql_param_list ("order"
,"Order"
,"The ORDER BY section"
,SQL_TYPE_SELECT_ORDER
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_LIMIT_COUNT,
g_object_class_install_property (klass, PROP_LIMIT_COUNT,
g_param_spec_uint ("limit-count"
,"Limit count"
,"The COUNT field of the LIMIT clause"
,0, G_MAXUINT, 0
,G_PARAM_READWRITE
,0, G_MAXUINT, 0, G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_LIMIT_OFFSET,
g_object_class_install_property (klass, PROP_LIMIT_OFFSET,
g_param_spec_uint ("limit-offset"
,"Limit offset"
,"The OFFSET field of the LIMIT clause"
,0, G_MAXUINT, 0
,G_PARAM_READWRITE
,0, G_MAXUINT, 0, G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_NEXT,
sql_param_object ("next"
,"Next"
,"The next #SqlSelect in case of a statement with more than one"
,SQL_TYPE_SELECT
,G_PARAM_READWRITE
g_object_class_install_property (klass, PROP_HAVING,
g_param_spec_object ("having"
,"Having"
,"The HAVING clause"
,SQL_TYPE_EXPR, G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_TYPE,
g_object_class_install_property (klass, PROP_TYPE,
g_param_spec_int ("type"
,"Type"
,"One of the possible options of #SqlSelectType"
,0, SQL_SELECT_COUNT - 1, 0
,G_PARAM_READWRITE
,0, SQL_SELECT_COUNT - 1, 0, G_PARAM_READWRITE
));
g_object_class_install_property (klass, PROP_NEXT,
g_param_spec_object ("next"
,"Next"
,"The next #SqlSelect in case of a statement with more than one"
,SQL_TYPE_SELECT, G_PARAM_READWRITE
));
}

View File

@ -19,8 +19,6 @@
#define SQL_SELECT_H
#include "sql-dml.h"
#include "sql-select-field.h"
#include "sql-select-order.h"
#define SQL_TYPE_SELECT (sql_select_get_type ())
#define SQL_SELECT(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, SQL_TYPE_SELECT, SqlSelect))
@ -40,6 +38,18 @@ typedef enum
}
SqlSelectType;
/**
* SqlOrderWay:
* @SQL_ORDER_ASC: ascendent order
* @SQL_ORDER_DESC: descendent order
**/
typedef enum
{
SQL_ORDER_ASC
,SQL_ORDER_DESC
}
SqlOrderWay;
/**
* SqlSelect:
* @expr: (element-type Sql.Expr):
@ -50,15 +60,16 @@ struct _SqlSelect
{
SqlDml parent;
gboolean distinct;
SqlList * fields;
SqlList * group;
GSList * expr;
GSList * alias; // List of Sql.SelectAlias
GSList * group;
SqlExpr * having;
SqlList * order;
GSList * order;
guint limit_offset;
guint limit_count;
SqlSelect * next;
SqlSelectType type;
SqlSelect * next;
};
struct _SqlSelectClass
@ -68,13 +79,13 @@ struct _SqlSelectClass
};
GType sql_select_get_type ();
SqlObject * sql_select_new ();
SqlSelect * sql_select_new ();
void sql_select_set_distinct (SqlSelect * obj, gboolean distinct);
void sql_select_add_expr (SqlSelect * obj, SqlExpr * expr);
void sql_select_set_alias (SqlSelect * obj, SqlExpr * expr, const gchar * alias);
void sql_select_add_group (SqlSelect * obj, SqlExpr * expr);
void sql_select_set_having (SqlSelect * obj, SqlExpr * expr);
void sql_select_add_order (SqlSelect * obj, SqlExpr * expr, SqlSelectOrderWay way);
void sql_select_add_order (SqlSelect * obj, SqlExpr * expr, SqlOrderWay way);
void sql_select_set_limit (SqlSelect * obj, guint count, guint offset);
void sql_select_set_next (SqlSelect * obj, SqlSelect * next, SqlSelectType type);

View File

@ -41,5 +41,6 @@ struct _SqlStmtClass
};
GType sql_stmt_get_type ();
gboolean sql_stmt_is_ready (SqlStmt * obj);
#endif

View File

@ -16,15 +16,6 @@
*/
#include "sql-string.h"
#include "sql-holder.h"
typedef struct
{
gchar * start;
gchar * end;
SqlHolder * holder;
}
HolderData;
/**
* SECTION: sql-string
@ -44,71 +35,81 @@ SqlString * sql_string_new (const gchar * sql)
static void sql_string_render (SqlString * obj, SqlRender * render)
{
GSList * i;
gchar * ptr = obj->sql;
for (i = obj->holders; i; i = i->next)
guint n;
gsize pos;
gchar * i = obj->sql;
GSList * p = obj->params;
for (n = 0; n < obj->positions->len && p; n++)
{
HolderData * holder_data = i->data;
g_string_append_len (render->buffer, ptr, holder_data->start - ptr - 1);
ptr = holder_data->end;
sql_render_add_object (render, holder_data->holder);
pos = g_array_index (obj->positions, gsize, n);
g_string_append_len (render->buffer, i, (obj->sql + pos) - i);
i = obj->sql + pos + 2;
sql_render_add_object (render, p->data);
p = p->next;
}
sql_render_append (render, ptr);
sql_render_append (render, i);
}
static void sql_string_free_holder_data (HolderData * holder_data)
static gboolean sql_string_is_ready (SqlString * obj)
{
g_object_unref (holder_data->holder);
g_free (holder_data);
guint n;
GSList * p = obj->params;
for (n = 0; n < obj->positions->len && p; n++)
{
if (!sql_object_is_ready (p->data))
return FALSE;
p = p->next;
}
return n == obj->positions->len;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
* sql_string_add_param:
* @obj: the #SqlString
* @id: the id assigned to the item
**/
void sql_string_add_param (SqlString * obj, const gchar * id, GvnParam * param)
void sql_string_add_expr (SqlString * obj, SqlExpr * expr)
{
g_return_if_fail (SQL_IS_STRING (obj));
g_return_if_fail (SQL_IS_EXPR (expr));
sql_object_list_add (SQL_OBJECT (obj), &obj->params, SQL_OBJECT (expr));
}
void sql_string_add_param (SqlString * obj, GvnParam * param)
{
g_return_if_fail (SQL_IS_STRING (obj));
g_return_if_fail (GVN_IS_PARAM (param));
SqlExpr * value = sql_value_new ();
sql_value_set_param (SQL_VALUE (value), param);
sql_object_add_held_object (SQL_OBJECT (obj), id, SQL_OBJECT (value));
g_object_unref (value);
sql_object_list_add (SQL_OBJECT (obj), &obj->params, SQL_OBJECT (value));
}
/**
* sql_string_add_value:
* @obj: the #SqlString
* @id: the id assigned to the item
**/
void sql_string_add_value (SqlString * obj, const gchar * id, GType type, gpointer content)
void sql_string_add_value (SqlString * obj, GType type, gconstpointer content)
{
g_return_if_fail (SQL_IS_STRING (obj));
GValue gvalue = {0};
SqlExpr * value;
GValue value = {0};
SqlExpr * expr;
gvn_value_new_with_content (&gvalue, type, content);
value = sql_value_new ();
sql_value_set_value (SQL_VALUE (value), &gvalue);
sql_object_add_held_object (SQL_OBJECT (obj), id, SQL_OBJECT (value));
g_object_unref (value);
g_value_unset (&gvalue);
gvn_value_new_with_content (&value, type, content);
expr = sql_value_new ();
sql_value_set_value (SQL_VALUE (expr), &value);
sql_object_list_add (SQL_OBJECT (obj), &obj->params, SQL_OBJECT (expr));
g_value_unset (&value);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
typedef enum
{
PROP_SQL = 1
};
}
SqlStringProp;
static void sql_string_set_property (SqlString * obj, guint id,
const GValue * value, GParamSpec * pspec)
@ -117,54 +118,35 @@ static void sql_string_set_property (SqlString * obj, guint id,
{
case PROP_SQL:
{
gchar * i;
gchar * n;
obj->sql = g_value_dup_string (value);
n = obj->sql;
if (obj->sql)
for (i = obj->sql; ; i++)
for (; n && *n != '\0'; n++)
{
switch (*i)
switch (*n)
{
case '#':
{
gchar * ptr = ++i;
gchar * holder_id;
HolderData * holder_data;
while (g_ascii_isalpha (*i))
i++;
holder_data = g_new (HolderData, 1);
holder_data->start = ptr;
holder_data->end = i;
obj->holders = g_slist_prepend (obj->holders, holder_data);
holder_id = g_strndup (ptr, i - ptr);
holder_data->holder = sql_holder_new (holder_id);
g_free (holder_id);
if (*(n+1) == 'p')
{
gsize pos = n - obj->sql;
g_array_append_val (obj->positions, pos);
n++;
}
break;
}
case '\'':
case '"':
case '`':
{
gchar delimiter = *i;
while (*(++i) != delimiter)
if (*i == '\\')
i++;
do {
n = g_strstr_len (++n, -1, "'");
}
while (n && *(n-1) == '\\');
break;
}
}
if (*i == '\0')
if (!n || *n == '\0')
break;
}
obj->holders = g_slist_reverse (obj->holders);
break;
}
default:
@ -189,14 +171,16 @@ static void sql_string_get_property (SqlString * obj, guint id,
static void sql_string_init (SqlString * obj)
{
obj->holders = NULL;
obj->sql = NULL;
obj->params = NULL;
obj->positions = g_array_sized_new (FALSE, FALSE, sizeof (gsize), 5);
}
static void sql_string_finalize (SqlString * obj)
{
g_free (obj->sql);
g_slist_free_full (obj->holders,
(GDestroyNotify) sql_string_free_holder_data);
g_array_free (obj->positions, TRUE);
g_slist_free_full (obj->params, (GDestroyNotify) g_object_unref);
G_OBJECT_CLASS (sql_string_parent_class)->finalize (G_OBJECT (obj));
}
@ -207,6 +191,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)->is_ready = (SqlObjectIsReadyFunc) sql_string_is_ready;
g_object_class_install_property (klass, PROP_SQL,
g_param_spec_string ("sql"

View File

@ -32,13 +32,15 @@ typedef struct _SqlStringClass SqlStringClass;
/**
* SqlString:
* @expr: (element-type Sql.Expr):
* @params: (element-type GvnParam):
* @positions: (element-type gsize):
**/
struct _SqlString
{
SqlStmt parent;
gchar * sql;
GSList * holders;
GSList * params;
GArray * positions;
};
struct _SqlStringClass
@ -49,7 +51,8 @@ struct _SqlStringClass
GType sql_string_get_type ();
SqlString * sql_string_new (const gchar * sql);
void sql_string_add_param (SqlString * obj, const gchar * id, GvnParam * param);
void sql_string_add_value (SqlString * obj, const gchar * id, GType type, gpointer content);
void sql_string_add_expr (SqlString * obj, SqlExpr * expr);
void sql_string_add_param (SqlString * obj, GvnParam * param);
void sql_string_add_value (SqlString * obj, GType type, gconstpointer content);
#endif

View File

@ -39,7 +39,7 @@ static void sql_subquery_render (SqlSubquery * obj, SqlRender * render)
if (obj->select)
{
sql_render_append (render, "(");
sql_render_add_item (render, TRUE, NULL, obj->select);
sql_render_add_item (render, T, NULL, obj->select);
sql_render_append (render, ")");
}
}
@ -49,10 +49,10 @@ static void sql_subquery_render (SqlSubquery * obj, SqlRender * render)
void sql_subquery_set_select (SqlSubquery * obj, SqlSelect * select)
{
g_return_if_fail (SQL_IS_SUBQUERY (obj));
g_return_if_fail (SQL_IS_SELECT (select) || !select);
g_return_if_fail (SQL_IS_SELECT (select));
sql_object_remove (obj, obj->select);
obj->select = sql_object_add (obj, select);
g_clear_object (&obj->select);
obj->select = g_object_ref_sink (select);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
@ -97,7 +97,7 @@ static void sql_subquery_init (SqlSubquery * obj)
static void sql_subquery_finalize (SqlSubquery * obj)
{
sql_object_remove (obj, obj->select);
g_clear_object (&obj->select);
G_OBJECT_CLASS (sql_subquery_parent_class)->finalize (G_OBJECT (obj));
}
@ -110,10 +110,9 @@ static void sql_subquery_class_init (SqlSubqueryClass * klass)
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_subquery_render;
g_object_class_install_property (k, PROP_SELECT,
sql_param_object ("select"
,"Select"
,"The SELECT statement"
,SQL_TYPE_SELECT
,G_PARAM_READWRITE
g_param_spec_object ("select"
, "Select"
, "An #SqlSelect"
, SQL_TYPE_SELECT, G_PARAM_READWRITE
));
}

View File

@ -26,7 +26,7 @@
**/
G_DEFINE_TYPE (SqlTable, sql_table, SQL_TYPE_TARGET);
SqlObject * sql_table_new (const gchar * name)
SqlTarget * sql_table_new (const gchar * name)
{
return g_object_new (SQL_TYPE_TABLE, "name", name, NULL);
}
@ -101,25 +101,27 @@ static void sql_table_finalize (SqlTable * obj)
{
g_free (obj->name);
g_free (obj->schema);
obj->name = NULL;
obj->schema = NULL;
G_OBJECT_CLASS (sql_table_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_table_class_init (SqlTableClass * klass)
static void sql_table_class_init (SqlTableClass * k)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_table_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_table_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_table_get_property;
GObjectClass * klass = G_OBJECT_CLASS (k);
klass->finalize = (GObjectFinalizeFunc) sql_table_finalize;
klass->set_property = (GObjectSetPropertyFunc) sql_table_set_property;
klass->get_property = (GObjectGetPropertyFunc) sql_table_get_property;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_table_render;
g_object_class_install_property (k, PROP_NAME,
g_object_class_install_property (klass, PROP_NAME,
g_param_spec_string ("name"
, "Name"
, "The table name"
, NULL, G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_SCHEMA,
g_object_class_install_property (klass, PROP_SCHEMA,
g_param_spec_string ("schema"
,"Schema"
,"The schema where the table is"

View File

@ -41,6 +41,6 @@ struct _SqlTableClass
};
GType sql_table_get_type ();
SqlObject * sql_table_new (const gchar * name);
SqlTarget * sql_table_new (const gchar * name);
#endif

View File

@ -34,7 +34,9 @@ void sql_target_set_alias (SqlTarget * obj, const gchar * alias)
g_return_if_fail (SQL_IS_TARGET (obj));
g_free (obj->alias);
obj->alias = g_strdup (alias);
if (alias)
obj->alias = g_strdup (alias);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
@ -72,17 +74,18 @@ static void sql_target_get_property (SqlTarget * obj, guint id,
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_target_init (SqlTarget * obj)
{
obj->alias = NULL;
}
static void sql_target_finalize (SqlTarget * obj)
{
g_free (obj->alias);
obj->alias = NULL;
G_OBJECT_CLASS (sql_target_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_target_init (SqlTarget * obj)
{
obj->alias = NULL;
}
static void sql_target_class_init (SqlTargetClass * k)
{
GObjectClass * klass = G_OBJECT_CLASS (k);
@ -92,9 +95,8 @@ static void sql_target_class_init (SqlTargetClass * k)
g_object_class_install_property (klass, PROP_ALIAS,
g_param_spec_string ("alias"
,"Alias"
,"The alias for the target"
,NULL
,G_PARAM_READWRITE
, "Alias"
, "The alias for the target"
, NULL, G_PARAM_READWRITE
));
}

View File

@ -26,92 +26,67 @@
**/
G_DEFINE_TYPE (SqlUpdate, sql_update, SQL_TYPE_DML);
SqlObject * sql_update_new ()
SqlUpdate * sql_update_new ()
{
return g_object_new (SQL_TYPE_UPDATE, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void sql_update_render_set (SqlUpdateSet * set, SqlRender * render)
{
sql_render_add_object (render, set->field);
sql_render_add_token (render, "=");
sql_render_add_object (render, set->expr);
}
static void sql_update_render (SqlUpdate * obj, SqlRender * render)
{
sql_render_add_list (render, TRUE, "UPDATE", SQL_DML (obj)->targets, ",");
sql_render_add_list (render, T, "UPDATE", SQL_DML (obj)->target, ",");
if (SQL_DML (obj)->targets)
if (SQL_DML (obj)->target)
{
sql_render_add_list (render, TRUE, "SET", obj->sets, ",");
sql_render_add_item (render, FALSE, "WHERE", SQL_DML (obj)->where);
sql_render_add_list_with_func (render, T, "SET", obj->set, ",",
(SqlRenderFunc) sql_update_render_set);
sql_render_add_item (render, F, "WHERE", SQL_DML (obj)->where);
}
}
static void sql_update_set_free (SqlUpdateSet * obj)
{
g_object_unref (obj->field);
g_object_unref (obj->expr);
g_free (obj);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
void sql_update_add_set (SqlUpdate * obj, SqlField * field, SqlExpr * expr)
{
g_return_if_fail (SQL_IS_UPDATE (obj));
g_return_if_fail (SQL_IS_FIELD (field) && SQL_IS_EXPR (expr));
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
enum
{
PROP_SETS = 1
};
static void sql_update_set_property (SqlUpdate * obj, guint id,
const GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_SETS:
sql_object_remove (obj, obj->sets);
obj->sets = sql_object_add (obj, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
static void sql_update_get_property (SqlUpdate * obj, guint id,
GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_SETS:
g_value_set_object (value, obj->sets);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
SqlUpdateSet * set = g_new (SqlUpdateSet, 1);
set->field = g_object_ref_sink (field);
set->expr = g_object_ref_sink (expr);
obj->set = g_slist_append (obj->set, set);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void sql_update_init (SqlUpdate * obj)
{
obj->sets = NULL;
obj->set = NULL;
}
static void sql_update_finalize (SqlUpdate * obj)
{
sql_object_remove (obj, obj->sets);
g_slist_free_full (obj->set, (GFreeFunc) sql_update_set_free);
G_OBJECT_CLASS (sql_update_parent_class)->finalize (G_OBJECT (obj));
}
static void sql_update_class_init (SqlUpdateClass * klass)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) sql_update_finalize;
k->set_property = (GObjectSetPropertyFunc) sql_update_set_property;
k->get_property = (GObjectGetPropertyFunc) sql_update_get_property;
G_OBJECT_CLASS (klass)->finalize = (GObjectFinalizeFunc) sql_update_finalize;
SQL_OBJECT_CLASS (klass)->render = (SqlRenderFunc) sql_update_render;
g_object_class_install_property (k, PROP_SETS,
sql_param_list ("sets"
,"Sets"
,"A list of sets"
,SQL_TYPE_UPDATE_SET
,G_PARAM_READWRITE
));
}

View File

@ -20,7 +20,6 @@
#include "sql-dml.h"
#include "sql-field.h"
#include "sql-update-set.h"
#define SQL_TYPE_UPDATE (sql_update_get_type ())
#define SQL_UPDATE(object) (G_TYPE_CHECK_INSTANCE_CAST (object, SQL_TYPE_UPDATE, SqlUpdate))
@ -29,13 +28,29 @@
typedef struct _SqlUpdate SqlUpdate;
typedef struct _SqlUpdateClass SqlUpdateClass;
typedef struct _SqlUpdateSet SqlUpdateSet;
/**
* SqlUpdateSet:
* @field: an #SqlField
* @expr: an #SqlExpr
*
* Defines a field for the SET clause for an #SqlUpdate.
**/
struct _SqlUpdateSet
{
SqlField * field;
SqlExpr * expr;
};
/**
* SqlUpdate:
* @set: (element-type Sql.UpdateSet):
**/
struct _SqlUpdate
{
SqlDml parent;
SqlList * sets; // List of SqlUpdateSet
GSList * set; // List of SqlUpdateSet
};
struct _SqlUpdateClass
@ -46,7 +61,7 @@ struct _SqlUpdateClass
GType sql_update_get_type ();
SqlObject * sql_update_new ();
SqlUpdate * sql_update_new ();
void sql_update_add_set (SqlUpdate * obj, SqlField * field, SqlExpr * expr);
#endif

View File

@ -28,12 +28,12 @@
**/
G_DEFINE_TYPE (SqlValue, sql_value, SQL_TYPE_EXPR);
SqlObject * sql_value_new ()
SqlExpr * sql_value_new ()
{
return g_object_new (SQL_TYPE_VALUE, NULL);
}
SqlObject * sql_value_new_with_value (const GValue * value)
SqlExpr * sql_value_new_with_value (const GValue * value)
{
g_return_val_if_fail (value, NULL);
g_return_val_if_fail (G_IS_VALUE (value), NULL);

View File

@ -42,10 +42,10 @@ struct _SqlValueClass
};
GType sql_value_get_type ();
SqlObject * sql_value_new ();
SqlObject * sql_value_new_with_value (const GValue * value);
SqlExpr * sql_value_new ();
SqlExpr * sql_value_new_with_value (const GValue * value);
const GValue * sql_value_get_value (SqlValue * obj);
void sql_value_set_value (SqlValue * obj, const GValue * value);
void sql_value_set_param (SqlValue * obj, GvnParam * param);
#endif
#endif

View File

@ -20,17 +20,11 @@
#include <gvn/gvn.h>
#include "sql-object.h"
#include "sql-holder.h"
#include "sql-list.h"
#include "sql-set.h"
#include "sql-string.h"
#include "sql-stmt.h"
#include "sql-multi-stmt.h"
#include "sql-select.h"
#include "sql-select-field.h"
#include "sql-select-order.h"
#include "sql-update.h"
#include "sql-update-set.h"
#include "sql-insert.h"
#include "sql-delete.h"
#include "sql-expr.h"

View File

@ -1,10 +1,20 @@
Db cheader_filename="db/db.h"
Calc.function#property type="Db.CalcFunc"
Conn.render.object#parameter type="GLib.Object"
Iterator.params type="Db.Param"
Model.get skip=false name="get_values"
Model.set skip=false name="set_values"
Model.search skip=false
// This is to overwrite the property in a custom vala file
// Model.main_table skip
Plugin.render.object#parameter type="GLib.Object"
Iter struct
Iter.*#method skip
Row struct
Model.get skip=false
Model.set skip=false
Model.search skip=false

View File

@ -6,4 +6,4 @@ value_get_valist skip=false
Param.value_changed#method name="emit_value_changed"
//FIXME
ParamSpec struct
//ParamSpec struct

View File

@ -1 +1,8 @@
Sql cheader_filename="sql/sql.h"
Render.object type="GLib.Object"
Render.add_object.object#parameter type="GLib.Object"
Render.get_string.object#parameter type="GLib.Object"
RenderFunc.obj#parameter type="GLib.Object"
parser_parse name="parse"

View File

@ -5,4 +5,4 @@ Builder.bind_columns skip=false
Grid.append_columns skip=false
Batch.objects skip
Form.@get type="unowned GLib.Object"

View File

@ -54,6 +54,7 @@ vn_image_DATA = \
image/hedera16x16.xpm \
image/hedera32x32.xpm \
image/icon.svg \
image/icon-debug.svg \
image/logo.svg \
image/load.gif
vn_gui_DATA = \
@ -68,9 +69,9 @@ gsettings_SCHEMAS = $(top_srcdir)/vn/schema/$(PACKAGE).gschema.xml
DEFINES = \
-D_GUI_DIR=\"$(vn_guidir)\" \
-D_VN_MODULE_QUERY_DIR=\"$(module_querydir)/sql\" \
-D_VN_MODULE_LIB_DIR=\"$(module_libdir)\" \
-D_VN_MODULE_DATA_DIR=\"$(module_datadir)\" \
-D_VN_MODULE_QUERY_DIR=\"$(module_querydir)\" \
-D_HEDERA_LOCALE_DIR=\"$(datadir)/locale\" \
-D_DTD_DIR=\"$(vn_xmldir)\"

View File

@ -18,15 +18,29 @@
#include "vn-column-combo.h"
#include "../vn-model.h"
G_DEFINE_TYPE (VnColumnCombo, vn_column_combo, VN_TYPE_COLUMN);
static void vn_column_combo_model_holder_interface_init (DbModelHolderInterface * iface);
G_DEFINE_TYPE_WITH_CODE (VnColumnCombo, vn_column_combo, VN_TYPE_COLUMN,
G_IMPLEMENT_INTERFACE (DB_TYPE_MODEL_HOLDER,
vn_column_combo_model_holder_interface_init)
);
static void vn_column_combo_on_status_changed (DbModel * model,
DbModelStatus status, VnColumn * obj)
DbModelStatus status, VnColumnCombo * obj)
{
if (status == DB_MODEL_STATUS_READY)
g_object_set (obj->cell, "model", VN_COLUMN_COMBO (obj)->tree_model, NULL);
{
g_object_set (VN_COLUMN (obj)->cell, "model", obj->tree_model, NULL);
db_model_use_null_row (obj->model, VN_COLUMN (obj)->null);
}
else
g_object_set (obj->cell, "model", NULL, NULL);
g_object_set (VN_COLUMN (obj)->cell, "model", NULL, NULL);
}
static DbModel * vn_column_combo_get_model (VnColumnCombo * obj)
{
return obj->model;
}
static void vn_column_combo_set_model (VnColumnCombo * obj, DbModel * model)
@ -55,18 +69,13 @@ static void vn_column_combo_set_value (VnColumnCombo * obj, GtkTreeModel * model
{
if (obj->model && db_model_get_status (obj->model) == DB_MODEL_STATUS_READY)
{
if (gvn_value_is_null (value))
{
g_object_set_property (cell, "text", value);
}
else
{
DbIter iter;
DbIter iter;
if (db_model_search_value (obj->model, obj->index_column, &iter, value))
g_object_set_property (cell, "text",
db_model_get_value (obj->model, &iter, obj->show_column, NULL));
}
if (gvn_value_is_null (value))
g_object_set_property (cell, "text", value);
else if (db_model_search_value (obj->model, obj->index_column, &iter, value))
g_object_set_property (cell, "text",
db_model_get_value (obj->model, &iter, obj->show_column, NULL));
}
}
@ -79,31 +88,54 @@ static void vn_column_combo_restore_focus (VnColumnCombo * obj)
(gtk_tree_view_column_get_tree_view (GTK_TREE_VIEW_COLUMN (obj)));
}
/*
* Sets the value of the entry to an empty string if a null value is selected.
*/
static gchar * vn_column_combo_on_format_entry_text (GtkComboBox * combo,
gchar * path, VnColumnCombo * obj)
{
gchar * str;
GtkTreeIter iter;
gtk_tree_model_get_iter_from_string (obj->tree_model, &iter, path);
gtk_tree_model_get (obj->tree_model, &iter, obj->show_column, &str, -1);
return str ? str : g_strdup ("");
}
/*
* Sets the autocompletion functionality to the cell being edited.
*/
static void vn_column_combo_on_editing_started (GtkCellRenderer * cell,
GtkCellEditable * editable, const gchar * path, VnColumnCombo * obj)
GtkCellEditable * cell_editable, const gchar * path, VnColumnCombo * obj)
{
GtkEntry * entry;
if (!GTK_IS_COMBO_BOX (editable) || !obj->tree_model)
if (!GTK_IS_COMBO_BOX (cell_editable) || !obj->tree_model)
return;
entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (editable)));
entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (cell_editable)));
if (!obj->completion_ready)
{
gtk_entry_completion_set_model (obj->completion, obj->tree_model);
g_object_set (obj->completion, "text-column", obj->show_column, NULL);
gtk_entry_completion_set_text_column (obj->completion, obj->show_column);
obj->completion_ready = TRUE;
g_signal_connect_swapped (editable, "editing-done",
g_signal_connect_swapped (cell_editable, "editing-done",
G_CALLBACK (vn_column_combo_restore_focus), obj);
obj->editable = editable;
obj->cell_editable = cell_editable;
}
gtk_entry_set_completion (entry, obj->completion);
// Each edition uses a new cell_editable.
if (obj->cell_editable)
g_signal_handlers_disconnect_by_func (obj->cell_editable,
vn_column_combo_on_format_entry_text, obj);
g_signal_connect (cell_editable, "format-entry-text",
G_CALLBACK (vn_column_combo_on_format_entry_text), obj);
}
/*
@ -115,14 +147,23 @@ static void vn_column_combo_on_edited (GtkCellRendererText *renderer,
{
DbIter iter;
GValue value = {0};
gvn_value_new_with_content (&value, G_TYPE_STRING, new_text);
if (db_model_search_value (obj->model, obj->show_column, &iter, &value))
if (!g_strcmp0 (new_text, ""))
{
const GValue * value;
g_value_init (&value, GVN_TYPE_NULL);
VN_COLUMN_GET_CLASS (obj)->value_changed (VN_COLUMN (obj), path, &value);
}
else
{
gvn_value_new_with_content (&value, G_TYPE_STRING, new_text);
if ((value = db_model_get_value (obj->model, &iter, obj->index_column, NULL)))
VN_COLUMN_GET_CLASS (obj)->value_changed (VN_COLUMN (obj), path, value);
if (db_model_search_value (obj->model, obj->show_column, &iter, &value))
{
const GValue * val;
if ((val = db_model_get_value (obj->model, &iter, obj->index_column, NULL)))
VN_COLUMN_GET_CLASS (obj)->value_changed (VN_COLUMN (obj), path, val);
}
}
g_value_unset (&value);
@ -133,7 +174,6 @@ static void vn_column_combo_on_edited (GtkCellRendererText *renderer,
static void vn_column_combo_set_editable (VnColumnCombo * obj, gboolean editable)
{
VnColumn * parent = VN_COLUMN (obj);
g_object_set (parent->cell, "editable", editable, NULL);
if (editable)
{
@ -149,21 +189,29 @@ static void vn_column_combo_set_editable (VnColumnCombo * obj, gboolean editable
}
else
{
g_signal_handlers_disconnect_by_func (parent->cell,
vn_column_combo_on_editing_started, obj);
g_signal_handlers_disconnect_by_func (parent->cell,
vn_column_combo_on_edited, obj);
g_signal_handlers_disconnect_by_func (parent->cell,
vn_column_combo_restore_focus, obj);
g_signal_handlers_disconnect_by_data (parent->cell, obj);
if (obj->editable)
g_signal_handlers_disconnect_by_func (obj->editable,
vn_column_combo_restore_focus, obj);
if (obj->cell_editable)
g_signal_handlers_disconnect_by_data (obj->cell_editable, obj);
obj->completion = NULL;
obj->completion_ready = FALSE;
obj->editable = NULL;
obj->cell_editable = NULL;
}
g_object_set (parent->cell, "editable", editable, NULL);
}
static void vn_column_combo_set_null (VnColumnCombo * obj, gboolean null)
{
if (vn_column_get_model (VN_COLUMN (obj)) && obj->model)
db_model_use_null_row (obj->model, null);
}
static void vn_column_combo_model_changed (VnColumnCombo * obj)
{
if (obj->model)
db_model_use_null_row (obj->model, VN_COLUMN (obj)->null);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Properties
@ -173,8 +221,6 @@ enum
PROP_INDEX_COLUMN = 1
,PROP_SHOW_COLUMN
,PROP_MODEL
,PROP_CONN
,PROP_SQL
};
static void vn_column_combo_set_property (VnColumnCombo * obj, guint id,
@ -193,22 +239,6 @@ static void vn_column_combo_set_property (VnColumnCombo * obj, guint id,
case PROP_MODEL:
vn_column_combo_set_model (obj, g_value_get_object (value));
break;
case PROP_CONN:
db_model_set_conn (obj->model, g_value_get_object (value));
break;
case PROP_SQL:
{
const gchar * sql = g_value_get_string (value);
if (sql)
{
DbModel * model = db_model_new_with_sql (NULL, g_value_get_string (value));
vn_column_combo_set_model (obj, model);
g_object_unref (model);
}
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -228,9 +258,6 @@ static void vn_column_combo_get_property (VnColumnCombo * obj, guint id,
case PROP_MODEL:
g_value_set_object (value, obj->model);
break;
case PROP_CONN:
g_value_set_object (value, db_model_get_conn (obj->model));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
@ -245,7 +272,7 @@ static void vn_column_combo_init (VnColumnCombo * obj)
obj->tree_model = NULL;
obj->completion = NULL;
obj->completion_ready = FALSE;
obj->editable = NULL;
obj->cell_editable = NULL;
VN_COLUMN_GET_CLASS (obj)->set_renderer (VN_COLUMN (obj), cell);
}
@ -263,6 +290,10 @@ static void vn_column_combo_class_init (VnColumnComboClass * klass)
k->get_property = (GObjectGetPropertyFunc) vn_column_combo_get_property;
VN_COLUMN_CLASS (klass)->set_value = (VnColumnSetValueFunc) vn_column_combo_set_value;
VN_COLUMN_CLASS (klass)->set_editable = (VnColumnSetEditableFunc) vn_column_combo_set_editable;
VN_COLUMN_CLASS (klass)->set_null = (VnColumnSetNullFunc) vn_column_combo_set_null;
VN_COLUMN_CLASS (klass)->model_changed = (VnColumnModelChangedFunc) vn_column_combo_model_changed;
g_object_class_override_property (k, PROP_MODEL, "model");
g_object_class_install_property (k, PROP_INDEX_COLUMN,
g_param_spec_uint ("index-column"
@ -278,25 +309,10 @@ static void vn_column_combo_class_init (VnColumnComboClass * klass)
,0, 255, 1
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_MODEL,
g_param_spec_object ("model"
,_("Model")
,_("The model from which the combo takes the values shown in the list")
,DB_TYPE_MODEL
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_CONN,
g_param_spec_object ("conn"
,_("Connection")
,_("The connection used by the model")
,DB_TYPE_CONN
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_SQL,
g_param_spec_string ("sql"
,_("SQL")
,_("The SQL query used to create the model")
, NULL
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE
));
}
static void vn_column_combo_model_holder_interface_init (DbModelHolderInterface * iface)
{
iface->get_model = (DbModelHolderGetModelFunc) vn_column_combo_get_model;
iface->set_model = (DbModelHolderSetModelFunc) vn_column_combo_set_model;
}

View File

@ -40,7 +40,7 @@ struct _VnColumnCombo
guint show_column;
GtkEntryCompletion * completion;
gboolean completion_ready;
GtkCellEditable * editable;
GtkCellEditable * cell_editable;
};
struct _VnColumnComboClass

View File

@ -117,7 +117,7 @@ static void vn_column_image_on_download_tooltip (DbFileLoader * fl,
{
GdkPixbuf * pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
if (data->image)
if (data->image && G_IS_OBJECT (data->image))
g_object_unref (data->image);
data->image = g_object_ref_sink (gtk_image_new_from_pixbuf (pixbuf));
@ -293,7 +293,7 @@ static void vn_column_image_set_value (VnColumnImage * obj, GtkTreeModel * model
return;
}
else
else
{
gint view_x, view_y;
GdkRectangle view_rect, cell_rect;
@ -325,12 +325,14 @@ static void vn_column_image_set_value (VnColumnImage * obj, GtkTreeModel * model
obj->loader = db_file_loader_new (obj->host, obj->path);
if (obj->tooltip_path && !obj->tooltips)
{
obj->tooltips = g_hash_table_new_full
((GHashFunc) g_direct_hash, (GEqualFunc) g_direct_equal,
(GDestroyNotify) NULL, (GDestroyNotify) free_tooltip_data);
g_object_set (view, "has-tooltip", TRUE, NULL);
g_signal_connect (view, "query-tooltip",
G_CALLBACK (vn_column_image_on_query_tooltip), obj);
}
data = g_new (DownloadData, 1);
data->obj = g_object_ref (obj);
@ -344,8 +346,6 @@ static void vn_column_image_set_value (VnColumnImage * obj, GtkTreeModel * model
}
}
static void vn_column_image_set_editable (VnColumn * obj, gboolean editable){}
static void vn_column_image_on_model_changed (VnColumnImage * obj)
{
if (obj->loader)
@ -366,6 +366,8 @@ static void vn_column_image_on_model_changed (VnColumnImage * obj)
obj->tooltips = NULL;
}
static void vn_column_image_set_editable (VnColumn * obj, gboolean editable){}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Property
enum
@ -447,7 +449,7 @@ static void vn_column_image_finalize (VnColumnImage * obj)
if (obj->loader)
{
db_file_loader_cancel_all (obj->loader);
g_object_unref (obj->loader);
g_object_unref (obj->loader);//XXX
}
if (obj->loaded)

View File

@ -39,11 +39,12 @@ struct _VnColumnImage
VnColumn parent;
gchar * host;
gchar * path;
gchar * tooltip_path;
gint tooltip_size;
DbFileLoader * loader;
GHashTable * loaded;
gchar * tooltip_path;
gint tooltip_size;
GHashTable * tooltips;
};
struct _VnColumnImageClass

View File

@ -19,12 +19,95 @@
G_DEFINE_TYPE (VnColumnSpin, vn_column_spin, VN_TYPE_COLUMN);
static void vn_column_entry_cb_edited (GtkCellRendererText * cell,
const gchar * path, gchar * text, VnColumnSpin * obj)
{
GValue value = {0};
if (g_strcmp0 (text, ""))
{
g_value_init (&value, G_TYPE_STRING);
g_value_set_string (&value, text);
}
else
g_value_init (&value, GVN_TYPE_NULL);
VN_COLUMN_GET_CLASS (obj)->value_changed (VN_COLUMN (obj), path, &value);
g_value_unset (&value);
}
static void vn_column_spin_set_editable (VnColumn * obj, gboolean editable)
{
g_object_set (obj->cell, "editable", editable, NULL);
if (editable)
g_signal_connect (obj->cell, "edited",
G_CALLBACK (vn_column_entry_cb_edited), obj);
else
g_signal_handlers_disconnect_by_func (obj->cell,
vn_column_entry_cb_edited, obj);
}
static void vn_column_spin_set_value (VnColumnSpin * obj, GtkTreeModel * model,
GtkTreeIter * iter, GtkCellRenderer * cell, const GValue * value)
{
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
enum
{
PROP_CLIMB_RATE = 1
,PROP_DIGITS
,PROP_VALUE_TYPE
};
static void vn_column_spin_set_property (VnColumnSpin * obj, guint id,
const GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_CLIMB_RATE:
g_object_set (VN_COLUMN (obj)->cell,
"climb-rate", g_value_get_double (value), NULL);
break;
case PROP_DIGITS:
g_object_set (VN_COLUMN (obj)->cell,
"digits", g_value_get_uint (value), NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
static void vn_column_spin_get_property (VnColumnSpin * obj, guint id,
GValue * value, GParamSpec * pspec)
{
switch (id)
{
case PROP_CLIMB_RATE:
{
gdouble climb_rate;
g_object_get (value, "climb-rate", &climb_rate, NULL);
g_value_set_double (value, climb_rate);
break;
}
case PROP_DIGITS:
{
guint digits;
g_object_get (VN_COLUMN (obj)->cell, "digits", &digits, NULL);
g_value_set_uint (value, digits);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, id, pspec);
}
}
static void vn_column_spin_init (VnColumnSpin * obj)
{
GtkCellRenderer * cell = gtk_cell_renderer_spin_new ();
VN_COLUMN_GET_CLASS (obj)->set_renderer (VN_COLUMN (obj), cell);
//??g_object_bind_property (obj, "digits", VN_COLUMN (obj)->cell, "digits");
}
static void vn_column_spin_finalize (VnColumnSpin * obj)
@ -35,5 +118,26 @@ static void vn_column_spin_finalize (VnColumnSpin * obj)
static void vn_column_spin_class_init (VnColumnSpinClass * klass)
{
GObjectClass * k = G_OBJECT_CLASS (klass);
VnColumnClass * col_k = VN_COLUMN_CLASS (klass);
k->finalize = (GObjectFinalizeFunc) vn_column_spin_finalize;
k->set_property = (GObjectSetPropertyFunc) vn_column_spin_set_property;
k->get_property = (GObjectGetPropertyFunc) vn_column_spin_get_property;
col_k->set_value = (VnColumnSetValueFunc) vn_column_spin_set_value;
col_k->set_editable = (VnColumnSetEditableFunc) vn_column_spin_set_editable;
g_object_class_install_property (k, PROP_CLIMB_RATE,
g_param_spec_double ("climb-rate"
,_("Climb rate")
,_("The acceleration rate when you hold down a button.")
,0 ,0 ,0
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_DIGITS,
g_param_spec_uint ("digits"
,_("Digits")
,_("The number of decimal places to display.")
,0 ,20 ,0
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
));
}

View File

@ -14,6 +14,7 @@ field_include_HEADERS = \
vn-http-image.h
AM_CPPFLAGS = \
-D_IMAGE_DIR=\"$(vn_imagedir)\" \
-I$(top_srcdir) \
$(gtk_CFLAGS)
libvnfield_la_LIBADD = $(gtk_LIBS)

View File

@ -28,8 +28,14 @@
*
* A combo box widget to select from a list of items, selected from a
* database.
*/
G_DEFINE_TYPE (VnCombo, vn_combo, VN_TYPE_FIELD);
*/
static void vn_combo_model_holder_interface_init (DbModelHolderInterface * iface);
G_DEFINE_TYPE_WITH_CODE (VnCombo, vn_combo, VN_TYPE_FIELD,
G_IMPLEMENT_INTERFACE (DB_TYPE_MODEL_HOLDER,
vn_combo_model_holder_interface_init)
);
/**
* vn_combo_new:
@ -44,20 +50,6 @@ VnField * vn_combo_new (DbModel * model)
return g_object_new (VN_TYPE_COMBO, "model", model, NULL);
}
/**
* vn_combo_new_with_sql:
* @conn: the connection used to create the combo model
* @sql: the SQL query used to create the combo model
*
* Creates a new #VnCombo
*
* Return value: a #VnCombo
**/
VnField * vn_combo_new_with_sql (DbConn * conn, const gchar * sql)
{
return g_object_new (VN_TYPE_COMBO, "sql", sql, "conn", conn, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Private
static void vn_combo_cb_changed (GtkComboBox * combo, VnCombo * obj)
@ -108,37 +100,20 @@ static void vn_combo_cb_status_changed (DbModel * model, DbModelStatus status, V
{
gtk_combo_box_set_model (obj->combo, obj->tree);
vn_combo_on_model_ready (obj, vn_field_get_value (VN_FIELD (obj)));
db_model_use_null_row (model, vn_field_get_null (VN_FIELD (obj)));
}
else
gtk_combo_box_set_model (obj->combo, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
* vn_combo_set_conn:
* @obj: a #VnCombo
* @conn: the #DbConn
*
* Sets the connection used to create the combo model.
**/
void vn_combo_set_conn (VnCombo * obj, DbConn * conn)
static DbModel * vn_combo_get_model (VnCombo * obj)
{
g_return_if_fail (VN_IS_COMBO (obj));
g_return_if_fail (DB_IS_CONN (conn));
g_return_if_fail (obj->model);
db_model_set_conn (obj->model, conn);
return obj->model;
}
/**
* vn_combo_set_model:
* @obj: a #VnCombo
* @model: the #DbModel
*
* Sets the SQL query used to create the combo model.
**/
void vn_combo_set_model (VnCombo * obj, DbModel * model)
static void vn_combo_set_model (VnCombo * obj, DbModel * model)
{
g_return_if_fail (VN_IS_COMBO (obj));
g_return_if_fail (DB_IS_MODEL (model) || !model);
@ -161,6 +136,8 @@ void vn_combo_set_model (VnCombo * obj, DbModel * model)
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
* vn_combo_get_index_column:
* @obj: a #VnCombo
@ -230,8 +207,6 @@ enum
PROP_INDEX_COLUMN = 1
,PROP_SHOW_COLUMN
,PROP_MODEL
,PROP_CONN
,PROP_SQL
};
static void vn_combo_set_property (VnCombo * obj, guint property_id,
@ -248,22 +223,6 @@ static void vn_combo_set_property (VnCombo * obj, guint property_id,
case PROP_MODEL:
vn_combo_set_model (obj, g_value_get_object (value));
break;
case PROP_CONN:
vn_combo_set_conn (obj, g_value_get_object (value));
break;
case PROP_SQL:
{
const gchar * sql = g_value_get_string (value);
if (sql)
{
DbModel * model = db_model_new_with_sql (NULL, g_value_get_string (value));
vn_combo_set_model (obj, model);
g_object_unref (model);
}
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
}
@ -283,9 +242,6 @@ static void vn_combo_get_property (VnCombo * obj, guint property_id,
case PROP_MODEL:
g_value_set_object (value, obj->model);
break;
case PROP_CONN:
g_value_set_object (value, db_model_get_conn (obj->model));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, property_id, pspec);
}
@ -323,6 +279,8 @@ static void vn_combo_class_init (VnComboClass * klass)
k->get_property = (GObjectGetPropertyFunc) vn_combo_get_property;
VN_FIELD_CLASS (klass)->set_value = (VnFieldSetValueFunc) vn_combo_set_value;
g_object_class_override_property (k, PROP_MODEL, "model");
g_object_class_install_property (k, PROP_INDEX_COLUMN,
g_param_spec_uint ("index-column"
,_("Index column")
@ -337,25 +295,10 @@ static void vn_combo_class_init (VnComboClass * klass)
,0, 255, 1
,G_PARAM_CONSTRUCT | G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_MODEL,
g_param_spec_object ("model"
,_("Model")
,_("The model from which the combo takes the values shown in the list")
,DB_TYPE_MODEL
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_CONN,
g_param_spec_object ("conn"
,_("Connection")
,_("The connection used by the model")
,DB_TYPE_CONN
,G_PARAM_READWRITE
));
g_object_class_install_property (k, PROP_SQL,
g_param_spec_string ("sql"
,_("SQL")
,_("The SQL query used to create the model")
, NULL
,G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE
));
}
static void vn_combo_model_holder_interface_init (DbModelHolderInterface * iface)
{
iface->get_model = (DbModelHolderGetModelFunc) vn_combo_get_model;
iface->set_model = (DbModelHolderSetModelFunc) vn_combo_set_model;
}

View File

@ -33,6 +33,7 @@ typedef struct _VnComboClass VnComboClass;
struct _VnCombo
{
VnField parent;
/* <private> */
DbModel * model;
GtkComboBox * combo;
GtkCellRenderer * cell;
@ -49,9 +50,6 @@ struct _VnComboClass
GType vn_combo_get_type ();
VnField * vn_combo_new (DbModel * model);
VnField * vn_combo_new_with_sql (DbConn * conn, const gchar * sql);
void vn_combo_set_conn (VnCombo * obj, DbConn * conn);
void vn_combo_set_model (VnCombo * obj, DbModel * model);
guint vn_combo_get_index_column (VnCombo * obj);
void vn_combo_set_index_column (VnCombo * obj, guint column);
guint vn_combo_get_show_column (VnCombo * obj);

Some files were not shown because too many files have changed in this diff Show More