[gimp] app: Introduce helper function file_open_get_layers()



commit 92df6ae6cdff6b5c139f04c5d0016a6e28a90ffe
Author: Martin Nordholts <martinn src gnome org>
Date:   Sat Aug 22 09:00:18 2009 +0200

    app: Introduce helper function file_open_get_layers()

 app/file/file-open.c |   52 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 35 insertions(+), 17 deletions(-)
---
diff --git a/app/file/file-open.c b/app/file/file-open.c
index a5fb9e0..3697e3a 100644
--- a/app/file/file-open.c
+++ b/app/file/file-open.c
@@ -82,6 +82,9 @@ static void     file_open_handle_color_profile (GimpImage                 *image
                                                 GimpContext               *context,
                                                 GimpProgress              *progress,
                                                 GimpRunMode                run_mode);
+static GList *  file_open_get_layers           (const GimpImage           *image,
+                                                gboolean                   merge_visible,
+                                                gint                      *n_visible);
 static gboolean file_open_file_proc_is_import  (const GimpPlugInProcedure *file_proc);
 
 
@@ -464,26 +467,11 @@ file_open_layers (Gimp                *gimp,
 
   if (new_image)
     {
-      GList *list;
-      gint   n_visible = 0;
+      gint n_visible = 0;
 
       gimp_image_undo_disable (new_image);
 
-      for (list = gimp_image_get_layer_iter (new_image);
-           list;
-           list = g_list_next (list))
-        {
-          if (! merge_visible)
-            layers = g_list_prepend (layers, list->data);
-
-          if (gimp_item_get_visible (list->data))
-            {
-              n_visible++;
-
-              if (! layers)
-                layers = g_list_prepend (layers, list->data);
-            }
-        }
+      layers = file_open_get_layers (new_image, merge_visible, &n_visible);
 
       if (merge_visible && n_visible > 1)
         {
@@ -724,6 +712,36 @@ file_open_handle_color_profile (GimpImage    *image,
     }
 }
 
+static GList *
+file_open_get_layers (const GimpImage *image,
+                      gboolean         merge_visible,
+                      gint            *n_visible)
+{
+  GList *iter   = NULL;
+  GList *layers = NULL;
+
+  for (iter = gimp_image_get_layer_iter (image);
+       iter;
+       iter = g_list_next (iter))
+    {
+      GimpItem *item = iter->data;
+
+      if (! merge_visible)
+        layers = g_list_prepend (layers, item);
+
+      if (gimp_item_get_visible (item))
+        {
+          if (n_visible)
+            (*n_visible)++;
+
+          if (! layers)
+            layers = g_list_prepend (layers, item);
+        }
+    }
+
+  return layers;
+}
+
 static gboolean
 file_open_file_proc_is_import (const GimpPlugInProcedure *file_proc)
 {



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