Commit 2712e272 authored by Tristan Van Berkom's avatar Tristan Van Berkom

* 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.
parent b65dae9d
......@@ -18,6 +18,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
......
......@@ -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
......@@ -330,26 +370,6 @@ append_items (GladeEditorTable *table,
table->properties = g_list_reverse (table->properties);
}
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)
{
......
......@@ -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;
};
......
......@@ -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));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment