[gimp] plug-ins: use the new item-type specific get_by_id() functions



commit 45d60acb65084c516c025417b04971f8bc531e82
Author: Michael Natterer <mitch gimp org>
Date:   Tue Sep 3 10:48:32 2019 +0200

    plug-ins: use the new item-type specific get_by_id() functions

 plug-ins/common/compose.c            |  6 +++---
 plug-ins/common/depth-merge.c        | 29 +++++++++--------------------
 plug-ins/common/sample-colorize.c    | 13 ++++++-------
 plug-ins/common/sparkle.c            |  2 +-
 plug-ins/common/tile.c               |  4 ++--
 plug-ins/common/van-gogh-lic.c       |  2 +-
 plug-ins/common/warp.c               | 12 ++++++------
 plug-ins/flame/flame.c               |  2 +-
 plug-ins/gimpressionist/brush.c      |  2 +-
 plug-ins/lighting/lighting-apply.c   |  4 ++--
 plug-ins/lighting/lighting-main.c    |  8 ++++----
 plug-ins/lighting/lighting-preview.c |  4 ++--
 plug-ins/lighting/lighting-shade.c   |  7 +++----
 plug-ins/lighting/lighting-ui.c      |  4 ++--
 14 files changed, 43 insertions(+), 56 deletions(-)
---
diff --git a/plug-ins/common/compose.c b/plug-ins/common/compose.c
index dd2e30e430..fe6ca9c6cf 100644
--- a/plug-ins/common/compose.c
+++ b/plug-ins/common/compose.c
@@ -590,7 +590,7 @@ compose_run (GimpProcedure        *procedure,
           compose_by_drawable = TRUE;
 
           composevals.do_recompose = TRUE;
-          composevals.source_layer = GIMP_LAYER (gimp_item_get_by_id (source));
+          composevals.source_layer = gimp_layer_get_by_id (source);
 
           if (! composevals.source_layer)
             {
@@ -606,7 +606,7 @@ compose_run (GimpProcedure        *procedure,
           for (i = 0; i < MAX_COMPOSE_IMAGES; i++)
             {
               composevals.inputs[i].is_object   = TRUE;
-              composevals.inputs[i].comp.object = gimp_item_get_by_id (input[i]);
+              composevals.inputs[i].comp.object = gimp_drawable_get_by_id (input[i]);
 
               /* fourth input is optional */
               if (i == 2 && nret == 5)
@@ -1431,7 +1431,7 @@ combo_callback (GimpIntComboBox *widget,
       gtk_widget_set_sensitive (composeint.color_spins[n],  FALSE);
 
       composeint.selected[n].is_object   = TRUE;
-      composeint.selected[n].comp.object = gimp_item_get_by_id (id);
+      composeint.selected[n].comp.object = gimp_drawable_get_by_id (id);
     }
 }
 
diff --git a/plug-ins/common/depth-merge.c b/plug-ins/common/depth-merge.c
index 6846f54f3d..e39b91e1ee 100644
--- a/plug-ins/common/depth-merge.c
+++ b/plug-ins/common/depth-merge.c
@@ -303,8 +303,7 @@ DepthMerge_construct (DepthMerge *dm)
 {
   dm->interface = NULL;
 
-  dm->resultDrawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.result_id));
+  dm->resultDrawable = gimp_drawable_get_by_id (dm->params.result_id);
 
   if (! gimp_drawable_mask_intersect (dm->resultDrawable,
                                       &(dm->selectionX), &(dm->selectionY),
@@ -316,17 +315,11 @@ DepthMerge_construct (DepthMerge *dm)
 
   dm->resultHasAlpha = gimp_drawable_has_alpha (dm->resultDrawable);
 
-  dm->source1Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.source1_id));
+  dm->source1Drawable = gimp_drawable_get_by_id (dm->params.source1_id);
+  dm->source2Drawable = gimp_drawable_get_by_id (dm->params.source2_id);
 
-  dm->source2Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.source2_id));
-
-  dm->depthMap1Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.depthMap1_id));
-
-  dm->depthMap2Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.depthMap2_id));
+  dm->depthMap1Drawable = gimp_drawable_get_by_id (dm->params.depthMap1_id);
+  dm->depthMap2Drawable = gimp_drawable_get_by_id (dm->params.depthMap2_id);
 
   dm->params.overlap = CLAMP (dm->params.overlap, 0, 2);
   dm->params.offset  = CLAMP (dm->params.offset, -1, 1);
