[gimp] app: create nicer object names from MyPaint brush filenames



commit 72f9bea765186baeef1d3fc0a3eea4feaf188ac8
Author: Michael Natterer <mitch gimp org>
Date:   Sat Jan 2 13:23:40 2016 +0100

    app: create nicer object names from MyPaint brush filenames

 app/core/gimpmybrush-load.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpmybrush-load.c b/app/core/gimpmybrush-load.c
index 70d9f0c..3299528 100644
--- a/app/core/gimpmybrush-load.c
+++ b/app/core/gimpmybrush-load.c
@@ -52,6 +52,7 @@ gimp_mybrush_load (GimpContext   *context,
   gchar        *path;
   gchar        *basename;
   gchar        *preview_filename;
+  gchar        *p;
 
   g_return_val_if_fail (G_IS_FILE (file), NULL);
   g_return_val_if_fail (G_IS_INPUT_STREAM (input), NULL);
@@ -113,10 +114,15 @@ gimp_mybrush_load (GimpContext   *context,
       return NULL;
     }
 
-  basename = g_file_get_basename (file);
+  basename = g_path_get_basename (gimp_file_get_utf8_name (file));
+
+  basename[strlen (basename) - 4] = '\0';
+  for (p = basename; *p; p++)
+    if (*p == '_' || *p == '-')
+      *p = ' ';
 
   brush = g_object_new (GIMP_TYPE_MYBRUSH,
-                        "name",        gimp_filename_to_utf8 (basename),
+                        "name",        basename,
                         "mime-type",   "image/x-gimp-myb",
                         "icon-pixbuf", pixbuf,
                         NULL);


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