diff --git a/anjuta/Makefile.am b/anjuta/Makefile.am
index 344a7be..8bc7e54 100644
--- a/anjuta/Makefile.am
+++ b/anjuta/Makefile.am
@@ -9,8 +9,7 @@ template_DATA = \
hedera/anjuta.session.tpl \
hedera/AUTHORS.tpl \
hedera/configure.ac.tpl \
- hedera/Makefile.am.tpl \
- hedera/translation
+ hedera/Makefile.am.tpl
anjuta_srcdir = $(templatedir)/src
anjuta_src_DATA = \
diff --git a/anjuta/hedera/Makefile.am.tpl b/anjuta/hedera/Makefile.am.tpl
index 1b83a10..7450f69 100644
--- a/anjuta/hedera/Makefile.am.tpl
+++ b/anjuta/hedera/Makefile.am.tpl
@@ -25,7 +25,9 @@ SUBDIRS = \
translationsdir =
translations_DATA = \
- po/es.po
+ po/es.po \
+ po/POTFILES.in \
+ po/POTFILES.skip
[+ENDIF+]
EXTRA_DIST = \
README \
diff --git a/anjuta/hedera/data/mod-menu.xml.tpl b/anjuta/hedera/data/mod-menu.xml.tpl
index f0969ea..27dfca1 100644
--- a/anjuta/hedera/data/mod-menu.xml.tpl
+++ b/anjuta/hedera/data/mod-menu.xml.tpl
@@ -1,12 +1,12 @@
[+ autogen5 template +]
-
diff --git a/anjuta/hedera/translation b/anjuta/hedera/translation
deleted file mode 100755
index e4b9ac0..0000000
--- a/anjuta/hedera/translation
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-
-getopt -Q \
- -o "hua:" \
- -l "help,update,add:" \
- -n "./translation" \
- -- $@
-
-case "$1" in
- -u|--update|'')
- cd ./po
- intltool-update -r
- cd ..
- ;;
-
- -a|--add)
- arg=$2
-
- if [ -z $arg ]; then
- exit 1;
- elif [ ${#arg} -lt 2 ]; then
- echo "./translation: language codes are at least two characters long." > /dev/stderr
- exit 1;
- fi
-
- msginit -i po/*.pot -o po/$arg.po -l $arg.utf8
- echo $arg >> po/LINGUAS
- #sort po/LINGUAS -o po/LINGUAS
- ;;
-
- -h|--help)
- echo -e \
-"Translation helper script.
- Note that only the first option is used. If no option is
-passed the '\033[1m-u\033[0m' option is used by default.
- Options:
- \033[1m-u, --update\033[0m
- Update the currently existing translations and
- the translations template. Also reports the current
- status of the translations.
- \033[1m-a, --add\033[0m \033[4mlang\033[0m
- Add a new translation for the \033[4mlang\033[0m language
- (using the gettext language and country codes), the
- charset will automatically be set to UTF-8. You will
- be asked to select your e-mail from a list.
- \033[1m-h, --help\033[0m
- Print this help text and exit."
- ;;
-esac
diff --git a/db/db-model-holder.c b/db/db-model-holder.c
index f4a3c2a..599c62a 100644
--- a/db/db-model-holder.c
+++ b/db/db-model-holder.c
@@ -29,7 +29,7 @@
* db_model_holder_get_model() and db_model_holder_set_model() methods.
**/
-G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_INVALID);
+G_DEFINE_INTERFACE (DbModelHolder, db_model_holder, G_TYPE_OBJECT);
/**
* db_model_holder_get_model:
diff --git a/glade/Makefile.am b/glade/Makefile.am
index df17d6a..8263d1a 100644
--- a/glade/Makefile.am
+++ b/glade/Makefile.am
@@ -15,6 +15,7 @@ libgladevn_la_LDFLAGS = -avoid-version
libgladevn_la_SOURCES = \
glade-vn.h \
glade-vn.c \
+ glade-sql-batch.c \
glade-vn-set.c \
glade-db-model.c \
glade-db-model-editor.h \
diff --git a/glade/glade-db-model-editor.c b/glade/glade-db-model-editor.c
index 8cfbf2c..2a996c2 100644
--- a/glade/glade-db-model-editor.c
+++ b/glade/glade-db-model-editor.c
@@ -19,13 +19,22 @@
//+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeModelEditor
-static void glade_model_editor_add_list_eprop (GladeModelEditor * obj,
- GladeWidgetAdaptor * adaptor, const gchar * name, const gchar * tooltip)
+GtkWidget * glade_model_editor_new (GladeWidgetAdaptor * adaptor,
+ GladeEditable * editable)
{
GtkWidget * frame, * alignment, * vbox;
- GladeEditorProperty * eprop =
- glade_widget_adaptor_create_eprop_by_name (adaptor, name, FALSE, TRUE);
+ GladeEditorProperty * eprop;
+ GladeModelEditor * obj;
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (editable), NULL);
+
+ obj = g_object_new (GLADE_TYPE_MODEL_EDITOR,
+ "orientation", GTK_ORIENTATION_VERTICAL, NULL);
+ obj->base = GTK_WIDGET (editable);
+ gtk_box_pack_start (GTK_BOX (obj), GTK_WIDGET (editable), TRUE, TRUE, 0);
+
+ eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "links", FALSE, TRUE);
obj->props = g_list_prepend (obj->props, eprop);
frame = gtk_frame_new (NULL);
@@ -42,27 +51,7 @@ static void glade_model_editor_add_list_eprop (GladeModelEditor * obj,
gtk_container_add (GTK_CONTAINER (alignment), vbox);
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
- gtk_widget_set_tooltip_text (vbox, tooltip);
-}
-
-GtkWidget * glade_model_editor_new (GladeWidgetAdaptor * adaptor,
- GladeEditable * editable)
-{
- GladeModelEditor * obj;
-
- g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
- g_return_val_if_fail (GLADE_IS_EDITABLE (editable), NULL);
-
- obj = g_object_new (GLADE_TYPE_MODEL_EDITOR,
- "orientation", GTK_ORIENTATION_VERTICAL, NULL);
- obj->base = GTK_WIDGET (editable);
- gtk_box_pack_start (GTK_BOX (obj), GTK_WIDGET (editable), TRUE, TRUE, 0);
-
- glade_model_editor_add_list_eprop (obj, adaptor, "links",
- _("List of parameters linked to the model"));
-
- glade_model_editor_add_list_eprop (obj, adaptor, "batch",
- _("List of SqlHolders and identifiers"));
+ gtk_widget_set_tooltip_text (vbox, _("List of parameters linked to the model"));
gtk_widget_show_all (GTK_WIDGET (obj));
return GTK_WIDGET (obj);
@@ -112,6 +101,8 @@ static void glade_model_editor_class_init (GladeModelEditorClass * k)
static void glade_model_editor_init (GladeModelEditor * obj)
{
+ obj->props = NULL;
+ obj->base = NULL;
}
static void glade_model_editor_editable_init (GladeEditableIface * iface)
@@ -122,26 +113,3 @@ static void glade_model_editor_editable_init (GladeEditableIface * iface)
G_DEFINE_TYPE_WITH_CODE (GladeModelEditor, glade_model_editor, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_model_editor_editable_init));
-
-//+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeDbList
-
-G_DEFINE_BOXED_TYPE (GladeDbList, glade_db_list, glade_db_list_copy, glade_db_list_free);
-
-void glade_db_list_free (GladeDbList * list)
-{
- if (!list)
- return;
-
- if (list->list)
- g_object_unref (list->list);
-
- g_free (list);
- list = NULL;
-}
-
-GladeDbList * glade_db_list_copy (const GladeDbList * list)
-{
- GladeDbList * l = g_new (GladeDbList, 1);
- l->list = list->list ? g_object_ref (list->list) : NULL;
- return l;
-}
diff --git a/glade/glade-db-model-editor.h b/glade/glade-db-model-editor.h
index 07809e9..44c3cc0 100644
--- a/glade/glade-db-model-editor.h
+++ b/glade/glade-db-model-editor.h
@@ -47,17 +47,4 @@ GType glade_model_editor_get_type (void) G_GNUC_CONST;
GtkWidget * glade_model_editor_new (GladeWidgetAdaptor * adaptor,
GladeEditable * editable);
-#define GLADE_TYPE_DB_LIST (glade_db_list_get_type())
-
-typedef struct _GladeDbList GladeDbList;
-
-struct _GladeDbList
-{
- GtkListStore * list;
-};
-
-GType glade_db_list_get_type (void) G_GNUC_CONST;
-void glade_db_list_free (GladeDbList * list);
-GladeDbList * glade_db_list_copy (const GladeDbList * list);
-
#endif
diff --git a/glade/glade-db-model.c b/glade/glade-db-model.c
index 2a2648c..e45194a 100644
--- a/glade/glade-db-model.c
+++ b/glade/glade-db-model.c
@@ -46,6 +46,8 @@ typedef struct
GtkWidget * entry;
gint width;
gint height;
+ gint x;
+ gint y;
}
GladeEPropSql;
@@ -57,18 +59,87 @@ GLADE_MAKE_EPROP (GladeEPropSql, glade_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))
+typedef struct
+{
+ GladeEditorProperty * eprop;
+ GtkTextBuffer * buffer;
+}
+SqlEditorData;
+
+void glade_eprop_sql_set_text_from_buffer (GladeEditorProperty * eprop, GtkTextBuffer * buffer)
+{
+ gchar * sql;
+ GValue val = G_VALUE_INIT;
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ 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);
+}
+
+static gboolean glade_eprop_sql_editor_save (GladeEditorProperty * eprop,
+ GtkTextBuffer * buffer)
+{
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ GladeWidget * widget = glade_property_get_widget (p);
+ GladeProject * project = glade_widget_get_project (widget);
+ const gchar * path = glade_project_get_path (project);
+
+ glade_eprop_sql_set_text_from_buffer (eprop, buffer);
+
+ if (!path)
+ {
+ GtkWidget * dialog = glade_util_file_dialog_new (_("Save as...")
+ ,project
+ ,GTK_WINDOW (glade_app_get_window ())
+ ,GLADE_FILE_DIALOG_ACTION_SAVE);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+ path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
+
+ gtk_widget_destroy (dialog);
+ }
+
+ return path ? glade_project_save (project, path, NULL) : FALSE;
+}
+
+static void glade_eprop_sql_on_editor_save_clicked (GtkToolButton * button,
+ SqlEditorData * data)
+{
+ glade_eprop_sql_editor_save (data->eprop, data->buffer);
+}
+
+static gboolean glade_eprop_sql_on_editor_key_pressed (GtkWidget * widget,
+ GdkEventKey * event, SqlEditorData * data)
+{
+ if (event->state & GDK_CONTROL_MASK
+ && (event->keyval == GDK_KEY_S || event->keyval == GDK_KEY_s))
+ return glade_eprop_sql_editor_save (data->eprop, data->buffer);
+ return FALSE;
+}
+
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;
+ GtkWidget * dialog_area, * scroll, * toolbar, * item;
+ GtkStyleContext * context;
+ SqlEditorData * data;
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
+ ,NULL
+ ,GTK_DIALOG_DESTROY_WITH_PARENT
,_("OK"), GTK_RESPONSE_OK
,_("Clear"), GTK_RESPONSE_REJECT
,_("Cancel"), GTK_RESPONSE_CANCEL
@@ -78,15 +149,19 @@ static void glade_eprop_sql_show_dialog (GtkButton * button, GladeEditorProperty
gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
gtk_window_set_default_size (GTK_WINDOW (dialog), obj->width, obj->height);
+ if (obj->x && obj->y)
+ gtk_window_move (GTK_WINDOW (dialog), obj->x, obj->y);
+
+ dialog_area = gtk_dialog_get_content_area (dialog);
+ gtk_widget_set_margin_top (dialog_area, 6);
+ gtk_widget_set_margin_bottom (dialog_area, 6);
+ gtk_widget_set_margin_start (dialog_area, 6);
+ gtk_widget_set_margin_end (dialog_area, 6);
+
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_bottom (scroll, 6);
- gtk_widget_set_margin_start (scroll, 6);
- gtk_widget_set_margin_end (scroll, 6);
- gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (dialog)),
- scroll, TRUE, TRUE, 6);
+ gtk_box_pack_start (GTK_BOX (dialog_area), scroll, TRUE, TRUE, 0);
#ifdef _HAVE_GTKSOURCEVIEW
GtkSourceLanguageManager * lm = gtk_source_language_manager_new ();
@@ -111,25 +186,38 @@ static void glade_eprop_sql_show_dialog (GtkButton * button, GladeEditorProperty
gtk_text_buffer_set_text (buffer, sql, -1);
gtk_container_add (GTK_CONTAINER (scroll), text);
- gtk_widget_show_all (scroll);
+
+ data = g_new (SqlEditorData, 1);
+ data->eprop = eprop;
+ data->buffer = buffer;
+
+ g_signal_connect (dialog, "key-press-event",
+ G_CALLBACK (glade_eprop_sql_on_editor_key_pressed), data);
+
+ toolbar = gtk_toolbar_new ();
+ gtk_box_pack_start (GTK_BOX (dialog_area), toolbar, FALSE, TRUE, 0);
+
+ item = GTK_WIDGET (g_object_new (GTK_TYPE_TOOL_BUTTON,
+ "icon-widget", gtk_image_new_from_icon_name
+ ("document-save-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR), NULL));
+ gtk_widget_set_tooltip_text (item, _("Save project"));
+ g_signal_connect (item, "clicked",
+ G_CALLBACK (glade_eprop_sql_on_editor_save_clicked), data);
+ gtk_container_add (GTK_CONTAINER (toolbar), item);
+
+ context = gtk_widget_get_style_context (scroll);
+ gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
+ context = gtk_widget_get_style_context (toolbar);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_INLINE_TOOLBAR);
+ gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
+
+ gtk_widget_show_all (dialog_area);
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);
+ glade_eprop_sql_set_text_from_buffer (eprop, buffer);
break;
}
case GTK_RESPONSE_REJECT:
@@ -148,7 +236,9 @@ static void glade_eprop_sql_show_dialog (GtkButton * button, GladeEditorProperty
obj->width = gtk_widget_get_allocated_width (GTK_WIDGET (dialog));
obj->height = gtk_widget_get_allocated_height (GTK_WIDGET (dialog));
+ gtk_window_get_position (GTK_WINDOW (dialog), &obj->x, &obj->y);
gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_free (data);
}
static void glade_eprop_sql_entry_text_changed (GtkEntry * entry,
@@ -186,8 +276,10 @@ static GtkWidget * glade_eprop_sql_create_input (GladeEditorProperty * eprop)
gtk_widget_show_all (box);
- obj->width = 750;
- obj->height = 550;
+ obj->width = 930;
+ obj->height = 730;
+ obj->x = 0;
+ obj->y = 0;
return box;
}
@@ -215,7 +307,8 @@ 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);
}
-//++++++++++++++++++++++++++++ Structure and prototypes for Links and Batch
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++ Links Editor Property
typedef struct
{
@@ -224,19 +317,7 @@ typedef struct
GtkTreeView * view;
gchar * path;
}
-GladeListEProp;
-
-void param_col_cell_data (GtkTreeViewColumn * view, GtkCellRenderer * cell,
- GtkTreeModel * model, GtkTreeIter * iter, gpointer data);
-static void glade_list_eprop_add_param_column (GladeListEProp * obj);
-static void glade_list_eporp_on_string_col_edited (GtkCellRendererText * cell,
- gchar * path, const gchar * text, GladeEditorProperty * eprop);
-static void glade_list_eprop_create_input (GladeListEProp * obj, GtkWidget * box,
- gchar * string);
-
-//+++++++++++++++++++++++++++++++++++++++++++++++++++ Links Editor Property
-
-typedef GladeListEProp GladeEPropLinks;
+GladeEPropLinks;
GLADE_MAKE_EPROP (GladeEPropLinks, glade_eprop_links)
#define GLADE_TYPE_EPROP_LINKS (glade_eprop_links_get_type ())
@@ -248,171 +329,66 @@ GLADE_MAKE_EPROP (GladeEPropLinks, glade_eprop_links)
enum
{
- LINKS_FIELD_COL
- ,LINKS_PARAM_COL
- ,LINKS_LINKED_COL
- ,LINKS_N_COLS
+ FIELD_COL
+ ,PARAM_COL
+ ,LINKED_COL
+ ,N_COLS
};
-static void linked_col_cell_data (GtkTreeViewColumn * view, GtkCellRenderer * cell,
- GtkTreeModel * model, GtkTreeIter * iter, gpointer data)
+static void glade_eprop_links_on_param_col_clicked (GtkEntry * entry,
+ GtkEntryIconPosition icon_pos, GdkEvent * event, GladeEditorProperty * eprop)
{
- gboolean val;
- gtk_tree_model_get (model, iter, LINKS_LINKED_COL, &val, -1);
- gtk_cell_renderer_toggle_set_active (GTK_CELL_RENDERER_TOGGLE (cell), val);
-}
-
-static void glade_eprop_links_on_linked_col_toggled (GtkCellRendererToggle * cell,
- gchar * path, GladeEditorProperty * eprop)
-{
- gboolean val;
GtkTreeIter iter;
GladeProperty * p = glade_editor_property_get_property (eprop);
- GladeDbList * list = g_value_get_boxed (glade_property_inline_value (p));
- GtkListStore * store = list->list;
+ GladeWidget * widget = glade_property_get_widget (p);
+ GladeProject * project = glade_widget_get_project (widget);
+ GtkListStore * store = ((GladeVnList *) g_value_get_boxed (glade_property_inline_value (p)))->list;
+ gchar * path = GLADE_EPROP_LINKS (eprop)->path;
if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
return;
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, LINKS_LINKED_COL, &val, -1);
- gtk_list_store_set (store, &iter, LINKS_LINKED_COL, !val, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, PARAM_COL, &widget, -1);
+
+ if (glade_editor_property_show_object_dialog (project,
+ _("Select a GvnParam"), NULL, GVN_TYPE_PARAM, NULL, &widget))
+ {
+ if (widget)
+ gtk_list_store_set (store, &iter, PARAM_COL, widget, -1);
+ else
+ gtk_list_store_set (store, &iter, PARAM_COL, NULL, -1);
+ }
}
-static GtkWidget * glade_eprop_links_create_input (GladeEditorProperty * eprop)
+static gboolean glade_eprop_links_on_param_key_pressed (GtkEntry * entry,
+ GdkEventKey * event, GladeEditorProperty * eprop)
{
- GtkCellRenderer * cell;
- GtkTreeViewColumn * column;
- GladeEPropLinks * obj = GLADE_EPROP_LINKS (eprop);
- GtkWidget * box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+ if (event->keyval == GDK_KEY_Return)
+ {
+ glade_eprop_links_on_param_col_clicked (entry, 0, NULL, eprop);
+ return TRUE;
+ }
+ else if (event->keyval == GDK_KEY_Delete)
+ {
+ GtkTreeIter iter;
+ gchar * path = GLADE_EPROP_LINKS (eprop)->path;
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ GtkListStore * store = ((GladeVnList *) g_value_get_boxed (glade_property_inline_value (p)))->list;
- glade_list_eprop_create_input ((GladeListEProp *) obj, box,
- _("Add or remove links"));
-
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell, "editable", TRUE, NULL);
- column = gtk_tree_view_column_new_with_attributes (_("Column"), cell,
- "text", LINKS_FIELD_COL, NULL);
- gtk_tree_view_column_set_expand (column, TRUE);
- g_signal_connect (cell, "edited",
- G_CALLBACK (glade_list_eporp_on_string_col_edited), obj);
- gtk_tree_view_append_column (obj->view, column);
-
- glade_list_eprop_add_param_column (obj);
-
- cell = gtk_cell_renderer_toggle_new ();
- column = gtk_tree_view_column_new_with_attributes (C_("Verb", "Link"), cell, NULL);
- gtk_tree_view_column_set_cell_data_func (column, cell, linked_col_cell_data, obj, NULL);
- g_signal_connect (cell, "toggled",
- G_CALLBACK (glade_eprop_links_on_linked_col_toggled), obj);
- gtk_tree_view_append_column (obj->view, column);
-
- g_object_set (G_OBJECT (box), "height-request", 200, NULL);
- gtk_widget_show_all (box);
- return box;
+ if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
+ {
+ gtk_list_store_set (store, &iter, PARAM_COL, NULL, -1);
+ return TRUE;
+ }
+ }
+ return FALSE;
}
-static void glade_eprop_links_finalize (GObject * object)
-{
- GladeEPropLinks * obj = GLADE_EPROP_LINKS (object);
- GObjectClass * parent = g_type_class_peek_parent (GLADE_EPROP_LINKS_GET_CLASS (obj));
- parent->finalize (G_OBJECT (obj));
-}
-
-static void glade_eprop_links_load (GladeEditorProperty * eprop, GladeProperty * property)
-{
- GladeDbList * list;
- GladeEPropLinks * obj = GLADE_EPROP_LINKS (eprop);
- GladeEditorPropertyClass * parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- parent_class->load (eprop, property);
-
- if (!property)
- return;
-
- if ((list = g_value_get_boxed (glade_property_inline_value (property))))
- gtk_tree_view_set_model (obj->view, GTK_TREE_MODEL (list->list));
- else
- gtk_tree_view_set_model (obj->view, NULL);
-}
-
-//+++++++++++++++++++++++++++++++++++++++++++++++++++ Batch Editor Property
-
-typedef GladeListEProp GladeEPropBatch;
-
-enum
-{
- BATCH_ID_COL
- ,BATCH_PARAM_COL
- ,BATCH_N_COLS
-};
-
-GLADE_MAKE_EPROP (GladeEPropBatch, glade_eprop_batch)
-#define GLADE_TYPE_EPROP_BATCH (glade_eprop_batch_get_type ())
-#define GLADE_EPROP_BATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EPROP_BATCH, GladeEPropBatch))
-#define GLADE_EPROP_BATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EPROP_BATCH, GladeEPropBatchClass))
-#define GLADE_IS_EPROP_BATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_BATCH))
-#define GLADE_IS_EPROP_BATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_BATCH))
-#define GLADE_EPROP_BATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_EPROP_BATCH, GladeEPropBatchClass))
-
-static GtkWidget * glade_eprop_batch_create_input (GladeEditorProperty * eprop)
-{
- GtkCellRenderer * cell;
- GtkTreeViewColumn * column;
- GladeEPropBatch * obj = GLADE_EPROP_BATCH (eprop);
- GtkWidget * box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
-
- glade_list_eprop_create_input ((GladeListEProp *) obj, box,
- _("Add or remove holders"));
-
- cell = gtk_cell_renderer_text_new ();
- g_object_set (cell, "editable", TRUE, NULL);
- column = gtk_tree_view_column_new_with_attributes (_("Identifier"), cell,
- "text", BATCH_ID_COL, NULL);
- gtk_tree_view_column_set_expand (column, TRUE);
- g_signal_connect (cell, "edited",
- G_CALLBACK (glade_list_eporp_on_string_col_edited), obj);
- gtk_tree_view_append_column (obj->view, column);
-
- glade_list_eprop_add_param_column (obj);
-
- g_object_set (G_OBJECT (box), "height-request", 200, NULL);
- gtk_widget_show_all (box);
- return box;
-}
-
-void glade_eprop_batch_finalize (GObject * object)
-{
- GladeEPropBatch * obj = GLADE_EPROP_BATCH (object);
- GObjectClass * parent = g_type_class_peek_parent (GLADE_EPROP_BATCH_GET_CLASS (obj));
- parent->finalize (G_OBJECT (obj));
-}
-
-static void glade_eprop_batch_load (GladeEditorProperty * eprop, GladeProperty * property)
-{
- GladeDbList * list;
- GladeEPropBatch * obj = GLADE_EPROP_BATCH (eprop);
- GladeEditorPropertyClass * parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- parent_class->load (eprop, property);
-
- if (!property)
- return;
-
- if ((list = g_value_get_boxed (glade_property_inline_value (property))))
- gtk_tree_view_set_model (obj->view, GTK_TREE_MODEL (list->list));
- else
- gtk_tree_view_set_model (obj->view, NULL);
-}
-
-//+++++++++++++++++++++++++++++++++++++++ Methods common to Links and Batch
-
-void param_col_cell_data (GtkTreeViewColumn * view, GtkCellRenderer * cell,
+static void param_col_cell_data (GtkTreeViewColumn * view, GtkCellRenderer * cell,
GtkTreeModel * model, GtkTreeIter * iter, gpointer data)
{
GladeWidget * param;
- gint col = GLADE_IS_EPROP_LINKS (data) ? LINKS_PARAM_COL : BATCH_PARAM_COL;
-
- gtk_tree_model_get (model, iter, col, ¶m, -1);
+ gtk_tree_model_get (model, iter, PARAM_COL, ¶m, -1);
if (param)
g_object_set (cell, "text", glade_widget_get_name (param), NULL);
@@ -420,61 +396,10 @@ void param_col_cell_data (GtkTreeViewColumn * view, GtkCellRenderer * cell,
g_object_set (cell, "text", "", NULL);
}
-static void glade_list_eprop_on_param_col_clicked (GtkEntry * entry,
- GtkEntryIconPosition icon_pos, GdkEvent * event, GladeEditorProperty * eprop)
-{
- GtkTreeIter iter;
- GladeProperty * p = glade_editor_property_get_property (eprop);
- GladeWidget * widget = glade_property_get_widget (p);
- GladeProject * project = glade_widget_get_project (widget);
- GtkListStore * store = ((GladeDbList *) g_value_get_boxed (glade_property_inline_value (p)))->list;
- gchar * path = ((GladeListEProp *) eprop)->path;
- gint col = GLADE_IS_EPROP_LINKS (eprop) ? LINKS_PARAM_COL : BATCH_PARAM_COL;
-
- if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
- return;
-
- gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, col, &widget, -1);
-
- if (glade_editor_property_show_object_dialog (project,
- _("Select a GvnParam"), NULL, GVN_TYPE_PARAM, NULL, &widget))
- {
- if (widget)
- gtk_list_store_set (store, &iter, col, widget, -1);
- else
- gtk_list_store_set (store, &iter, col, NULL, -1);
- }
-}
-
-static gboolean glade_list_eprop_on_param_key_pressed (GtkEntry * entry,
- GdkEventKey * event, GladeEditorProperty * eprop)
-{
- if (event->keyval == GDK_KEY_Return)
- {
- glade_list_eprop_on_param_col_clicked (entry, 0, NULL, eprop);
- return TRUE;
- }
- else if (event->keyval == GDK_KEY_Delete)
- {
- GtkTreeIter iter;
- gchar * path = ((GladeListEProp *) eprop)->path;
- GladeProperty * p = glade_editor_property_get_property (eprop);
- GtkListStore * store = ((GladeDbList *) g_value_get_boxed (glade_property_inline_value (p)))->list;
-
- if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
- {
- gint col = GLADE_IS_EPROP_LINKS (eprop) ? LINKS_PARAM_COL : BATCH_PARAM_COL;
- gtk_list_store_set (store, &iter, col, NULL, -1);
- return TRUE;
- }
- }
- return FALSE;
-}
-
-static void glade_list_eporp_on_param_col_editing_started (GtkCellRendererText * cell,
+static void glade_eporp_links_on_param_col_editing_started (GtkCellRendererText * cell,
GtkEntry * entry, gchar * path, GladeEditorProperty * eprop)
{
- GladeListEProp * obj = (GladeListEProp *) eprop;
+ GladeEPropLinks * obj = GLADE_EPROP_LINKS (eprop);
if (GTK_IS_ENTRY (entry))
{
@@ -503,9 +428,9 @@ static void glade_list_eporp_on_param_col_editing_started (GtkCellRendererText *
obj->path = g_strdup (path);
g_signal_connect (entry, "icon-press",
- G_CALLBACK (glade_list_eprop_on_param_col_clicked), eprop);
+ G_CALLBACK (glade_eprop_links_on_param_col_clicked), eprop);
g_signal_connect (entry, "key-press-event",
- G_CALLBACK (glade_list_eprop_on_param_key_pressed), eprop);
+ G_CALLBACK (glade_eprop_links_on_param_key_pressed), eprop);
}
else
{
@@ -522,32 +447,42 @@ static void glade_list_eporp_on_param_col_editing_started (GtkCellRendererText *
}
}
-static void glade_list_eprop_add_param_column (GladeListEProp * obj)
-{
- GtkTreeViewColumn * column;
- GtkCellRenderer * cell = gtk_cell_renderer_text_new ();
- g_object_set (cell, "editable", TRUE, NULL);
- column = gtk_tree_view_column_new_with_attributes (_("Param"), cell, NULL);
- gtk_tree_view_column_set_cell_data_func (column, cell, param_col_cell_data, obj, NULL);
- gtk_tree_view_column_set_expand (column, TRUE);
- g_signal_connect (cell, "editing-started",
- G_CALLBACK (glade_list_eporp_on_param_col_editing_started), obj);
- gtk_tree_view_append_column (obj->view, column);
-}
-
-static void glade_list_eporp_on_string_col_edited (GtkCellRendererText * cell,
+static void glade_eporp_links_on_field_col_edited (GtkCellRendererText * cell,
gchar * path, const gchar * text, GladeEditorProperty * eprop)
{
GtkTreeIter iter;
- gint col = GLADE_IS_EPROP_LINKS (eprop) ? LINKS_FIELD_COL : BATCH_ID_COL;
GladeProperty * p = glade_editor_property_get_property (eprop);
- GladeDbList * list = g_value_get_boxed (glade_property_inline_value (p));
- GtkListStore * store = list->list;
+ GladeVnList * list = g_value_get_boxed (glade_property_inline_value (p));
+ GtkListStore * store = list->list;
if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
return;
- gtk_list_store_set (store, &iter, col, text, -1);
+ gtk_list_store_set (store, &iter, FIELD_COL, text, -1);
+}
+
+static void linked_col_cell_data (GtkTreeViewColumn * view, GtkCellRenderer * cell,
+ GtkTreeModel * model, GtkTreeIter * iter, gpointer data)
+{
+ gboolean val;
+ gtk_tree_model_get (model, iter, LINKED_COL, &val, -1);
+ gtk_cell_renderer_toggle_set_active (GTK_CELL_RENDERER_TOGGLE (cell), val);
+}
+
+static void glade_eprop_links_on_linked_col_toggled (GtkCellRendererToggle * cell,
+ gchar * path, GladeEditorProperty * eprop)
+{
+ gboolean val;
+ GtkTreeIter iter;
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ GladeVnList * list = g_value_get_boxed (glade_property_inline_value (p));
+ GtkListStore * store = list->list;
+
+ if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, LINKED_COL, &val, -1);
+ gtk_list_store_set (store, &iter, LINKED_COL, !val, -1);
}
static void glade_widget_on_remove_widget (GladeProject * project,
@@ -561,36 +496,30 @@ static void glade_widget_on_remove_widget (GladeProject * project,
if (gtk_tree_model_get_iter_first (m, &iter))
do
{
- gint col = 1; // XXX LINKS_PARAM_COL and BATCH_PARAM_COL
GladeWidget * param;
- gtk_tree_model_get (m, &iter, col, ¶m, -1);
+ gtk_tree_model_get (m, &iter, PARAM_COL, ¶m, -1);
if (param == widget)
- gtk_list_store_set (store, &iter, col, NULL, -1);
+ gtk_list_store_set (store, &iter, PARAM_COL, NULL, -1);
}
while (gtk_tree_model_iter_next (m, &iter));
}
}
-static void glade_list_eprop_on_add_clicked (GtkButton * button, GladeListEProp * obj)
+static void glade_eporp_links_on_add_clicked (GtkButton * button,
+ GladeEPropLinks * obj)
{
GtkTreeIter iter;
GtkTreePath * path;
- GladeDbList * list;
+ GladeVnList * list;
GtkListStore * store;
GladeProperty * p = glade_editor_property_get_property (GLADE_EDITOR_PROPERTY (obj));
if (!(list = g_value_get_boxed (glade_property_inline_value (p))))
- {
- list = g_new (GladeDbList, 1);
-
- if (GLADE_IS_EPROP_LINKS (obj))
- list->list = gtk_list_store_new (LINKS_N_COLS,
- G_TYPE_STRING, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN);
- else
- list->list = gtk_list_store_new (BATCH_N_COLS,
- G_TYPE_STRING, GLADE_TYPE_WIDGET);
-
+ {
+ list = g_new (GladeVnList, 1);
+ list->list = gtk_list_store_new (N_COLS,
+ G_TYPE_STRING, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN);
glade_property_set (p, list);
g_signal_connect (glade_widget_get_project (glade_property_get_widget (p)),
@@ -610,8 +539,8 @@ static void glade_list_eprop_on_add_clicked (GtkButton * button, GladeListEProp
gtk_tree_path_free (path);
}
-static void glade_list_eprop_on_remove_clicked (GtkButton * button,
- GladeListEProp * obj)
+static void glade_eporp_links_on_remove_clicked (GtkButton * button,
+ GladeEPropLinks * obj)
{
GtkTreeIter iter;
GtkListStore * store;
@@ -635,31 +564,34 @@ static void glade_list_eprop_on_remove_clicked (GtkButton * button,
}
}
-static gboolean glade_list_eprop_on_view_key_press (GtkWidget * treeview,
- GdkEventKey * event, GladeListEProp * obj)
+static gboolean glade_eprop_links_on_view_key_press (GtkWidget * treeview,
+ GdkEventKey * event, GladeEPropLinks * obj)
{
if (event->keyval == GDK_KEY_Delete)
{
- glade_list_eprop_on_remove_clicked (NULL, obj);
+ glade_eporp_links_on_remove_clicked (NULL, obj);
return TRUE;
}
else if ((event->state & GDK_CONTROL_MASK) != 0
&& (event->keyval == GDK_KEY_n || event->keyval == GDK_KEY_N))
{
- glade_list_eprop_on_add_clicked (NULL, obj);
+ glade_eporp_links_on_add_clicked (NULL, obj);
return TRUE;
}
return FALSE;
}
-static void glade_list_eprop_create_input (GladeListEProp * obj, GtkWidget * box,
- gchar * string)
+static GtkWidget * glade_eprop_links_create_input (GladeEditorProperty * eprop)
{
+ GtkCellRenderer * cell;
+ GtkTreeViewColumn * column;
+ GladeEPropLinks * obj = GLADE_EPROP_LINKS (eprop);
GtkWidget * scroll, * button, * label,
- * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
+ * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4),
+ * box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
- label = gtk_label_new (string);
+ label = gtk_label_new (_("Add or remove links"));
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_misc_set_padding (GTK_MISC (label), 2, 4);
@@ -668,13 +600,15 @@ static void glade_list_eprop_create_input (GladeListEProp * obj, GtkWidget * box
button = gtk_button_new ();
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON));
- g_signal_connect (button, "clicked", G_CALLBACK (glade_list_eprop_on_add_clicked), obj);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_eporp_links_on_add_clicked), obj);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
button = gtk_button_new ();
gtk_button_set_image (GTK_BUTTON (button),
gtk_image_new_from_icon_name ("list-remove-symbolic", GTK_ICON_SIZE_BUTTON));
- g_signal_connect (button, "clicked", G_CALLBACK (glade_list_eprop_on_remove_clicked), obj);
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_eporp_links_on_remove_clicked), obj);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
@@ -683,12 +617,66 @@ static void glade_list_eprop_create_input (GladeListEProp * obj, GtkWidget * box
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
- g_object_set (G_OBJECT (scroll), "height-request", 50, NULL);
gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
obj->view = GTK_TREE_VIEW (gtk_tree_view_new ());
- g_signal_connect (obj->view, "key-press-event", G_CALLBACK (glade_list_eprop_on_view_key_press), obj);
+ g_signal_connect (obj->view, "key-press-event",
+ G_CALLBACK (glade_eprop_links_on_view_key_press), obj);
gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (obj->view));
+
+ cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell, "editable", TRUE, NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Column"), cell,
+ "text", FIELD_COL, NULL);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ g_signal_connect (cell, "edited",
+ G_CALLBACK (glade_eporp_links_on_field_col_edited), obj);
+ gtk_tree_view_append_column (obj->view, column);
+
+ cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell, "editable", TRUE, NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Param"), cell, NULL);
+ gtk_tree_view_column_set_cell_data_func (column, cell, param_col_cell_data, obj, NULL);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ g_signal_connect (cell, "editing-started",
+ G_CALLBACK (glade_eporp_links_on_param_col_editing_started), obj);
+ gtk_tree_view_append_column (obj->view, column);
+
+ cell = gtk_cell_renderer_toggle_new ();
+ column = gtk_tree_view_column_new_with_attributes (C_("Verb", "Link"), cell, NULL);
+ gtk_tree_view_column_set_cell_data_func (column, cell, linked_col_cell_data, obj, NULL);
+ g_signal_connect (cell, "toggled",
+ G_CALLBACK (glade_eprop_links_on_linked_col_toggled), obj);
+ gtk_tree_view_append_column (obj->view, column);
+
+ g_object_set (G_OBJECT (box), "height-request", 200, NULL);
+ gtk_widget_show_all (box);
+ return box;
+}
+
+static void glade_eprop_links_finalize (GObject * object)
+{
+ GladeEPropLinks * obj = GLADE_EPROP_LINKS (object);
+ GObjectClass * parent =
+ g_type_class_peek_parent (GLADE_EPROP_LINKS_GET_CLASS (obj));
+ parent->finalize (G_OBJECT (obj));
+}
+
+static void glade_eprop_links_load (GladeEditorProperty * eprop, GladeProperty * property)
+{
+ GladeVnList * list;
+ GladeEPropLinks * obj = GLADE_EPROP_LINKS (eprop);
+ GladeEditorPropertyClass * parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ parent_class->load (eprop, property);
+
+ if (!property)
+ return;
+
+ if ((list = g_value_get_boxed (glade_property_inline_value (property))))
+ gtk_tree_view_set_model (obj->view, GTK_TREE_MODEL (list->list));
+ else
+ gtk_tree_view_set_model (obj->view, NULL);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++ DbModel Widget Adaptor
@@ -707,10 +695,6 @@ GladeEditorProperty * glade_db_model_create_eprop (GladeWidgetAdaptor * adaptor,
eprop = g_object_new (GLADE_TYPE_EPROP_LINKS,
"property-class", klass,
"use-command", use_command, NULL);
- else if (!g_strcmp0 (prop_id, "batch"))
- eprop = g_object_new (GLADE_TYPE_EPROP_BATCH,
- "property-class", klass,
- "use-command", use_command, NULL);
else
eprop = GWA_GET_CLASS (G_TYPE_OBJECT)->create_eprop (adaptor,
klass, use_command);
@@ -735,7 +719,7 @@ void glade_db_model_write_widget (GladeWidgetAdaptor * adaptor,
{
GtkTreeIter iter;
GtkTreeModel * m;
- GladeDbList * l;
+ GladeVnList * l;
GladeProperty * prop;
if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
@@ -770,9 +754,9 @@ void glade_db_model_write_widget (GladeWidgetAdaptor * adaptor,
GladeXmlNode * link_node;
gtk_tree_model_get (m, &iter
- ,LINKS_FIELD_COL, &field
- ,LINKS_PARAM_COL, ¶m
- ,LINKS_LINKED_COL, &linked
+ ,FIELD_COL, &field
+ ,PARAM_COL, ¶m
+ ,LINKED_COL, &linked
, -1);
link_node = glade_xml_node_new (context, "link");
@@ -793,48 +777,6 @@ void glade_db_model_write_widget (GladeWidgetAdaptor * adaptor,
glade_xml_node_append_child (node, links_node);
}
}
-
- prop = glade_widget_get_property (widget, "batch");
-// Custom tag for the "batch" property, e.g.:
-//
-//
-//
- if ((l = g_value_get_boxed (glade_property_inline_value (prop))))
- {
- m = GTK_TREE_MODEL (l->list);
-
- if (gtk_tree_model_get_iter_first (m, &iter))
- {
- GladeXmlNode * batch_node = glade_xml_node_new (context, "batch");
-
- do
- {
- gchar * id;
- GladeWidget * param;
- GladeXmlNode * holder_node;
-
- gtk_tree_model_get (m, &iter
- ,BATCH_ID_COL, &id
- ,BATCH_PARAM_COL, ¶m
- , -1);
-
- holder_node = glade_xml_node_new (context, "holder");
- glade_xml_node_append_child (batch_node, holder_node);
- glade_xml_node_set_property_string (holder_node,
- "id", id ? id : "");
- glade_xml_node_set_property_string (holder_node, "param",
- param ? glade_widget_get_name (param) : "");
-
- g_free (id);
- }
- while (gtk_tree_model_iter_next (m, &iter));
-
- if (!glade_xml_node_get_children (batch_node))
- glade_xml_node_delete (batch_node);
- else
- glade_xml_node_append_child (node, batch_node);
- }
- }
}
typedef struct
@@ -848,10 +790,7 @@ ParseData;
void glade_db_model_on_parse_finished (GladeProject * p, ParseData * pd)
{
GladeWidget * param = glade_project_get_widget_by_name (p, pd->param_name);
- gint col = 1;// XXX LINKS_PARAM_COL and BATCH_PARAM_COL
-
- gtk_list_store_set (pd->store, pd->iter, col, param, -1);
-
+ gtk_list_store_set (pd->store, pd->iter, PARAM_COL, param, -1);
g_object_unref (pd->store);
gtk_tree_iter_free (pd->iter);
g_free (pd->param_name);
@@ -864,7 +803,7 @@ void glade_db_model_read_widget (GladeWidgetAdaptor * adaptor,
GladeXmlNode * prop_node;
GladeProperty * prop;
GladeProject * proj;
- GladeDbList * list;
+ GladeVnList * list;
GtkListStore * store;
if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
@@ -876,15 +815,15 @@ void glade_db_model_read_widget (GladeWidgetAdaptor * adaptor,
{
GladeXmlNode * links_node = prop_node;
proj = glade_widget_get_project (widget);
- list = g_new (GladeDbList, 1);
- store = gtk_list_store_new (LINKS_N_COLS, G_TYPE_STRING, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN);
+ list = g_new (GladeVnList, 1);
+ store = gtk_list_store_new (N_COLS, G_TYPE_STRING, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN);
list->list = store;
for (links_node = glade_xml_node_get_children (links_node); links_node;
links_node = glade_xml_node_next (links_node))
{
GtkTreeIter iter;
- gint col = LINKS_PARAM_COL;
+ gint col = PARAM_COL;
gchar * field = glade_xml_get_property_string (links_node, "field"),
* param_name = glade_xml_get_property_string (links_node, "param");
gboolean linked = glade_xml_get_property_boolean (links_node, "linked", TRUE);
@@ -908,8 +847,8 @@ void glade_db_model_read_widget (GladeWidgetAdaptor * adaptor,
}
gtk_list_store_set (store, &iter
- ,LINKS_FIELD_COL, field
- ,LINKS_LINKED_COL, linked
+ ,FIELD_COL, field
+ ,LINKED_COL, linked
,col, param
,-1);
@@ -920,51 +859,4 @@ void glade_db_model_read_widget (GladeWidgetAdaptor * adaptor,
prop = glade_widget_get_property (widget, "links");
glade_property_set (prop, list);
}
-
- if ((prop_node = glade_xml_search_child (node, "batch")))
- {
- GladeXmlNode * batch_node = prop_node;
- proj = glade_widget_get_project (widget);
- list = g_new (GladeDbList, 1);
- store = gtk_list_store_new (BATCH_N_COLS, G_TYPE_STRING, GLADE_TYPE_WIDGET);
- list->list = store;
-
- for (batch_node = glade_xml_node_get_children (batch_node); batch_node;
- batch_node = glade_xml_node_next (batch_node))
- {
- GtkTreeIter iter;
- gint col = BATCH_PARAM_COL;
- gchar * id = glade_xml_get_property_string (batch_node, "id"),
- * param_name = glade_xml_get_property_string (batch_node, "param");
- GladeWidget * param = glade_project_get_widget_by_name (proj, param_name);
-
- gtk_list_store_append (store, &iter);
-
- if (!param)
- {
- // If the parameter hasn't been read yet, load it after the parse
- ParseData * pd;
- pd = g_new (ParseData, 1);
- pd->store = g_object_ref (store);
- pd->iter = gtk_tree_iter_copy (&iter);
- pd->param_name = g_strdup (param_name);
-
- g_signal_connect (proj, "parse-finished",
- G_CALLBACK (glade_db_model_on_parse_finished), pd);
-
- col = -1;
- }
-
- gtk_list_store_set (store, &iter
- ,BATCH_ID_COL, id
- ,col, param
- ,-1);
-
- g_free (id);
- g_free (param_name);
- }
-
- prop = glade_widget_get_property (widget, "batch");
- glade_property_set (prop, list);
- }
}
diff --git a/glade/glade-sql-batch.c b/glade/glade-sql-batch.c
new file mode 100644
index 0000000..00779c1
--- /dev/null
+++ b/glade/glade-sql-batch.c
@@ -0,0 +1,648 @@
+/*
+ * 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 .
+ */
+
+#include "glade-vn.h"
+
+//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ SqlBatchEditor
+
+#define GLADE_TYPE_BATCH_EDITOR (glade_batch_editor_get_type ())
+#define GLADE_BATCH_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_BATCH_EDITOR, GladeBatchEditor))
+#define GLADE_BATCH_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_BATCH_EDITOR, GladeBatchEditorClass))
+#define GLADE_IS_BATCH_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_BATCH_EDITOR))
+#define GLADE_IS_BATCH_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_BATCH_EDITOR))
+#define GLADE_BATCH_EDITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_TYPE_BATCH_EDITOR, GladeBatchEditorClass))
+
+typedef struct _GladeBatchEditor GladeBatchEditor;
+typedef struct _GladeBatchEditorClass GladeBatchEditorClass;
+
+struct _GladeBatchEditor
+{
+ GtkBox parent;
+
+ GtkWidget * base;
+ GList * props;
+};
+
+struct _GladeBatchEditorClass
+{
+ GtkVBoxClass parent;
+};
+
+GType glade_batch_editor_get_type (void) G_GNUC_CONST;
+
+static GtkWidget * glade_sql_batch_editor_new (GladeWidgetAdaptor * adaptor,
+ GladeEditable * editable)
+{
+ GtkWidget * frame, * alignment, * vbox;
+ GladeEditorProperty * eprop;
+ GladeBatchEditor * obj;
+
+ g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), NULL);
+ g_return_val_if_fail (GLADE_IS_EDITABLE (editable), NULL);
+
+ obj = g_object_new (GLADE_TYPE_BATCH_EDITOR,
+ "orientation", GTK_ORIENTATION_VERTICAL, NULL);
+ obj->base = GTK_WIDGET (editable);
+ gtk_box_pack_start (GTK_BOX (obj), GTK_WIDGET (editable), TRUE, TRUE, 0);
+
+ eprop = glade_widget_adaptor_create_eprop_by_name (adaptor, "items", FALSE, TRUE);
+ obj->props = g_list_prepend (obj->props, eprop);
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_widget (GTK_FRAME (frame),
+ glade_editor_property_get_item_label (eprop));
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
+ gtk_box_pack_start (GTK_BOX (obj), frame, FALSE, FALSE, 12);
+
+ alignment = gtk_alignment_new (0.5F, 0.5F, 1.0F, 1.0F);
+ gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 6, 0, 12, 0);
+ gtk_container_add (GTK_CONTAINER (frame), alignment);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_add (GTK_CONTAINER (alignment), vbox);
+
+ gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (eprop), FALSE, FALSE, 4);
+ gtk_widget_set_tooltip_text (vbox, _("List of items"));
+
+ gtk_widget_show_all (GTK_WIDGET (obj));
+ return GTK_WIDGET (obj);
+}
+
+static void glade_batch_editor_load (GladeEditable * editable, GladeWidget * widget)
+{
+ GList *l;
+ GladeBatchEditor * obj = GLADE_BATCH_EDITOR (editable);
+ GladeEditableIface * iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE);
+ iface->load (editable, widget);
+
+ if (obj->base)
+ glade_editable_load (GLADE_EDITABLE (obj->base), widget);
+
+ for (l = obj->props; l; l = l->next)
+ glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget);
+}
+
+static void glade_batch_editor_set_show_name (GladeEditable * editable, gboolean show_name)
+{
+ GladeBatchEditor * obj = GLADE_BATCH_EDITOR (editable);
+ glade_editable_set_show_name (GLADE_EDITABLE (obj->base), show_name);
+}
+
+static void glade_batch_editor_finalize (GObject * object)
+{
+ GladeBatchEditor * obj = GLADE_BATCH_EDITOR (object);
+ GObjectClass * parent = g_type_class_peek_parent (GLADE_BATCH_EDITOR_GET_CLASS (obj));
+
+ if (obj->props)
+ g_list_free (obj->props);
+
+ obj->props = NULL;
+ obj->base = NULL;
+
+ glade_editable_load (GLADE_EDITABLE (obj), NULL);
+
+ parent->finalize (G_OBJECT (obj));
+}
+
+static void glade_batch_editor_class_init (GladeBatchEditorClass * k)
+{
+ GObjectClass * klass = G_OBJECT_CLASS (k);
+ klass->finalize = glade_batch_editor_finalize;
+}
+
+static void glade_batch_editor_init (GladeBatchEditor * obj)
+{
+ obj->props = NULL;
+ obj->base = NULL;
+}
+
+static void glade_batch_editor_editable_init (GladeEditableIface * iface)
+{
+ iface->load = glade_batch_editor_load;
+ iface->set_show_name = glade_batch_editor_set_show_name;
+}
+
+G_DEFINE_TYPE_WITH_CODE (GladeBatchEditor, glade_batch_editor, GTK_TYPE_BOX,
+ G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_batch_editor_editable_init));
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++ Items Editor Property
+
+
+typedef struct
+{
+ GladeEditorProperty parent;
+
+ GtkTreeView * view;
+ gchar * path;
+}
+GladeEPropItems;
+
+GLADE_MAKE_EPROP (GladeEPropItems, glade_eprop_items)
+#define GLADE_TYPE_EPROP_ITEMS (glade_eprop_items_get_type ())
+#define GLADE_EPROP_ITEMS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GLADE_TYPE_EPROP_ITEMS, GladeEPropItems))
+#define GLADE_EPROP_ITEMS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GLADE_TYPE_EPROP_ITEMS, GladeEPropItemsClass))
+#define GLADE_IS_EPROP_ITEMS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GLADE_TYPE_EPROP_ITEMS))
+#define GLADE_IS_EPROP_ITEMS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GLADE_TYPE_EPROP_ITEMS))
+#define GLADE_EPROP_ITEMS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GLADE_EPROP_ITEMS, GladeEPropItemsClass))
+
+enum
+{
+ ID_COL
+ ,PARAM_COL
+ ,N_COLS
+};
+
+static void glade_eprop_items_on_param_col_clicked (GtkEntry * entry,
+ GtkEntryIconPosition icon_pos, GdkEvent * event, GladeEditorProperty * eprop)
+{
+ GtkTreeIter iter;
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ GladeWidget * widget = glade_property_get_widget (p);
+ GladeProject * project = glade_widget_get_project (widget);
+ GtkListStore * store = ((GladeVnList *) g_value_get_boxed (glade_property_inline_value (p)))->list;
+ gchar * path = GLADE_EPROP_ITEMS (eprop)->path;
+
+ if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, PARAM_COL, &widget, -1);
+
+ if (glade_editor_property_show_object_dialog (project,
+ _("Select a GvnParam"), NULL, GVN_TYPE_PARAM, NULL, &widget))
+ {
+ if (widget)
+ gtk_list_store_set (store, &iter, PARAM_COL, widget, -1);
+ else
+ gtk_list_store_set (store, &iter, PARAM_COL, NULL, -1);
+ }
+}
+
+static gboolean glade_eprop_items_on_param_key_pressed (GtkEntry * entry,
+ GdkEventKey * event, GladeEditorProperty * eprop)
+{
+ if (event->keyval == GDK_KEY_Return)
+ {
+ glade_eprop_items_on_param_col_clicked (entry, 0, NULL, eprop);
+ return TRUE;
+ }
+ else if (event->keyval == GDK_KEY_Delete)
+ {
+ GtkTreeIter iter;
+ gchar * path = GLADE_EPROP_ITEMS (eprop)->path;
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ GtkListStore * store = ((GladeVnList *) g_value_get_boxed (glade_property_inline_value (p)))->list;
+
+ if (gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
+ {
+ gtk_list_store_set (store, &iter, PARAM_COL, NULL, -1);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static void param_col_cell_data (GtkTreeViewColumn * view, GtkCellRenderer * cell,
+ GtkTreeModel * model, GtkTreeIter * iter, gpointer data)
+{
+ GladeWidget * param;
+ gtk_tree_model_get (model, iter, PARAM_COL, ¶m, -1);
+
+ if (param)
+ g_object_set (cell, "text", glade_widget_get_name (param), NULL);
+ else
+ g_object_set (cell, "text", "", NULL);
+}
+
+static void glade_eporp_items_on_param_col_editing_started (GtkCellRendererText * cell,
+ GtkEntry * entry, gchar * path, GladeEditorProperty * eprop)
+{
+ GladeEPropItems * obj = GLADE_EPROP_ITEMS (eprop);
+
+ if (GTK_IS_ENTRY (entry))
+ {
+ GList * n;
+ gboolean have_params = FALSE;
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ GladeProject * project = glade_widget_get_project
+ (glade_property_get_widget (p));
+ GList * objects = (GList *) glade_project_get_objects (project);
+
+ for (n = objects; n; n = n->next)
+ if ((have_params = GVN_IS_PARAM (n->data)))
+ break;
+
+ if (have_params)
+ {
+ g_object_set (entry
+ ,"secondary-icon-name", "content-loading-symbolic"
+ ,"secondary-icon-sensitive", TRUE
+ ,"secondary-icon-tooltip-text", _("Select the parameter from a list")
+ ,NULL);
+
+ if (obj->path)
+ g_free (obj->path);
+
+ obj->path = g_strdup (path);
+
+ g_signal_connect (entry, "icon-press",
+ G_CALLBACK (glade_eprop_items_on_param_col_clicked), eprop);
+ g_signal_connect (entry, "key-press-event",
+ G_CALLBACK (glade_eprop_items_on_param_key_pressed), eprop);
+ }
+ else
+ {
+ g_object_set (entry
+ ,"secondary-icon-name", "dialog-warning-symbolic"
+ ,"secondary-icon-sensitive", FALSE
+ ,"secondary-icon-tooltip-text", _("You need to create at least "
+ "one GvnParam or derived object")
+ ,NULL);
+ g_signal_handlers_disconnect_by_data (entry, eprop);
+ }
+
+ g_object_set (entry, "editable", FALSE, NULL);
+ }
+}
+
+static void glade_eporp_items_on_id_col_edited (GtkCellRendererText * cell,
+ gchar * path, const gchar * text, GladeEditorProperty * eprop)
+{
+ GtkTreeIter iter;
+ GladeProperty * p = glade_editor_property_get_property (eprop);
+ GladeVnList * list = g_value_get_boxed (glade_property_inline_value (p));
+ GtkListStore * store = list->list;
+
+ if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path))
+ return;
+
+ gtk_list_store_set (store, &iter, ID_COL, text, -1);
+}
+
+static void glade_widget_on_remove_widget (GladeProject * project,
+ GladeWidget * widget, GtkListStore * store)
+{
+ if (g_type_is_a (G_OBJECT_TYPE (glade_widget_get_object (widget)), GVN_TYPE_PARAM))
+ {
+ GtkTreeIter iter;
+ GtkTreeModel * m = GTK_TREE_MODEL (store);
+
+ if (gtk_tree_model_get_iter_first (m, &iter))
+ do
+ {
+ GladeWidget * param;
+ gtk_tree_model_get (m, &iter, PARAM_COL, ¶m, -1);
+
+ if (param == widget)
+ gtk_list_store_set (store, &iter, PARAM_COL, NULL, -1);
+ }
+ while (gtk_tree_model_iter_next (m, &iter));
+ }
+}
+
+static void glade_eporp_items_on_add_clicked (GtkButton * button,
+ GladeEPropItems * obj)
+{
+ GtkTreeIter iter;
+ GtkTreePath * path;
+ GladeVnList * list;
+ GtkListStore * store;
+ GladeProperty * p = glade_editor_property_get_property (GLADE_EDITOR_PROPERTY (obj));
+
+ if (!(list = g_value_get_boxed (glade_property_inline_value (p))))
+ {
+ list = g_new (GladeVnList, 1);
+ list->list = gtk_list_store_new (N_COLS,
+ G_TYPE_STRING, GLADE_TYPE_WIDGET, G_TYPE_BOOLEAN);
+ glade_property_set (p, list);
+
+ g_signal_connect (glade_widget_get_project (glade_property_get_widget (p)),
+ "remove-widget", G_CALLBACK (glade_widget_on_remove_widget), list->list);
+ }
+
+ store = list->list;
+ gtk_tree_view_set_model (obj->view, GTK_TREE_MODEL (store));
+
+ gtk_list_store_append (store, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
+
+ gtk_tree_view_scroll_to_cell (obj->view, path, NULL, FALSE, 0, 0);
+ gtk_tree_view_set_cursor (obj->view, path, NULL, TRUE);
+ gtk_widget_grab_focus (GTK_WIDGET (obj->view));
+
+ gtk_tree_path_free (path);
+}
+
+static void glade_eporp_items_on_remove_clicked (GtkButton * button,
+ GladeEPropItems * obj)
+{
+ GtkTreeIter iter;
+ GtkListStore * store;
+ GtkTreeSelection * selection = gtk_tree_view_get_selection (obj->view);
+ GladeProperty * p;
+
+ if (!gtk_tree_selection_get_selected (selection, (GtkTreeModel **) &store, &iter))
+ return;
+
+ p = glade_editor_property_get_property (GLADE_EDITOR_PROPERTY (obj));
+ gtk_list_store_remove (store, &iter);
+
+ if (!gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter))
+ {
+ gtk_tree_view_set_model (obj->view, NULL);
+ glade_command_set_property (p, NULL);
+
+ g_signal_handlers_disconnect_by_func
+ (glade_widget_get_project (glade_property_get_widget (p)),
+ glade_widget_on_remove_widget, store);
+ }
+}
+
+static gboolean glade_eprop_items_on_view_key_press (GtkWidget * treeview,
+ GdkEventKey * event, GladeEPropItems * obj)
+{
+ if (event->keyval == GDK_KEY_Delete)
+ {
+ glade_eporp_items_on_remove_clicked (NULL, obj);
+ return TRUE;
+ }
+ else if ((event->state & GDK_CONTROL_MASK) != 0
+ && (event->keyval == GDK_KEY_n || event->keyval == GDK_KEY_N))
+ {
+ glade_eporp_items_on_add_clicked (NULL, obj);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static GtkWidget * glade_eprop_items_create_input (GladeEditorProperty * eprop)
+{
+ GtkCellRenderer * cell;
+ GtkTreeViewColumn * column;
+ GladeEPropItems * obj = GLADE_EPROP_ITEMS (eprop);
+ GtkWidget * scroll, * button, * label,
+ * hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4),
+ * box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+
+ label = gtk_label_new (_("Add or remove items"));
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_misc_set_padding (GTK_MISC (label), 2, 4);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_icon_name ("list-add-symbolic", GTK_ICON_SIZE_BUTTON));
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_eporp_items_on_add_clicked), obj);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ button = gtk_button_new ();
+ gtk_button_set_image (GTK_BUTTON (button),
+ gtk_image_new_from_icon_name ("list-remove-symbolic", GTK_ICON_SIZE_BUTTON));
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (glade_eporp_items_on_remove_clicked), obj);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+ gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
+
+ obj->view = GTK_TREE_VIEW (gtk_tree_view_new ());
+ g_signal_connect (obj->view, "key-press-event",
+ G_CALLBACK (glade_eprop_items_on_view_key_press), obj);
+ gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (obj->view));
+
+ cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell, "editable", TRUE, NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Identifier"), cell,
+ "text", ID_COL, NULL);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ g_signal_connect (cell, "edited",
+ G_CALLBACK (glade_eporp_items_on_id_col_edited), obj);
+ gtk_tree_view_append_column (obj->view, column);
+
+ cell = gtk_cell_renderer_text_new ();
+ g_object_set (cell, "editable", TRUE, NULL);
+ column = gtk_tree_view_column_new_with_attributes (_("Parameter"), cell, NULL);
+ gtk_tree_view_column_set_cell_data_func (column, cell, param_col_cell_data, obj, NULL);
+ gtk_tree_view_column_set_expand (column, TRUE);
+ g_signal_connect (cell, "editing-started",
+ G_CALLBACK (glade_eporp_items_on_param_col_editing_started), obj);
+ gtk_tree_view_append_column (obj->view, column);
+
+ g_object_set (G_OBJECT (box), "height-request", 200, NULL);
+ gtk_widget_show_all (box);
+ return box;
+}
+
+static void glade_eprop_items_finalize (GObject * object)
+{
+ GladeEPropItems * obj = GLADE_EPROP_ITEMS (object);
+ GObjectClass * parent =
+ g_type_class_peek_parent (GLADE_EPROP_ITEMS_GET_CLASS (obj));
+ parent->finalize (G_OBJECT (obj));
+}
+
+static void glade_eprop_items_load (GladeEditorProperty * eprop, GladeProperty * property)
+{
+ GladeVnList * list;
+ GladeEPropItems * obj = GLADE_EPROP_ITEMS (eprop);
+ GladeEditorPropertyClass * parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ parent_class->load (eprop, property);
+
+ if (!property)
+ return;
+
+ if ((list = g_value_get_boxed (glade_property_inline_value (property))))
+ gtk_tree_view_set_model (obj->view, GTK_TREE_MODEL (list->list));
+ else
+ gtk_tree_view_set_model (obj->view, NULL);
+}
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++ SqlBatch Widget Adaptor
+
+GladeEditorProperty * glade_sql_batch_create_eprop (GladeWidgetAdaptor * adaptor,
+ GladePropertyClass * klass, gboolean use_command)
+{
+ GladeEditorProperty * eprop;
+ const gchar * prop_id = glade_property_class_id (klass);
+
+ if (!g_strcmp0 (prop_id, "items"))
+ eprop = g_object_new (GLADE_TYPE_EPROP_ITEMS,
+ "property-class", klass,
+ "use-command", use_command, NULL);
+ else
+ eprop = GWA_GET_CLASS (G_TYPE_OBJECT)->create_eprop (adaptor,
+ klass, use_command);
+
+ return eprop;
+}
+
+GladeEditable * glade_sql_batch_create_editable (GladeWidgetAdaptor * adaptor,
+ GladeEditorPageType type)
+{
+ GladeEditable * editable =
+ GWA_GET_CLASS (G_TYPE_OBJECT)->create_editable (adaptor, type);
+
+ if (type == GLADE_PAGE_GENERAL)
+ return GLADE_EDITABLE (glade_sql_batch_editor_new (adaptor, editable));
+
+ return editable;
+}
+
+void glade_sql_batch_write_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlContext * context, GladeXmlNode * node)
+{
+ GtkTreeIter iter;
+ GladeVnList * l;
+ GtkTreeModel * m;
+ GladeXmlNode * items_node;
+ GladeProperty * prop;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
+
+ prop = glade_widget_get_property (widget, "items");
+// Custom tag for the "items" property, e.g.:
+//
+//
+//
+ if (!(l = g_value_get_boxed (glade_property_inline_value (prop))))
+ return;
+
+ m = GTK_TREE_MODEL (l->list);
+
+ if (!gtk_tree_model_get_iter_first (m, &iter))
+ return;
+
+ items_node = glade_xml_node_new (context, "items");
+
+ do
+ {
+ gchar * id;
+ GladeWidget * param;
+ GladeXmlNode * item_node;
+
+ gtk_tree_model_get (m, &iter
+ ,ID_COL, &id
+ ,PARAM_COL, ¶m
+ , -1);
+
+ item_node = glade_xml_node_new (context, "item");
+ glade_xml_node_append_child (items_node, item_node);
+ glade_xml_node_set_property_string (item_node, "id", id ? id : "");
+ glade_xml_node_set_property_string (item_node, "param",
+ param ? glade_widget_get_name (param) : "");
+
+ g_free (id);
+ }
+ while (gtk_tree_model_iter_next (m, &iter));
+
+ if (!glade_xml_node_get_children (items_node))
+ glade_xml_node_delete (items_node);
+ else
+ glade_xml_node_append_child (node, items_node);
+}
+
+typedef struct
+{
+ GtkListStore * store;
+ GtkTreeIter * iter;
+ gchar * param_name;
+}
+ParseData;
+
+void glade_sql_batch_on_parse_finished (GladeProject * p, ParseData * pd)
+{
+ GladeWidget * param = glade_project_get_widget_by_name (p, pd->param_name);
+
+ gtk_list_store_set (pd->store, pd->iter, PARAM_COL, param, -1);
+
+ g_object_unref (pd->store);
+ gtk_tree_iter_free (pd->iter);
+ g_free (pd->param_name);
+ g_free (pd);
+}
+
+void glade_sql_batch_read_widget (GladeWidgetAdaptor * adaptor,
+ GladeWidget * widget, GladeXmlNode * node)
+{
+ GladeXmlNode * items_node;
+ GladeProperty * prop;
+ GladeProject * proj;
+ GladeVnList * list;
+ GtkListStore * store;
+
+ if (!glade_xml_node_verify (node, GLADE_XML_TAG_WIDGET))
+ return;
+
+ GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
+
+ if ((items_node = glade_xml_search_child (node, "items")) == NULL)
+ return;
+
+ proj = glade_widget_get_project (widget);
+ list = g_new (GladeVnList, 1);
+ store = gtk_list_store_new (N_COLS, G_TYPE_STRING, GLADE_TYPE_WIDGET);
+ list->list = store;
+
+ for (items_node = glade_xml_node_get_children (items_node); items_node;
+ items_node = glade_xml_node_next (items_node))
+ {
+ GtkTreeIter iter;
+ gint col = PARAM_COL;
+ gchar * id = glade_xml_get_property_string (items_node, "id"),
+ * param_name = glade_xml_get_property_string (items_node, "param");
+ GladeWidget * param = glade_project_get_widget_by_name (proj, param_name);
+
+ gtk_list_store_append (store, &iter);
+
+ if (!param)
+ {
+ // If the parameter hasn't been read yet, load it after the parse
+ ParseData * pd;
+ pd = g_new (ParseData, 1);
+ pd->store = g_object_ref (store);
+ pd->iter = gtk_tree_iter_copy (&iter);
+ pd->param_name = g_strdup (param_name);
+
+ g_signal_connect (proj, "parse-finished",
+ G_CALLBACK (glade_sql_batch_on_parse_finished), pd);
+
+ col = -1;
+ }
+
+ gtk_list_store_set (store, &iter
+ ,ID_COL, id
+ ,col, param
+ ,-1);
+
+ g_free (id);
+ g_free (param_name);
+ }
+
+ prop = glade_widget_get_property (widget, "items");
+ glade_property_set (prop, list);
+}
\ No newline at end of file
diff --git a/glade/glade-vn-batch.c b/glade/glade-vn-batch.c
deleted file mode 100644
index 8203e9d..0000000
--- a/glade/glade-vn-batch.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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 .
- */
-
-#include "glade-vn.h"
-
-void glade_vn_set_add_child (GladeWidgetAdaptor * adaptor,
- VnSet * group, GObject * child)
-{
- if (G_IS_OBJECT (child))
- vn_set_add (group, child);
-}
-
-void glade_vn_set_remove_child (GladeWidgetAdaptor * adaptor,
- VnSet * group, GObject * child)
-{
- if (G_IS_OBJECT (child))
- vn_set_remove (group, child);
-}
-
-void glade_vn_set_replace_child (GladeWidgetAdaptor * adaptor,
- GObject * container, GObject * current, GObject * new)
-{
- VnSet * group = VN_SET (container);
- glade_vn_set_remove_child (adaptor, group, current);
- glade_vn_set_add_child (adaptor, group, new);
-}
-
-GList * glade_vn_set_get_children (GladeWidgetAdaptor * adaptor,
- VnSet * group)
-{
- return vn_set_get_objects_list (group);
-}
-
-gboolean glade_vn_set_add_verify (GladeWidgetAdaptor * adaptor,
- VnSet * container, GObject * child, gboolean user_feedback)
-{
- if (G_IS_OBJECT (child))
- return TRUE;
-
- if (user_feedback)
- {
- GladeWidgetAdaptor * object_adaptor =
- glade_widget_adaptor_get_by_type (G_TYPE_OBJECT);
-
- glade_util_ui_message (glade_app_get_window ()
- ,GLADE_UI_INFO
- ,NULL
- ,"Only objects of type %s can be added to objects of type %s."
- ,glade_widget_adaptor_get_name (object_adaptor)
- ,glade_widget_adaptor_get_name (adaptor)
- );
- }
-
- return FALSE;
-}
diff --git a/glade/glade-vn.c b/glade/glade-vn.c
index 99fc84c..9c33e58 100644
--- a/glade/glade-vn.c
+++ b/glade/glade-vn.c
@@ -17,18 +17,6 @@
#include "glade-vn.h"
-GObject * glade_vn_field_get_internal_child (GladeWidgetAdaptor * adaptor,
- GObject * parent, const gchar * name)
-{
- return G_OBJECT (vn_field_get_widget (VN_FIELD (parent)));
-}
-
-GObject * glade_vn_column_get_internal_child (GladeWidgetAdaptor * adaptor,
- GObject * parent, const gchar * name)
-{
- return G_OBJECT (vn_column_get_cell_renderer (VN_COLUMN (parent)));
-}
-
gboolean glade_vn_set_first_catalog (gpointer catalog_name)
{
GList * l, * catalogs = glade_app_get_catalogs (),
@@ -70,3 +58,40 @@ void glade_vn_init ()
g_idle_add (glade_vn_set_first_catalog, "vn");
}
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++ GladeDbList
+
+G_DEFINE_BOXED_TYPE (GladeVnList, glade_vn_list, glade_vn_list_copy, glade_vn_list_free);
+
+void glade_vn_list_free (GladeVnList * list)
+{
+ if (!list)
+ return;
+
+ if (list->list)
+ g_object_unref (list->list);
+
+ g_free (list);
+ list = NULL;
+}
+
+GladeVnList * glade_vn_list_copy (const GladeVnList * list)
+{
+ GladeVnList * l = g_new (GladeVnList, 1);
+ l->list = list->list ? g_object_ref (list->list) : NULL;
+ return l;
+}
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++ Internal children
+
+GObject * glade_vn_field_get_internal_child (GladeWidgetAdaptor * adaptor,
+ GObject * parent, const gchar * name)
+{
+ return G_OBJECT (vn_field_get_widget (VN_FIELD (parent)));
+}
+
+GObject * glade_vn_column_get_internal_child (GladeWidgetAdaptor * adaptor,
+ GObject * parent, const gchar * name)
+{
+ return G_OBJECT (vn_column_get_cell_renderer (VN_COLUMN (parent)));
+}
diff --git a/glade/glade-vn.h b/glade/glade-vn.h
index 0000d41..1803140 100644
--- a/glade/glade-vn.h
+++ b/glade/glade-vn.h
@@ -23,4 +23,17 @@
void glade_vn_init ();
+#define GLADE_TYPE_VN_LIST (glade_vn_list_get_type())
+
+typedef struct _GladeVnList GladeVnList;
+
+struct _GladeVnList
+{
+ GtkListStore * list;
+};
+
+GType glade_vn_list_get_type (void) G_GNUC_CONST;
+void glade_vn_list_free (GladeVnList * list);
+GladeVnList * glade_vn_list_copy (const GladeVnList * list);
+
#endif
\ No newline at end of file
diff --git a/glade/vn.xml b/glade/vn.xml
index 74d333f..55295de 100644
--- a/glade/vn.xml
+++ b/glade/vn.xml
@@ -5,11 +5,19 @@
glade_vn_init
-
+
-
-
+
+
+ GParamBoxed
+ GladeVnList
+
+
+ glade_sql_batch_create_eprop
+ glade_sql_batch_create_editable
+ glade_sql_batch_write_widget
+ glade_sql_batch_read_widget
@@ -29,13 +37,7 @@
GParamBoxed
- GladeDbList
-
-
-
-
- GParamBoxed
- GladeDbList
+ GladeVnList
@@ -203,7 +205,7 @@
-
+
diff --git a/module/data/consulter-menu.xml b/module/data/consulter-menu.xml
index f13c5f4..d83e0d6 100644
--- a/module/data/consulter-menu.xml
+++ b/module/data/consulter-menu.xml
@@ -1,15 +1,15 @@
-
diff --git a/module/data/example-menu.xml b/module/data/example-menu.xml
index 3727ea1..c086a5f 100644
--- a/module/data/example-menu.xml
+++ b/module/data/example-menu.xml
@@ -1,18 +1,18 @@
-