[gimp] app: make using gimp_drawable_update() less verbose



commit 68cc8bb86f49d22203cbd191c64ccc059885f0d8
Author: Michael Natterer <mitch gimp org>
Date:   Fri Jan 13 02:14:40 2017 +0100

    app: make using gimp_drawable_update() less verbose
    
    Allow passing -1 for the drawable's width/height, instead of requiring
    gimp_item_get_width,height() in many callers.

 app/core/gimpchannel.c                     |   47 ++++++---------------------
 app/core/gimpdrawable-fill.c               |    5 +--
 app/core/gimpdrawable-floating-selection.c |   10 +-----
 app/core/gimpdrawable.c                    |   16 +++++-----
 app/core/gimpimage-color-profile.c         |    4 +--
 app/core/gimpimage-merge.c                 |    5 +--
 app/core/gimplayer.c                       |   45 +++++---------------------
 app/core/gimpmaskundo.c                    |    5 +--
 app/core/gimpselection.c                   |   10 ++---
 9 files changed, 38 insertions(+), 109 deletions(-)
---
diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c
index 7d61562..2ec9db5 100644
--- a/app/core/gimpchannel.c
+++ b/app/core/gimpchannel.c
@@ -1275,9 +1275,7 @@ gimp_channel_real_feather (GimpChannel *channel,
 
   channel->bounds_known = FALSE;
 
-  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (channel)),
-                        gimp_item_get_height (GIMP_ITEM (channel)));
+  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 }
 
 static void
@@ -1299,9 +1297,7 @@ gimp_channel_real_sharpen (GimpChannel *channel,
 
   channel->bounds_known = FALSE;
 
-  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (channel)),
-                        gimp_item_get_height (GIMP_ITEM (channel)));
+  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 }
 
 static void
@@ -1342,9 +1338,7 @@ gimp_channel_real_clear (GimpChannel *channel,
   channel->x2           = gimp_item_get_width  (GIMP_ITEM (channel));
   channel->y2           = gimp_item_get_height (GIMP_ITEM (channel));
 
-  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (channel)),
-                        gimp_item_get_height (GIMP_ITEM (channel)));
+  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 }
 
 static void
@@ -1373,9 +1367,7 @@ gimp_channel_real_all (GimpChannel *channel,
   channel->x2           = gimp_item_get_width  (GIMP_ITEM (channel));
   channel->y2           = gimp_item_get_height (GIMP_ITEM (channel));
 
-  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (channel)),
-                        gimp_item_get_height (GIMP_ITEM (channel)));
+  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 }
 
 static void
@@ -1402,9 +1394,7 @@ gimp_channel_real_invert (GimpChannel *channel,
 
       channel->bounds_known = FALSE;
 
-      gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (channel)),
-                            gimp_item_get_height (GIMP_ITEM (channel)));
+      gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
     }
 }
 
@@ -1480,9 +1470,7 @@ gimp_channel_real_border (GimpChannel            *channel,
 
   channel->bounds_known = FALSE;
 
-  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (channel)),
-                        gimp_item_get_height (GIMP_ITEM (channel)));
+  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 }
 
 static void
@@ -1548,9 +1536,7 @@ gimp_channel_real_grow (GimpChannel *channel,
 
   channel->bounds_known = FALSE;
 
-  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (channel)),
-                        gimp_item_get_height (GIMP_ITEM (channel)));
+  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 }
 
 static void
@@ -1606,9 +1592,7 @@ gimp_channel_real_shrink (GimpChannel *channel,
 
   channel->bounds_known = FALSE;
 
-  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (channel)),
-                        gimp_item_get_height (GIMP_ITEM (channel)));
+  gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 }
 
 static void
@@ -1797,10 +1781,7 @@ gimp_channel_set_color (GimpChannel   *channel,
                                     &channel->color);
         }
 
-      gimp_drawable_update (GIMP_DRAWABLE (channel),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (channel)),
-                            gimp_item_get_height (GIMP_ITEM (channel)));
+      gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 
       g_signal_emit (channel, channel_signals[COLOR_CHANGED], 0);
     }
@@ -1851,10 +1832,7 @@ gimp_channel_set_opacity (GimpChannel *channel,
                                     &channel->color);
         }
 
-      gimp_drawable_update (GIMP_DRAWABLE (channel),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (channel)),
-                            gimp_item_get_height (GIMP_ITEM (channel)));
+      gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
 
       g_signal_emit (channel, channel_signals[COLOR_CHANGED], 0);
     }
@@ -1900,10 +1878,7 @@ gimp_channel_set_show_masked (GimpChannel *channel,
             }
         }
 
-      gimp_drawable_update (GIMP_DRAWABLE (channel),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (channel)),
-                            gimp_item_get_height (GIMP_ITEM (channel)));
+      gimp_drawable_update (GIMP_DRAWABLE (channel), 0, 0, -1, -1);
     }
 }
 
diff --git a/app/core/gimpdrawable-fill.c b/app/core/gimpdrawable-fill.c
index 8dcb543..75566c2 100644
--- a/app/core/gimpdrawable-fill.c
+++ b/app/core/gimpdrawable-fill.c
@@ -72,10 +72,7 @@ gimp_drawable_fill (GimpDrawable *drawable,
                              gimp_drawable_get_buffer (drawable),
                              &color, pattern, 0, 0);
 
