[gimp] app: port the pluginrc code from filename to GFile
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: port the pluginrc code from filename to GFile
- Date: Wed, 2 Jul 2014 22:07:51 +0000 (UTC)
commit f146d454e8f372236120a56d5c50ecbe58917619
Author: Michael Natterer <mitch gimp org>
Date: Thu Jul 3 00:04:58 2014 +0200
app: port the pluginrc code from filename to GFile
app/plug-in/gimppluginmanager-restore.c | 39 +++++++++++++++++-------------
app/plug-in/plug-in-rc.c | 34 +++++++++++++-------------
app/plug-in/plug-in-rc.h | 12 ++++----
3 files changed, 45 insertions(+), 40 deletions(-)
---
diff --git a/app/plug-in/gimppluginmanager-restore.c b/app/plug-in/gimppluginmanager-restore.c
index 8f69674..e3f94c4 100644
--- a/app/plug-in/gimppluginmanager-restore.c
+++ b/app/plug-in/gimppluginmanager-restore.c
@@ -52,9 +52,9 @@
static void gimp_plug_in_manager_search (GimpPlugInManager *manager,
GimpInitStatusFunc status_callback);
-static gchar * gimp_plug_in_manager_get_pluginrc (GimpPlugInManager *manager);
+static GFile * gimp_plug_in_manager_get_pluginrc (GimpPlugInManager *manager);
static void gimp_plug_in_manager_read_pluginrc (GimpPlugInManager *manager,
- const gchar *pluginrc,
+ GFile *file,
GimpInitStatusFunc status_callback);
static void gimp_plug_in_manager_query_new (GimpPlugInManager *manager,
GimpContext *context,
@@ -85,7 +85,7 @@ gimp_plug_in_manager_restore (GimpPlugInManager *manager,
GimpInitStatusFunc status_callback)
{
Gimp *gimp;
- gchar *pluginrc;
+ GFile *pluginrc;
GSList *list;
GError *error = NULL;
@@ -128,7 +128,7 @@ gimp_plug_in_manager_restore (GimpPlugInManager *manager,
if (manager->write_pluginrc)
{
if (gimp->be_verbose)
- g_print ("Writing '%s'\n", gimp_filename_to_utf8 (pluginrc));
+ g_print ("Writing '%s'\n", gimp_file_get_utf8_name (pluginrc));
if (! plug_in_rc_write (manager->plug_in_defs, pluginrc, &error))
{
@@ -140,7 +140,7 @@ gimp_plug_in_manager_restore (GimpPlugInManager *manager,
manager->write_pluginrc = FALSE;
}
- g_free (pluginrc);
+ g_object_unref (pluginrc);
/* create locale and help domain lists */
for (list = manager->plug_in_defs; list; list = list->next)
@@ -246,28 +246,33 @@ gimp_plug_in_manager_search (GimpPlugInManager *manager,
g_free (path);
}
-static gchar *
+static GFile *
gimp_plug_in_manager_get_pluginrc (GimpPlugInManager *manager)
{
Gimp *gimp = manager->gimp;
- gchar *pluginrc;
+ GFile *pluginrc;
if (gimp->config->plug_in_rc_path)
{
- pluginrc = gimp_config_path_expand (gimp->config->plug_in_rc_path,
- TRUE, NULL);
+ gchar *path;
- if (! g_path_is_absolute (pluginrc))
+ path = gimp_config_path_expand (gimp->config->plug_in_rc_path,
+ TRUE, NULL);
+
+ if (! g_path_is_absolute (path))
{
- gchar *str = g_build_filename (gimp_directory (), pluginrc, NULL);
+ gchar *str = g_build_filename (gimp_directory (), path, NULL);
- g_free (pluginrc);
- pluginrc = str;
+ g_free (path);
+ path = str;
}
+
+ pluginrc = g_file_new_for_path (path);
+ g_free (path);
}
else
{
- pluginrc = gimp_personal_rc_file ("pluginrc");
+ pluginrc = gimp_personal_rc_gfile ("pluginrc");
}
return pluginrc;
@@ -276,17 +281,17 @@ gimp_plug_in_manager_get_pluginrc (GimpPlugInManager *manager)
/* read the pluginrc file for cached data */
static void
gimp_plug_in_manager_read_pluginrc (GimpPlugInManager *manager,
- const gchar *pluginrc,
+ GFile *pluginrc,
GimpInitStatusFunc status_callback)
{
GSList *rc_defs;
GError *error = NULL;
status_callback (_("Resource configuration"),
- gimp_filename_to_utf8 (pluginrc), 0.0);
+ gimp_file_get_utf8_name (pluginrc), 0.0);
if (manager->gimp->be_verbose)
- g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (pluginrc));
+ g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (pluginrc));
rc_defs = plug_in_rc_parse (manager->gimp, pluginrc, &error);
diff --git a/app/plug-in/plug-in-rc.c b/app/plug-in/plug-in-rc.c
index c436f13..233d0dc 100644
--- a/app/plug-in/plug-in-rc.c
+++ b/app/plug-in/plug-in-rc.c
@@ -96,9 +96,9 @@ enum
GSList *
-plug_in_rc_parse (Gimp *gimp,
- const gchar *filename,
- GError **error)
+plug_in_rc_parse (Gimp *gimp,
+ GFile *file,
+ GError **error)
{
GScanner *scanner;
GEnumClass *enum_class;
@@ -108,10 +108,10 @@ plug_in_rc_parse (Gimp *gimp,
GTokenType token;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
- g_return_val_if_fail (filename != NULL, NULL);
+ g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
- scanner = gimp_scanner_new_file (filename, error);
+ scanner = gimp_scanner_new_gfile (file, error);
if (! scanner)
return NULL;
@@ -225,14 +225,14 @@ plug_in_rc_parse (Gimp *gimp,
g_set_error (error,
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_VERSION,
_("Skipping '%s': wrong GIMP protocol version."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
}
else if (file_version != PLUG_IN_RC_FILE_VERSION)
{
g_set_error (error,
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_VERSION,
_("Skipping '%s': wrong pluginrc file format version."),
- gimp_filename_to_utf8 (filename));
+ gimp_file_get_utf8_name (file));
}
else
{
@@ -783,21 +783,21 @@ plug_in_has_init_deserialize (GScanner *scanner,
/* serialize functions */
gboolean
-plug_in_rc_write (GSList *plug_in_defs,
- const gchar *filename,
- GError **error)
+plug_in_rc_write (GSList *plug_in_defs,
+ GFile *file,
+ GError **error)
{
GimpConfigWriter *writer;
GEnumClass *enum_class;
GSList *list;
- writer = gimp_config_writer_new_file (filename,
- FALSE,
- "GIMP pluginrc\n\n"
- "This file can safely be removed and "
- "will be automatically regenerated by "
- "querying the installed plugins.",
- error);
+ writer = gimp_config_writer_new_gfile (file,
+ FALSE,
+ "GIMP pluginrc\n\n"
+ "This file can safely be removed and "
+ "will be automatically regenerated by "
+ "querying the installed plugins.",
+ error);
if (!writer)
return FALSE;
diff --git a/app/plug-in/plug-in-rc.h b/app/plug-in/plug-in-rc.h
index c4c0726..6c71f98 100644
--- a/app/plug-in/plug-in-rc.h
+++ b/app/plug-in/plug-in-rc.h
@@ -22,12 +22,12 @@
#define __PLUG_IN_RC_H__
-GSList * plug_in_rc_parse (Gimp *gimp,
- const gchar *filename,
- GError **error);
-gboolean plug_in_rc_write (GSList *plug_in_defs,
- const gchar *filename,
- GError **error);
+GSList * plug_in_rc_parse (Gimp *gimp,
+ GFile *file,
+ GError **error);
+gboolean plug_in_rc_write (GSList *plug_in_defs,
+ GFile *file,
+ GError **error);
#endif /* __PLUG_IN_RC_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]