[gimp] Bug 790328 - Buffer dialog should support renaming of entries
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 790328 - Buffer dialog should support renaming of entries
- Date: Tue, 14 Nov 2017 19:38:18 +0000 (UTC)
commit 7aadf34a237e7979406b19e4c8857af66065f755
Author: Michael Natterer <mitch gimp org>
Date: Tue Nov 14 20:37:19 2017 +0100
Bug 790328 - Buffer dialog should support renaming of entries
Enable name editing in GimpBufferView. Evil code duplication for now,
to be refactored...
app/widgets/gimpbufferview.c | 69 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpbufferview.c b/app/widgets/gimpbufferview.c
index 3eefb7c..3567e11 100644
--- a/app/widgets/gimpbufferview.c
+++ b/app/widgets/gimpbufferview.c
@@ -33,6 +33,8 @@
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
+#include "gimpcontainertreestore.h"
+#include "gimpcontainertreeview.h"
#include "gimpcontainerview.h"
#include "gimpbufferview.h"
#include "gimpdnd.h"
@@ -54,6 +56,10 @@ static void gimp_buffer_view_set_context (GimpDocked *docked,
static void gimp_buffer_view_activate_item (GimpContainerEditor *editor,
GimpViewable *viewable);
+static void gimp_buffer_view_tree_name_edited (GtkCellRendererText *cell,
+ const gchar *path_str,
+ const gchar *new_name,
+ GimpBufferView *view);
static void gimp_buffer_view_clipboard_changed (Gimp *gimp,
GimpBufferView *buffer_view);
@@ -145,6 +151,17 @@ gimp_buffer_view_new (GimpViewType view_type,
editor = GIMP_CONTAINER_EDITOR (buffer_view);
+ if (GIMP_IS_CONTAINER_TREE_VIEW (editor->view))
+ {
+ GimpContainerTreeView *tree_view;
+
+ tree_view = GIMP_CONTAINER_TREE_VIEW (editor->view);
+
+ gimp_container_tree_view_connect_name_edited (tree_view,
+ G_CALLBACK (gimp_buffer_view_tree_name_edited),
+ buffer_view);
+ }
+
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (editor), frame, FALSE, FALSE, 0);
@@ -258,6 +275,58 @@ gimp_buffer_view_activate_item (GimpContainerEditor *editor,
}
static void
+gimp_buffer_view_tree_name_edited (GtkCellRendererText *cell,
+ const gchar *path_str,
+ const gchar *new_name,
+ GimpBufferView *view)
+{
+ GimpContainerTreeView *tree_view;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ tree_view = GIMP_CONTAINER_TREE_VIEW (GIMP_CONTAINER_EDITOR (view)->view);
+
+ path = gtk_tree_path_new_from_string (path_str);
+
+ if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
+ {
+ GimpViewRenderer *renderer;
+ GimpObject *object;
+ const gchar *old_name;
+
+ gtk_tree_model_get (tree_view->model, &iter,
+ GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &renderer,
+ -1);
+
+ object = GIMP_OBJECT (renderer->viewable);
+
+ 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_tree_store_set (GTK_TREE_STORE (tree_view->model), &iter,
+ GIMP_CONTAINER_TREE_STORE_COLUMN_NAME, name,
+ -1);
+ g_free (name);
+ }
+
+ g_object_unref (renderer);
+ }
+
+ gtk_tree_path_free (path);
+}
+
+static void
gimp_buffer_view_clipboard_changed (Gimp *gimp,
GimpBufferView *buffer_view)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]