summaryrefslogtreecommitdiff
path: root/plugins/gtk+/glade-column-types.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tvb@src.gnome.org>2008-10-16 14:31:42 +0000
committerTristan Van Berkom <tvb@src.gnome.org>2008-10-16 14:31:42 +0000
commit4f1e473e0809ddd33e7e58de401f56b8b27516b1 (patch)
treeedf270fdac8f422c05042a5b2fcf243113210b53 /plugins/gtk+/glade-column-types.c
parent9c7ab5ccecad6a33be739241f8d77a6fcf820f97 (diff)
downloadglade-4f1e473e0809ddd33e7e58de401f56b8b27516b1.tar.gz
Encapsulated name tracking mechanism
* gladeui/Makefile.am, gladeui/glade-name-context.[ch]: Encapsulated name tracking mechanism * gladeui/glade-project.c, gladeui/glade-command.c: Now added a naming policy to the project with prefs and load/save support + a glade command to set it - also revamped the prefs dialog, it also pops up automatically for new projects. * gladeui/glade-editor.c, gladeui/glade-editor-property.c, gladeui/glade-property-class.c, gladeui/glade-property.c, gladeui/glade-widget.c: All effected since now glade_property_class_make_gvalue_from_string () needs a GladeWidget argument to do hierachic context sensitive searches... that and naming is much cleaner now. * src/glade-window.c: remember to pass ownership of the project to the app. * plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-column-types.c, plugins/gtk+/glade-model-data.c: BEWARE: Dangerous and still a work in progress. svn path=/trunk/; revision=1972
Diffstat (limited to 'plugins/gtk+/glade-column-types.c')
-rw-r--r--plugins/gtk+/glade-column-types.c166
1 files changed, 66 insertions, 100 deletions
diff --git a/plugins/gtk+/glade-column-types.c b/plugins/gtk+/glade-column-types.c
index 15c2d974..ba62f2ed 100644
--- a/plugins/gtk+/glade-column-types.c
+++ b/plugins/gtk+/glade-column-types.c
@@ -223,106 +223,31 @@ glade_eprop_column_types_finalize (GObject *object)
}
static void
-eprop_reload_value (GladeEPropColumnTypes *eprop_types)
+eprop_column_append (GladeEditorProperty *eprop,
+ GType type,
+ const gchar *column_name)
{
- GladeEditorProperty *eprop = GLADE_EDITOR_PROPERTY (eprop_types);
- GtkTreeModel *model = GTK_TREE_MODEL (eprop_types->store);
- GValue value = {0, };
- GtkTreeIter iter;
- GList *list = NULL, *l;
- GNode *data_tree = NULL;
-
- if (gtk_tree_model_get_iter_first (model, &iter))
- {
- do
- {
- GladeColumnType *data = g_new0(GladeColumnType, 1);
-
- gtk_tree_model_get (model, &iter,
- COLUMN_COLUMN_NAME, &data->column_name,
- COLUMN_GTYPE, &data->type,
- -1);
-
- list = g_list_append (list, data);
- } while (gtk_tree_model_iter_next (model, &iter));
- }
-
- glade_widget_property_get (eprop->property->widget, "data", &data_tree);
- if (data_tree)
- {
- GNode *row, *iter;
- gint colnum;
- data_tree = glade_model_data_tree_copy (data_tree);
-
- glade_command_push_group (_("Setting columns of %s"), eprop->property->widget->name);
-
- /* Remove extra columns */
- for (row = data_tree->children; row; row = row->next)
- {
-
- for (colnum = 0, iter = row->children; iter;
- colnum++, iter = iter->next)
- {
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GList *columns = NULL;
+ GladeColumnType *data;
+ GValue value = { 0, };
- }
- }
+ glade_property_get (eprop->property, &columns);
+ if (columns)
+ columns = glade_column_list_copy (columns);
- g_value_init (&value, GLADE_TYPE_MODEL_DATA_TREE);
- g_value_take_boxed (&value, data_tree);
- glade_editor_property_commit (eprop, &value);
- g_value_unset (&value);
+ data = g_new0 (GladeColumnType, 1);
+ data->column_name = g_strdup (column_name);
+ data->type = type;
- }
+ columns = g_list_append (columns, data);
g_value_init (&value, GLADE_TYPE_COLUMN_TYPE_LIST);
- g_value_take_boxed (&value, list);
+ g_value_take_boxed (&value, columns);
glade_editor_property_commit (eprop, &value);
g_value_unset (&value);
-
- if (data_tree)
- {
- glade_model_data_tree_free (data_tree);
- glade_command_pop_group ();
- }
}
-static void
-eprop_column_append (GladeEPropColumnTypes *eprop_types,
- GType type,
- const gchar *name,
- const gchar *column_name)
-{
- gtk_list_store_insert_with_values (eprop_types->store, NULL, -1,
- COLUMN_NAME, name ? name : g_type_name (type),
- COLUMN_GTYPE, type,
- COLUMN_COLUMN_NAME, column_name,
- -1);
-}
-
-static void
-glade_eprop_column_types_load (GladeEditorProperty *eprop, GladeProperty *property)
-{
- GladeEditorPropertyClass *parent_class =
- g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
- GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
- GList *l, *list;
-
- /* Chain up first */
- parent_class->load (eprop, property);
-
- /* Clear Store */
- gtk_list_store_clear (eprop_types->store);
- /* We could set the combo to the first item */
-
- list = g_value_get_boxed (property->value);
-
- for (l = list; l; l = g_list_next (l))
- {
- GladeColumnType *data = l->data;
-
- eprop_column_append (eprop_types, data->type, NULL, data->column_name);
- }
-}
static void
glade_eprop_column_types_add_clicked (GtkWidget *button,
@@ -340,36 +265,77 @@ glade_eprop_column_types_add_clicked (GtkWidget *button,
COLUMN_GTYPE, &type2add,
-1);
- eprop_column_append (eprop_types, type2add, name, NULL);
- eprop_reload_value (eprop_types);
+ eprop_column_append (GLADE_EDITOR_PROPERTY (eprop_types), type2add, NULL);
}
static void
glade_eprop_column_types_delete_clicked (GtkWidget *button,
GladeEPropColumnTypes *eprop_types)
{
+ /* Remove from list and commit value, dont touch the liststore except in load() */
+
GtkTreeIter iter;
if (gtk_tree_selection_get_selected (eprop_types->selection, NULL, &iter))
gtk_list_store_remove (GTK_LIST_STORE (eprop_types->store), &iter);
}
-static gboolean
-eprop_reload_value_idle (gpointer data)
-{
- eprop_reload_value (GLADE_EPROP_COLUMN_TYPES (data));
- return FALSE;
-}
-
static void
eprop_treeview_row_deleted (GtkTreeModel *tree_model,
GtkTreePath *path,
GladeEditorProperty *eprop)
{
+ GtkTreeIter iter;
if (eprop->loading) return;
- eprop_reload_value_idle (eprop);
+
+ /* Find the deleted row and remove that column... */
+ if (!gtk_tree_model_get_iter (tree_model, &iter, path))
+ return;
+
+ /* Get it by name... */
+
}
+
+static void
+eprop_column_load (GladeEPropColumnTypes *eprop_types,
+ GType type,
+ const gchar *name,
+ const gchar *column_name)
+{
+ gtk_list_store_insert_with_values (eprop_types->store, NULL, -1,
+ COLUMN_NAME, name ? name : g_type_name (type),
+ COLUMN_GTYPE, type,
+ COLUMN_COLUMN_NAME, column_name,
+ -1);
+}
+
+static void
+glade_eprop_column_types_load (GladeEditorProperty *eprop, GladeProperty *property)
+{
+ GladeEditorPropertyClass *parent_class =
+ g_type_class_peek_parent (GLADE_EDITOR_PROPERTY_GET_CLASS (eprop));
+ GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
+ GList *l, *list;
+
+ /* Chain up first */
+ parent_class->load (eprop, property);
+
+ /* Clear Store */
+ gtk_list_store_clear (eprop_types->store);
+ /* We could set the combo to the first item */
+
+ list = g_value_get_boxed (property->value);
+
+ for (l = list; l; l = g_list_next (l))
+ {
+ GladeColumnType *data = l->data;
+
+ eprop_column_load (eprop_types, data->type, NULL, data->column_name);
+ }
+}
+
+
static GtkWidget *
glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
{