[glade3/glade-3-8] * gladeui/glade-inspector.c: - Avoid changing project selection when selection is cleared, selec
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3/glade-3-8] * gladeui/glade-inspector.c: - Avoid changing project selection when selection is cleared, selec
- Date: Thu, 16 Dec 2010 16:18:57 +0000 (UTC)
commit 94b97080393cac07fcfcc8786aa2617e98efac13
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Fri Dec 17 01:23:47 2010 +0900
* gladeui/glade-inspector.c:
- Avoid changing project selection when selection is cleared, selection get's cleared
when the user changes a widget name and a filter is applied (removing the entry from
the filtered model), avoiding syncing project selection avoids making the editor disappear
when the user changes a widget name (fixes bug 604322).
- Also plugged some leaked objects retrieved by gtk_tree_model_get().
* gladeui/glade-editor-table.c: Fire a warning when entry is edited with no widget
loaded, also change the ->loading flag strategy for blocking signal emission instead.
ChangeLog | 10 +++++
gladeui/glade-editor-table.c | 76 ++++++++++++++++++++++++++---------------
gladeui/glade-editor-table.h | 3 --
gladeui/glade-inspector.c | 38 ++++++++++++++++----
4 files changed, 88 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bb25796..b100df5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,6 +16,16 @@
* plugins/gtk+/glade-gtk.c: Set added treeviewcolumns to fixed sizing mode if the
treeview is set to use fixed height mode (closing bug 596480).
+ * gladeui/glade-inspector.c:
+ - Avoid changing project selection when selection is cleared, selection get's cleared
+ when the user changes a widget name and a filter is applied (removing the entry from
+ the filtered model), avoiding syncing project selection avoids making the editor disappear
+ when the user changes a widget name (fixes bug 604322).
+ - Also plugged some leaked objects retrieved by gtk_tree_model_get().
+
+ * gladeui/glade-editor-table.c: Fire a warning when entry is edited with no widget
+ loaded, also change the ->loading flag strategy for blocking signal emission instead.
+
2010-12-15 Tristan Van Berkom <tristanvb openismus com>
* gladeui/glade-project.c: Cleanup glade_project_remove_object(), make sure row_deleted is
diff --git a/gladeui/glade-editor-table.c b/gladeui/glade-editor-table.c
index 5d12478..8fae807 100644
--- a/gladeui/glade-editor-table.c
+++ b/gladeui/glade-editor-table.c
@@ -37,6 +37,20 @@ G_DEFINE_TYPE_WITH_CODE (GladeEditorTable, glade_editor_table, GTK_TYPE_TABLE,
G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE,
glade_editor_table_editable_init));
+
+#define BLOCK_NAME_ENTRY_CB(table) \
+ do { if (table->name_entry) \
+ g_signal_handlers_block_by_func (G_OBJECT (table->name_entry), \
+ G_CALLBACK (widget_name_edited), table); \
+ } while (0);
+
+#define UNBLOCK_NAME_ENTRY_CB(table) \
+ do { if (table->name_entry) \
+ g_signal_handlers_unblock_by_func (G_OBJECT (table->name_entry), \
+ G_CALLBACK (widget_name_edited), table); \
+ } while (0);
+
+
static void
glade_editor_table_class_init (GladeEditorTableClass *klass)
{
@@ -107,6 +121,29 @@ glade_editor_table_grab_focus (GtkWidget *widget)
GTK_WIDGET_CLASS (glade_editor_table_parent_class)->grab_focus (widget);
}
+static void
+widget_name_edited (GtkWidget *editable, GladeEditorTable *table)
+{
+ GladeWidget *widget;
+ gchar *new_name;
+
+ g_return_if_fail (GTK_IS_EDITABLE (editable));
+ g_return_if_fail (GLADE_IS_EDITOR_TABLE (table));
+
+ if (table->loaded_widget == NULL)
+ {
+ g_warning ("Name entry edited with no loaded widget in editor %p!\n",
+ table);
+ return;
+ }
+
+ widget = table->loaded_widget;
+ new_name = gtk_editable_get_chars (GTK_EDITABLE (editable), 0, -1);
+
+ if (glade_project_available_widget_name (widget->project, widget, new_name))
+ glade_command_set_name (widget, new_name);
+ g_free (new_name);
+}
static void
widget_name_changed (GladeWidget *widget,
@@ -116,10 +153,12 @@ widget_name_changed (GladeWidget *widget,
if (!gtk_widget_get_mapped (GTK_WIDGET (table)))
return;
- table->loading = TRUE;
if (table->name_entry)
+ {
+ BLOCK_NAME_ENTRY_CB (table);
gtk_entry_set_text (GTK_ENTRY (table->name_entry), table->loaded_widget->name);
- table->loading = FALSE;
+ UNBLOCK_NAME_ENTRY_CB (table);
+ }
}
@@ -129,6 +168,8 @@ widget_finalized (GladeEditorTable *table,
{
table->loaded_widget = NULL;
+ g_warning ("Finalized widget in editor %p\n", table);
+
glade_editable_load (GLADE_EDITABLE (table), NULL);
}
@@ -142,12 +183,9 @@ glade_editor_table_load (GladeEditable *editable,
GList *list;
/* abort mission */
- if ((!table->loaded_widget && !widget) ||
- (table->loaded_widget && table->loaded_widget == widget))
+ if (table->loaded_widget == widget)
return;
- table->loading = TRUE;
-
if (table->loaded_widget)
{
g_signal_handlers_disconnect_by_func (G_OBJECT (table->loaded_widget),
@@ -161,6 +199,8 @@ glade_editor_table_load (GladeEditable *editable,
table->loaded_widget = widget;
+ BLOCK_NAME_ENTRY_CB (table);
+
if (table->loaded_widget)
{
g_signal_connect (G_OBJECT (table->loaded_widget), "notify::name",
@@ -178,14 +218,14 @@ glade_editor_table_load (GladeEditable *editable,
else if (table->name_entry)
gtk_entry_set_text (GTK_ENTRY (table->name_entry), "");
+ UNBLOCK_NAME_ENTRY_CB (table);
+
/* Sync up properties, even if widget is NULL */
for (list = table->properties; list; list = list->next)
{
property = list->data;
glade_editor_property_load_by_widget (property, widget);
}
-
- table->loading = FALSE;
}
static void
@@ -331,26 +371,6 @@ append_items (GladeEditorTable *table,
}
static void
-widget_name_edited (GtkWidget *editable, GladeEditorTable *table)
-{
- GladeWidget *widget;
- gchar *new_name;
-
- g_return_if_fail (GTK_IS_EDITABLE (editable));
- g_return_if_fail (GLADE_IS_EDITOR_TABLE (table));
-
- if (table->loading) return;
-
- widget = table->loaded_widget;
- new_name = gtk_editable_get_chars (GTK_EDITABLE (editable), 0, -1);
-
- if (glade_project_available_widget_name (widget->project, widget, new_name))
- glade_command_set_name (widget, new_name);
- g_free (new_name);
-}
-
-
-static void
append_name_field (GladeEditorTable *table)
{
gchar *text = _("The Object's name");
diff --git a/gladeui/glade-editor-table.h b/gladeui/glade-editor-table.h
index 1f08d30..c32d9d5 100644
--- a/gladeui/glade-editor-table.h
+++ b/gladeui/glade-editor-table.h
@@ -69,9 +69,6 @@ struct _GladeEditorTable
* the general tab, a packing tab or the query popup ?
*/
- gboolean loading; /* Avoid recursion while loading values into widgets
- */
-
gint rows;
};
diff --git a/gladeui/glade-inspector.c b/gladeui/glade-inspector.c
index 5daaec5..6dff168 100644
--- a/gladeui/glade-inspector.c
+++ b/gladeui/glade-inspector.c
@@ -578,30 +578,50 @@ static void
selection_foreach_func (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
- gpointer data)
+ GList **selection)
{
GObject* object;
gtk_tree_model_get (model, iter, GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object, -1);
if (object)
- glade_app_selection_add (object, FALSE);
+ {
+ *selection = g_list_prepend (*selection, object);
+ g_object_unref (object);
+ }
}
static void
selection_changed_cb (GtkTreeSelection *selection,
GladeInspector *inspector)
{
+ GList *sel = NULL, *l;
+
+ gtk_tree_selection_selected_foreach (selection,
+ (GtkTreeSelectionForeachFunc)selection_foreach_func,
+ &sel);
+
+ /* We dont modify the project selection for a change that
+ * leaves us with no selection.
+ *
+ * This is typically because the user is changing the name
+ * of a widget and the filter is active, the new name causes
+ * the row to go out of the model and the selection to be
+ * cleared, if we clear the selection we remove the editor
+ * that the user is trying to type into.
+ */
+ if (!sel)
+ return;
+
g_signal_handlers_block_by_func (inspector->priv->project,
G_CALLBACK (project_selection_changed_cb),
inspector);
-
+
glade_app_selection_clear (FALSE);
-
- gtk_tree_selection_selected_foreach (selection,
- selection_foreach_func,
- inspector);
+ for (l = sel; l; l = l->next)
+ glade_app_selection_add (G_OBJECT (l->data), FALSE);
glade_app_selection_changed ();
+ g_list_free (sel);
g_signal_handlers_unblock_by_func (inspector->priv->project,
G_CALLBACK (project_selection_changed_cb),
@@ -648,7 +668,8 @@ button_press_cb (GtkWidget *widget,
GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object, -1);
if (widget != NULL)
- glade_popup_widget_pop (glade_widget_get_from_gobject (object), event, TRUE);
+ glade_popup_widget_pop (glade_widget_get_from_gobject (object),
+ event, TRUE);
else
glade_popup_simple_pop (event);
@@ -864,6 +885,7 @@ glade_inspector_get_selected_items (GladeInspector *inspector)
gtk_tree_model_get (GTK_TREE_MODEL (priv->project), &iter,
GLADE_PROJECT_MODEL_COLUMN_OBJECT, &object, -1);
+ g_object_unref (object);
items = g_list_prepend (items, glade_widget_get_from_gobject (object));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]