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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -205,7 +205,7 @@ gimp_unitrc_load (Gimp *gimp)
if (gimp->be_verbose) if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); 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) 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); file = gimp_sysconf_directory_file ("unitrc", NULL);
scanner = gimp_scanner_new_gfile (file, NULL); scanner = gimp_scanner_new_file (file, NULL);
} }
if (! scanner) if (! scanner)
@ -303,16 +303,16 @@ gimp_unitrc_save (Gimp *gimp)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file)); g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
writer = writer =
gimp_config_writer_new_from_gfile (file, gimp_config_writer_new_from_file (file,
TRUE, TRUE,
"GIMP units\n\n" "GIMP units\n\n"
"This file contains the user unit database. " "This file contains the user unit database. "
"You can edit this list with the unit " "You can edit this list with the unit "
"editor. You are not supposed to edit it " "editor. You are not supposed to edit it "
"manually, but of course you can do.\n" "manually, but of course you can do.\n"
"This file will be entirely rewritten each " "This file will be entirely rewritten each "
"time you exit.", "time you exit.",
NULL); NULL);
g_object_unref (file); 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)); g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
processed_ids = NULL; processed_ids = NULL;
gimp_config_deserialize_gfile (GIMP_CONFIG (manager), gimp_config_deserialize_file (GIMP_CONFIG (manager),
file, &processed_ids, &error); file, &processed_ids, &error);
if (error) if (error)
{ {
g_printerr ("Failed to parse '%s': %s\n", g_printerr ("Failed to parse '%s': %s\n",
@ -653,12 +653,12 @@ gimp_extension_manager_exit (GimpExtensionManager *manager)
if (manager->p->gimp->be_verbose) if (manager->p->gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file)); g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (manager), if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager),
file, file,
"GIMP extensionrc", "GIMP extensionrc",
"end of extensionrc", "end of extensionrc",
NULL, NULL,
&error)) &error))
{ {
gimp_message_literal (manager->p->gimp, NULL, GIMP_MESSAGE_ERROR, error->message); gimp_message_literal (manager->p->gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error); g_error_free (error);

View File

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

View File

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

View File

@ -331,11 +331,11 @@ color_profile_combo_box_new (ProfileDialog *private)
GtkListStore *store; GtkListStore *store;
GtkWidget *combo; GtkWidget *combo;
GtkWidget *chooser; 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); store = gimp_color_profile_store_new (history);
g_free (history); g_object_unref (history);
if (private->default_profile) if (private->default_profile)
{ {

View File

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

View File

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

View File

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

View File

@ -264,11 +264,11 @@ gimp_operation_config_serialize (Gimp *gimp,
gimp_operation_config_remove_sep (container); gimp_operation_config_remove_sep (container);
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (container), if (! gimp_config_serialize_to_file (GIMP_CONFIG (container),
file, file,
"settings", "settings",
"end of settings", "end of settings",
NULL, &error)) NULL, &error))
{ {
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR,
error->message); error->message);
@ -305,9 +305,9 @@ gimp_operation_config_deserialize (Gimp *gimp,
if (gimp->be_verbose) if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (container), if (! gimp_config_deserialize_file (GIMP_CONFIG (container),
file, file,
NULL, &error)) NULL, &error))
{ {
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, 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 (G_IS_FILE (file), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, 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) if (! scanner)
return NULL; return NULL;
@ -1105,14 +1105,14 @@ plug_in_rc_write (GSList *plug_in_defs,
GEnumClass *enum_class; GEnumClass *enum_class;
GSList *list; GSList *list;
writer = gimp_config_writer_new_from_gfile (file, writer = gimp_config_writer_new_from_file (file,
FALSE, FALSE,
"GIMP pluginrc\n\n" "GIMP pluginrc\n\n"
"This file can safely be removed and " "This file can safely be removed and "
"will be automatically regenerated by " "will be automatically regenerated by "
"querying the installed plug-ins.", "querying the installed plug-ins.",
error); error);
if (!writer) if (! writer)
return FALSE; return FALSE;
enum_class = g_type_class_ref (GIMP_TYPE_ICON_TYPE); 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) if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (gimp_config_deserialize_gfile (GIMP_CONFIG (gimp_list), file, if (gimp_config_deserialize_file (GIMP_CONFIG (gimp_list), file,
NULL, &error)) NULL, &error))
{ {
gint n = gimp_container_get_n_children (gimp->tool_info_list); gint n = gimp_container_get_n_children (gimp->tool_info_list);
gint i; gint i;
@ -423,11 +423,11 @@ gimp_tools_save (Gimp *gimp,
if (gimp->be_verbose) if (gimp->be_verbose)
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file)); g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
gimp_config_serialize_to_gfile (GIMP_CONFIG (gimp->tool_info_list), gimp_config_serialize_to_file (GIMP_CONFIG (gimp->tool_info_list),
file, file,
"GIMP toolrc", "GIMP toolrc",
"end of toolrc", "end of toolrc",
NULL, NULL); NULL, NULL);
g_object_unref (file); g_object_unref (file);
} }

View File

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

View File

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

View File

@ -113,10 +113,10 @@ gimp_devices_restore (Gimp *gimp)
if (gimp->be_verbose) if (gimp->be_verbose)
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
if (! gimp_config_deserialize_gfile (GIMP_CONFIG (manager), if (! gimp_config_deserialize_file (GIMP_CONFIG (manager),
file, file,
gimp, gimp,
&error)) &error))
{ {
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); 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); gimp_device_info_save_tool (current_device);
} }
if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (manager), if (! gimp_config_serialize_to_file (GIMP_CONFIG (manager),
file, file,
"GIMP devicerc", "GIMP devicerc",
"end of devicerc", "end of devicerc",
NULL, NULL,
&error)) &error))
{ {
gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message);
g_error_free (error); 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"); GFile *file = gimp_procedure_config_get_file (config, ".last");
gboolean success; gboolean success;
success = gimp_config_deserialize_gfile (GIMP_CONFIG (config), success = gimp_config_deserialize_file (GIMP_CONFIG (config),
file, file,
NULL, error); NULL, error);
if (! success && (*error)->code == GIMP_CONFIG_ERROR_OPEN_ENOENT) 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"); GFile *file = gimp_procedure_config_get_file (config, ".last");
gboolean success; gboolean success;
success = gimp_config_serialize_to_gfile (GIMP_CONFIG (config), success = gimp_config_serialize_to_file (GIMP_CONFIG (config),
file, file,
"settings", "settings",
"end of settings", "end of settings",
NULL, error); NULL, error);
g_object_unref (file); g_object_unref (file);

View File

@ -277,47 +277,6 @@ gimp_config_iface_copy (GimpConfig *src,
/** /**
* gimp_config_serialize_to_file: * gimp_config_serialize_to_file:
* @config: a #GObject that implements the #GimpConfigInterface. * @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. * @file: the #GFile to write the configuration to.
* @header: optional file header (must be ASCII only) * @header: optional file header (must be ASCII only)
* @footer: optional file footer (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 * Since: 2.10
**/ **/
gboolean gboolean
gimp_config_serialize_to_gfile (GimpConfig *config, gimp_config_serialize_to_file (GimpConfig *config,
GFile *file, GFile *file,
const gchar *header, const gchar *header,
const gchar *footer, const gchar *footer,
gpointer data, gpointer data,
GError **error) GError **error)
{ {
GimpConfigWriter *writer; 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 (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, 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) if (!writer)
return FALSE; return FALSE;
@ -500,54 +459,6 @@ gimp_config_serialize_to_parasite (GimpConfig *config,
/** /**
* gimp_config_deserialize_file: * gimp_config_deserialize_file:
* @config: a #GObject that implements the #GimpConfigInterface. * @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. * @file: the #GFile to read configuration from.
* @data: user data passed to the deserialize implementation. * @data: user data passed to the deserialize implementation.
* @error: return location for a possible error * @error: return location for a possible error
@ -562,10 +473,10 @@ gimp_config_deserialize_file (GimpConfig *config,
* Since: 2.10 * Since: 2.10
**/ **/
gboolean gboolean
gimp_config_deserialize_gfile (GimpConfig *config, gimp_config_deserialize_file (GimpConfig *config,
GFile *file, GFile *file,
gpointer data, gpointer data,
GError **error) GError **error)
{ {
GScanner *scanner; GScanner *scanner;
gboolean success; 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 (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, 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) if (! scanner)
return FALSE; return FALSE;

View File

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

View File

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

View File

@ -118,43 +118,6 @@ gimp_config_writer_newline (GimpConfigWriter *writer)
/** /**
* gimp_config_writer_new_from_file: * 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 * @file: a #GFile
* @atomic: if %TRUE the file is written atomically * @atomic: if %TRUE the file is written atomically
* @header: text to include as comment at the top of the file * @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 * Since: 2.10
**/ **/
GimpConfigWriter * GimpConfigWriter *
gimp_config_writer_new_from_gfile (GFile *file, gimp_config_writer_new_from_file (GFile *file,
gboolean atomic, gboolean atomic,
const gchar *header, const gchar *header,
GError **error) GError **error)
{ {
GimpConfigWriter *writer; GimpConfigWriter *writer;
GOutputStream *output; GOutputStream *output;

View File

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

View File

@ -78,32 +78,6 @@ static void gimp_scanner_message (GimpScanner *scanner,
/** /**
* gimp_scanner_new_file: * 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 * @file: a #GFile
* @error: return location for #GError, or %NULL * @error: return location for #GError, or %NULL
* *
@ -112,8 +86,8 @@ gimp_scanner_new_file (const gchar *filename,
* Since: 2.10 * Since: 2.10
**/ **/
GimpScanner * GimpScanner *
gimp_scanner_new_gfile (GFile *file, gimp_scanner_new_file (GFile *file,
GError **error) GError **error)
{ {
GimpScanner *scanner; GimpScanner *scanner;
gchar *path; gchar *path;

View File

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

View File

@ -288,7 +288,7 @@ gimp_color_profile_combo_box_changed (GtkComboBox *combo)
* gimp_color_profile_combo_box_new: * gimp_color_profile_combo_box_new:
* @dialog: a #GtkDialog to present when the user selects the * @dialog: a #GtkDialog to present when the user selects the
* "Select color profile from disk..." item * "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 * Create a combo-box widget for selecting color profiles. The combo-box
* is populated from the file specified as @history. This filename is * 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 * Since: 2.4
**/ **/
GtkWidget * GtkWidget *
gimp_color_profile_combo_box_new (GtkWidget *dialog, gimp_color_profile_combo_box_new (GtkWidget *dialog,
const gchar *history) GFile *history)
{ {
GtkWidget *combo; GtkWidget *combo;
GtkListStore *store; GtkListStore *store;
g_return_val_if_fail (GTK_IS_DIALOG (dialog), NULL); 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); store = gimp_color_profile_store_new (history);
combo = gimp_color_profile_combo_box_new_with_model (dialog, 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; GType gimp_color_profile_combo_box_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_profile_combo_box_new (GtkWidget *dialog, 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, GtkWidget * gimp_color_profile_combo_box_new_with_model (GtkWidget *dialog,
GtkTreeModel *model); GtkTreeModel *model);

View File

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

View File

@ -64,7 +64,7 @@ struct _GimpColorProfileStoreClass
GType gimp_color_profile_store_get_type (void) G_GNUC_CONST; 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, void gimp_color_profile_store_add_file (GimpColorProfileStore *store,
GFile *file, GFile *file,