@@ -898,8 +891,7 @@ dialogSource1ChangedCallback (GtkWidget  *widget,
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
                                  &dm->params.source1_id);
 
-  dm->source1Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.source1_id));
+  dm->source1Drawable = gimp_drawable_get_by_id (dm->params.source1_id);
 
   util_fillReducedBuffer (dm->interface->previewSource1,
                           babl_format ("R'G'B'A u8"),
@@ -919,8 +911,7 @@ dialogSource2ChangedCallback (GtkWidget  *widget,
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
                                  &dm->params.source2_id);
 
-  dm->source2Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.source2_id));
+  dm->source2Drawable = gimp_drawable_get_by_id (dm->params.source2_id);
 
   util_fillReducedBuffer (dm->interface->previewSource2,
                           babl_format ("R'G'B'A u8"),
@@ -940,8 +931,7 @@ dialogDepthMap1ChangedCallback (GtkWidget  *widget,
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
                                  &dm->params.depthMap1_id);
 
-  dm->depthMap1Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.depthMap1_id));
+  dm->depthMap1Drawable = gimp_drawable_get_by_id (dm->params.depthMap1_id);
 
   util_fillReducedBuffer (dm->interface->previewDepthMap1,
                           babl_format ("Y' u8"),
@@ -961,8 +951,7 @@ dialogDepthMap2ChangedCallback (GtkWidget  *widget,
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
                                  &dm->params.depthMap2_id);
 
-  dm->depthMap2Drawable =
-    GIMP_DRAWABLE (gimp_item_get_by_id (dm->params.depthMap2_id));
+  dm->depthMap2Drawable = gimp_drawable_get_by_id (dm->params.depthMap2_id);
 
   util_fillReducedBuffer (dm->interface->previewDepthMap2,
                           babl_format ("Y' u8"),
diff --git a/plug-ins/common/sample-colorize.c b/plug-ins/common/sample-colorize.c
index 4942d0d0c0..4ec89a75c1 100644
--- a/plug-ins/common/sample-colorize.c
+++ b/plug-ins/common/sample-colorize.c
@@ -333,7 +333,7 @@ run (const gchar      *name,
   g_show_progress = FALSE;
 
   run_mode = param[0].data.d_int32;
-  drawable = GIMP_DRAWABLE (gimp_item_get_by_id (param[2].data.d_drawable));
+  drawable = gimp_drawable_get_by_id (param[2].data.d_drawable);
 
   *nreturn_vals = 1;
   *return_vals = values;
@@ -470,7 +470,7 @@ smp_toggle_callback (GtkWidget *widget,
   if ((data == &g_di.sample_show_selection) ||
       (data == &g_di.sample_show_color))
     {
-      update_preview (GIMP_DRAWABLE (gimp_item_get_by_id (g_values.sample_id)));
+      update_preview (gimp_drawable_get_by_id (g_values.sample_id));
       return;
     }
 
@@ -524,7 +524,7 @@ smp_sample_combo_callback (GtkWidget *widget)
     }
   else
     {
-      update_preview (GIMP_DRAWABLE (gimp_item_get_by_id (g_values.sample_id)));
+      update_preview (gimp_drawable_get_by_id (g_values.sample_id));
 
       gtk_dialog_set_response_sensitive (GTK_DIALOG (g_di.dialog),
                                          RESPONSE_GET_COLORS, TRUE);
@@ -538,7 +538,7 @@ smp_dest_combo_callback (GtkWidget *widget)
 
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &id);
 
-  g_values.dst = GIMP_DRAWABLE (gimp_item_get_by_id (id));
+  g_values.dst = gimp_drawable_get_by_id (id);
 
   update_preview (g_values.dst);
 
@@ -937,7 +937,7 @@ smp_get_colors (GtkWidget *dialog)
   gint   i;
   guchar buffer[3 * DA_WIDTH * GRADIENT_HEIGHT];
 
-  update_preview (GIMP_DRAWABLE (gimp_item_get_by_id (g_values.sample_id)));
+  update_preview (gimp_drawable_get_by_id (g_values.sample_id));
 
   if (dialog && main_colorize (MC_GET_SAMPLE_COLORS) >= 0)  /* do not colorize, just analyze sample colors */
     gtk_dialog_set_response_sensitive (GTK_DIALOG (g_di.dialog),
@@ -3043,8 +3043,7 @@ main_colorize (gint mc_flags)
         {
           sample_drawable = TRUE;
 
-          init_gdrw (&sample_gdrw, GIMP_DRAWABLE (gimp_item_get_by_id (id)),
-                     FALSE);
+          init_gdrw (&sample_gdrw, gimp_drawable_get_by_id (id), FALSE);
           free_colors ();
           rc = sample_analyze (&sample_gdrw);
         }
diff --git a/plug-ins/common/sparkle.c b/plug-ins/common/sparkle.c
index a940e29cef..6c677b0c89 100644
--- a/plug-ins/common/sparkle.c
+++ b/plug-ins/common/sparkle.c
@@ -216,7 +216,7 @@ run (const gchar      *name,
 
   run_mode    = param[0].data.d_int32;
   drawable_ID = param[2].data.d_drawable;
-  drawable    = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_ID));
+  drawable    = gimp_drawable_get_by_id (drawable_ID);
 
   if (! gimp_drawable_mask_intersect (drawable, &x, &y, &w, &h))
     {
diff --git a/plug-ins/common/tile.c b/plug-ins/common/tile.c
index 5248d308cc..1b9d1f8650 100644
--- a/plug-ins/common/tile.c
+++ b/plug-ins/common/tile.c
@@ -159,7 +159,7 @@ run (const gchar      *name,
 
       /*  First acquire information with a dialog  */
       if (! tile_dialog (gimp_image_get_by_id (param[1].data.d_image),
-                         GIMP_DRAWABLE (gimp_item_get_by_id (param[2].data.d_drawable))))
+                         gimp_drawable_get_by_id (param[2].data.d_drawable)))
         return;
       break;
 
@@ -197,7 +197,7 @@ run (const gchar      *name,
       gimp_progress_init (_("Tiling"));
 
       tile (gimp_image_get_by_id (param[1].data.d_image),
-            GIMP_DRAWABLE (gimp_item_get_by_id (param[2].data.d_drawable)),
+            gimp_drawable_get_by_id (param[2].data.d_drawable),
             &new_image,
             &new_layer);
 
diff --git a/plug-ins/common/van-gogh-lic.c b/plug-ins/common/van-gogh-lic.c
index 5fc89c1fc9..f9ee186140 100644
--- a/plug-ins/common/van-gogh-lic.c
+++ b/plug-ins/common/van-gogh-lic.c
@@ -640,7 +640,7 @@ compute_image (GimpDrawable *drawable)
 
   source_drw_has_alpha = gimp_drawable_has_alpha (drawable);
 
-  effect_image = GIMP_DRAWABLE (gimp_item_get_by_id (licvals.effect_image_id));
+  effect_image = gimp_drawable_get_by_id (licvals.effect_image_id);
 
   effect_width =  gimp_drawable_width  (effect_image);
   effect_height = gimp_drawable_height (effect_image);
diff --git a/plug-ins/common/warp.c b/plug-ins/common/warp.c
index 419d5a61b7..d6e7990ce9 100644
--- a/plug-ins/common/warp.c
+++ b/plug-ins/common/warp.c
@@ -267,7 +267,7 @@ run (const gchar      *name,
                       &color_pixel[2]);
 
   run_mode = param[0].data.d_int32;
-  drawable = GIMP_DRAWABLE (gimp_item_get_by_id (param[2].data.d_drawable));
+  drawable = gimp_drawable_get_by_id (param[2].data.d_drawable);
 
   *nreturn_vals = 1;
   *return_vals  = values;
@@ -1084,7 +1084,7 @@ diff (GimpDrawable  *drawable,
 
   if (do_vecmap)
     {
-      vdraw = GIMP_DRAWABLE (gimp_item_get_by_id (dvals.vector_map_id));
+      vdraw = gimp_drawable_get_by_id (dvals.vector_map_id);
 
       /* bytes per pixel in SOURCE drawable */
       vformat = get_u8_format (vdraw);
@@ -1099,7 +1099,7 @@ diff (GimpDrawable  *drawable,
 
   if (do_gradmap)
     {
-      gdraw = GIMP_DRAWABLE (gimp_item_get_by_id (dvals.grad_map_id));
+      gdraw = gimp_drawable_get_by_id (dvals.grad_map_id);
 
       gformat = get_u8_format (gdraw);
       gbytes  = babl_format_get_bytes_per_pixel (gformat);
@@ -1116,7 +1116,7 @@ diff (GimpDrawable  *drawable,
 
   if (do_magmap)
     {
-      mdraw = GIMP_DRAWABLE (gimp_item_get_by_id (dvals.mag_map_id));
+      mdraw = gimp_drawable_get_by_id (dvals.mag_map_id);
 
       mformat = get_u8_format (mdraw);
       mbytes  = babl_format_get_bytes_per_pixel (mformat);
@@ -1321,8 +1321,8 @@ warp (GimpDrawable *orig_draw)
   /* index var. over all "warp" Displacement iterations */
   gint          warp_iter;
 
-  disp_map = GIMP_DRAWABLE (gimp_item_get_by_id (dvals.warp_map_id));
-  mag_draw = GIMP_DRAWABLE (gimp_item_get_by_id (dvals.mag_map_id));
+  disp_map = gimp_drawable_get_by_id (dvals.warp_map_id);
+  mag_draw = gimp_drawable_get_by_id (dvals.mag_map_id);
 
   /* calculate new X,Y Displacement image maps */
 
diff --git a/plug-ins/flame/flame.c b/plug-ins/flame/flame.c
index 88796581ac..a8cd7b1760 100644
--- a/plug-ins/flame/flame.c
+++ b/plug-ins/flame/flame.c
@@ -308,7 +308,7 @@ drawable_to_cmap (control_point *cp)
     }
   else
     {
-      GimpDrawable *drawable = GIMP_DRAWABLE (gimp_item_get_by_id (config.cmap_drawable_id));
+      GimpDrawable *drawable = gimp_drawable_get_by_id (config.cmap_drawable_id);
       GeglBuffer   *buffer   = gimp_drawable_get_buffer (drawable);
       gint          width    = gegl_buffer_get_width  (buffer);
       gint          height   = gegl_buffer_get_height (buffer);
diff --git a/plug-ins/gimpressionist/brush.c b/plug-ins/gimpressionist/brush.c
index 7af32532b7..f9a975342c 100644
--- a/plug-ins/gimpressionist/brush.c
+++ b/plug-ins/gimpressionist/brush.c
@@ -130,7 +130,7 @@ brushdmenuselect (GtkWidget *widget,
 
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &drawable_id);
 
-  drawable = GIMP_DRAWABLE (gimp_item_get_by_id (drawable_id));
+  drawable = gimp_drawable_get_by_id (drawable_id);
 
   if (! drawable)
     return;
diff --git a/plug-ins/lighting/lighting-apply.c b/plug-ins/lighting/lighting-apply.c
index b7735995c4..37a27a0d80 100644
--- a/plug-ins/lighting/lighting-apply.c
+++ b/plug-ins/lighting/lighting-apply.c
@@ -73,7 +73,7 @@ compute_image (void)
 
   if (mapvals.bump_mapped == TRUE && mapvals.bumpmap_id != -1)
     {
-      bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
+      bumpmap_setup (gimp_drawable_get_by_id (mapvals.bumpmap_id));
     }
 
   precompute_init (width, height);
@@ -84,7 +84,7 @@ compute_image (void)
     }
   else
     {
-      envmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id)));
+      envmap_setup (gimp_drawable_get_by_id (mapvals.envmap_id));
 
       ray_func = get_ray_color_ref;
     }
diff --git a/plug-ins/lighting/lighting-main.c b/plug-ins/lighting/lighting-main.c
index 96910e114f..4520216ccc 100644
--- a/plug-ins/lighting/lighting-main.c
+++ b/plug-ins/lighting/lighting-main.c
@@ -130,8 +130,8 @@ check_drawables (void)
         }
       else
         {
-          drawable = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.drawable_id));
-          map      = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id));
+          drawable = gimp_drawable_get_by_id (mapvals.drawable_id);
+          map      = gimp_drawable_get_by_id (mapvals.bumpmap_id);
 
           if (gimp_drawable_is_indexed (map) ||
               (gimp_drawable_width  (drawable) != gimp_drawable_width  (map)) ||
@@ -152,7 +152,7 @@ check_drawables (void)
         }
       else
         {
-          map = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id));
+          map = gimp_drawable_get_by_id (mapvals.envmap_id);
 
           if (gimp_drawable_is_gray   (map) ||
               gimp_drawable_has_alpha (map))
@@ -246,7 +246,7 @@ run (const gchar      *name,
   /* ========================== */
 
   run_mode = param[0].data.d_int32;
-  drawable = GIMP_DRAWABLE (gimp_item_get_by_id (param[2].data.d_drawable));
+  drawable = gimp_drawable_get_by_id (param[2].data.d_drawable);
 
   mapvals.drawable_id = gimp_item_get_id (GIMP_ITEM (drawable));
 
diff --git a/plug-ins/lighting/lighting-preview.c b/plug-ins/lighting/lighting-preview.c
index b86c997685..a22db2009e 100644
--- a/plug-ins/lighting/lighting-preview.c
+++ b/plug-ins/lighting/lighting-preview.c
@@ -96,7 +96,7 @@ compute_preview (gint startx, gint starty, gint w, gint h)
 
   if (mapvals.bump_mapped == TRUE && mapvals.bumpmap_id != -1)
     {
-      bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
+      bumpmap_setup (gimp_drawable_get_by_id (mapvals.bumpmap_id));
     }
 
   imagey = 0;
@@ -108,7 +108,7 @@ compute_preview (gint startx, gint starty, gint w, gint h)
 
   if (mapvals.env_mapped == TRUE && mapvals.envmap_id != -1)
     {
-      envmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id)));
+      envmap_setup (gimp_drawable_get_by_id (mapvals.envmap_id));
 
       if (mapvals.previewquality)
         ray_func = get_ray_color_ref;
