Commit 8c95eb1a authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/widgets/gimpdatafactoryview.c

2004-12-10  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpdatafactoryview.c
	(gimp_data_factory_view_tree_name_edited)
	* app/widgets/gimpitemtreeview.c
	(gimp_item_tree_view_name_edited)
	* app/widgets/gimptemplateview.c
	(gimp_template_view_tree_name_edited): call gimp_object_set_name()
	or gimp_item_rename() only if the item's name has actually changed
	and restore the old text otherwise. Fixes one instance of "name is
	not updated correctly after editing" for which I blamed GTK+ in
	bug #145463 :-) The other instances should be fixed in GTK+ HEAD
	and are imho unfixable with GTK+ 2.4.
parent 4ee9b210
2004-12-10 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdatafactoryview.c
(gimp_data_factory_view_tree_name_edited)
* app/widgets/gimpitemtreeview.c
(gimp_item_tree_view_name_edited)
* app/widgets/gimptemplateview.c
(gimp_template_view_tree_name_edited): call gimp_object_set_name()
or gimp_item_rename() only if the item's name has actually changed
and restore the old text otherwise. Fixes one instance of "name is
not updated correctly after editing" for which I blamed GTK+ in
bug #145463 :-) The other instances should be fixed in GTK+ HEAD
and are imho unfixable with GTK+ 2.4.
2004-12-10 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontainertreeview.c
......
......@@ -281,6 +281,7 @@ gimp_data_factory_view_tree_name_edited (GtkCellRendererText *cell,
{
GimpViewRenderer *renderer;
GimpData *data;
const gchar *old_name;
gtk_tree_model_get (tree_view->model, &iter,
tree_view->model_column_renderer, &renderer,
......@@ -288,7 +289,12 @@ gimp_data_factory_view_tree_name_edited (GtkCellRendererText *cell,
data = GIMP_DATA (renderer->viewable);
if (data->writable)
old_name = gimp_object_get_name (GIMP_OBJECT (data));
if (! old_name) old_name = "";
if (! new_name) new_name = "";
if (data->writable && strcmp (old_name, new_name))
{
gimp_object_set_name (GIMP_OBJECT (data), new_name);
}
......
......@@ -120,7 +120,7 @@ static void gimp_item_tree_view_size_changed (GimpImage *gimage,
static void gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
const gchar *path,
const gchar *name,
const gchar *new_name,
GimpItemTreeView *view);
static void gimp_item_tree_view_visible_changed (GimpItem *item,
......@@ -848,7 +848,7 @@ gimp_item_tree_view_size_changed (GimpImage *gimage,
static void
gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
const gchar *path_str,
const gchar *new_text,
const gchar *new_name,
GimpItemTreeView *view)
{
GimpContainerTreeView *tree_view;
......@@ -863,6 +863,7 @@ gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
{
GimpViewRenderer *renderer;
GimpItem *item;
const gchar *old_name;
gtk_tree_model_get (tree_view->model, &iter,
tree_view->model_column_renderer, &renderer,
......@@ -870,7 +871,13 @@ gimp_item_tree_view_name_edited (GtkCellRendererText *cell,
item = GIMP_ITEM (renderer->viewable);
if (gimp_item_rename (item, new_text))
old_name = gimp_object_get_name (GIMP_OBJECT (item));
if (! old_name) old_name = "";
if (! new_name) new_name = "";
if (strcmp (old_name, new_name) &&
gimp_item_rename (item, new_name))
{
gimp_image_flush (gimp_item_get_image (item));
}
......
......@@ -229,6 +229,7 @@ gimp_template_view_tree_name_edited (GtkCellRendererText *cell,
{
GimpViewRenderer *renderer;
GimpObject *object;
const gchar *old_name;
gtk_tree_model_get (tree_view->model, &iter,
tree_view->model_column_renderer, &renderer,
......@@ -236,7 +237,24 @@ gimp_template_view_tree_name_edited (GtkCellRendererText *cell,
object = GIMP_OBJECT (renderer->viewable);
gimp_object_set_name (object, new_name);
old_name = gimp_object_get_name (object);
if (! old_name) old_name = "";
if (! new_name) new_name = "";
if (strcmp (old_name, new_name))
{
gimp_object_set_name (object, new_name);
}
else
{
gchar *name = gimp_viewable_get_description (renderer->viewable, NULL);
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), &iter,
tree_view->model_column_name, name,
-1);
g_free (name);
}
g_object_unref (renderer);
}
......
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