Commit 481aceb8 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Moved widget name policing to gladeproject.


	* gladeui/glade-widget.c, gladeui/glade-project.c: Moved
	  widget name policing to gladeproject.

	* gladeui/glade-editor.c: Dont commit name values if name
	  already exists in the project.


svn path=/trunk/; revision=1739
parent fb149e09
......@@ -14,6 +14,14 @@
- Reintroducing GtkScaleButton and GtkVolumeButton in trunk.
- Reintroducing icon-theme dialog in trunk.
* gladeui/glade-id-allocator.c: Avoid crashing on id 0.
* gladeui/glade-widget.c, gladeui/glade-project.c: Moved
widget name policing to gladeproject.
* gladeui/glade-editor.c: Dont commit name values if name
already exists in the project.
2008-03-09 Tristan Van Berkom <tvb@gnome.org>
* NEWS, configure.ac: Rolling 3.4.2
......
......@@ -412,7 +412,8 @@ glade_editor_widget_name_changed (GtkWidget *editable, GladeEditor *editor)
widget = editor->loaded_widget;
new_name = gtk_editable_get_chars (GTK_EDITABLE (editable), 0, -1);
glade_command_set_name (widget, new_name);
if (!glade_project_get_widget_by_name (widget->project, new_name))
glade_command_set_name (widget, new_name);
g_free (new_name);
}
......
......@@ -154,7 +154,7 @@ glade_id_allocator_release (GladeIDAllocator *allocator,
{
g_return_if_fail (allocator != NULL);
id--;
id = id > 0 ? id - 1 : 0;
allocator->data[id >> 5] |= 1 << (id & 31);
}
......
......@@ -937,6 +937,7 @@ glade_project_add_object (GladeProject *project,
if (GLADE_IS_PLACEHOLDER (object))
return;
/* Only widgets accounted for in the catalog or widgets declared
* in the plugin with glade_widget_new_for_internal_child () are
* usefull in the project.
......@@ -947,6 +948,16 @@ glade_project_add_object (GladeProject *project,
/* Dont add widgets that are already in the project */
if (glade_project_has_object (project, object))
return;
/* Police widget names here (just rename them on the way in the project)
*/
if (glade_project_get_widget_by_name (project, gwidget->name) != NULL)
{
gchar *name = glade_project_new_widget_name (project, gwidget->name);
glade_widget_set_name (gwidget, name);
g_free (name);
}
/* Code body starts here */
reentrancy_count++;
......@@ -1127,10 +1138,28 @@ glade_project_remove_object (GladeProject *project, GObject *object)
void
glade_project_widget_name_changed (GladeProject *project, GladeWidget *widget, const char *old_name)
{
GladeWidget *iter;
GList *l;
g_return_if_fail (GLADE_IS_PROJECT (project));
g_return_if_fail (GLADE_IS_WIDGET (widget));
glade_project_release_widget_name (project, widget, old_name);
/* Police widget names here (just rename them on the way in the project)
*/
for (l = project->priv->objects; l; l = l->next)
{
iter = glade_widget_get_from_gobject (l->data);
if (widget != iter &&
!strcmp (widget->name, iter->name))
{
gchar *name = glade_project_new_widget_name (project, widget->name);
glade_widget_set_name (widget, name);
g_free (name);
}
}
g_signal_emit (G_OBJECT (project),
glade_project_signals [WIDGET_NAME_CHANGED],
......
......@@ -1348,14 +1348,7 @@ glade_widget_dup_internal (GladeWidget *parent,
}
else
{
gchar *name;
if (exact)
name = g_strdup (template_widget->name);
else
name = glade_project_new_widget_name (template_widget->project,
template_widget->name);
gchar *name = g_strdup (template_widget->name);
gwidget = glade_widget_adaptor_create_widget
(template_widget->adaptor, FALSE,
"name", name,
......@@ -2172,7 +2165,7 @@ glade_widget_show (GladeWidget *widget)
GtkWidget *layout;
g_return_if_fail (GLADE_IS_WIDGET (widget));
/* Position window at saved coordinates or in the center */
if (GTK_IS_WINDOW (widget->object) && glade_widget_embed (widget))
{
......@@ -2613,8 +2606,17 @@ glade_widget_set_name (GladeWidget *widget, const gchar *name)
{
g_return_if_fail (GLADE_IS_WIDGET (widget));
if (widget->name != name) {
if (widget->project &&
glade_project_get_widget_by_name (widget->project, name))
{
/* print a warning ? */
return;
}
if (widget->name)
g_free (widget->name);
widget->name = g_strdup (name);
g_object_notify (G_OBJECT (widget), "name");
}
......
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