[gimp] libgimpbase, app: add variants of gimp_$foo_directory() which return GFiles
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpbase, app: add variants of gimp_$foo_directory() which return GFiles
- Date: Mon, 28 Jul 2014 09:06:26 +0000 (UTC)
commit b03d69dd40072dc24c33e15bc55dd5cab010bdfd
Author: Michael Natterer <mitch gimp org>
Date: Mon Jul 28 02:04:01 2014 +0200
libgimpbase, app: add variants of gimp_$foo_directory() which return GFiles
gimp_directory_file(), gimp_data_directory_file() etc. The new
functions take a variable list of path elements to the file,
the list has to be NULL-terminated. Remove the newly added
gimp_personal_rc_gfile(). Start using the new functions in app/.
app/core/gimp-contexts.c | 6 +-
app/core/gimp-modules.c | 4 +-
app/core/gimp-parasites.c | 4 +-
app/core/gimp-tags.c | 8 +-
app/core/gimp-templates.c | 17 +--
app/core/gimp-units.c | 10 +-
app/core/gimptooloptions.c | 2 +-
app/dialogs/dialogs.c | 2 +-
app/dialogs/tips-dialog.c | 6 +-
app/gui/color-history.c | 4 +-
app/gui/session.c | 6 +-
app/gui/themes.c | 4 +-
app/plug-in/gimppluginmanager-restore.c | 2 +-
app/tools/gimp-tools.c | 4 +-
app/widgets/gimpcontrollers.c | 11 +-
app/widgets/gimpdevices.c | 6 +-
libgimpbase/gimpbase.def | 6 +-
libgimpbase/gimpenv.c | 223 +++++++++++++++++++++++++------
libgimpbase/gimpenv.h | 12 ++-
19 files changed, 235 insertions(+), 102 deletions(-)
---
diff --git a/app/core/gimp-contexts.c b/app/core/gimp-contexts.c
index bcb8224..46fb6fb 100644
--- a/app/core/gimp-contexts.c
+++ b/app/core/gimp-contexts.c
@@ -79,7 +79,7 @@ gimp_contexts_load (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- file = gimp_personal_rc_gfile ("contextrc");
+ file = gimp_directory_file ("contextrc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -116,7 +116,7 @@ gimp_contexts_save (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- file = gimp_personal_rc_gfile ("contextrc");
+ file = gimp_directory_file ("contextrc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
@@ -142,7 +142,7 @@ gimp_contexts_clear (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
- file = gimp_personal_rc_gfile ("contextrc");
+ file = gimp_directory_file ("contextrc", NULL);
if (! g_file_delete (file, NULL, &my_error) &&
my_error->code != G_IO_ERROR_NOT_FOUND)
diff --git a/app/core/gimp-modules.c b/app/core/gimp-modules.c
index 645a886..47012aa 100644
--- a/app/core/gimp-modules.c
+++ b/app/core/gimp-modules.c
@@ -76,7 +76,7 @@ gimp_modules_load (Gimp *gimp)
/* FIXME, gimp->be_verbose is not yet initialized in init() */
gimp->module_db->verbose = gimp->be_verbose;
- file = gimp_personal_rc_gfile ("modulerc");
+ file = gimp_directory_file ("modulerc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -192,7 +192,7 @@ gimp_modules_unload (Gimp *gimp)
else
p = "";
- file = gimp_personal_rc_gfile ("modulerc");
+ file = gimp_directory_file ("modulerc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
diff --git a/app/core/gimp-parasites.c b/app/core/gimp-parasites.c
index cc9f414..ec03589 100644
--- a/app/core/gimp-parasites.c
+++ b/app/core/gimp-parasites.c
@@ -119,7 +119,7 @@ gimp_parasiterc_load (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
- file = gimp_personal_rc_gfile ("parasiterc");
+ file = gimp_directory_file ("parasiterc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -152,7 +152,7 @@ gimp_parasiterc_save (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_PARASITE_LIST (gimp->parasites));
- file = gimp_personal_rc_gfile ("parasiterc");
+ file = gimp_directory_file ("parasiterc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
diff --git a/app/core/gimp-tags.c b/app/core/gimp-tags.c
index ef485b7..7b24f37 100644
--- a/app/core/gimp-tags.c
+++ b/app/core/gimp-tags.c
@@ -72,6 +72,7 @@ static const gchar* attribute_name_to_value (const gchar *
gboolean
gimp_tags_user_install (void)
{
+ GFile *file;
gchar *filename;
GMarkupParser markup_parser;
GimpXmlParser *xml_parser;
@@ -105,8 +106,7 @@ gimp_tags_user_install (void)
g_string_append (tags_installer.buf, "<?xml version='1.0' encoding='UTF-8'?>\n");
g_string_append (tags_installer.buf, "<tags>\n");
- filename = g_build_filename (gimp_data_directory (), "tags",
- "gimp-tags-default.xml", NULL);
+ file = gimp_data_directory_file ("tags", "gimp-tags-default.xml", NULL);
markup_parser.start_element = gimp_tags_installer_load_start_element;
markup_parser.end_element = gimp_tags_installer_load_end_element;
@@ -116,9 +116,9 @@ gimp_tags_user_install (void)
xml_parser = gimp_xml_parser_new (&markup_parser, &tags_installer);
- result = gimp_xml_parser_parse_file (xml_parser, filename, &error);
+ result = gimp_xml_parser_parse_gfile (xml_parser, file, &error);
- g_free (filename);
+ g_object_unref (file);
gimp_xml_parser_free (xml_parser);
if (! result)
diff --git a/app/core/gimp-templates.c b/app/core/gimp-templates.c
index 0c28831..94eca7f 100644
--- a/app/core/gimp-templates.c
+++ b/app/core/gimp-templates.c
@@ -44,7 +44,7 @@ gimp_templates_load (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_LIST (gimp->templates));
- file = gimp_personal_rc_gfile ("templaterc");
+ file = gimp_directory_file ("templaterc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -54,14 +54,10 @@ gimp_templates_load (Gimp *gimp)
{
if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
- gchar *tmp;
-
g_clear_error (&error);
g_object_unref (file);
- tmp = g_build_filename (gimp_sysconf_directory (), "templaterc", NULL);
- file = g_file_new_for_path (tmp);
- g_free (tmp);
+ file = gimp_sysconf_directory_file ("templaterc", NULL);
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (gimp->templates),
file, NULL, &error))
@@ -99,7 +95,7 @@ gimp_templates_save (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_LIST (gimp->templates));
- file = gimp_personal_rc_gfile ("templaterc");
+ file = gimp_directory_file ("templaterc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
@@ -173,17 +169,14 @@ void
gimp_templates_migrate (const gchar *olddir)
{
GimpContainer *templates = gimp_list_new (GIMP_TYPE_TEMPLATE, TRUE);
- GFile *file = gimp_personal_rc_gfile ("templaterc");
+ GFile *file = gimp_directory_file ("templaterc", NULL);
if (gimp_config_deserialize_gfile (GIMP_CONFIG (templates), file,
NULL, NULL))
{
- gchar *tmp;
GFile *sysconf_file;
- tmp = g_build_filename (gimp_sysconf_directory (), "templaterc", NULL);
- sysconf_file = g_file_new_for_path (tmp);
- g_free (tmp);
+ sysconf_file = gimp_sysconf_directory_file ("templaterc", NULL);
if (olddir && (strstr (olddir, "2.0") || strstr (olddir, "2.2")))
{
diff --git a/app/core/gimp-units.c b/app/core/gimp-units.c
index cdb8bd8..0c5b5d5 100644
--- a/app/core/gimp-units.c
+++ b/app/core/gimp-units.c
@@ -90,7 +90,7 @@ gimp_unitrc_load (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
- file = gimp_personal_rc_gfile ("unitrc");
+ file = gimp_directory_file ("unitrc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -99,14 +99,10 @@ gimp_unitrc_load (Gimp *gimp)
if (! scanner && error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
- gchar *tmp;
-
g_clear_error (&error);
g_object_unref (file);
- tmp = g_build_filename (gimp_sysconf_directory (), "unitrc", NULL);
- file = g_file_new_for_path (tmp);
- g_free (tmp);
+ file = gimp_sysconf_directory_file ("unitrc", NULL);
scanner = gimp_scanner_new_gfile (file, NULL);
}
@@ -191,7 +187,7 @@ gimp_unitrc_save (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
- file = gimp_personal_rc_gfile ("unitrc");
+ file = gimp_directory_file ("unitrc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
diff --git a/app/core/gimptooloptions.c b/app/core/gimptooloptions.c
index db3bcca..d22ab06 100644
--- a/app/core/gimptooloptions.c
+++ b/app/core/gimptooloptions.c
@@ -380,7 +380,7 @@ gimp_tool_options_delete (GimpToolOptions *tool_options,
void
gimp_tool_options_create_folder (void)
{
- GFile *file = gimp_personal_rc_gfile ("tool-options");
+ GFile *file = gimp_directory_file ("tool-options", NULL);
g_file_make_directory (file, NULL, NULL);
g_object_unref (file);
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index 88a991d..1624a8d 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -578,7 +578,7 @@ dialogs_get_dockrc_file (void)
if (! basename)
basename = "dockrc";
- return gimp_personal_rc_gfile (basename);
+ return gimp_directory_file (basename, NULL);
}
void
diff --git a/app/dialogs/tips-dialog.c b/app/dialogs/tips-dialog.c
index 7c09cc0..e0fd927 100644
--- a/app/dialogs/tips-dialog.c
+++ b/app/dialogs/tips-dialog.c
@@ -73,13 +73,9 @@ tips_dialog_create (Gimp *gimp)
if (!tips)
{
GError *error = NULL;
- gchar *filename;
GFile *file;
- filename = g_build_filename (gimp_data_directory (), "tips",
- "gimp-tips.xml", NULL);
- file = g_file_new_for_path (filename);
- g_free (filename);
+ file = gimp_data_directory_file ("tips", "gimp-tips.xml", NULL);
tips = gimp_tips_from_file (file, &error);
diff --git a/app/gui/color-history.c b/app/gui/color-history.c
index 4e3286a..c766d43 100644
--- a/app/gui/color-history.c
+++ b/app/gui/color-history.c
@@ -57,7 +57,7 @@ color_history_save (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
- file = gimp_personal_rc_gfile ("colorrc");
+ file = gimp_directory_file ("colorrc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
@@ -111,7 +111,7 @@ color_history_restore (Gimp *gimp)
g_return_if_fail (GIMP_IS_GIMP (gimp));
- file = gimp_personal_rc_gfile ("colorrc");
+ file = gimp_directory_file ("colorrc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
diff --git a/app/gui/session.c b/app/gui/session.c
index c8e366c..1ec83f1 100644
--- a/app/gui/session.c
+++ b/app/gui/session.c
@@ -81,14 +81,10 @@ session_init (Gimp *gimp)
if (! scanner && error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
- gchar *tmp;
-
g_clear_error (&error);
g_object_unref (file);
- tmp = g_build_filename (gimp_sysconf_directory (), "sessionrc", NULL);
- file = g_file_new_for_path (tmp);
- g_free (tmp);
+ file = gimp_sysconf_directory_file ("sessionrc", NULL);
scanner = gimp_scanner_new_gfile (file, NULL);
}
diff --git a/app/gui/themes.c b/app/gui/themes.c
index 6c10406..4535f56 100644
--- a/app/gui/themes.c
+++ b/app/gui/themes.c
@@ -261,7 +261,7 @@ themes_apply_theme (Gimp *gimp,
g_return_if_fail (GIMP_IS_GIMP (gimp));
- themerc = gimp_personal_rc_gfile ("themerc");
+ themerc = gimp_directory_file ("themerc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (themerc));
@@ -295,7 +295,7 @@ themes_apply_theme (Gimp *gimp,
gtkrc_theme = g_file_new_for_path (gimp_gtkrc ());
}
- gtkrc_user = gimp_personal_rc_gfile ("gtkrc");
+ gtkrc_user = gimp_directory_file ("gtkrc", NULL);
tmp = g_file_get_path (gtkrc_theme);
esc_gtkrc_theme = g_strescape (tmp, NULL);
diff --git a/app/plug-in/gimppluginmanager-restore.c b/app/plug-in/gimppluginmanager-restore.c
index ee0d68b..a1576e7 100644
--- a/app/plug-in/gimppluginmanager-restore.c
+++ b/app/plug-in/gimppluginmanager-restore.c
@@ -272,7 +272,7 @@ gimp_plug_in_manager_get_pluginrc (GimpPlugInManager *manager)
}
else
{
- pluginrc = gimp_personal_rc_gfile ("pluginrc");
+ pluginrc = gimp_directory_file ("pluginrc", NULL);
}
return pluginrc;
diff --git a/app/tools/gimp-tools.c b/app/tools/gimp-tools.c
index cba6ea7..7c07d2d 100644
--- a/app/tools/gimp-tools.c
+++ b/app/tools/gimp-tools.c
@@ -266,7 +266,7 @@ gimp_tools_restore (Gimp *gimp)
gimp_list = gimp_list_new (GIMP_TYPE_TOOL_INFO, FALSE);
- file = gimp_personal_rc_gfile ("toolrc");
+ file = gimp_directory_file ("toolrc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -411,7 +411,7 @@ gimp_tools_save (Gimp *gimp,
}
}
- file = gimp_personal_rc_gfile ("toolrc");
+ file = gimp_directory_file ("toolrc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
diff --git a/app/widgets/gimpcontrollers.c b/app/widgets/gimpcontrollers.c
index e2d7f13..6b91814 100644
--- a/app/widgets/gimpcontrollers.c
+++ b/app/widgets/gimpcontrollers.c
@@ -143,7 +143,7 @@ gimp_controllers_restore (Gimp *gimp,
manager->ui_manager = g_object_ref (ui_manager);
- file = gimp_personal_rc_gfile ("controllerrc");
+ file = gimp_directory_file ("controllerrc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -153,15 +153,10 @@ gimp_controllers_restore (Gimp *gimp,
{
if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
- gchar *tmp;
-
g_clear_error (&error);
g_object_unref (file);
- tmp = g_build_filename (gimp_sysconf_directory (),
- "controllerrc", NULL);
- file = g_file_new_for_path (tmp);
- g_free (tmp);
+ file = gimp_sysconf_directory_file ("controllerrc", NULL);
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (manager->controllers),
file, NULL, &error))
@@ -203,7 +198,7 @@ gimp_controllers_save (Gimp *gimp)
g_return_if_fail (manager != NULL);
- file = gimp_personal_rc_gfile ("controllerrc");
+ file = gimp_directory_file ("controllerrc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
diff --git a/app/widgets/gimpdevices.c b/app/widgets/gimpdevices.c
index 4d822f6..0dfae7a 100644
--- a/app/widgets/gimpdevices.c
+++ b/app/widgets/gimpdevices.c
@@ -111,7 +111,7 @@ gimp_devices_restore (Gimp *gimp)
gimp_device_info_set_default_tool (device_info);
}
- file = gimp_personal_rc_gfile ("devicerc");
+ file = gimp_directory_file ("devicerc", NULL);
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
@@ -154,7 +154,7 @@ gimp_devices_save (Gimp *gimp,
if (devicerc_deleted && ! always_save)
return;
- file = gimp_personal_rc_gfile ("devicerc");
+ file = gimp_directory_file ("devicerc", NULL);
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
@@ -190,7 +190,7 @@ gimp_devices_clear (Gimp *gimp,
g_return_val_if_fail (GIMP_IS_DEVICE_MANAGER (manager), FALSE);
- file = gimp_personal_rc_gfile ("devicerc");
+ file = gimp_directory_file ("devicerc", NULL);
if (! g_file_delete (file, NULL, &my_error) &&
my_error->code != G_IO_ERROR_NOT_FOUND)
diff --git a/libgimpbase/gimpbase.def b/libgimpbase/gimpbase.def
index 1d39321..05b528d 100644
--- a/libgimpbase/gimpbase.def
+++ b/libgimpbase/gimpbase.def
@@ -18,10 +18,12 @@ EXPORTS
gimp_cpu_accel_get_support
gimp_cpu_accel_set_use
gimp_data_directory
+ gimp_data_directory_file
gimp_datafiles_check_extension
gimp_datafiles_read_directories
gimp_desaturate_mode_get_type
gimp_directory
+ gimp_directory_file
gimp_dodge_burn_type_get_type
gimp_enum_get_desc
gimp_enum_get_value
@@ -54,6 +56,7 @@ EXPORTS
gimp_installation_directory
gimp_interpolation_type_get_type
gimp_locale_directory
+ gimp_locale_directory_file
gimp_major_version
gimp_mask_apply_mode_get_type
gimp_memsize_deserialize
@@ -112,12 +115,12 @@ EXPORTS
gimp_pdb_proc_type_get_type
gimp_pdb_status_type_get_type
gimp_personal_rc_file
- gimp_personal_rc_gfile
gimp_pixels_to_units
gimp_pixpipe_params_build
gimp_pixpipe_params_init
gimp_pixpipe_params_parse
gimp_plug_in_directory
+ gimp_plug_in_directory_file
gimp_precision_get_type
gimp_progress_command_get_type
gimp_rectangle_intersect
@@ -131,6 +134,7 @@ EXPORTS
gimp_stack_trace_mode_get_type
gimp_strip_uline
gimp_sysconf_directory
+ gimp_sysconf_directory_file
gimp_text_direction_get_type
gimp_text_hint_style_get_type
gimp_text_justification_get_type
diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c
index 9c0c040..aad50bb 100644
--- a/libgimpbase/gimpenv.c
+++ b/libgimpbase/gimpenv.c
@@ -555,23 +555,6 @@ gimp_sysconf_directory (void)
}
/**
- * gimp_user_directory:
- * @type: the type of user directory to retrieve
- *
- * This procedure is deprecated! Use g_get_user_special_dir() instead.
- *
- * Returns: The path to the specified user directory, or %NULL if the
- * logical ID was not found.
- *
- * Since: GIMP 2.4
- **/
-const gchar *
-gimp_user_directory (GimpUserDirectory type)
-{
- return g_get_user_special_dir (type);
-}
-
-/**
* gimp_plug_in_directory:
*
* Returns the top directory for GIMP plug_ins and modules. If the
@@ -606,53 +589,213 @@ gimp_plug_in_directory (void)
return gimp_plug_in_dir;
}
+static GFile *
+gimp_child_file (const gchar *parent,
+ const gchar *element,
+ va_list args)
+{
+ GFile *file = g_file_new_for_path (parent);
+
+ while (element)
+ {
+ GFile *child = g_file_get_child (file, element);
+
+ g_object_unref (file);
+ file = child;
+
+ element = va_arg (args, const gchar *);
+ }
+
+ return file;
+}
+
/**
- * gimp_personal_rc_file:
- * @basename: The basename of a rc_file.
+ * gimp_directory_file:
+ * @first_element: the first element of a path to a file in the
+ * user's GIMP directory, or %NULL.
+ * @...: a %NULL terminated list of the remaining elements of the path
+ * to the file.
*
- * Returns the name of a file in the user-specific GIMP settings directory.
+ * Returns a #GFile in the user's GIMP directory, or the data
+ * directory itself if @first_element is %NULL.
*
- * The returned string is newly allocated and should be freed with
- * g_free() after use. The returned string is in the encoding used for
- * filenames by GLib, which isn't necessarily UTF-8. (On Windows it
- * always is UTF-8.)
+ * See also: gimp_directory().
*
- * Returns: The name of a file in the user-specific GIMP settings directory.
+ * Since: GIMP 2.10
+ *
+ * Returns: a new @GFile for the path, Free with g_object_unref().
**/
-gchar *
-gimp_personal_rc_file (const gchar *basename)
+GFile *
+gimp_directory_file (const gchar *first_element,
+ ...)
{
- return g_build_filename (gimp_directory (), basename, NULL);
+ GFile *file;
+ va_list args;
+
+ va_start (args, first_element);
+ file = gimp_child_file (gimp_directory (), first_element, args);
+ va_end (args);
+
+ return file;
}
/**
- * gimp_personal_rc_gfile:
- * @basename: The basename of a rc_file.
+ * gimp_data_directory_file:
+ * @first_element: the first element of a path to a file in the
+ * data directory, or %NULL.
+ * @...: a %NULL terminated list of the remaining elements of the path
+ * to the file.
+ *
+ * Returns a #GFile in the data directory, or the data directory
+ * itself if @first_element is %NULL.
+ *
+ * See also: gimp_data_directory().
+ *
+ * Since: GIMP 2.10
+ *
+ * Returns: a new @GFile for the path, Free with g_object_unref().
+ **/
+GFile *
+gimp_data_directory_file (const gchar *first_element,
+ ...)
+{
+ GFile *file;
+ va_list args;
+
+ va_start (args, first_element);
+ file = gimp_child_file (gimp_data_directory (), first_element, args);
+ va_end (args);
+
+ return file;
+}
+
+/**
+ * gimp_locale_directory_file:
+ * @first_element: the first element of a path to a file in the
+ * locale directory, or %NULL.
+ * @...: a %NULL terminated list of the remaining elements of the path
+ * to the file.
+ *
+ * Returns a #GFile in the locale directory, or the locale directory
+ * itself if @first_element is %NULL.
+ *
+ * See also: gimp_locale_directory().
*
- * Returns a #GFile in the user-specific GIMP settings directory.
+ * Since: GIMP 2.10
+ *
+ * Returns: a new @GFile for the path, Free with g_object_unref().
+ **/
+GFile *
+gimp_locale_directory_file (const gchar *first_element,
+ ...)
+{
+ GFile *file;
+ va_list args;
+
+ va_start (args, first_element);
+ file = gimp_child_file (gimp_locale_directory (), first_element, args);
+ va_end (args);
+
+ return file;
+}
+
+/**
+ * gimp_sysconf_directory_file:
+ * @first_element: the first element of a path to a file in the
+ * sysconf directory, or %NULL.
+ * @...: a %NULL terminated list of the remaining elements of the path
+ * to the file.
*
- * The returned #GFile is newly allocated and should be freed with
- * g_object_unref() after use.
+ * Returns a #GFile in the sysconf directory, or the sysconf directory
+ * itself if @first_element is %NULL.
*
- * See gimp_personal_rc_file().
+ * See also: gimp_sysconf_directory().
*
* Since: GIMP 2.10
*
- * Returns: A #GFile in the user-specific GIMP settings directory.
+ * Returns: a new @GFile for the path, Free with g_object_unref().
**/
GFile *
-gimp_personal_rc_gfile (const gchar *basename)
+gimp_sysconf_directory_file (const gchar *first_element,
+ ...)
{
- gchar *path = gimp_personal_rc_file (basename);
- GFile *file;
+ GFile *file;
+ va_list args;
- file = g_file_new_for_path (path);
- g_free (path);
+ va_start (args, first_element);
+ file = gimp_child_file (gimp_sysconf_directory (), first_element, args);
+ va_end (args);
return file;
}
/**
+ * gimp_plug_in_directory_file:
+ * @first_element: the first element of a path to a file in the
+ * plug-in directory, or %NULL.
+ * @...: a %NULL terminated list of the remaining elements of the path
+ * to the file.
+ *
+ * Returns a #GFile in the plug-in directory, or the plug-in directory
+ * itself if @first_element is %NULL.
+ *
+ * See also: gimp_plug_in_directory().
+ *
+ * Since: GIMP 2.10
+ *
+ * Returns: a new @GFile for the path, Free with g_object_unref().
+ **/
+GFile *
+gimp_plug_in_directory_file (const gchar *first_element,
+ ...)
+{
+ GFile *file;
+ va_list args;
+
+ va_start (args, first_element);
+ file = gimp_child_file (gimp_plug_in_directory (), first_element, args);
+ va_end (args);
+
+ return file;
+}
+
+/**
+ * gimp_user_directory:
+ * @type: the type of user directory to retrieve
+ *
+ * This procedure is deprecated! Use g_get_user_special_dir() instead.
+ *
+ * Returns: The path to the specified user directory, or %NULL if the
+ * logical ID was not found.
+ *
+ * Since: GIMP 2.4
+ **/
+const gchar *
+gimp_user_directory (GimpUserDirectory type)
+{
+ return g_get_user_special_dir (type);
+}
+
+/**
+ * gimp_personal_rc_file:
+ * @basename: The basename of a rc_file.
+ *
+ * Returns the name of a file in the user-specific GIMP settings directory.
+ *
+ * The returned string is newly allocated and should be freed with
+ * g_free() after use. The returned string is in the encoding used for
+ * filenames by GLib, which isn't necessarily UTF-8. (On Windows it
+ * always is UTF-8.)
+ *
+ * Returns: The name of a file in the user-specific GIMP settings directory.
+ **/
+gchar *
+gimp_personal_rc_file (const gchar *basename)
+{
+ return g_build_filename (gimp_directory (), basename, NULL);
+}
+
+/**
* gimp_gtkrc:
*
* Returns the name of GIMP's application-specific gtkrc file.
diff --git a/libgimpbase/gimpenv.h b/libgimpbase/gimpenv.h
index 12770bc..0afdf6c 100644
--- a/libgimpbase/gimpenv.h
+++ b/libgimpbase/gimpenv.h
@@ -54,6 +54,17 @@ const gchar * gimp_locale_directory (void) G_GNUC_CONST;
const gchar * gimp_sysconf_directory (void) G_GNUC_CONST;
const gchar * gimp_plug_in_directory (void) G_GNUC_CONST;
+GFile * gimp_directory_file (const gchar *first_element,
+ ...) G_GNUC_MALLOC;
+GFile * gimp_data_directory_file (const gchar *first_element,
+ ...) G_GNUC_MALLOC;
+GFile * gimp_locale_directory_file (const gchar *first_element,
+ ...) G_GNUC_MALLOC;
+GFile * gimp_sysconf_directory_file (const gchar *first_element,
+ ...) G_GNUC_MALLOC;
+GFile * gimp_plug_in_directory_file (const gchar *first_element,
+ ...) G_GNUC_MALLOC;
+
#ifndef GIMP_DISABLE_DEPRECATED
GIMP_DEPRECATED_FOR(g_get_user_special_dir)
const gchar * gimp_user_directory (GimpUserDirectory type) G_GNUC_CONST;
@@ -61,7 +72,6 @@ const gchar * gimp_user_directory (GimpUserDirectory type) G_GNUC_
const gchar * gimp_gtkrc (void) G_GNUC_CONST;
gchar * gimp_personal_rc_file (const gchar *basename) G_GNUC_MALLOC;
-GFile * gimp_personal_rc_gfile (const gchar *basename);
GList * gimp_path_parse (const gchar *path,
gint max_paths,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]