[gimp/wip/Jehan/layers-dockable-refresh: 13/69] app: blink the lock cell when failing to switch visibility (eye).




commit abf15feaed51461baedb8c17a69d3153a6e745c9
Author: Jehan <jehan girinstud io>
Date:   Tue Feb 9 16:49:04 2021 +0100

    app: blink the lock cell when failing to switch visibility (eye).

 app/core/gimpitem.c            | 14 ++++++++++----
 app/core/gimpitem.h            |  2 +-
 app/tools/gimptools-utils.c    | 23 +----------------------
 app/widgets/gimpitemtreeview.c | 33 ++++++++++++++++++++++++++++++++-
 app/widgets/gimpitemtreeview.h |  2 ++
 5 files changed, 46 insertions(+), 28 deletions(-)
---
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 98257f33a6..2080b4d322 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -2310,18 +2310,22 @@ gimp_item_parasite_list (GimpItem *item,
   return list;
 }
 
-void
+gboolean
 gimp_item_set_visible (GimpItem *item,
                        gboolean  visible,
                        gboolean  push_undo)
 {
-  g_return_if_fail (GIMP_IS_ITEM (item));
+  g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
 
   visible = visible ? TRUE : FALSE;
 
-  if (gimp_item_get_visible (item) != visible &&
-      ! gimp_item_is_visibility_locked (item))
+  if (gimp_item_get_visible (item) != visible)
     {
+      if (gimp_item_is_visibility_locked (item))
+        {
+          return FALSE;
+        }
+
       if (push_undo && gimp_item_is_attached (item))
         {
           GimpImage *image = gimp_item_get_image (item);
@@ -2339,6 +2343,8 @@ gimp_item_set_visible (GimpItem *item,
 
       g_object_notify_by_pspec (G_OBJECT (item), gimp_item_props[PROP_VISIBLE]);
     }
+
+  return TRUE;
 }
 
 gboolean
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index 2c9794c9ed..a12a1487c2 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -355,7 +355,7 @@ const GimpParasite * gimp_item_parasite_find (GimpItem           *item,
 gchar        ** gimp_item_parasite_list      (GimpItem           *item,
                                               gint               *count);
 
-void            gimp_item_set_visible        (GimpItem           *item,
+gboolean        gimp_item_set_visible        (GimpItem           *item,
                                               gboolean            visible,
                                               gboolean            push_undo);
 gboolean        gimp_item_get_visible        (GimpItem           *item);
diff --git a/app/tools/gimptools-utils.c b/app/tools/gimptools-utils.c
index db078c48bf..85f24acf20 100644
--- a/app/tools/gimptools-utils.c
+++ b/app/tools/gimptools-utils.c
@@ -50,10 +50,6 @@ gimp_tools_blink_lock_box (Gimp     *gimp,
   GdkMonitor       *monitor;
   const gchar      *identifier;
 
-  GtkTreeIter      *iter;
-  GtkTreePath      *path;
-  GdkRectangle      rect;
-
   g_return_if_fail (GIMP_IS_GIMP (gimp));
   g_return_if_fail (GIMP_IS_ITEM (item));
 
@@ -79,22 +75,5 @@ gimp_tools_blink_lock_box (Gimp     *gimp,
     return;
 
   view = GIMP_ITEM_TREE_VIEW (gtk_bin_get_child (GTK_BIN (dockable)));
-
-  /* Find the item in the tree view. */
-  iter = gimp_container_view_lookup (GIMP_CONTAINER_VIEW (view),
-                                     (GimpViewable *) item);
-  path = gtk_tree_model_get_path (GIMP_CONTAINER_TREE_VIEW (view)->model, iter);
-
-  /* Scroll dockable to make sure the cell is showing. */
-  gtk_tree_view_scroll_to_cell (GIMP_CONTAINER_TREE_VIEW (view)->view, path,
-                                gtk_tree_view_get_column (GIMP_CONTAINER_TREE_VIEW (view)->view, 1),
-                                FALSE, 0.0, 0.0);
-
-  /* Now blink the lock cell of the specified item. */
-  gtk_tree_view_get_cell_area (GIMP_CONTAINER_TREE_VIEW (view)->view, path,
-                               gtk_tree_view_get_column (GIMP_CONTAINER_TREE_VIEW (view)->view, 1),
-                               &rect);
-  gimp_widget_blink_rect (GTK_WIDGET (GIMP_CONTAINER_TREE_VIEW (view)->view), &rect);
-
-  gtk_tree_path_free (path);
+  gimp_item_tree_view_blink_lock (view, item);
 }
diff --git a/app/widgets/gimpitemtreeview.c b/app/widgets/gimpitemtreeview.c
index 75bd173814..641bcdb4a3 100644
--- a/app/widgets/gimpitemtreeview.c
+++ b/app/widgets/gimpitemtreeview.c
@@ -858,6 +858,36 @@ gimp_item_tree_view_add_lock (GimpItemTreeView *view,
   gtk_widget_show (image);
 }
 
+void
+gimp_item_tree_view_blink_lock (GimpItemTreeView *view,
+                                GimpItem         *item)
+{
+  GtkTreeIter  *iter;
+  GtkTreePath  *path;
+  GdkRectangle  rect;
+
+  g_return_if_fail (GIMP_IS_ITEM_TREE_VIEW (view));
+  g_return_if_fail (GIMP_IS_ITEM (item));
+
+  /* Find the item in the tree view. */
+  iter = gimp_container_view_lookup (GIMP_CONTAINER_VIEW (view),
+                                     (GimpViewable *) item);
+  path = gtk_tree_model_get_path (GIMP_CONTAINER_TREE_VIEW (view)->model, iter);
+
+  /* Scroll dockable to make sure the cell is showing. */
+  gtk_tree_view_scroll_to_cell (GIMP_CONTAINER_TREE_VIEW (view)->view, path,
+                                gtk_tree_view_get_column (GIMP_CONTAINER_TREE_VIEW (view)->view, 1),
+                                FALSE, 0.0, 0.0);
+
+  /* Now blink the lock cell of the specified item. */
+  gtk_tree_view_get_cell_area (GIMP_CONTAINER_TREE_VIEW (view)->view, path,
+                               gtk_tree_view_get_column (GIMP_CONTAINER_TREE_VIEW (view)->view, 1),
+                               &rect);
+  gimp_widget_blink_rect (GTK_WIDGET (GIMP_CONTAINER_TREE_VIEW (view)->view), &rect);
+
+  gtk_tree_path_free (path);
+}
+
 GtkWidget *
 gimp_item_tree_view_get_new_button (GimpItemTreeView *view)
 {
@@ -1672,7 +1702,8 @@ gimp_item_tree_view_eye_clicked (GtkCellRendererToggle *toggle,
           if (undo && GIMP_ITEM_UNDO (undo)->item == item)
             push_undo = FALSE;
 
-          gimp_item_set_visible (item, ! active, push_undo);
+          if (! gimp_item_set_visible (item, ! active, push_undo))
+            gimp_item_tree_view_blink_lock (view, item);
 
           if (!push_undo)
             gimp_undo_refresh_preview (undo, context);
diff --git a/app/widgets/gimpitemtreeview.h b/app/widgets/gimpitemtreeview.h
index 680ac056a3..05319a7763 100644
--- a/app/widgets/gimpitemtreeview.h
+++ b/app/widgets/gimpitemtreeview.h
@@ -149,6 +149,8 @@ void        gimp_item_tree_view_add_lock          (GimpItemTreeView *view,
                                                    const gchar      *undo_unlock_label,
                                                    const gchar      *tooltip,
                                                    const gchar      *help_id);
+void        gimp_item_tree_view_blink_lock        (GimpItemTreeView *view,
+                                                   GimpItem         *item);
 
 GtkWidget * gimp_item_tree_view_get_new_button    (GimpItemTreeView *view);
 GtkWidget * gimp_item_tree_view_get_delete_button (GimpItemTreeView *view);


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