[gimp] gimptool: Replace path generation code with glib functions



commit eb11a466ac1851d4ebd4f1219a3546d12c60fb09
Author: Mukund Sivaraman <muks banu com>
Date:   Tue Oct 4 18:28:52 2011 +0530

    gimptool: Replace path generation code with glib functions

 tools/gimptool.c |   84 +++++++++++++++++++++--------------------------------
 1 files changed, 33 insertions(+), 51 deletions(-)
---
diff --git a/tools/gimptool.c b/tools/gimptool.c
index 9593405..4229edf 100644
--- a/tools/gimptool.c
+++ b/tools/gimptool.c
@@ -526,33 +526,24 @@ do_build_nogimpui (const gchar *what)
 }
 
 static gchar *
-get_user_plugin_dir (gboolean forward_slashes)
+get_user_plugin_dir (void)
 {
-#ifdef G_OS_WIN32
-  /* In the --install-bin and --uninstall modes we want
-   * to use backward slashes on Win32, because we invoke
-   * the COPY and DEL commands directly with system().
-   */
-
-  const gchar slash = forward_slashes ? '/' : '\\';
-#else
-  const gchar slash = '/';
-#endif
-
-  return g_strdup_printf ("%s%c" GIMPDIR "%cplug-ins",
-			  g_get_home_dir (), slash, slash);
+  return g_build_filename (g_get_home_dir (),
+                           GIMPDIR,
+                           "plug-ins",
+                           NULL);
 }
 
 static void
 do_install (const gchar *what)
 {
-  do_build_2 (get_cflags (), get_libs (), get_user_plugin_dir (FALSE), what);
+  do_build_2 (get_cflags (), get_libs (), get_user_plugin_dir (), what);
 }
 
 static void
 do_install_noui (const gchar *what)
 {
-  do_build_2 (get_cflags_noui (), get_libs_noui (), get_user_plugin_dir (FALSE), what);
+  do_build_2 (get_cflags_noui (), get_libs_noui (), get_user_plugin_dir (), what);
 }
 
 static void
@@ -564,15 +555,16 @@ do_install_nogimpui (const gchar *what)
 static gchar *
 get_sys_plugin_dir (gboolean forward_slashes)
 {
-#ifdef G_OS_WIN32
-  const gchar slash = forward_slashes ? '/' : '\\';
-#else
-  const gchar slash = '/';
-#endif
+  const gchar *rprefix;
 
-  return g_strdup_printf ("%s%clib%cgimp%c" GIMP_PLUGIN_VERSION "%cplug-ins",
-			  get_runtime_prefix (slash),
-			  slash, slash, slash, slash);
+  rprefix = get_runtime_prefix (forward_slashes ? '/' : G_DIR_SEPARATOR);
+
+  return g_build_path (forward_slashes ? "/" : G_DIR_SEPARATOR_S,
+                       rprefix,
+                       "lib", "gimp",
+                       GIMP_PLUGIN_VERSION,
+                       "plug-ins",
+                       NULL);
 }
 
 static void
@@ -608,7 +600,7 @@ do_install_bin_2 (const gchar *dir,
 static void
 do_install_bin (const gchar *what)
 {
-  do_install_bin_2 (get_user_plugin_dir (FALSE), what);
+  do_install_bin_2 (get_user_plugin_dir (), what);
 }
 
 static void
@@ -640,7 +632,7 @@ maybe_append_exe (const gchar *what)
 static void
 do_uninstall_bin (const gchar *what)
 {
-  do_uninstall (get_user_plugin_dir (FALSE), maybe_append_exe (what));
+  do_uninstall (get_user_plugin_dir (), maybe_append_exe (what));
 }
 
 static void
@@ -650,56 +642,46 @@ do_uninstall_admin_bin (const gchar *what)
 }
 
 static gchar *
-get_user_script_dir (gboolean forward_slashes)
+get_user_script_dir (void)
 {
-#ifdef G_OS_WIN32
-  const gchar slash = forward_slashes ? '/' : '\\';
-#else
-  const gchar slash = '/';
-#endif
-
-  return g_strdup_printf ("%s%c" GIMPDIR "%cscripts",
-			  g_get_home_dir (), slash, slash);
+  return g_build_filename (g_get_home_dir (),
+                           GIMPDIR,
+                           "scripts",
+                           NULL);
 }
 
 static void
 do_install_script (const gchar *what)
 {
-  do_install_bin_2 (get_user_script_dir (FALSE), what);
+  do_install_bin_2 (get_user_script_dir (), what);
 }
 
 static gchar *
-get_sys_script_dir (gboolean forward_slashes)
+get_sys_script_dir (void)
 {
-#ifdef G_OS_WIN32
-  const gchar slash = forward_slashes ? '/' : '\\';
-#else
-  const gchar slash = '/';
-#endif
-
-  return g_strdup_printf ("%s%cshare%cgimp%c%s%cscripts",
-                          get_runtime_prefix (slash),
-                          slash, slash, slash,
-                          GIMP_API_VERSION,
-                          slash);
+  return g_build_filename (get_runtime_prefix (G_DIR_SEPARATOR),
+                           "share", "gimp",
+                           GIMP_API_VERSION,
+                           "scripts",
+                           NULL);
 }
 
 static void
 do_install_admin_script (const gchar *what)
 {
-  do_install_bin_2 (get_sys_script_dir (FALSE), what);
+  do_install_bin_2 (get_sys_script_dir (), what);
 }
 
 static void
 do_uninstall_script (const gchar *what)
 {
-  do_uninstall (get_user_script_dir (FALSE), what);
+  do_uninstall (get_user_script_dir (), what);
 }
 
 static void
 do_uninstall_admin_script (const gchar *what)
 {
-  do_uninstall (get_sys_script_dir (FALSE), what);
+  do_uninstall (get_sys_script_dir (), what);
 }
 
 int



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