[gimp] app: source tools should not be choosable for bucket fill stroke.



commit 08c3bb407be3d528aaf8059c02f01fe980976a8d
Author: Jehan <jehan girinstud io>
Date:   Thu Mar 3 18:36:23 2022 +0100

    app: source tools should not be choosable for bucket fill stroke.
    
    Since we can't select a source, the source tools would fail stroking
    with an error. It was usable when stroking a path or selection as we
    can have the source tool started while running these. Since only one
    tool can be started at once, this is not possible when running bucket
    fill tool (it would require some logics change on tools).
    
    This change has 2 parts: add an "insensitive" column to
    GimpContainerComboBox (allowing to mark some cells as insensitive), then
    use this new attribute in the GimpBucketFillOptions to show all source
    tools as insensitive.

 app/tools/gimpbucketfilloptions.c   | 38 +++++++++++++++++++++++++++++++++++++
 app/widgets/gimpcontainercombobox.c |  4 ++++
 2 files changed, 42 insertions(+)
---
diff --git a/app/tools/gimpbucketfilloptions.c b/app/tools/gimpbucketfilloptions.c
index 9fdb094a80..a3c9f23c24 100644
--- a/app/tools/gimpbucketfilloptions.c
+++ b/app/tools/gimpbucketfilloptions.c
@@ -38,10 +38,14 @@
 
 #include "display/gimpdisplay.h"
 
+#include "paint/gimpsourceoptions.h"
+
 #include "widgets/gimpcontainercombobox.h"
+#include "widgets/gimpcontainertreestore.h"
 #include "widgets/gimpcontainerview.h"
 #include "widgets/gimppropwidgets.h"
 #include "widgets/gimpviewablebox.h"
+#include "widgets/gimpviewrenderer.h"
 #include "widgets/gimpwidgets-utils.h"
 
 #include "gimpbucketfilloptions.h"
@@ -101,6 +105,11 @@ static gboolean
                                                           GList                 *items,
                                                           GList                 *paths,
                                                           GimpBucketFillOptions *options);
+static void  gimp_bucket_fill_options_tool_cell_renderer (GtkCellLayout         *layout,
+                                                          GtkCellRenderer       *cell,
+                                                          GtkTreeModel          *model,
+                                                          GtkTreeIter           *iter,
+                                                          gpointer               data);
 
 static void   gimp_bucket_fill_options_reset             (GimpConfig            *config);
 static void   gimp_bucket_fill_options_update_area       (GimpBucketFillOptions *options);
@@ -473,6 +482,31 @@ gimp_bucket_fill_options_select_stroke_tool (GimpContainerView     *view,
   return TRUE;
 }
 
+static void
+gimp_bucket_fill_options_tool_cell_renderer (GtkCellLayout   *layout,
+                                             GtkCellRenderer *cell,
+                                             GtkTreeModel    *model,
+                                             GtkTreeIter     *iter,
+                                             gpointer         data)
+{
+  GimpViewRenderer *renderer;
+
+  gtk_tree_model_get (model, iter,
+                      GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &renderer,
+                      -1);
+
+  if (renderer->viewable)
+    {
+      GimpPaintInfo *info = GIMP_PAINT_INFO (renderer->viewable);
+
+      if (GIMP_IS_SOURCE_OPTIONS (info->paint_options))
+        gtk_tree_store_set (GTK_TREE_STORE (model), iter,
+                            GIMP_CONTAINER_TREE_STORE_COLUMN_NAME_SENSITIVE, FALSE,
+                            -1);
+    }
+  g_object_unref (renderer);
+}
+
 static void
 gimp_bucket_fill_options_reset (GimpConfig *config)
 {
@@ -714,6 +748,10 @@ gimp_bucket_fill_options_gui (GimpToolOptions *tool_options)
   widget = gimp_container_combo_box_new (gimp->paint_info_list,
                                          GIMP_CONTEXT (options->stroke_options),
                                          16, 0);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (widget),
+                                      GIMP_CONTAINER_COMBO_BOX (widget)->viewable_renderer,
+                                      gimp_bucket_fill_options_tool_cell_renderer,
+                                      options, NULL);
   g_signal_connect (widget, "select-items",
                     G_CALLBACK (gimp_bucket_fill_options_select_stroke_tool),
                     options);
diff --git a/app/widgets/gimpcontainercombobox.c b/app/widgets/gimpcontainercombobox.c
index f04e31d092..a0c0c69447 100644
--- a/app/widgets/gimpcontainercombobox.c
+++ b/app/widgets/gimpcontainercombobox.c
@@ -162,6 +162,8 @@ gimp_container_combo_box_init (GimpContainerComboBox *combo)
   gtk_cell_layout_set_attributes (layout, cell,
                                   "renderer",
                                   GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER,
+                                  "sensitive",
+                                  GIMP_CONTAINER_TREE_STORE_COLUMN_NAME_SENSITIVE,
                                   NULL);
 
   gimp_container_tree_store_add_renderer_cell (GIMP_CONTAINER_TREE_STORE (model),
@@ -174,6 +176,8 @@ gimp_container_combo_box_init (GimpContainerComboBox *combo)
   gtk_cell_layout_set_attributes (layout, cell,
                                   "text",
                                   GIMP_CONTAINER_TREE_STORE_COLUMN_NAME,
+                                  "sensitive",
+                                  GIMP_CONTAINER_TREE_STORE_COLUMN_NAME_SENSITIVE,
                                   NULL);
 
   combo->text_renderer = cell;


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