-  gimp_drawable_update (drawable,
-                        0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (drawable)),
-                        gimp_item_get_height (GIMP_ITEM (drawable)));
+  gimp_drawable_update (drawable, 0, 0, -1, -1);
 }
 
 void
diff --git a/app/core/gimpdrawable-floating-selection.c b/app/core/gimpdrawable-floating-selection.c
index b33a350..bb62821 100644
--- a/app/core/gimpdrawable-floating-selection.c
+++ b/app/core/gimpdrawable-floating-selection.c
@@ -336,10 +336,7 @@ gimp_drawable_fs_affect_changed (GimpImage       *image,
 
   gimp_drawable_sync_fs_filter (drawable);
 
-  gimp_drawable_update (GIMP_DRAWABLE (fs),
-                        0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (fs)),
-                        gimp_item_get_height (GIMP_ITEM (fs)));
+  gimp_drawable_update (GIMP_DRAWABLE (fs), 0, 0, -1, -1);
 }
 
 static void
@@ -350,10 +347,7 @@ gimp_drawable_fs_mask_changed (GimpImage    *image,
 
   gimp_drawable_sync_fs_filter (drawable);
 
-  gimp_drawable_update (GIMP_DRAWABLE (fs),
-                        0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (fs)),
-                        gimp_item_get_height (GIMP_ITEM (fs)));
+  gimp_drawable_update (GIMP_DRAWABLE (fs), 0, 0, -1, -1);
 }
 
 static void
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 5c394ab..79217fc 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -973,6 +973,12 @@ gimp_drawable_update (GimpDrawable *drawable,
 {
   g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
 
+  if (width == -1)
+    width = gimp_item_get_width (GIMP_ITEM (drawable));
+
+  if (height == -1)
+    height = gimp_item_get_height (GIMP_ITEM (drawable));
+
   g_signal_emit (drawable, gimp_drawable_signals[UPDATE], 0,
                  x, y, width, height);
 }
@@ -1192,10 +1198,7 @@ gimp_drawable_set_buffer_full (GimpDrawable *drawable,
       gimp_item_get_offset_x (item) != offset_x                        ||
       gimp_item_get_offset_y (item) != offset_y)
     {
-      gimp_drawable_update (drawable,
-                            0, 0,
-                            gimp_item_get_width  (item),
-                            gimp_item_get_height (item));
+      gimp_drawable_update (drawable, 0, 0, -1, -1);
     }
 
   g_object_freeze_notify (G_OBJECT (drawable));
@@ -1207,10 +1210,7 @@ gimp_drawable_set_buffer_full (GimpDrawable *drawable,
 
   g_object_thaw_notify (G_OBJECT (drawable));
 
-  gimp_drawable_update (drawable,
-                        0, 0,
-                        gimp_item_get_width  (item),
-                        gimp_item_get_height (item));
+  gimp_drawable_update (drawable, 0, 0, -1, -1);
 }
 
 GeglNode *
diff --git a/app/core/gimpimage-color-profile.c b/app/core/gimpimage-color-profile.c
index 854a01f..e502bd3 100644
--- a/app/core/gimpimage-color-profile.c
+++ b/app/core/gimpimage-color-profile.c
@@ -743,9 +743,7 @@ gimp_image_convert_profile_layers (GimpImage                *image,
                                        intent, bpc,
                                        sub_progress);
 
-      gimp_drawable_update (drawable, 0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (drawable)),
-                            gimp_item_get_height (GIMP_ITEM (drawable)));
+      gimp_drawable_update (drawable, 0, 0, -1, -1);
 
       if (sub_progress)
         g_object_unref (sub_progress);
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index f66f818..2e729f8 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -687,10 +687,7 @@ gimp_image_merge_layers (GimpImage     *image,
                             TRUE);
     }
 
-  gimp_drawable_update (GIMP_DRAWABLE (merge_layer),
-                        0, 0,
-                        gimp_item_get_width  (GIMP_ITEM (merge_layer)),
-                        gimp_item_get_height (GIMP_ITEM (merge_layer)));
+  gimp_drawable_update (GIMP_DRAWABLE (merge_layer), 0, 0, -1, -1);
 
   return merge_layer;
 }
diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c
index 3e73075..d6ff559 100644
--- a/app/core/gimplayer.c
+++ b/app/core/gimplayer.c
@@ -547,10 +547,7 @@ gimp_layer_notify (GObject    *object,
     {
       gimp_layer_update_mode_node (GIMP_LAYER (object));
 
-      gimp_drawable_update (GIMP_DRAWABLE (object),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (object)),
-                            gimp_item_get_height (GIMP_ITEM (object)));
+      gimp_drawable_update (GIMP_DRAWABLE (object), 0, 0, -1, -1);
     }
 }
 
