[gimp] app: show message when attempting to change layers while there is a floating sel.



commit 070e10eda77a868bfdde4457fe86f39178b2e18e
Author: Ell <ell_se yahoo com>
Date:   Tue Jan 1 09:10:06 2019 -0500

    app: show message when attempting to change layers while there is a floating sel.
    
    In GimpDrawableTreeView, show an error message when attempting to
    select a different drawable while the image has an active floating
    selection.  In GimpLayerTreeView, also blink the editor button-row
    when this happens, as a hint that the floating selection can be
    committed/canceled through the buttons (we already highlight the
    relevant ones.)

 app/widgets/gimpdrawabletreeview.c | 18 +++++++++++++++---
 app/widgets/gimplayertreeview.c    | 10 ++++++++++
 2 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/app/widgets/gimpdrawabletreeview.c b/app/widgets/gimpdrawabletreeview.c
index 5a394aac0b..5b17d7953a 100644
--- a/app/widgets/gimpdrawabletreeview.c
+++ b/app/widgets/gimpdrawabletreeview.c
@@ -28,6 +28,7 @@
 #include "widgets-types.h"
 
 #include "core/gimp.h"
+#include "core/gimpcontext.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpdrawable-edit.h"
 #include "core/gimpfilloptions.h"
@@ -167,16 +168,27 @@ gimp_drawable_tree_view_select_item (GimpContainerView *view,
                                      gpointer           insert_data)
 {
   GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (view);
+  GimpImage        *image     = gimp_item_tree_view_get_image (item_view);
   gboolean          success   = TRUE;
 
-  if (gimp_item_tree_view_get_image (item_view))
+  if (image)
     {
-      GimpLayer *floating_sel =
-        gimp_image_get_floating_selection (gimp_item_tree_view_get_image (item_view));
+      GimpLayer *floating_sel = gimp_image_get_floating_selection (image);
 
       success = (item         == NULL ||
                  floating_sel == NULL ||
                  item         == GIMP_VIEWABLE (floating_sel));
+
+      if (! success)
+        {
+          Gimp        *gimp    = image->gimp;
+          GimpContext *context = gimp_get_user_context (gimp);
+          GObject     *display = gimp_context_get_display (context);
+
+          gimp_message_literal (gimp, display, GIMP_MESSAGE_WARNING,
+                                _("Cannot select item while a floating "
+                                  "selection is active."));
+        }
     }
 
   if (success)
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index 0c16395bad..cfd97cf5e9 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -578,6 +578,16 @@ gimp_layer_tree_view_select_item (GimpContainerView *view,
         }
     }
 
+  if (! success)
+    {
+      GimpEditor *editor = GIMP_EDITOR (view);
+
+      /* currently, select_item() only ever fails when there is a floating
+       * selection, which can be committed/canceled through the editor buttons.
+       */
+      gimp_widget_blink (GTK_WIDGET (gimp_editor_get_button_box (editor)));
+    }
+
   return success;
 }
 


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