diff --git a/plug-ins/lighting/lighting-shade.c b/plug-ins/lighting/lighting-shade.c
index 36cb27b8f7..310e69f44d 100644
--- a/plug-ins/lighting/lighting-shade.c
+++ b/plug-ins/lighting/lighting-shade.c
@@ -140,8 +140,7 @@ precompute_init (gint w,
 
   if (mapvals.bumpmap_id != -1)
     {
-      GimpDrawable *drawable =
-        GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id));
+      GimpDrawable *drawable = gimp_drawable_get_by_id (mapvals.bumpmap_id);
 
       bpp = gimp_drawable_bpp (drawable);
     }
@@ -186,7 +185,7 @@ interpol_row (gint x1,
 
   if (mapvals.bumpmap_id != -1)
     {
-      bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
+      bumpmap_setup (gimp_drawable_get_by_id (mapvals.bumpmap_id));
 
       bpp = babl_format_get_bytes_per_pixel (bump_format);
     }
@@ -316,7 +315,7 @@ precompute_normals (gint x1,
 
   if (mapvals.bumpmap_id != -1)
     {
-      bumpmap_setup (GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.bumpmap_id)));
+      bumpmap_setup (gimp_drawable_get_by_id (mapvals.bumpmap_id));
 
       bpp = babl_format_get_bytes_per_pixel (bump_format);
     }
diff --git a/plug-ins/lighting/lighting-ui.c b/plug-ins/lighting/lighting-ui.c
index 7b36957409..1b77d614de 100644
--- a/plug-ins/lighting/lighting-ui.c
+++ b/plug-ins/lighting/lighting-ui.c
@@ -258,7 +258,7 @@ bumpmap_constrain (GimpImage *image,
                    GimpItem  *item,
                    gpointer   data)
 {
-  GimpDrawable *dr = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.drawable_id));
+  GimpDrawable *dr = gimp_drawable_get_by_id (mapvals.drawable_id);
 
   return  ((gimp_drawable_width (GIMP_DRAWABLE (item)) ==
             gimp_drawable_width (dr)) &&
@@ -284,7 +284,7 @@ envmap_combo_callback (GtkWidget *widget,
   gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget),
                                  &mapvals.envmap_id);
 
-  env = GIMP_DRAWABLE (gimp_item_get_by_id (mapvals.envmap_id));
+  env = gimp_drawable_get_by_id (mapvals.envmap_id);
 
   env_width  = gimp_drawable_width  (env);
   env_height = gimp_drawable_height (env);


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