libgimpconfig: get rid of filenames in all config related APIs

and rename function names which say "gfile" to just "file".
This commit is contained in:
Michael Natterer 2019-09-21 12:53:38 +02:00
parent b327e0ff2f
commit dbd793d631
32 changed files with 214 additions and 383 deletions

View File

@ -111,8 +111,8 @@ gimp_lang_rc_constructed (GObject *object)
g_print ("Parsing '%s' for configured language.\n",
gimp_file_get_utf8_name (rc->system_gimprc));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc),
rc->system_gimprc, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (rc),
rc->system_gimprc, NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
g_message ("%s", error->message);
@ -124,8 +124,8 @@ gimp_lang_rc_constructed (GObject *object)
g_print ("Parsing '%s' for configured language.\n",
gimp_file_get_utf8_name (rc->user_gimprc));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc),
rc->user_gimprc, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (rc),
rc->user_gimprc, NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
g_message ("%s", error->message);

View File

@ -315,8 +315,8 @@ gimp_rc_load_system (GimpRc *rc)
g_print ("Parsing '%s'\n",
gimp_file_get_utf8_name (rc->system_gimprc));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc),
rc->system_gimprc, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (rc),
rc->system_gimprc, NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
g_message ("%s", error->message);
@ -336,8 +336,8 @@ gimp_rc_load_user (GimpRc *rc)
g_print ("Parsing '%s'\n",
gimp_file_get_utf8_name (rc->user_gimprc));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (rc),
rc->user_gimprc, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (rc),
rc->user_gimprc, NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
@ -530,8 +530,8 @@ gimp_rc_save (GimpRc *rc)
if (gimp)
g_object_unref (gimp);
gimp_config_deserialize_gfile (GIMP_CONFIG (global),
rc->system_gimprc, NULL, NULL);
gimp_config_deserialize_file (GIMP_CONFIG (global),
rc->system_gimprc, NULL, NULL);
header = g_strconcat (top, gimp_file_get_utf8_name (rc->system_gimprc),
bottom, NULL);
@ -540,10 +540,10 @@ gimp_rc_save (GimpRc *rc)
g_print ("Writing '%s'\n",
gimp_file_get_utf8_name (rc->user_gimprc));
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (rc),
rc->user_gimprc,
header, footer, global,
&error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (rc),
rc->user_gimprc,
header, footer, global,
&error))
{
g_message ("%s", error->message);
g_error_free (error);

View File

@ -84,9 +84,9 @@ gimp_contexts_load (Gimp *gimp,
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
success = gimp_config_deserialize_gfile (GIMP_CONFIG (gimp_get_user_context (gimp)),
file,
NULL, &my_error);
success = gimp_config_deserialize_file (GIMP_CONFIG (gimp_get_user_context (gimp)),
file,
NULL, &my_error);
g_object_unref (file);
@ -121,11 +121,11 @@ gimp_contexts_save (Gimp *gimp,
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
success = gimp_config_serialize_to_gfile (GIMP_CONFIG (gimp_get_user_context (gimp)),
file,
"GIMP user context",
"end of user context",
NULL, error);
success = gimp_config_serialize_to_file (GIMP_CONFIG (gimp_get_user_context (gimp)),
file,
"GIMP user context",
"end of user context",
NULL, error);
g_object_unref (file);

View File

@ -75,7 +75,7 @@ gimp_modules_load (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
scanner = gimp_scanner_new_gfile (file, NULL);
scanner = gimp_scanner_new_file (file, NULL);
g_object_unref (file);
if (scanner)
@ -195,10 +195,10 @@ gimp_modules_unload (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
writer = gimp_config_writer_new_from_gfile (file,
TRUE,
"GIMP modulerc",
&error);
writer = gimp_config_writer_new_from_file (file,
TRUE,
"GIMP modulerc",
&error);
g_object_unref (file);
if (writer)

View File

@ -124,8 +124,8 @@ gimp_parasiterc_load (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (gimp->parasites),
file, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->parasites),
file, NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
@ -157,10 +157,10 @@ gimp_parasiterc_save (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (gimp->parasites),
file,
header, footer, NULL,
&error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (gimp->parasites),
file,
header, footer, NULL,
&error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error);

View File

@ -49,8 +49,8 @@ gimp_templates_load (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (gimp->templates),
file, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
file, NULL, &error))
{
if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
@ -59,8 +59,8 @@ gimp_templates_load (Gimp *gimp)
file = gimp_sysconf_directory_file ("templaterc", NULL);
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (gimp->templates),
file, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates),
file, NULL, &error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR,
error->message);
@ -100,10 +100,10 @@ gimp_templates_save (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (gimp->templates),
file,
header, footer, NULL,
&error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (gimp->templates),
file,
header, footer, NULL,
&error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error);
@ -171,8 +171,8 @@ gimp_templates_migrate (const gchar *olddir)
GimpContainer *templates = gimp_list_new (GIMP_TYPE_TEMPLATE, TRUE);
GFile *file = gimp_directory_file ("templaterc", NULL);
if (gimp_config_deserialize_gfile (GIMP_CONFIG (templates), file,
NULL, NULL))
if (gimp_config_deserialize_file (GIMP_CONFIG (templates), file,
NULL, NULL))
{
GFile *sysconf_file;
@ -190,23 +190,23 @@ gimp_templates_migrate (const gchar *olddir)
class->get_child_by_name = gimp_templates_migrate_get_child_by_name;
gimp_config_deserialize_gfile (GIMP_CONFIG (templates),
sysconf_file, NULL, NULL);
gimp_config_deserialize_file (GIMP_CONFIG (templates),
sysconf_file, NULL, NULL);
class->get_child_by_name = func;
}
else
{
gimp_config_deserialize_gfile (GIMP_CONFIG (templates),
sysconf_file, NULL, NULL);
gimp_config_deserialize_file (GIMP_CONFIG (templates),
sysconf_file, NULL, NULL);
}
g_object_unref (sysconf_file);
gimp_list_reverse (GIMP_LIST (templates));
gimp_config_serialize_to_gfile (GIMP_CONFIG (templates), file,
NULL, NULL, NULL, NULL);
gimp_config_serialize_to_file (GIMP_CONFIG (templates), file,
NULL, NULL, NULL, NULL);
}
g_object_unref (file);

View File

@ -205,7 +205,7 @@ gimp_unitrc_load (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
scanner = gimp_scanner_new_gfile (file, &error);
scanner = gimp_scanner_new_file (file, &error);
if (! scanner && error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
@ -214,7 +214,7 @@ gimp_unitrc_load (Gimp *gimp)
file = gimp_sysconf_directory_file ("unitrc", NULL);
scanner = gimp_scanner_new_gfile (file, NULL);
scanner = gimp_scanner_new_file (file, NULL);
}
if (! scanner)
@ -303,16 +303,16 @@ gimp_unitrc_save (Gimp *gimp)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
writer =
gimp_config_writer_new_from_gfile (file,
TRUE,
"GIMP units\n\n"
"This file contains the user unit database. "
"You can edit this list with the unit "
"editor. You are not supposed to edit it "
"manually, but of course you can do.\n"
"This file will be entirely rewritten each "
"time you exit.",
NULL);
gimp_config_writer_new_from_file (file,
TRUE,
"GIMP units\n\n"
"This file contains the user unit database. "
"You can edit this list with the unit "
"editor. You are not supposed to edit it "
"manually, but of course you can do.\n"
"This file will be entirely rewritten each "
"time you exit.",
NULL);
g_object_unref (file);

View File

@ -576,8 +576,8 @@ gimp_extension_manager_initialize (GimpExtensionManager *manager)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
processed_ids = NULL;
gimp_config_deserialize_gfile (GIMP_CONFIG (manager),
file, &processed_ids, &error);
gimp_config_deserialize_file (GIMP_CONFIG (manager),
file, &processed_ids, &error);
if (error)
{
g_printerr ("Failed to parse '%s': %s\n",
@ -653,12 +653,12 @@ gimp_extension_manager_exit (GimpExtensionManager *manager)
if (manager->p->gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (manager),
file,
"GIMP extensionrc",
"end of extensionrc",
NULL,
&error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager),
file,
"GIMP extensionrc",
"end of extensionrc",
NULL,
&error))
{
gimp_message_literal (manager->p->gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error);

View File

@ -90,7 +90,7 @@ gimp_palette_mru_load (GimpPaletteMru *mru,
palette = GIMP_PALETTE (mru);
scanner = gimp_scanner_new_gfile (file, NULL);
scanner = gimp_scanner_new_file (file, NULL);
if (! scanner)
return;
@ -153,12 +153,12 @@ gimp_palette_mru_save (GimpPaletteMru *mru,
g_return_if_fail (GIMP_IS_PALETTE_MRU (mru));
g_return_if_fail (G_IS_FILE (file));
writer = gimp_config_writer_new_from_gfile (file,
TRUE,
"GIMP colorrc\n\n"
"This file holds a list of "
"recently used colors.",
NULL);
writer = gimp_config_writer_new_from_file (file,
TRUE,
"GIMP colorrc\n\n"
"This file holds a list of "
"recently used colors.",
NULL);
if (! writer)
return;

View File

@ -297,11 +297,11 @@ gimp_tool_options_serialize (GimpToolOptions *tool_options,
footer = g_strdup_printf ("end of %s options",
gimp_object_get_name (tool_options->tool_info));
retval = gimp_config_serialize_to_gfile (GIMP_CONFIG (tool_options),
file,
header, footer,
NULL,
error);
retval = gimp_config_serialize_to_file (GIMP_CONFIG (tool_options),
file,
header, footer,
NULL,
error);
g_free (header);
g_free (footer);
@ -326,10 +326,10 @@ gimp_tool_options_deserialize (GimpToolOptions *tool_options,
if (tool_options->tool_info->gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
retval = gimp_config_deserialize_gfile (GIMP_CONFIG (tool_options),
file,
NULL,
error);
retval = gimp_config_deserialize_file (GIMP_CONFIG (tool_options),
file,
NULL,
error);
g_object_unref (file);

View File

@ -331,11 +331,11 @@ color_profile_combo_box_new (ProfileDialog *private)
GtkListStore *store;
GtkWidget *combo;
GtkWidget *chooser;
gchar *history;
GFile *history;
history = gimp_personal_rc_file ("profilerc");
history = gimp_directory_file ("profilerc", NULL);
store = gimp_color_profile_store_new (history);
g_free (history);
g_object_unref (history);
if (private->default_profile)
{

View File

@ -616,9 +616,9 @@ dialogs_load_recent_docks (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (global_recent_docks),
file,
NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (global_recent_docks),
file,
NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
@ -651,11 +651,11 @@ dialogs_save_recent_docks (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (global_recent_docks),
file,
"recently closed docks",
"end of recently closed docks",
NULL, &error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (global_recent_docks),
file,
"recently closed docks",
"end of recently closed docks",
NULL, &error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_clear_error (&error);

View File

@ -1309,12 +1309,12 @@ prefs_dialog_new (Gimp *gimp,
{
GObject *color_config = G_OBJECT (core_config->color_management);
GtkListStore *store;
gchar *filename;
GFile *file;
gint row = 0;
filename = gimp_personal_rc_file ("profilerc");
store = gimp_color_profile_store_new (filename);
g_free (filename);
file = gimp_directory_file ("profilerc");
store = gimp_color_profile_store_new (file);
g_object_unref (file);
gimp_color_profile_store_add_file (GIMP_COLOR_PROFILE_STORE (store),
NULL, NULL);

View File

@ -79,7 +79,7 @@ session_init (Gimp *gimp)
file = session_file (gimp);
scanner = gimp_scanner_new_gfile (file, &error);
scanner = gimp_scanner_new_file (file, &error);
if (! scanner && error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
@ -88,7 +88,7 @@ session_init (Gimp *gimp)
file = gimp_sysconf_directory_file ("sessionrc", NULL);
scanner = gimp_scanner_new_gfile (file, NULL);
scanner = gimp_scanner_new_file (file, NULL);
}
if (! scanner)
@ -368,18 +368,18 @@ session_save (Gimp *gimp,
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
writer =
gimp_config_writer_new_from_gfile (file,
TRUE,
"GIMP sessionrc\n\n"
"This file takes session-specific info "
"(that is info, you want to keep between "
"two GIMP sessions). You are not supposed "
"to edit it manually, but of course you "
"can do. The sessionrc will be entirely "
"rewritten every time you quit GIMP. "
"If this file isn't found, defaults are "
"used.",
NULL);
gimp_config_writer_new_from_file (file,
TRUE,
"GIMP sessionrc\n\n"
"This file takes session-specific info "
"(that is info, you want to keep between "
"two GIMP sessions). You are not supposed "
"to edit it manually, but of course you "
"can do. The sessionrc will be entirely "
"rewritten every time you quit GIMP. "
"If this file isn't found, defaults are "
"used.",
NULL);
g_object_unref (file);
if (!writer)

View File

@ -264,11 +264,11 @@ gimp_operation_config_serialize (Gimp *gimp,
gimp_operation_config_remove_sep (container);
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (container),
file,
"settings",
"end of settings",
NULL, &error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (container),
file,
"settings",
"end of settings",
NULL, &error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR,
error->message);
@ -305,9 +305,9 @@ gimp_operation_config_deserialize (Gimp *gimp,
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (container),
file,
NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (container),
file,
NULL, &error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR,

View File

@ -115,7 +115,7 @@ plug_in_rc_parse (Gimp *gimp,
g_return_val_if_fail (G_IS_FILE (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
scanner = gimp_scanner_new_gfile (file, error);
scanner = gimp_scanner_new_file (file, error);
if (! scanner)
return NULL;
@ -1105,14 +1105,14 @@ plug_in_rc_write (GSList *plug_in_defs,
GEnumClass *enum_class;
GSList *list;
writer = gimp_config_writer_new_from_gfile (file,
FALSE,
"GIMP pluginrc\n\n"
"This file can safely be removed and "
"will be automatically regenerated by "
"querying the installed plug-ins.",
error);
if (!writer)
writer = gimp_config_writer_new_from_file (file,
FALSE,
"GIMP pluginrc\n\n"
"This file can safely be removed and "
"will be automatically regenerated by "
"querying the installed plug-ins.",
error);
if (! writer)
return FALSE;
enum_class = g_type_class_ref (GIMP_TYPE_ICON_TYPE);

View File

@ -270,8 +270,8 @@ gimp_tools_restore (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (gimp_config_deserialize_gfile (GIMP_CONFIG (gimp_list), file,
NULL, &error))
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;
@ -423,11 +423,11 @@ gimp_tools_save (Gimp *gimp,
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
gimp_config_serialize_to_gfile (GIMP_CONFIG (gimp->tool_info_list),
file,
"GIMP toolrc",
"end of toolrc",
NULL, NULL);
gimp_config_serialize_to_file (GIMP_CONFIG (gimp->tool_info_list),
file,
"GIMP toolrc",
"end of toolrc",
NULL, NULL);
g_object_unref (file);
}

View File

@ -122,7 +122,7 @@ gimp_action_history_init (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
scanner = gimp_scanner_new_gfile (file, NULL);
scanner = gimp_scanner_new_file (file, NULL);
g_object_unref (file);
if (! scanner)
@ -222,8 +222,8 @@ gimp_action_history_exit (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
writer = gimp_config_writer_new_from_gfile (file, TRUE, "GIMP action-history",
NULL);
writer = gimp_config_writer_new_from_file (file, TRUE, "GIMP action-history",
NULL);
g_object_unref (file);
for (actions = history.items->head, i = 0;

View File

@ -150,8 +150,8 @@ gimp_controllers_restore (Gimp *gimp,
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (manager->controllers),
file, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (manager->controllers),
file, NULL, &error))
{
if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
@ -160,8 +160,8 @@ gimp_controllers_restore (Gimp *gimp,
file = gimp_sysconf_directory_file ("controllerrc", NULL);
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (manager->controllers),
file, NULL, &error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (manager->controllers),
file, NULL, &error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR,
error->message);
@ -205,10 +205,10 @@ gimp_controllers_save (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (manager->controllers),
file,
header, footer, NULL,
&error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager->controllers),
file,
header, footer, NULL,
&error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error);

View File

@ -113,10 +113,10 @@ gimp_devices_restore (Gimp *gimp)
if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (manager),
file,
gimp,
&error))
if (! gimp_config_deserialize_file (GIMP_CONFIG (manager),
file,
gimp,
&error))
{
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
@ -183,12 +183,12 @@ gimp_devices_save (Gimp *gimp,
gimp_device_info_save_tool (current_device);
}
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (manager),
file,
"GIMP devicerc",
"end of devicerc",
NULL,
&error))
if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager),
file,
"GIMP devicerc",
"end of devicerc",
NULL,
&error))
{
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error);

View File

@ -405,9 +405,9 @@ gimp_procedure_config_load_last (GimpProcedureConfig *config,
GFile *file = gimp_procedure_config_get_file (config, ".last");
gboolean success;
success = gimp_config_deserialize_gfile (GIMP_CONFIG (config),
file,
NULL, error);
success = gimp_config_deserialize_file (GIMP_CONFIG (config),
file,
NULL, error);
if (! success && (*error)->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
{
@ -427,11 +427,11 @@ gimp_procedure_config_save_last (GimpProcedureConfig *config,
GFile *file = gimp_procedure_config_get_file (config, ".last");
gboolean success;
success = gimp_config_serialize_to_gfile (GIMP_CONFIG (config),
file,
"settings",
"end of settings",
NULL, error);
success = gimp_config_serialize_to_file (GIMP_CONFIG (config),
file,
"settings",
"end of settings",
NULL, error);
g_object_unref (file);

View File

@ -277,47 +277,6 @@ gimp_config_iface_copy (GimpConfig *src,
/**
* gimp_config_serialize_to_file:
* @config: a #GObject that implements the #GimpConfigInterface.
* @filename: the name of the file to write the configuration to.
* @header: optional file header (must be ASCII only)
* @footer: optional file footer (must be ASCII only)
* @data: user data passed to the serialize implementation.
* @error: return location for a possible error
*
* Serializes the object properties of @config to the file specified
* by @filename. If a file with that name already exists, it is
* overwritten. Basically this function opens @filename for you and
* calls the serialize function of the @config's #GimpConfigInterface.
*
* Returns: %TRUE if serialization succeeded, %FALSE otherwise.
*
* Since: 2.4
**/
gboolean
gimp_config_serialize_to_file (GimpConfig *config,
const gchar *filename,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error)
{
GimpConfigWriter *writer;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
writer = gimp_config_writer_new_from_file (filename, TRUE, header, error);
if (!writer)
return FALSE;
GIMP_CONFIG_GET_INTERFACE (config)->serialize (config, writer, data);
return gimp_config_writer_finish (writer, footer, error);
}
/**
* gimp_config_serialize_to_gfile:
* @config: a #GObject that implements the #GimpConfigInterface.
* @file: the #GFile to write the configuration to.
* @header: optional file header (must be ASCII only)
* @footer: optional file footer (must be ASCII only)
@ -334,12 +293,12 @@ gimp_config_serialize_to_file (GimpConfig *config,
* Since: 2.10
**/
gboolean
gimp_config_serialize_to_gfile (GimpConfig *config,
GFile *file,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error)
gimp_config_serialize_to_file (GimpConfig *config,
GFile *file,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error)
{
GimpConfigWriter *writer;
@ -347,7 +306,7 @@ gimp_config_serialize_to_gfile (GimpConfig *config,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
writer = gimp_config_writer_new_from_gfile (file, TRUE, header, error);
writer = gimp_config_writer_new_from_file (file, TRUE, header, error);
if (!writer)
return FALSE;
@ -500,54 +459,6 @@ gimp_config_serialize_to_parasite (GimpConfig *config,
/**
* gimp_config_deserialize_file:
* @config: a #GObject that implements the #GimpConfigInterface.
* @filename: the name of the file to read configuration from.
* @data: user data passed to the deserialize implementation.
* @error: return location for a possible error
*
* Opens the file specified by @filename, reads configuration data
* from it and configures @config accordingly. Basically this function
* creates a properly configured #GScanner for you and calls the
* deserialize function of the @config's #GimpConfigInterface.
*
* Returns: %TRUE if deserialization succeeded, %FALSE otherwise.
*
* Since: 2.4
**/
gboolean
gimp_config_deserialize_file (GimpConfig *config,
const gchar *filename,
gpointer data,
GError **error)
{
GScanner *scanner;
gboolean success;
g_return_val_if_fail (GIMP_IS_CONFIG (config), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
scanner = gimp_scanner_new_file (filename, error);
if (! scanner)
return FALSE;
g_object_freeze_notify (G_OBJECT (config));
success = GIMP_CONFIG_GET_INTERFACE (config)->deserialize (config,
scanner, 0, data);
g_object_thaw_notify (G_OBJECT (config));
gimp_scanner_unref (scanner);
if (! success)
g_assert (error == NULL || *error != NULL);
return success;
}
/**
* gimp_config_deserialize_gfile:
* @config: a #GObject that implements the #GimpConfigInterface.
* @file: the #GFile to read configuration from.
* @data: user data passed to the deserialize implementation.
* @error: return location for a possible error
@ -562,10 +473,10 @@ gimp_config_deserialize_file (GimpConfig *config,
* Since: 2.10
**/
gboolean
gimp_config_deserialize_gfile (GimpConfig *config,
GFile *file,
gpointer data,
GError **error)
gimp_config_deserialize_file (GimpConfig *config,
GFile *file,
gpointer data,
GError **error)
{
GScanner *scanner;
gboolean success;
@ -574,7 +485,7 @@ gimp_config_deserialize_gfile (GimpConfig *config,
g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
scanner = gimp_scanner_new_gfile (file, error);
scanner = gimp_scanner_new_file (file, error);
if (! scanner)
return FALSE;

View File

@ -74,12 +74,6 @@ struct _GimpConfigInterface
GType gimp_config_get_type (void) G_GNUC_CONST;
gboolean gimp_config_serialize_to_file (GimpConfig *config,
const gchar *filename,
const gchar *header,
const gchar *footer,
gpointer data,
GError **error);
gboolean gimp_config_serialize_to_gfile (GimpConfig *config,
GFile *file,
const gchar *header,
const gchar *footer,
@ -103,10 +97,6 @@ GimpParasite *
gpointer data);
gboolean gimp_config_deserialize_file (GimpConfig *config,
const gchar *filename,
gpointer data,
GError **error);
gboolean gimp_config_deserialize_gfile (GimpConfig *config,
GFile *file,
gpointer data,
GError **error);

View File

@ -24,7 +24,6 @@ EXPORTS
gimp_config_copy
gimp_config_deserialize
gimp_config_deserialize_file
gimp_config_deserialize_gfile
gimp_config_deserialize_parasite
gimp_config_deserialize_properties
gimp_config_deserialize_property
@ -51,7 +50,6 @@ EXPORTS
gimp_config_serialize_property_by_name
gimp_config_serialize_to_fd
gimp_config_serialize_to_file
gimp_config_serialize_to_gfile
gimp_config_serialize_to_parasite
gimp_config_serialize_to_stream
gimp_config_serialize_to_string
@ -69,7 +67,6 @@ EXPORTS
gimp_config_writer_linefeed
gimp_config_writer_new_from_fd
gimp_config_writer_new_from_file
gimp_config_writer_new_from_gfile
gimp_config_writer_new_from_stream
gimp_config_writer_new_from_string
gimp_config_writer_open
@ -86,7 +83,6 @@ EXPORTS
gimp_param_spec_config_path_type
gimp_scanner_get_type
gimp_scanner_new_file
gimp_scanner_new_gfile
gimp_scanner_new_stream
gimp_scanner_new_string
gimp_scanner_parse_boolean

View File

@ -118,43 +118,6 @@ gimp_config_writer_newline (GimpConfigWriter *writer)
/**
* gimp_config_writer_new_from_file:
* @filename: a filename
* @atomic: if %TRUE the file is written atomically
* @header: text to include as comment at the top of the file
* @error: return location for errors
*
* Creates a new #GimpConfigWriter and sets it up to write to
* @filename. If @atomic is %TRUE, a temporary file is used to avoid
* possible race conditions. The temporary file is then moved to
* @filename when the writer is closed.
*
* Returns: (nullable): a new #GimpConfigWriter or %NULL in case of an error
*
* Since: 2.4
**/
GimpConfigWriter *
gimp_config_writer_new_from_file (const gchar *filename,
gboolean atomic,
const gchar *header,
GError **error)
{
GimpConfigWriter *writer;
GFile *file;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
file = g_file_new_for_path (filename);
writer = gimp_config_writer_new_from_gfile (file, atomic, header, error);
g_object_unref (file);
return writer;
}
/**
* gimp_config_writer_new_from_gfile:
* @file: a #GFile
* @atomic: if %TRUE the file is written atomically
* @header: text to include as comment at the top of the file
@ -170,10 +133,10 @@ gimp_config_writer_new_from_file (const gchar *filename,
* Since: 2.10
**/
GimpConfigWriter *
gimp_config_writer_new_from_gfile (GFile *file,
gboolean atomic,
const gchar *header,
GError **error)
gimp_config_writer_new_from_file (GFile *file,
gboolean atomic,
const gchar *header,
GError **error)
{
GimpConfigWriter *writer;
GOutputStream *output;

View File

@ -40,11 +40,7 @@
GType gimp_config_writer_get_type (void) G_GNUC_CONST;
GimpConfigWriter * gimp_config_writer_new_from_file (const gchar *filename,
gboolean atomic,
const gchar *header,
GError **error);
GimpConfigWriter * gimp_config_writer_new_from_gfile (GFile *file,
GimpConfigWriter * gimp_config_writer_new_from_file (GFile *file,
gboolean atomic,
const gchar *header,
GError **error);

View File

@ -78,32 +78,6 @@ static void gimp_scanner_message (GimpScanner *scanner,
/**
* gimp_scanner_new_file:
* @filename:
* @error:
*
* Returns: (transfer full): The new #GimpScanner.
*
* Since: 2.4
**/
GimpScanner *
gimp_scanner_new_file (const gchar *filename,
GError **error)
{
GimpScanner *scanner;
GFile *file;
g_return_val_if_fail (filename != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
file = g_file_new_for_path (filename);
scanner = gimp_scanner_new_gfile (file, error);
g_object_unref (file);
return scanner;
}
/**
* gimp_scanner_new_gfile:
* @file: a #GFile
* @error: return location for #GError, or %NULL
*
@ -112,8 +86,8 @@ gimp_scanner_new_file (const gchar *filename,
* Since: 2.10
**/
GimpScanner *
gimp_scanner_new_gfile (GFile *file,
GError **error)
gimp_scanner_new_file (GFile *file,
GError **error)
{
GimpScanner *scanner;
gchar *path;

View File

@ -41,9 +41,7 @@
GType gimp_scanner_get_type (void) G_GNUC_CONST;
GimpScanner * gimp_scanner_new_file (const gchar *filename,
GError **error);
GimpScanner * gimp_scanner_new_gfile (GFile *file,
GimpScanner * gimp_scanner_new_file (GFile *file,
GError **error);
GimpScanner * gimp_scanner_new_stream (GInputStream *input,
GError **error);

View File

@ -288,7 +288,7 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
* gimp_color_profile_combo_box_new:
* @dialog: a #GtkDialog to present when the user selects the
* "Select color profile from disk..." item
* @history: filename of the profilerc (or %NULL for no history)
* @history: #GFile of the profilerc (or %NULL for no history)
*
* Create a combo-box widget for selecting color profiles. The combo-box
* is populated from the file specified as @history. This filename is
@ -313,13 +313,14 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
* Since: 2.4
**/
GtkWidget *
gimp_color_profile_combo_box_new (GtkWidget *dialog,
const gchar *history)
gimp_color_profile_combo_box_new (GtkWidget *dialog,
GFile *history)
{
GtkWidget *combo;
GtkListStore *store;
g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL);
g_return_val_if_fail (history == NULL || G_IS_FILE (history), NULL);
store = gimp_color_profile_store_new (history);
combo = gimp_color_profile_combo_box_new_with_model (dialog,

View File

@ -65,7 +65,7 @@ struct _GimpColorProfileComboBoxClass
GType gimp_color_profile_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_profile_combo_box_new (GtkWidget *dialog,
const gchar *history);
GFile *history);
GtkWidget * gimp_color_profile_combo_box_new_with_model (GtkWidget *dialog,
GtkTreeModel *model);

View File

@ -56,7 +56,7 @@ enum
struct _GimpColorProfileStorePrivate
{
gchar *history;
GFile *history;
};
#define GET_PRIVATE(obj) (((GimpColorProfileStore *) (obj))->priv)
@ -83,10 +83,10 @@ static void gimp_color_profile_store_get_separator (GimpColorProfileStore
GtkTreeIter *iter,
gboolean top);
static gboolean gimp_color_profile_store_save (GimpColorProfileStore *store,
const gchar *filename,
GFile *file,
GError **error);
static gboolean gimp_color_profile_store_load (GimpColorProfileStore *store,
const gchar *filename,
GFile *file,
GError **error);
@ -110,16 +110,16 @@ gimp_color_profile_store_class_init (GimpColorProfileStoreClass *klass)
/**
* GimpColorProfileStore:history:
*
* Filename of the color history used to populate the profile store.
* #GFile of the color history used to populate the profile store.
*
* Since: 2.4
*/
g_object_class_install_property (object_class,
PROP_HISTORY,
g_param_spec_string ("history",
g_param_spec_object ("history",
"History",
"Filename of the color history used to populate the profile store",
NULL,
"Filen of the color history used to populate the profile store",
G_TYPE_FILE,
G_PARAM_CONSTRUCT_ONLY |
GIMP_PARAM_READWRITE));
}
@ -179,7 +179,7 @@ gimp_color_profile_store_finalize (GObject *object)
{
GimpColorProfileStorePrivate *private = GET_PRIVATE (object);
g_clear_pointer (&private->history, g_free);
g_clear_object (&private->history);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -196,7 +196,7 @@ gimp_color_profile_store_set_property (GObject *object,
{
case PROP_HISTORY:
g_return_if_fail (private->history == NULL);
private->history = g_value_dup_string (value);
private->history = g_value_dup_object (value);
break;
default:
@ -216,7 +216,7 @@ gimp_color_profile_store_get_property (GObject *object,
switch (property_id)
{
case PROP_HISTORY:
g_value_set_string (value, private->history);
g_value_set_object (value, private->history);
break;
default:
@ -228,13 +228,13 @@ gimp_color_profile_store_get_property (GObject *object,
/**
* gimp_color_profile_store_new:
* @history: filename of the profilerc (or %NULL for no history)
* @history: #GFile of the profilerc (or %NULL for no history)
*
* Creates a new #GimpColorProfileStore object and populates it with
* last used profiles read from the file @history. The updated history
* is written back to disk when the store is disposed.
*
* The filename passed as @history is typically created using the
* The #GFile passed as @history is typically created using the
* following code snippet:
* <informalexample><programlisting>
* gchar *history = gimp_personal_rc_file ("profilerc");
@ -245,8 +245,10 @@ gimp_color_profile_store_get_property (GObject *object,
* Since: 2.4
**/
GtkListStore *
gimp_color_profile_store_new (const gchar *history)
gimp_color_profile_store_new (GFile *history)
{
g_return_val_if_fail (history == NULL || G_IS_FILE (history), NULL);
return g_object_new (GIMP_TYPE_COLOR_PROFILE_STORE,
"history", history,
NULL);
@ -255,9 +257,9 @@ gimp_color_profile_store_new (const gchar *history)
/**
* gimp_color_profile_store_add_file:
* @store: a #GimpColorProfileStore
* @file: file of the profile to add (or %NULL)
* @file: #GFile of the profile to add (or %NULL)
* @label: label to use for the profile
* (may only be %NULL if @filename is %NULL)
* (may only be %NULL if @file is %NULL)
*
* Adds a color profile item to the #GimpColorProfileStore. Items
* added with this function will be kept at the top, separated from
@ -635,14 +637,14 @@ gimp_color_profile_store_load_profile (GimpColorProfileStore *store,
static gboolean
gimp_color_profile_store_load (GimpColorProfileStore *store,
const gchar *filename,
GFile *file,
GError **error)
{
GScanner *scanner;
GTokenType token;
gint i = 0;
scanner = gimp_scanner_new_file (filename, error);
scanner = gimp_scanner_new_file (file, error);
if (! scanner)
return FALSE;
@ -687,7 +689,7 @@ gimp_color_profile_store_load (GimpColorProfileStore *store,
static gboolean
gimp_color_profile_store_save (GimpColorProfileStore *store,
const gchar *filename,
GFile *file,
GError **error)
{
GimpConfigWriter *writer;
@ -698,7 +700,7 @@ gimp_color_profile_store_save (GimpColorProfileStore *store,
gboolean iter_valid;
gint i;
writer = gimp_config_writer_new_from_file (filename,
writer = gimp_config_writer_new_from_file (file,
TRUE,
"GIMP color profile history",
error);

View File

@ -64,7 +64,7 @@ struct _GimpColorProfileStoreClass
GType gimp_color_profile_store_get_type (void) G_GNUC_CONST;
GtkListStore * gimp_color_profile_store_new (const gchar *history);
GtkListStore * gimp_color_profile_store_new (GFile *history);
void gimp_color_profile_store_add_file (GimpColorProfileStore *store,
GFile *file,