[gimp] Bug 750556 - validate a tree cell modification on focus out.



commit 0aae50cfe22de308462e6a824e6402f78b439b93
Author: Jehan <jehan girinstud io>
Date:   Thu Jun 11 19:33:58 2015 +0200

    Bug 750556 - validate a tree cell modification on focus out.
    
    For instance, modifying a layer and going directly to draw in the canvas
    should not cancel the layer name.
    You can still cancel a layer renaming in progress with ESC.

 app/widgets/gimpcontainertreeview.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index 25ece21..e8c7a5d 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -91,6 +91,9 @@ static void          gimp_container_tree_view_set_view_size     (GimpContainerVi
 
 static void          gimp_container_tree_view_real_edit_name    (GimpContainerTreeView       *tree_view);
 
+static gboolean      gimp_container_tree_view_edit_focus_out    (GtkWidget                   *widget,
+                                                                 GdkEvent                    *event,
+                                                                 gpointer                     user_data);
 static void          gimp_container_tree_view_name_started      (GtkCellRendererText         *cell,
                                                                  GtkCellEditable             *editable,
                                                                  const gchar                 *path_str,
@@ -852,6 +855,17 @@ gimp_container_tree_view_real_edit_name (GimpContainerTreeView *tree_view)
 
 /*  callbacks  */
 
+static gboolean
+gimp_container_tree_view_edit_focus_out (GtkWidget *widget,
+                                         GdkEvent  *event,
+                                         gpointer   user_data)
+{
+  /* When focusing out of a tree view, I want its content to be updated
+   * as though it had been activated. */
+  g_signal_emit_by_name (widget, "activate", 0);
+  return TRUE;
+}
+
 static void
 gimp_container_tree_view_name_started (GtkCellRendererText   *cell,
                                        GtkCellEditable       *editable,
@@ -863,6 +877,10 @@ gimp_container_tree_view_name_started (GtkCellRendererText   *cell,
 
   path = gtk_tree_path_new_from_string (path_str);
 
+  g_signal_connect (GTK_ENTRY (editable), "focus-out-event",
+                    G_CALLBACK (gimp_container_tree_view_edit_focus_out),
+                    tree_view);
+
   if (gtk_tree_model_get_iter (tree_view->model, &iter, path))
     {
       GimpViewRenderer *renderer;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]