VnBuilder eliminado

This commit is contained in:
Alejandro T. Colombini Gómez 2013-10-17 18:04:08 +02:00
parent 8321089e6f
commit ffb99fccc3
10 changed files with 14 additions and 250 deletions

View File

@ -75,12 +75,6 @@ struct _DbModelPrivate
gint old_sort_column_id;
DbSortType order;
DbSortType old_order;
DbIterCompareFunc default_sort_func;
gpointer default_sort_data;
GDestroyNotify default_sort_destroy;
DbIterCompareFunc sort_func;
gpointer sort_data;
GDestroyNotify sort_destroy;
};
G_DEFINE_TYPE (DbModel, db_model, G_TYPE_OBJECT)
@ -3279,9 +3273,6 @@ static void db_model_init (DbModel *obj)
obj->priv->fresh = TRUE;
obj->priv->sort_column_id = DB_MODEL_UNSORTED_SORT_COLUMN_ID;
obj->priv->default_sort_data = NULL;
obj->priv->default_sort_func = NULL;
obj->priv->default_sort_destroy = NULL;
}
static void db_model_finalize (DbModel * obj)

View File

@ -152,21 +152,6 @@ typedef enum
}
DbSortType;
/**
* DbIterCompareFunc:
* @model: a #DbModel
* @a: a #DbIter
* @b: a #DbIter
* @user_data: (closure): user-provided data to use while comparing two #DbIter
*
* Prototype of a function used to search some in a model using
* #DbIter to iterate through it.
**/
typedef gint (*DbIterCompareFunc) (DbModel * model
,DbIter * a
,DbIter * b
,gpointer user_data);
struct _DbModel
{
GObject parent;
@ -278,15 +263,5 @@ gboolean db_model_get_sort_column_id (DbModel * obj,
void db_model_set_sort_column_id (DbModel * obj,
gint sort_column_id,
DbSortType order);
void db_model_set_sort_func (DbModel * obj,
gint sort_column_id,
DbIterCompareFunc func,
gpointer data,
GDestroyNotify destroy);
void db_model_set_default_sort_func (DbModel * obj,
DbIterCompareFunc func,
gpointer data,
GDestroyNotify destroy);
gboolean db_model_has_default_sort_func (DbModel * obj);
#endif

View File

@ -113,7 +113,7 @@
<xi:include href="xml/vn-model.xml"/>
<xi:include href="xml/vn-grid.xml"/>
<xi:include href="xml/vn-handler.xml"/>
<xi:include href="xml/vn-builder.xml"/>
<xi:include href="xml/vn-batch.xml"/>
<xi:include href="xml/vn-field.xml"/>
<xi:include href="xml/vn-column.xml"/>
</chapter>

View File

@ -1,153 +0,0 @@
/*
* Copyright (C) 2012 - 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 "vn-builder.h"
#include "vn-field.h"
#include <vn/field/field.h>
#include <vn/column/column.h>
/**
* SECTION: vn-builder
* @Short_description: functions to use with the GtkBuilder
* @Title: VnBuilder
*
* These are a set of functions that make it easy to create and bind interfaces
* to data using the #GtkBuilder and the #DbLib, part of the Hedera library.
**/
G_DEFINE_TYPE (VnBuilder, vn_builder, GTK_TYPE_BUILDER);
VnBuilder * vn_builder_new ()
{
return g_object_new (VN_TYPE_BUILDER, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Public
/**
* vn_builder_load_file:
* @obj: a #VnBuilder
* @conn: a #DbConn
* @filename: the name of the file to parse
* @err: (out) (allow-none): return location for an error, or %NULL
*
* Parses a file containing a GtkBuilder UI definition and merges it with the
* current contents of builder. Also sets de conn property of objects that use
* the #DbConn
*
* Return value: A positive value on success, 0 if an error occurred
**/
guint vn_builder_load_file (VnBuilder * obj, DbConn * conn, const gchar * filename, GError ** err)
{
guint success;
GtkBuilder * builder;
g_return_val_if_fail (VN_IS_BUILDER (obj), 0);
g_return_val_if_fail (DB_IS_CONN (conn), 0);
builder = GTK_BUILDER (obj);
success = gtk_builder_add_from_file (builder, filename, err);
if (success)
{
GSList * n;
GSList * objects = gtk_builder_get_objects (builder);
for (n = objects; n; n = n->next)
if (DB_IS_MODEL (n->data))
db_model_set_conn (n->data, conn);
g_slist_free (objects);
}
return success;
}
/**
* vn_builder_bind_fields:
* @obj: a #VnBuilder
* @iterator: where params are obtained.
* @...: pairs of column name and field id, terminated with -1
*
* Binds several iterator parameters to #VnEntry entries.
* The variable list argument should contain a string with the column name and
* a string the #VnField id.
**/
void vn_builder_bind_fields (VnBuilder * obj, DbIterator * iterator, ...)
{
va_list vl;
gchar * column;
const gchar * id;
VnField * field;
g_return_if_fail (VN_IS_BUILDER (obj));
g_return_if_fail (DB_IS_ITERATOR (iterator));
va_start (vl, iterator);
while ((column = va_arg (vl, gchar *)) != NULL)
{
id = va_arg (vl, gchar *);
field = vn_builder_get (obj, id);
if (VN_IS_FIELD (field))
vn_field_set_param (field, db_iterator_get_param (iterator, column));
else
g_warning ("VnBuilder: Object '%s' isn't a VnField!", id);
}
va_end (vl);
}
/**
* vn_builder_bind_columns:
* @obj: a #VnBuilder
* @...: pairs of column name and column id, terminated with -1
*
* Binds several model columns to #VnColumn columns.
* The variable list argument should contain a string with the column name and
* a string the #VnColumn id.
**/
void vn_builder_bind_columns (VnBuilder * obj, ...)
{
va_list vl;
gchar * column_name;
const gchar * id;
VnColumn * column;
g_return_if_fail (VN_IS_BUILDER (obj));
va_start (vl, obj);
while ((column_name = va_arg (vl, gchar *)) != NULL)
{
id = va_arg (vl, gchar *);
column = vn_builder_get (obj, id);
if (VN_IS_COLUMN (column))
vn_column_set_column_name (column, column_name);
else
g_warning ("VnBuilder: Object '%s' isn't a VnColumn!", id);
}
va_end (vl);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++ Class
static void vn_builder_init (VnBuilder * obj) {}
static void vn_builder_class_init (VnBuilderClass * k) {}

View File

@ -1,54 +0,0 @@
/*
* Copyright (C) 2012 - 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/>.
*/
#ifndef VN_BUILDER_H
#define VN_BUILDER_H
#include <db/db.h>
#include <gtk/gtk.h>
#include "vn-column.h"
#define VN_TYPE_BUILDER (vn_builder_get_type ())
#define VN_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_BUILDER, VnBuilder))
#define VN_IS_BUILDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_BUILDER))
#define VN_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, VN_TYPE_BUILDER, VnBuilderClass))
#define VN_IS_BUILDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, VN_TYPE_BUILDER))
#define VN_BUILDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, VN_TYPE_BUILDER, VnBuilderClass))
#define vn_builder_get(obj,name) ((gpointer) gtk_builder_get_object (GTK_BUILDER (obj), name))
typedef struct _VnBuilder VnBuilder;
typedef struct _VnBuilderClass VnBuilderClass;
struct _VnBuilder
{
GtkBuilder parent;
};
struct _VnBuilderClass
{
/* <private> */
GtkBuilderClass parent;
};
GType vn_builder_get_type ();
VnBuilder * vn_builder_new ();
guint vn_builder_load_file (VnBuilder * obj, DbConn * conn, const gchar * filename, GError ** err);
void vn_builder_bind_fields (VnBuilder * obj, DbIterator * iterator, ...);
void vn_builder_bind_columns (VnBuilder * obj, ...);
#endif

View File

@ -16,6 +16,7 @@
*/
#include "vn-form.h"
#include "vn-batch.h"
G_DEFINE_ABSTRACT_TYPE (VnForm, vn_form, GTK_TYPE_ALIGNMENT);
@ -34,15 +35,23 @@ void vn_form_open (VnForm * obj)
gchar * file;
GError * err = NULL;
obj->builder = GTK_BUILDER (vn_builder_new ());
obj->builder = gtk_builder_new ();
gtk_builder_set_translation_domain (obj->builder, vn_mod_get_text_domain (obj->mod));
dir = vn_mod_get_data_dir (obj->mod);
file = g_strdup_printf ("%s/%s.glade", dir, obj->name);
if (vn_builder_load_file (VN_BUILDER (obj->builder), obj->conn, file, &err))
if (gtk_builder_add_from_file (obj->builder, file, &err))
{
// Get the VnBatch "models" containing the models needing a connection
const GList * m;
VnBatch * models = VN_BATCH (gtk_builder_get_object (obj->builder, "models"));
for (m = vn_batch_get_objects (models); m; m = m->next)
db_model_set_conn (m->data, obj->conn);
gtk_builder_connect_signals (obj->builder, obj);
VN_FORM_GET_CLASS (obj)->open (obj, obj->builder, NULL);
gtk_container_add (GTK_CONTAINER (obj), vn_form_get (obj, "main"));
gtk_widget_show_all (GTK_WIDGET (obj));

View File

@ -18,8 +18,6 @@
#ifndef VN_FORM_H
#define VN_FORM_H
#include "vn-builder.h"
#define VN_TYPE_FORM (vn_form_get_type ())
#define VN_FORM(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_FORM, VnForm))
#define VN_IS_FORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_FORM))

View File

@ -18,7 +18,8 @@
#ifndef VN_GUI_H
#define VN_GUI_H
#include "vn-builder.h"
#include <gtk/gtk.h>
#include <db/db.h>
#define VN_TYPE_GUI (vn_gui_get_type ())
#define VN_GUI(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_GUI, VnGui))

View File

@ -18,8 +18,6 @@
#ifndef VN_MOD_H
#define VN_MOD_H
#include "vn-builder.h"
#define VN_TYPE_MOD (vn_mod_get_type ())
#define VN_MOD(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, VN_TYPE_MOD, VnMod))
#define VN_IS_MOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, VN_TYPE_MOD))

View File

@ -23,7 +23,6 @@
#include "vn-model.h"
#include "vn-handler.h"
#include "vn-grid.h"
#include "vn-builder.h"
#include "vn-login.h"
#include "vn-gui.h"
#include "vn-mod.h"