[gimp] app: improve placement of new tools with existing toolrc



commit 58d04375c9692a5651d059923661b3babae5fa9f
Author: Ell <ell_se yahoo com>
Date:   Fri Jan 10 18:36:27 2020 +0200

    app: improve placement of new tools with existing toolrc
    
    When ordering tools according to an existing toolrc file (which
    is always present in a pre-existing profile), preserve the default
    placement of newly-added tools, instead of always adding them to
    the bottom of the list.

 app/tools/gimp-tools.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimp-tools.c b/app/tools/gimp-tools.c
index ad1f18c410..7ee6f7f2a2 100644
--- a/app/tools/gimp-tools.c
+++ b/app/tools/gimp-tools.c
@@ -275,12 +275,11 @@ gimp_tools_restore (Gimp *gimp)
   if (gimp_config_deserialize_file (GIMP_CONFIG (gimp_list), file,
                                     NULL, &error))
     {
-      gint n = gimp_container_get_n_children (gimp->tool_info_list);
-      gint i;
+      gint i = 0;
 
-      for (list = GIMP_LIST (gimp_list)->queue->head, i = 0;
+      for (list = GIMP_LIST (gimp_list)->queue->head;
            list;
-           list = g_list_next (list), i++)
+           list = g_list_next (list))
         {
           const gchar *name = gimp_object_get_name (list->data);
 
@@ -289,12 +288,21 @@ gimp_tools_restore (Gimp *gimp)
 
           if (object)
             {
+              while (! gimp_container_get_child_by_name (
+                         gimp_list,
+                         gimp_object_get_name (
+                           gimp_container_get_child_by_index (
+                             gimp->tool_info_list, i))))
+                {
+                  i++;
+                }
+
               g_object_set (object,
                             "visible", GIMP_TOOL_INFO (list->data)->visible,
                             NULL);
 
               gimp_container_reorder (gimp->tool_info_list,
-                                      object, MIN (i, n - 1));
+                                      object, i++);
             }
         }
     }


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