@@ -879,10 +876,7 @@ gimp_layer_translate (GimpItem *item,
     gimp_image_undo_push_item_displace (gimp_item_get_image (item), NULL, item);
 
   /*  update the old region  */
-  gimp_drawable_update (GIMP_DRAWABLE (layer),
-                        0, 0,
-                        gimp_item_get_width  (item),
-                        gimp_item_get_height (item));
+  gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
 
   /*  invalidate the selection boundary because of a layer modification  */
   gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (layer));
@@ -891,10 +885,7 @@ gimp_layer_translate (GimpItem *item,
                                              push_undo);
 
   /*  update the new region  */
-  gimp_drawable_update (GIMP_DRAWABLE (layer),
-                        0, 0,
-                        gimp_item_get_width  (item),
-                        gimp_item_get_height (item));
+  gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
 
   if (layer->mask)
     {
@@ -1405,10 +1396,7 @@ gimp_layer_add_mask (GimpLayer      *layer,
   if (gimp_layer_get_apply_mask (layer) ||
       gimp_layer_get_show_mask (layer))
     {
-      gimp_drawable_update (GIMP_DRAWABLE (layer),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (layer)),
-                            gimp_item_get_height (GIMP_ITEM (layer)));
+      gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
     }
 
   g_signal_connect (mask, "update",
@@ -1724,10 +1712,7 @@ gimp_layer_apply_mask (GimpLayer         *layer,
   /*  If applying actually changed the view  */
   if (view_changed)
     {
-      gimp_drawable_update (GIMP_DRAWABLE (layer),
-                            0, 0,
-                            gimp_item_get_width  (item),
-                            gimp_item_get_height (item));
+      gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
     }
   else
     {
@@ -1778,10 +1763,7 @@ gimp_layer_set_apply_mask (GimpLayer *layer,
             }
         }
 
-      gimp_drawable_update (GIMP_DRAWABLE (layer),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (layer)),
-                            gimp_item_get_height (GIMP_ITEM (layer)));
+      gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
 
       g_signal_emit (layer, layer_signals[APPLY_MASK_CHANGED], 0);
     }
@@ -1867,10 +1849,7 @@ gimp_layer_set_show_mask (GimpLayer *layer,
           gimp_layer_update_mode_node (layer);
         }
 
-      gimp_drawable_update (GIMP_DRAWABLE (layer),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (layer)),
-                            gimp_item_get_height (GIMP_ITEM (layer)));
+      gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
 
       g_signal_emit (layer, layer_signals[SHOW_MASK_CHANGED], 0);
     }
@@ -2048,10 +2027,7 @@ gimp_layer_set_opacity (GimpLayer *layer,
       if (gimp_filter_peek_node (GIMP_FILTER (layer)))
         gimp_layer_update_mode_node (layer);
 
-      gimp_drawable_update (GIMP_DRAWABLE (layer),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (layer)),
-                            gimp_item_get_height (GIMP_ITEM (layer)));
+      gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
     }
 }
 
@@ -2087,10 +2063,7 @@ gimp_layer_set_mode (GimpLayer     *layer,
       if (gimp_filter_peek_node (GIMP_FILTER (layer)))
         gimp_layer_update_mode_node (layer);
 
-      gimp_drawable_update (GIMP_DRAWABLE (layer),
-                            0, 0,
-                            gimp_item_get_width  (GIMP_ITEM (layer)),
-                            gimp_item_get_height (GIMP_ITEM (layer)));
+      gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
     }
 }
 
diff --git a/app/core/gimpmaskundo.c b/app/core/gimpmaskundo.c
index 076458c..558d2cb 100644
--- a/app/core/gimpmaskundo.c
+++ b/app/core/gimpmaskundo.c
@@ -271,10 +271,7 @@ gimp_mask_undo_pop (GimpUndo            *undo,
   mask_undo->y      = y;
   mask_undo->format = format;
 
-  gimp_drawable_update (drawable,
-                        0, 0,
-                        gimp_item_get_width  (item),
-                        gimp_item_get_height (item));
+  gimp_drawable_update (drawable, 0, 0, -1, -1);
 }
 
 static void
diff --git a/app/core/gimpselection.c b/app/core/gimpselection.c
index 26ec5da..8a7a3b3 100644
--- a/app/core/gimpselection.c
+++ b/app/core/gimpselection.c
@@ -392,10 +392,9 @@ gimp_selection_invalidate_boundary (GimpDrawable *drawable)
   layer = gimp_image_get_active_layer (image);
 
   if (layer && gimp_layer_is_floating_sel (layer))
-    gimp_drawable_update (GIMP_DRAWABLE (layer),
-                          0, 0,
-                          gimp_item_get_width  (GIMP_ITEM (layer)),
-                          gimp_item_get_height (GIMP_ITEM (layer)));
+    {
+      gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, -1, -1);
+    }
 
 #if 0
   /*  invalidate the preview  */
@@ -663,8 +662,7 @@ gimp_selection_load (GimpSelection *selection,
 
   GIMP_CHANNEL (selection)->bounds_known = FALSE;
 
-  gimp_drawable_update (GIMP_DRAWABLE (selection),
-                        0, 0, width, height);
+  gimp_drawable_update (GIMP_DRAWABLE (selection), 0, 0, -1, -1);
 }
 
 GimpChannel *


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