mirror of https://github.com/GNOME/gimp.git
app, libgimpwidgets: use the new config path <-> GFile functions
Gets rid of temporary variables to hold both expanded and unexpanded paths.
This commit is contained in:
parent
d36d956770
commit
e8309826b7
|
@ -641,14 +641,14 @@ vectors_export_cmd_callback (GtkAction *action,
|
|||
|
||||
if (config->vectors_export_path)
|
||||
{
|
||||
gchar *folder = gimp_config_path_expand (config->vectors_export_path,
|
||||
TRUE, NULL);
|
||||
GFile *folder = gimp_file_new_for_config_path (config->vectors_export_path,
|
||||
NULL);
|
||||
|
||||
if (folder)
|
||||
{
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
|
||||
folder);
|
||||
g_free (folder);
|
||||
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog->dialog),
|
||||
folder, NULL);
|
||||
g_object_unref (folder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -678,14 +678,14 @@ vectors_import_cmd_callback (GtkAction *action,
|
|||
|
||||
if (config->vectors_import_path)
|
||||
{
|
||||
gchar *folder = gimp_config_path_expand (config->vectors_import_path,
|
||||
TRUE, NULL);
|
||||
GFile *folder = gimp_file_new_for_config_path (config->vectors_import_path,
|
||||
NULL);
|
||||
|
||||
if (folder)
|
||||
{
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
|
||||
folder);
|
||||
g_free (folder);
|
||||
gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog->dialog),
|
||||
folder, NULL);
|
||||
g_object_unref (folder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -923,18 +923,17 @@ vectors_import_response (GtkWidget *widget,
|
|||
GimpDialogConfig *config;
|
||||
GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
|
||||
GFile *file;
|
||||
gchar *folder;
|
||||
GError *error = NULL;
|
||||
gchar *folder = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
|
||||
|
||||
folder = gtk_file_chooser_get_current_folder (chooser);
|
||||
file = gtk_file_chooser_get_current_folder_file (chooser);
|
||||
|
||||
if (folder)
|
||||
if (file)
|
||||
{
|
||||
gchar *tmp = gimp_config_path_unexpand (folder, TRUE, NULL);
|
||||
g_free (folder);
|
||||
folder = tmp;
|
||||
folder = gimp_file_get_config_path (file, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_object_set (config,
|
||||
|
@ -982,18 +981,17 @@ vectors_export_response (GtkWidget *widget,
|
|||
GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
|
||||
GimpVectors *vectors = NULL;
|
||||
GFile *file;
|
||||
gchar *folder;
|
||||
gchar *folder = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
|
||||
|
||||
folder = gtk_file_chooser_get_current_folder (chooser);
|
||||
file = gtk_file_chooser_get_current_folder_file (chooser);
|
||||
|
||||
if (folder)
|
||||
if (file)
|
||||
{
|
||||
gchar *tmp = gimp_config_path_unexpand (folder, TRUE, NULL);
|
||||
g_free (folder);
|
||||
folder = tmp;
|
||||
folder = gimp_file_get_config_path (file, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_object_set (config,
|
||||
|
|
|
@ -1251,7 +1251,6 @@ gimp_get_temp_file (Gimp *gimp,
|
|||
static gint id = 0;
|
||||
static gint pid;
|
||||
gchar *basename;
|
||||
gchar *path;
|
||||
GFile *dir;
|
||||
GFile *file;
|
||||
|
||||
|
@ -1265,12 +1264,8 @@ gimp_get_temp_file (Gimp *gimp,
|
|||
else
|
||||
basename = g_strdup_printf ("gimp-temp-%d%d", pid, id++);
|
||||
|
||||
path = gimp_config_path_expand (GIMP_GEGL_CONFIG (gimp->config)->temp_path,
|
||||
TRUE, NULL);
|
||||
|
||||
dir = g_file_new_for_path (path);
|
||||
g_free (path);
|
||||
|
||||
dir = gimp_file_new_for_config_path (GIMP_GEGL_CONFIG (gimp->config)->temp_path,
|
||||
NULL);
|
||||
file = g_file_get_child (dir, basename);
|
||||
g_free (basename);
|
||||
g_object_unref (dir);
|
||||
|
|
|
@ -260,19 +260,15 @@ plug_in_def_deserialize (Gimp *gimp,
|
|||
{
|
||||
GimpPlugInDef *plug_in_def;
|
||||
GimpPlugInProcedure *proc = NULL;
|
||||
gchar *name;
|
||||
gchar *path;
|
||||
GFile *file;
|
||||
gint64 mtime;
|
||||
GTokenType token;
|
||||
|
||||
if (! gimp_scanner_parse_string (scanner, &name))
|
||||
if (! gimp_scanner_parse_string (scanner, &path))
|
||||
return G_TOKEN_STRING;
|
||||
|
||||
path = gimp_config_path_expand (name, TRUE, NULL);
|
||||
g_free (name);
|
||||
|
||||
file = g_file_new_for_path (path);
|
||||
file = gimp_file_new_for_config_path (path, NULL);
|
||||
g_free (path);
|
||||
|
||||
plug_in_def = gimp_plug_in_def_new (file);
|
||||
|
@ -825,21 +821,17 @@ plug_in_rc_write (GSList *plug_in_defs,
|
|||
{
|
||||
GSList *list2;
|
||||
gchar *path;
|
||||
gchar *utf8;
|
||||
|
||||
path = g_file_get_path (plug_in_def->file);
|
||||
utf8 = gimp_config_path_unexpand (path, TRUE, NULL);
|
||||
g_free (path);
|
||||
|
||||
if (! utf8)
|
||||
path = gimp_file_get_config_path (plug_in_def->file, NULL);
|
||||
if (! path)
|
||||
continue;
|
||||
|
||||
gimp_config_writer_open (writer, "plug-in-def");
|
||||
gimp_config_writer_string (writer, utf8);
|
||||
gimp_config_writer_string (writer, path);
|
||||
gimp_config_writer_printf (writer, "%"G_GINT64_FORMAT,
|
||||
plug_in_def->mtime);
|
||||
|
||||
g_free (utf8);
|
||||
g_free (path);
|
||||
|
||||
for (list2 = plug_in_def->procedures; list2; list2 = list2->next)
|
||||
{
|
||||
|
|
|
@ -1627,19 +1627,15 @@ gimp_prop_profile_combo_box_new (GObject *config,
|
|||
|
||||
if (G_IS_PARAM_SPEC_STRING (param_spec))
|
||||
{
|
||||
gchar *value;
|
||||
gchar *path;
|
||||
|
||||
g_object_get (config,
|
||||
property_name, &value,
|
||||
property_name, &path,
|
||||
NULL);
|
||||
|
||||
path = value ? gimp_config_path_expand (value, TRUE, NULL) : NULL;
|
||||
g_free (value);
|
||||
|
||||
if (path)
|
||||
{
|
||||
file = g_file_new_for_path (path);
|
||||
file = gimp_file_new_for_config_path (path, NULL);
|
||||
g_free (path);
|
||||
}
|
||||
}
|
||||
|
@ -1704,7 +1700,7 @@ gimp_prop_profile_combo_callback (GimpColorProfileComboBox *combo,
|
|||
gchar *path = NULL;
|
||||
|
||||
if (file)
|
||||
path = g_file_get_path (file);
|
||||
path = gimp_file_get_config_path (file, NULL);
|
||||
|
||||
g_object_set (config,
|
||||
param_spec->name, path,
|
||||
|
@ -1737,19 +1733,15 @@ gimp_prop_profile_combo_notify (GObject *config,
|
|||
|
||||
if (G_IS_PARAM_SPEC_STRING (param_spec))
|
||||
{
|
||||
gchar *value;
|
||||
gchar *path;
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
param_spec->name, &path,
|
||||
NULL);
|
||||
|
||||
path = value ? gimp_config_path_expand (value, TRUE, NULL) : NULL;
|
||||
g_free (value);
|
||||
|
||||
if (path)
|
||||
{
|
||||
file = g_file_new_for_path (path);
|
||||
file = gimp_file_new_for_config_path (path, NULL);
|
||||
g_free (path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -639,14 +639,7 @@ gimp_color_profile_store_load_profile (GimpColorProfileStore *store,
|
|||
}
|
||||
else
|
||||
{
|
||||
gchar *expand = gimp_config_path_expand (path, TRUE, NULL);
|
||||
|
||||
if (expand)
|
||||
{
|
||||
file = g_file_new_for_path (expand);
|
||||
|
||||
g_free (expand);
|
||||
}
|
||||
file = gimp_file_new_for_config_path (path, NULL);
|
||||
}
|
||||
|
||||
if (file)
|
||||
|
@ -779,21 +772,14 @@ gimp_color_profile_store_save (GimpColorProfileStore *store,
|
|||
{
|
||||
if (files[i] && labels[i])
|
||||
{
|
||||
gchar *path = g_file_get_path (files[i]);
|
||||
gchar *path = gimp_file_get_config_path (files[i], NULL);
|
||||
|
||||
if (path)
|
||||
{
|
||||
gchar *unexpand = gimp_config_path_unexpand (path, TRUE, NULL);
|
||||
|
||||
if (unexpand)
|
||||
{
|
||||
gimp_config_writer_open (writer, "color-profile");
|
||||
gimp_config_writer_string (writer, labels[i]);
|
||||
gimp_config_writer_string (writer, unexpand);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_free (unexpand);
|
||||
}
|
||||
gimp_config_writer_open (writer, "color-profile");
|
||||
gimp_config_writer_string (writer, labels[i]);
|
||||
gimp_config_writer_string (writer, path);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
|
|
|
@ -2374,26 +2374,29 @@ gimp_prop_file_chooser_button_setup (GtkWidget *button,
|
|||
GParamSpec *param_spec)
|
||||
{
|
||||
gchar *value;
|
||||
gchar *filename;
|
||||
GFile *file = NULL;
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
NULL);
|
||||
|
||||
filename = value ? gimp_config_path_expand (value, TRUE, NULL) : NULL;
|
||||
g_free (value);
|
||||
|
||||
if (filename)
|
||||
if (value)
|
||||
{
|
||||
gchar *basename = g_path_get_basename (filename);
|
||||
file = gimp_file_new_for_config_path (value, NULL);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
if (file)
|
||||
{
|
||||
gchar *basename = g_file_get_basename (file);
|
||||
|
||||
if (basename && basename[0] == '.')
|
||||
gtk_file_chooser_set_show_hidden (GTK_FILE_CHOOSER (button), TRUE);
|
||||
|
||||
g_free (basename);
|
||||
|
||||
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (button), filename);
|
||||
g_free (filename);
|
||||
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (button), file, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
set_param_spec (G_OBJECT (button), button, param_spec);
|
||||
|
@ -2414,29 +2417,34 @@ gimp_prop_file_chooser_button_callback (GtkFileChooser *button,
|
|||
GObject *config)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
GFile *file;
|
||||
gchar *path = NULL;
|
||||
gchar *value;
|
||||
gchar *utf8;
|
||||
|
||||
param_spec = get_param_spec (G_OBJECT (button));
|
||||
if (! param_spec)
|
||||
return;
|
||||
|
||||
value = gtk_file_chooser_get_filename (button);
|
||||
utf8 = value ? gimp_config_path_unexpand (value, TRUE, NULL) : NULL;
|
||||
g_free (value);
|
||||
file = gtk_file_chooser_get_file (button);
|
||||
|
||||
if (file)
|
||||
{
|
||||
path = gimp_file_get_config_path (file, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
NULL);
|
||||
|
||||
if (! (value && utf8 && strcmp (value, utf8) == 0))
|
||||
if (! (path && value && strcmp (path, value) == 0))
|
||||
{
|
||||
g_signal_handlers_block_by_func (config,
|
||||
gimp_prop_file_chooser_button_notify,
|
||||
button);
|
||||
|
||||
g_object_set (config,
|
||||
param_spec->name, utf8,
|
||||
param_spec->name, path,
|
||||
NULL);
|
||||
|
||||
g_signal_handlers_unblock_by_func (config,
|
||||
|
@ -2444,8 +2452,8 @@ gimp_prop_file_chooser_button_callback (GtkFileChooser *button,
|
|||
button);
|
||||
}
|
||||
|
||||
g_free (path);
|
||||
g_free (value);
|
||||
g_free (utf8);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2454,29 +2462,35 @@ gimp_prop_file_chooser_button_notify (GObject *config,
|
|||
GtkFileChooser *button)
|
||||
{
|
||||
gchar *value;
|
||||
gchar *filename;
|
||||
GFile *file = NULL;
|
||||
|
||||
g_object_get (config,
|
||||
param_spec->name, &value,
|
||||
NULL);
|
||||
|
||||
filename = value ? gimp_config_path_expand (value, TRUE, NULL) : NULL;
|
||||
g_free (value);
|
||||
if (value)
|
||||
{
|
||||
file = gimp_file_new_for_config_path (value, NULL);
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
g_signal_handlers_block_by_func (button,
|
||||
gimp_prop_file_chooser_button_callback,
|
||||
config);
|
||||
|
||||
if (filename)
|
||||
gtk_file_chooser_set_filename (button, filename);
|
||||
if (file)
|
||||
{
|
||||
gtk_file_chooser_set_file (button, file, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
else
|
||||
gtk_file_chooser_unselect_all (button);
|
||||
{
|
||||
gtk_file_chooser_unselect_all (button);
|
||||
}
|
||||
|
||||
g_signal_handlers_unblock_by_func (button,
|
||||
gimp_prop_file_chooser_button_callback,
|
||||
config);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue