[glade3] 2010-03-09 Tristan Van Berkom <tvb gnome org>
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3] 2010-03-09 Tristan Van Berkom <tvb gnome org>
- Date: Tue, 9 Mar 2010 21:32:04 +0000 (UTC)
commit a226760c3326cf8187dd4429d4747e4cf6a7b905
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Tue Mar 9 14:08:38 2010 -0500
2010-03-09 Tristan Van Berkom <tvb gnome org>
* plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-column-types.[ch],
plugins/gtk+/glade-model-data.c: Allow litteral string values for
column types in the tree store editor, Glade will serialize/deserialize
the string litterally and if there is a valid type returned from
g_type_from_name() (i.e. a valid introduced type by that name); then
that GType will be used to setup the column types of runtime treestores
in the project; otherwise it will use G_TYPE_POINTER for those columns.
This closes bug 597095.
2010-03-09 Marco Diego Aurélio Mesquita <marcodiegomesquita gmail com>
* gladeui/glade-project.c: Avoid collapsing commands when a project is freshly saved
(this fixes a false "unmodified" state after changing the same property before and
after project save).
ChangeLog | 22 ++++++-
gladeui/glade-design-layout.c | 2 +-
gladeui/glade-project.c | 6 +-
plugins/gtk+/glade-cell-renderer-editor.c | 2 +-
plugins/gtk+/glade-column-types.c | 98 ++++++++---------------------
plugins/gtk+/glade-column-types.h | 2 +-
plugins/gtk+/glade-convert.c | 2 +-
plugins/gtk+/glade-gtk.c | 79 ++++++++++++++++-------
plugins/gtk+/glade-model-data.c | 11 +--
9 files changed, 114 insertions(+), 110 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 14ea835..8819275 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,12 +1,30 @@
+2010-03-09 Tristan Van Berkom <tvb gnome org>
+
+ * plugins/gtk+/glade-gtk.c, plugins/gtk+/glade-column-types.[ch],
+ plugins/gtk+/glade-model-data.c: Allow litteral string values for
+ column types in the tree store editor, Glade will serialize/deserialize
+ the string litterally and if there is a valid type returned from
+ g_type_from_name() (i.e. a valid introduced type by that name); then
+ that GType will be used to setup the column types of runtime treestores
+ in the project; otherwise it will use G_TYPE_POINTER for those columns.
+
+ This closes bug 597095.
+
+2010-03-09 Marco Diego Aurélio Mesquita <marcodiegomesquita gmail com>
+
+ * gladeui/glade-project.c: Avoid collapsing commands when a project is freshly saved
+ (this fixes a false "unmodified" state after changing the same property before and
+ after project save).
+
2010-01-28 Javier Jardon <jjardon gnome org>
* README: Glade requires GTK+ >= 2.20
-2009-12-18 Javier Jardón <jjardon gnome org>
+2009-12-18 Javier Jardón <jjardon gnome org>
* doc/gladeui-docs.sgml: Fix doc location link
-2009-12-04 Javier Jardón <jjardon gnome org>
+2009-12-04 Javier Jardón <jjardon gnome org>
Use accessor functions instead direct access. Second patch
diff --git a/gladeui/glade-design-layout.c b/gladeui/glade-design-layout.c
index d18900d..ac661ae 100644
--- a/gladeui/glade-design-layout.c
+++ b/gladeui/glade-design-layout.c
@@ -649,7 +649,7 @@ glade_design_layout_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y;
window = gtk_widget_get_parent_window (widget);
- gtk_widget_set_window (widget, window);
+ gtk_widget_set_window (widget, g_object_ref (window));
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index cb144b7..599bec4 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -517,12 +517,14 @@ glade_project_push_undo_impl (GladeProject *project, GladeCommand *cmd)
priv->undo_stack = NULL;
}
- /* Try to unify only if group depth is 0 */
+ /* Try to unify only if group depth is 0 and the project has not been recently saved*/
if (glade_command_get_group_depth() == 0 &&
- priv->prev_redo_item != NULL)
+ priv->prev_redo_item != NULL &&
+ project->priv->prev_redo_item != project->priv->first_modification)
{
GladeCommand *cmd1 = priv->prev_redo_item->data;
+
if (glade_command_unifies (cmd1, cmd))
{
glade_command_collapse (cmd1, cmd);
diff --git a/plugins/gtk+/glade-cell-renderer-editor.c b/plugins/gtk+/glade-cell-renderer-editor.c
index dca3491..3df09d4 100644
--- a/plugins/gtk+/glade-cell-renderer-editor.c
+++ b/plugins/gtk+/glade-cell-renderer-editor.c
@@ -512,7 +512,7 @@ glade_eprop_cell_attribute_load (GladeEditorProperty *eprop,
{
GladeColumnType *column = l->data;
gchar *str = g_strdup_printf ("%s - %s", column->column_name,
- g_type_name (column->type));
+ column->type_name);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, str, -1);
diff --git a/plugins/gtk+/glade-column-types.c b/plugins/gtk+/glade-column-types.c
index bcc56b7..10efe4a 100644
--- a/plugins/gtk+/glade-column-types.c
+++ b/plugins/gtk+/glade-column-types.c
@@ -35,7 +35,6 @@
enum
{
COLUMN_NAME,
- COLUMN_GTYPE,
COLUMN_COLUMN_NAME,
COLUMN_TYPE_EDITABLE,
COLUMN_NAME_EDITABLE,
@@ -47,48 +46,9 @@ enum
static GtkTreeModel *types_model = NULL;
static gint
-find_by_type (GType *a, GType *b)
+find_by_type_name (const gchar *a, const gchar *b)
{
- return *a - *b;
-}
-
-static gint
-type_alpha_sort (GType *a, GType *b)
-{
- return strcmp (g_type_name (*a), g_type_name (*b));
-}
-
-static GType
-lookup_type (const gchar *type_name)
-{
- GtkTreeIter iter;
- gchar *iter_type_name;
- GType type = 0, iter_type;
-
- if (gtk_tree_model_get_iter_first (types_model, &iter))
- {
- do
- {
- iter_type_name = NULL;
- gtk_tree_model_get (types_model, &iter,
- COLUMN_NAME, &iter_type_name,
- COLUMN_GTYPE, &iter_type,
- -1);
- g_assert (iter_type_name);
-
- if (strcmp (iter_type_name, type_name) == 0)
- {
- type = iter_type;
- g_free (iter_type_name);
- break;
- }
-
- g_free (iter_type_name);
-
- }
- while (gtk_tree_model_iter_next (types_model, &iter));
- }
- return type;
+ return strcmp (a, b);
}
static void
@@ -121,29 +81,25 @@ column_types_store_populate_enums_flags (GtkListStore *store,
if ((enums ? G_TYPE_IS_ENUM (pclass->pspec->value_type) :
G_TYPE_IS_FLAGS (pclass->pspec->value_type)) &&
- !g_list_find_custom (types, &(pclass->pspec->value_type),
- (GCompareFunc)find_by_type))
- {
- types = g_list_prepend (types,
- g_memdup (&(pclass->pspec->value_type),
- sizeof (GType)));
- }
+ !g_list_find_custom (types, g_type_name (pclass->pspec->value_type),
+ (GCompareFunc)find_by_type_name))
+ types = g_list_prepend (types, g_strdup (g_type_name (pclass->pspec->value_type)));
+
}
}
g_list_free (adaptors);
- types = g_list_sort (types, (GCompareFunc)type_alpha_sort);
+ types = g_list_sort (types, (GCompareFunc)find_by_type_name);
for (l = types; l; l = l->next)
{
- GType *type = l->data;
+ gchar *type_name = l->data;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- COLUMN_NAME, g_type_name (*type),
- COLUMN_GTYPE, *type,
+ COLUMN_NAME, type_name,
-1);
- g_free (type);
+ g_free (type_name);
}
g_list_free (types);
}
@@ -175,7 +131,6 @@ column_types_store_populate (GtkListStore *store)
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
COLUMN_NAME, g_type_name (types[i]),
- COLUMN_GTYPE, types[i],
-1);
}
@@ -193,7 +148,7 @@ glade_column_list_copy (GList *list)
GladeColumnType *new_data = g_new0(GladeColumnType, 1);
GladeColumnType *data = l->data;
- new_data->type = data->type;
+ new_data->type_name = g_strdup (data->type_name);
new_data->column_name = g_strdup (data->column_name);
retval = g_list_prepend (retval, new_data);
@@ -205,6 +160,7 @@ glade_column_list_copy (GList *list)
void
glade_column_type_free (GladeColumnType *column)
{
+ g_free (column->type_name);
g_free (column->column_name);
g_free (column);
}
@@ -235,7 +191,6 @@ glade_column_list_find_column (GList *list, const gchar *column_name)
return column;
}
-
GType
glade_column_type_list_get_type (void)
{
@@ -327,12 +282,17 @@ eprop_column_adjust_rows (GladeEditorProperty *eprop, GList *columns)
/* Add mising columns and reorder... */
for (list = g_list_last (columns); list; list = list->prev)
{
+ GType data_type;
+
column = list->data;
+ if ((data_type = g_type_from_name (column->type_name)) == G_TYPE_INVALID)
+ data_type = G_TYPE_POINTER;
+
if ((idx = glade_model_data_column_index (data_tree, column->column_name)) < 0)
{
glade_model_data_insert_column (data_tree,
- column->type,
+ data_type,
column->column_name,
0);
@@ -352,7 +312,7 @@ eprop_column_adjust_rows (GladeEditorProperty *eprop, GList *columns)
static void
eprop_column_append (GladeEditorProperty *eprop,
- GType type,
+ const gchar *type_name,
const gchar *column_name)
{
GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
@@ -366,7 +326,7 @@ eprop_column_append (GladeEditorProperty *eprop,
data = g_new0 (GladeColumnType, 1);
data->column_name = g_strdup (column_name);
- data->type = type;
+ data->type_name = g_strdup (type_name);
columns = g_list_append (columns, data);
@@ -521,12 +481,11 @@ eprop_column_add_new (GladeEPropColumnTypes *eprop_types)
static void
eprop_column_load (GladeEPropColumnTypes *eprop_types,
- GType type,
+ const gchar *type_name,
const gchar *column_name)
{
gtk_list_store_insert_with_values (eprop_types->store, NULL, -1,
- COLUMN_NAME, g_type_name (type),
- COLUMN_GTYPE, type,
+ COLUMN_NAME, type_name,
COLUMN_COLUMN_NAME, column_name,
COLUMN_TYPE_EDITABLE, FALSE,
COLUMN_NAME_EDITABLE, TRUE,
@@ -627,7 +586,7 @@ glade_eprop_column_types_load (GladeEditorProperty *eprop, GladeProperty *proper
{
GladeColumnType *data = l->data;
- eprop_column_load (eprop_types, data->type, data->column_name);
+ eprop_column_load (eprop_types, data->type_name, data->column_name);
glade_name_context_add_name (eprop_types->context, data->column_name);
}
@@ -732,16 +691,15 @@ column_type_edited (GtkCellRendererText *cell,
{
GladeEPropColumnTypes *eprop_types = GLADE_EPROP_COLUMN_TYPES (eprop);
GtkTreeIter iter;
- GType type;
gchar *column_name;
if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (eprop_types->store), &iter, path))
return;
- if (type_name && (type = lookup_type (type_name)) != 0)
+ if (type_name && type_name[0])
{
column_name = glade_name_context_new_name (eprop_types->context, type_name);
- eprop_column_append (eprop, type, column_name);
+ eprop_column_append (eprop, type_name, column_name);
g_free (column_name);
}
else
@@ -816,9 +774,8 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
/* We make sure to do this after all the adaptors are parsed
* because we load the enums/flags from the adaptors
*/
- types_model = (GtkTreeModel *)gtk_list_store_new (2,
- G_TYPE_STRING,
- G_TYPE_GTYPE);
+ types_model = (GtkTreeModel *)gtk_list_store_new (1,
+ G_TYPE_STRING);
column_types_store_populate (GTK_LIST_STORE (types_model));
}
@@ -839,7 +796,6 @@ glade_eprop_column_types_create_input (GladeEditorProperty *eprop)
eprop_types->store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING,
- G_TYPE_GTYPE,
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN,
diff --git a/plugins/gtk+/glade-column-types.h b/plugins/gtk+/glade-column-types.h
index 7c5e0c7..f2c3fbc 100644
--- a/plugins/gtk+/glade-column-types.h
+++ b/plugins/gtk+/glade-column-types.h
@@ -28,7 +28,7 @@ G_BEGIN_DECLS
typedef struct
{
- GType type;
+ gchar *type_name;
gchar *column_name;
} GladeColumnType;
diff --git a/plugins/gtk+/glade-convert.c b/plugins/gtk+/glade-convert.c
index 2bea21a..6874462 100644
--- a/plugins/gtk+/glade-convert.c
+++ b/plugins/gtk+/glade-convert.c
@@ -548,7 +548,7 @@ convert_combos_finished (GladeProject *project,
GList *columns = NULL;
GladeColumnType *column = g_new0 (GladeColumnType, 1);
- column->type = G_TYPE_STRING;
+ column->type_name = g_strdup ("gchararray");
column->column_name = g_strdup_printf ("item text");
columns = g_list_append (columns, column);
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index b55eddc..0726644 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -4756,8 +4756,11 @@ static void
glade_gtk_entry_changed (GtkEditable *editable, GladeWidget *gentry)
{
const gchar *text, *text_prop;
- GladeProperty *prop;
-
+ GladeProperty *prop;
+
+ if (glade_widget_superuser ())
+ return;
+
text = gtk_entry_get_text (GTK_ENTRY (editable));
glade_widget_property_get (gentry, "text", &text_prop);
@@ -5002,6 +5005,14 @@ glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor *adaptor,
}
/* ----------------------------- GtkWindow ------------------------------ */
+static gint
+glade_gtk_widget_show_on_delete (GtkWidget *widget,
+ gpointer user_data)
+{
+ gtk_widget_show (widget);
+ return TRUE;
+}
+
void
glade_gtk_window_deep_post_create (GladeWidgetAdaptor *adaptor,
GObject *object,
@@ -5014,7 +5025,7 @@ glade_gtk_window_deep_post_create (GladeWidgetAdaptor *adaptor,
/* Chain her up first */
GWA_GET_CLASS (GTK_TYPE_CONTAINER)->deep_post_create (adaptor, object, reason);
- g_signal_connect (object, "delete", G_CALLBACK (gtk_widget_show), NULL);
+ g_signal_connect (object, "delete-event", G_CALLBACK (glade_gtk_widget_show_on_delete), NULL);
}
#define GLADE_TAG_ACCEL_GROUPS "accel-groups"
@@ -9876,7 +9887,11 @@ glade_gtk_store_set_columns (GObject *object,
for (i = 0; l; l = g_list_next (l), i++)
{
GladeColumnType *data = l->data;
- types[i] = data->type;
+
+ if (g_type_from_name (data->type_name) != G_TYPE_INVALID)
+ types[i] = g_type_from_name (data->type_name);
+ else
+ types[i] = G_TYPE_POINTER;
}
if (GTK_IS_LIST_STORE (object))
@@ -10023,7 +10038,7 @@ glade_gtk_store_string_from_value (GladeWidgetAdaptor *adaptor,
{
GladeColumnType *data = l->data;
g_string_append_printf (string, (g_list_next (l)) ? "%s:%s|" : "%s:%s",
- g_type_name (data->type), data->column_name);
+ data->type_name, data->column_name);
}
return g_string_free (string, FALSE);
}
@@ -10049,7 +10064,10 @@ glade_gtk_store_string_from_value (GladeWidgetAdaptor *adaptor,
{
data = iter->data;
- str = glade_utils_string_from_value (&data->value, fmt);
+ if (G_VALUE_TYPE (&data->value) != G_TYPE_POINTER)
+ str = glade_utils_string_from_value (&data->value, fmt);
+ else
+ str = g_strdup ("(null)");
is_last = !row->next && !iter->next;
g_string_append_printf (string, "%s[%d]:%s",
@@ -10105,7 +10123,7 @@ glade_gtk_store_write_columns (GladeWidget *widget,
column_node = glade_xml_node_new (context, GLADE_TAG_COLUMN);
glade_xml_node_append_child (columns_node, column_node);
glade_xml_node_set_property_string (column_node, GLADE_TAG_TYPE,
- g_type_name (data->type));
+ data->type_name);
}
if (!glade_xml_node_get_children (columns_node))
@@ -10149,9 +10167,13 @@ glade_gtk_store_write_data (GladeWidget *widget,
data = iter->data;
+ /* Skip inserializable data */
+ if (G_VALUE_TYPE (&data->value) == G_TYPE_POINTER)
+ continue;
+
string = glade_utils_string_from_value (&data->value,
glade_project_get_format (widget->project));
-
+
/* XXX Log error: data col j exceeds columns on row i */
if (!g_list_nth (columns, colnum))
break;
@@ -10246,7 +10268,7 @@ glade_gtk_store_read_columns (GladeWidget *widget, GladeXmlNode *node)
}
type = glade_xml_get_property_string_required (prop, GLADE_TAG_TYPE, NULL);
- data->type = g_type_from_name (type);
+ data->type_name = g_strdup (type);
data->column_name = column_name[0] ? g_strdup (column_name) : g_ascii_strdown (type, -1);
if (glade_name_context_has_name (context, data->column_name))
@@ -10315,28 +10337,37 @@ glade_gtk_store_read_data (GladeWidget *widget, GladeXmlNode *node)
continue;
column_type = list->data;
-
- /* XXX Do we need object properties to somehow work at load time here ??
- * should we be doing this part in "finished" ? ... todo thinkso...
- */
- value_str = glade_xml_get_content (col_node);
- value = glade_utils_value_from_string (column_type->type, value_str, widget->project, widget);
- g_free (value_str);
-
- data = glade_model_data_new (column_type->type, column_type->column_name);
-
- g_value_copy (value, &data->value);
- g_value_unset (value);
- g_free (value);
+
+ /* Ignore unloaded column types for the workspace */
+ if (g_type_from_name (column_type->type_name) != G_TYPE_INVALID)
+ {
+ /* XXX Do we need object properties to somehow work at load time here ??
+ * should we be doing this part in "finished" ? ... todo thinkso...
+ */
+ value_str = glade_xml_get_content (col_node);
+ value = glade_utils_value_from_string
+ (g_type_from_name (column_type->type_name), value_str, widget->project, widget);
+ g_free (value_str);
+
+ data = glade_model_data_new (g_type_from_name (column_type->type_name), column_type->column_name);
+
+ g_value_copy (value, &data->value);
+ g_value_unset (value);
+ g_free (value);
+ }
+ else
+ {
+ data = glade_model_data_new (G_TYPE_POINTER, column_type->column_name);
+ }
data->name = g_strdup (column_type->column_name);
data->i18n_translatable = glade_xml_get_property_boolean (col_node, GLADE_TAG_TRANSLATABLE, FALSE);
data->i18n_context = glade_xml_get_property_string (col_node, GLADE_TAG_CONTEXT);
data->i18n_comment = glade_xml_get_property_string (col_node, GLADE_TAG_COMMENT);
-
+
item = g_node_new (data);
g_node_append (row, item);
-
+
/* dont increment colnum on invalid xml tags... */
colnum++;
}
diff --git a/plugins/gtk+/glade-model-data.c b/plugins/gtk+/glade-model-data.c
index db94dec..4a45d64 100644
--- a/plugins/gtk+/glade-model-data.c
+++ b/plugins/gtk+/glade-model-data.c
@@ -36,6 +36,7 @@ GladeModelData *
glade_model_data_new (GType type, const gchar *column_name)
{
GladeModelData *data = g_new0 (GladeModelData, 1);
+
g_value_init (&data->value, type);
if (type == G_TYPE_STRING)
@@ -295,7 +296,7 @@ append_row (GNode *node, GList *columns)
for (list = columns; list; list = list->next)
{
column = list->data;
- data = glade_model_data_new (column->type, column->column_name);
+ data = glade_model_data_new (g_type_from_name (column->type_name), column->column_name);
g_node_append_data (row, data);
}
}
@@ -970,16 +971,12 @@ eprop_model_generate_column (GladeEditorProperty *eprop,
NULL);
}
- else if (type == G_TYPE_OBJECT || g_type_is_a (type, G_TYPE_OBJECT))
+ else /* All uneditable types at this point (currently we dont do object data here, TODO) */
{
- /* text renderer and object dialog (or raw text for pixbuf) */;
+ /* text renderer and object dialog (or raw text for pixbuf) */
renderer = gtk_cell_renderer_text_new ();
g_object_set (G_OBJECT (renderer), "editable", FALSE, NULL);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
- gtk_tree_view_column_set_attributes (column, renderer,
- "text", NUM_COLUMNS + colnum,
- NULL);
-
}
g_signal_connect (G_OBJECT (renderer), "editing-started",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]