[gimp] app: Add "Flood" select action



commit 71119d41c0e6df99094d8b15907283450007918b
Author: Ell <ell_se yahoo com>
Date:   Sun Jan 24 17:43:35 2016 +0000

    app: Add "Flood" select action
    
    and associated UI entries.
    
    This action applies the "gimp:flood" operation to the selection.

 app/actions/select-actions.c  |    7 +++++++
 app/actions/select-commands.c |   11 +++++++++++
 app/actions/select-commands.h |    2 ++
 app/core/gimpselection.c      |   11 +++++++++++
 app/widgets/gimphelp-ids.h    |    1 +
 menus/image-menu.xml.in       |    1 +
 menus/selection-menu.xml      |    1 +
 7 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/app/actions/select-actions.c b/app/actions/select-actions.c
index c1ba5d8..02af2af 100644
--- a/app/actions/select-actions.c
+++ b/app/actions/select-actions.c
@@ -101,6 +101,12 @@ static const GimpActionEntry select_actions[] =
     G_CALLBACK (select_border_cmd_callback),
     GIMP_HELP_SELECTION_BORDER },
 
+  { "select-flood", NULL,
+    NC_("select-action", "F_lood"), NULL,
+    NC_("select-action", "Level the selection's interior"),
+    G_CALLBACK (select_flood_cmd_callback),
+    GIMP_HELP_SELECTION_FLOOD },
+
   { "select-save", GIMP_STOCK_SELECTION_TO_CHANNEL,
     NC_("select-action", "Save to _Channel"), NULL,
     NC_("select-action", "Save the selection to a channel"),
@@ -169,6 +175,7 @@ select_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("select-shrink",  drawable && sel);
   SET_SENSITIVE ("select-grow",    drawable && sel);
   SET_SENSITIVE ("select-border",  drawable && sel);
+  SET_SENSITIVE ("select-flood",   drawable && sel);
 
   SET_SENSITIVE ("select-save",               drawable && !fs);
   SET_SENSITIVE ("select-stroke",             writable && !children && sel);
diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c
index e9999df..6f9aef8 100644
--- a/app/actions/select-commands.c
+++ b/app/actions/select-commands.c
@@ -308,6 +308,17 @@ select_border_cmd_callback (GtkAction *action,
 }
 
 void
+select_flood_cmd_callback (GtkAction *action,
+                           gpointer   data)
+{
+  GimpImage *image;
+  return_if_no_image (image, data);
+
+  gimp_channel_flood (gimp_image_get_mask (image), TRUE);
+  gimp_image_flush (image);
+}
+
+void
 select_save_cmd_callback (GtkAction *action,
                           gpointer   data)
 {
diff --git a/app/actions/select-commands.h b/app/actions/select-commands.h
index f70307c..f34bc7f 100644
--- a/app/actions/select-commands.h
+++ b/app/actions/select-commands.h
@@ -37,6 +37,8 @@ void   select_border_cmd_callback           (GtkAction *action,
                                              gpointer   data);
 void   select_grow_cmd_callback             (GtkAction *action,
                                              gpointer   data);
+void   select_flood_cmd_callback            (GtkAction *action,
+                                             gpointer   data);
 void   select_save_cmd_callback             (GtkAction *action,
                                              gpointer   data);
 void   select_stroke_cmd_callback           (GtkAction *action,
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index dc2a375..669f2fd 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -131,6 +131,8 @@ static void       gimp_selection_shrink        (GimpChannel         *channel,
                                                 gint                 radius_y,
                                                 gboolean             edge_lock,
                                                 gboolean             push_undo);
+static void       gimp_selection_flood         (GimpChannel         *channel,
+                                                gboolean             push_undo);
 
 
 G_DEFINE_TYPE (GimpSelection, gimp_selection, GIMP_TYPE_CHANNEL)
@@ -173,6 +175,7 @@ gimp_selection_class_init (GimpSelectionClass *klass)
   channel_class->border               = gimp_selection_border;
   channel_class->grow                 = gimp_selection_grow;
   channel_class->shrink               = gimp_selection_shrink;
+  channel_class->flood                = gimp_selection_flood;
 
   channel_class->feather_desc         = C_("undo-type", "Feather Selection");
   channel_class->sharpen_desc         = C_("undo-type", "Sharpen Selection");
@@ -182,6 +185,7 @@ gimp_selection_class_init (GimpSelectionClass *klass)
   channel_class->border_desc          = C_("undo-type", "Border Selection");
   channel_class->grow_desc            = C_("undo-type", "Grow Selection");
   channel_class->shrink_desc          = C_("undo-type", "Shrink Selection");
+  channel_class->flood_desc           = C_("undo-type", "Flood Selection");
 }
 
 static void
@@ -533,6 +537,13 @@ gimp_selection_shrink (GimpChannel *channel,
                                             push_undo);
 }
 
+static void
+gimp_selection_flood (GimpChannel *channel,
+                      gboolean     push_undo)
+{
+  GIMP_CHANNEL_CLASS (parent_class)->flood (channel, push_undo);
+}
+
 
 /*  public functions  */
 
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index 796e70f..1daccbf 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -74,6 +74,7 @@
 #define GIMP_HELP_SELECTION_SHRINK                "gimp-selection-shrink"
 #define GIMP_HELP_SELECTION_GROW                  "gimp-selection-grow"
 #define GIMP_HELP_SELECTION_BORDER                "gimp-selection-border"
+#define GIMP_HELP_SELECTION_FLOOD                 "gimp-selection-flood"
 #define GIMP_HELP_SELECTION_STROKE                "gimp-selection-stroke"
 #define GIMP_HELP_SELECTION_TO_CHANNEL            "gimp-selection-to-channel"
 #define GIMP_HELP_SELECTION_TO_PATH               "gimp-selection-to-path"
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index 9200840..037324c 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -243,6 +243,7 @@
         <menuitem action="select-shrink" />
         <menuitem action="select-grow" />
         <menuitem action="select-border" />
+        <menuitem action="select-flood" />
       </placeholder>
       <separator />
       <menuitem action="quick-mask-toggle" />
diff --git a/menus/selection-menu.xml b/menus/selection-menu.xml
index 3fb7e09..2ef3ece 100644
--- a/menus/selection-menu.xml
+++ b/menus/selection-menu.xml
@@ -15,6 +15,7 @@
       <menuitem action="select-shrink" />
       <menuitem action="select-grow" />
       <menuitem action="select-border" />
+      <menuitem action="select-flood" />
     </placeholder>
     <separator />
     <menuitem action="select-save" />


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