mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
libgimpbase: remove gimp_personal_rc_file()
and port its remaining users to gimp_directory_file().
This commit is contained in:
parent
7806021a41
commit
1bca89163d
13 changed files with 181 additions and 196 deletions
|
@ -90,15 +90,10 @@ static GdkPixbufAnimation *
|
||||||
gint max_height,
|
gint max_height,
|
||||||
gboolean be_verbose);
|
gboolean be_verbose);
|
||||||
static GdkPixbufAnimation *
|
static GdkPixbufAnimation *
|
||||||
splash_image_load_from_path (const gchar *filename,
|
splash_image_load_from_file (GFile *file,
|
||||||
gint max_width,
|
gint max_width,
|
||||||
gint max_height,
|
gint max_height,
|
||||||
gboolean be_verbose);
|
gboolean be_verbose);
|
||||||
static GdkPixbufAnimation *
|
|
||||||
splash_image_load_from_file (GFile *file,
|
|
||||||
gint max_width,
|
|
||||||
gint max_height,
|
|
||||||
gboolean be_verbose);
|
|
||||||
static GdkPixbufAnimation *
|
static GdkPixbufAnimation *
|
||||||
splash_image_pick_from_dirs (GList *dirs,
|
splash_image_pick_from_dirs (GList *dirs,
|
||||||
gint max_width,
|
gint max_width,
|
||||||
|
@ -485,7 +480,6 @@ splash_image_load (Gimp *gimp,
|
||||||
gboolean be_verbose)
|
gboolean be_verbose)
|
||||||
{
|
{
|
||||||
GdkPixbufAnimation *animation = NULL;
|
GdkPixbufAnimation *animation = NULL;
|
||||||
gchar *filename;
|
|
||||||
GFile *file;
|
GFile *file;
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
|
@ -500,18 +494,16 @@ splash_image_load (Gimp *gimp,
|
||||||
return animation;
|
return animation;
|
||||||
|
|
||||||
/* File "gimp-splash.png" in personal configuration directory. */
|
/* File "gimp-splash.png" in personal configuration directory. */
|
||||||
filename = gimp_personal_rc_file ("gimp-splash.png");
|
file = gimp_directory_file ("gimp-splash.png", NULL);
|
||||||
animation = splash_image_load_from_path (filename,
|
animation = splash_image_load_from_file (file,
|
||||||
max_width, max_height,
|
max_width, max_height,
|
||||||
be_verbose);
|
be_verbose);
|
||||||
g_free (filename);
|
g_object_unref (file);
|
||||||
if (animation)
|
if (animation)
|
||||||
return animation;
|
return animation;
|
||||||
|
|
||||||
/* Random image under splashes/ directory in personal config dir. */
|
/* Random image under splashes/ directory in personal config dir. */
|
||||||
filename = gimp_personal_rc_file ("splashes");
|
file = gimp_directory_file ("splashes", NULL);
|
||||||
file = g_file_new_for_path (filename);
|
|
||||||
g_free (filename);
|
|
||||||
list = NULL;
|
list = NULL;
|
||||||
list = g_list_prepend (list, file);
|
list = g_list_prepend (list, file);
|
||||||
animation = splash_image_pick_from_dirs (list,
|
animation = splash_image_pick_from_dirs (list,
|
||||||
|
@ -522,19 +514,16 @@ splash_image_load (Gimp *gimp,
|
||||||
return animation;
|
return animation;
|
||||||
|
|
||||||
/* Release splash image. */
|
/* Release splash image. */
|
||||||
filename = g_build_filename (gimp_data_directory (),
|
file = gimp_data_directory_file ("images", "gimp-splash.png", NULL);
|
||||||
"images", "gimp-splash.png", NULL);
|
animation = splash_image_load_from_file (file,
|
||||||
animation = splash_image_load_from_path (filename,
|
|
||||||
max_width, max_height,
|
max_width, max_height,
|
||||||
be_verbose);
|
be_verbose);
|
||||||
g_free (filename);
|
g_object_unref (file);
|
||||||
if (animation)
|
if (animation)
|
||||||
return animation;
|
return animation;
|
||||||
|
|
||||||
/* Random release image in installed splashes/ directory. */
|
/* Random release image in installed splashes/ directory. */
|
||||||
filename = g_build_filename (gimp_data_directory (), "splashes", NULL);
|
file = gimp_data_directory_file ("splashes", NULL);
|
||||||
file = g_file_new_for_path (filename);
|
|
||||||
g_free (filename);
|
|
||||||
list = NULL;
|
list = NULL;
|
||||||
list = g_list_prepend (list, file);
|
list = g_list_prepend (list, file);
|
||||||
animation = splash_image_pick_from_dirs (list,
|
animation = splash_image_pick_from_dirs (list,
|
||||||
|
@ -545,24 +534,6 @@ splash_image_load (Gimp *gimp,
|
||||||
return animation;
|
return animation;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkPixbufAnimation *
|
|
||||||
splash_image_load_from_path (const gchar *filename,
|
|
||||||
gint max_width,
|
|
||||||
gint max_height,
|
|
||||||
gboolean be_verbose)
|
|
||||||
{
|
|
||||||
GdkPixbufAnimation *animation;
|
|
||||||
GFile *file;
|
|
||||||
|
|
||||||
file = g_file_new_for_path (filename);
|
|
||||||
animation = splash_image_load_from_file (file,
|
|
||||||
max_width, max_height,
|
|
||||||
be_verbose);
|
|
||||||
g_object_unref (file);
|
|
||||||
|
|
||||||
return animation;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GdkPixbufAnimation *
|
static GdkPixbufAnimation *
|
||||||
splash_image_load_from_file (GFile *file,
|
splash_image_load_from_file (GFile *file,
|
||||||
gint max_width,
|
gint max_width,
|
||||||
|
|
|
@ -414,23 +414,28 @@ menus_exit (Gimp *gimp)
|
||||||
void
|
void
|
||||||
menus_restore (Gimp *gimp)
|
menus_restore (Gimp *gimp)
|
||||||
{
|
{
|
||||||
|
GFile *file;
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||||
|
|
||||||
filename = gimp_personal_rc_file ("menurc");
|
file = gimp_directory_file ("menurc", NULL);
|
||||||
|
|
||||||
if (gimp->be_verbose)
|
if (gimp->be_verbose)
|
||||||
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
|
g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file));
|
||||||
|
|
||||||
|
filename = g_file_get_path (file);
|
||||||
gtk_accel_map_load (filename);
|
gtk_accel_map_load (filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
menus_save (Gimp *gimp,
|
menus_save (Gimp *gimp,
|
||||||
gboolean always_save)
|
gboolean always_save)
|
||||||
{
|
{
|
||||||
|
GFile *file;
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
|
|
||||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||||
|
@ -438,14 +443,17 @@ menus_save (Gimp *gimp,
|
||||||
if (menurc_deleted && ! always_save)
|
if (menurc_deleted && ! always_save)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
filename = gimp_personal_rc_file ("menurc");
|
file = gimp_directory_file ("menurc", NULL);
|
||||||
|
|
||||||
if (gimp->be_verbose)
|
if (gimp->be_verbose)
|
||||||
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
|
g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file));
|
||||||
|
|
||||||
|
filename = g_file_get_path (file);
|
||||||
gtk_accel_map_save (filename);
|
gtk_accel_map_save (filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
|
|
||||||
menurc_deleted = FALSE;
|
menurc_deleted = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,30 +42,34 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
gchar *filename;
|
GFile *file;
|
||||||
gchar *md5;
|
gchar *md5;
|
||||||
GTimeVal modtime;
|
GTimeVal modtime;
|
||||||
} GimpTestFileState;
|
} GimpTestFileState;
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gimp_test_get_file_state_verbose (const gchar *filename,
|
gimp_test_get_file_state_verbose (GFile *file,
|
||||||
GimpTestFileState *filestate)
|
GimpTestFileState *filestate)
|
||||||
{
|
{
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
|
|
||||||
filestate->filename = g_strdup (filename);
|
filestate->file = g_object_ref (file);
|
||||||
|
|
||||||
/* Get checksum */
|
/* Get checksum */
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
|
gchar *filename;
|
||||||
gchar *contents = NULL;
|
gchar *contents = NULL;
|
||||||
gsize length = 0;
|
gsize length = 0;
|
||||||
|
|
||||||
|
filename = g_file_get_path (file);
|
||||||
success = g_file_get_contents (filename,
|
success = g_file_get_contents (filename,
|
||||||
&contents,
|
&contents,
|
||||||
&length,
|
&length,
|
||||||
NULL);
|
NULL);
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
filestate->md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5,
|
filestate->md5 = g_compute_checksum_for_string (G_CHECKSUM_MD5,
|
||||||
|
@ -79,7 +83,6 @@ gimp_test_get_file_state_verbose (const gchar *filename,
|
||||||
/* Get modification time */
|
/* Get modification time */
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
GFile *file = g_file_new_for_path (filename);
|
|
||||||
GFileInfo *info = g_file_query_info (file,
|
GFileInfo *info = g_file_query_info (file,
|
||||||
G_FILE_ATTRIBUTE_TIME_MODIFIED, 0,
|
G_FILE_ATTRIBUTE_TIME_MODIFIED, 0,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
@ -93,25 +96,25 @@ gimp_test_get_file_state_verbose (const gchar *filename,
|
||||||
{
|
{
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! success)
|
if (! success)
|
||||||
g_printerr ("Failed to get initial file info for '%s'\n", filename);
|
g_printerr ("Failed to get initial file info for '%s'\n",
|
||||||
|
gimp_file_get_utf8_name (file));
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gimp_test_file_state_changes (const gchar *filename,
|
gimp_test_file_state_changes (GFile *file,
|
||||||
GimpTestFileState *state1,
|
GimpTestFileState *state1,
|
||||||
GimpTestFileState *state2)
|
GimpTestFileState *state2)
|
||||||
{
|
{
|
||||||
if (state1->modtime.tv_sec == state2->modtime.tv_sec &&
|
if (state1->modtime.tv_sec == state2->modtime.tv_sec &&
|
||||||
state1->modtime.tv_usec == state2->modtime.tv_usec)
|
state1->modtime.tv_usec == state2->modtime.tv_usec)
|
||||||
{
|
{
|
||||||
g_printerr ("A new '%s' was not created\n", filename);
|
g_printerr ("A new '%s' was not created\n",
|
||||||
|
gimp_file_get_utf8_name (file));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,13 +123,14 @@ gimp_test_file_state_changes (const gchar *filename,
|
||||||
char *diff_argv[5] = {
|
char *diff_argv[5] = {
|
||||||
"diff",
|
"diff",
|
||||||
"-u",
|
"-u",
|
||||||
state1->filename,
|
g_file_get_path (state1->file),
|
||||||
state2->filename,
|
g_file_get_path (state2->file),
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
g_printerr ("'%s' was changed but should not have been. Reason, using "
|
g_printerr ("'%s' was changed but should not have been. Reason, using "
|
||||||
"`diff -u $expected $actual`\n", filename);
|
"`diff -u $expected $actual`\n",
|
||||||
|
gimp_file_get_utf8_name (file));
|
||||||
|
|
||||||
g_spawn_sync (NULL /*working_directory*/,
|
g_spawn_sync (NULL /*working_directory*/,
|
||||||
diff_argv,
|
diff_argv,
|
||||||
|
@ -139,6 +143,9 @@ gimp_test_file_state_changes (const gchar *filename,
|
||||||
NULL /*exist_status*/,
|
NULL /*exist_status*/,
|
||||||
NULL /*error*/);
|
NULL /*error*/);
|
||||||
|
|
||||||
|
g_free (diff_argv[2]);
|
||||||
|
g_free (diff_argv[3]);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +178,8 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
|
||||||
GimpTestFileState initial_dockrc_state = { NULL, NULL, { 0, 0 } };
|
GimpTestFileState initial_dockrc_state = { NULL, NULL, { 0, 0 } };
|
||||||
GimpTestFileState final_sessionrc_state = { NULL, NULL, { 0, 0 } };
|
GimpTestFileState final_sessionrc_state = { NULL, NULL, { 0, 0 } };
|
||||||
GimpTestFileState final_dockrc_state = { NULL, NULL, { 0, 0 } };
|
GimpTestFileState final_dockrc_state = { NULL, NULL, { 0, 0 } };
|
||||||
gchar *sessionrc_filename = NULL;
|
GFile *sessionrc_file = NULL;
|
||||||
gchar *dockrc_filename = NULL;
|
GFile *dockrc_file = NULL;
|
||||||
|
|
||||||
/* Make sure to run this before we use any GIMP functions */
|
/* Make sure to run this before we use any GIMP functions */
|
||||||
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
gimp_test_utils_set_gimp3_directory ("GIMP_TESTING_ABS_TOP_SRCDIR",
|
||||||
|
@ -183,13 +190,13 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
|
||||||
* the read file, which is why we check the MD5 of the -expected
|
* the read file, which is why we check the MD5 of the -expected
|
||||||
* variant
|
* variant
|
||||||
*/
|
*/
|
||||||
sessionrc_filename = gimp_personal_rc_file (expected_sessionrc);
|
sessionrc_file = gimp_directory_file (expected_sessionrc, NULL);
|
||||||
dockrc_filename = gimp_personal_rc_file (expected_dockrc);
|
dockrc_file = gimp_directory_file (expected_dockrc, NULL);
|
||||||
|
|
||||||
/* Remember the modtimes and MD5s */
|
/* Remember the modtimes and MD5s */
|
||||||
g_assert (gimp_test_get_file_state_verbose (sessionrc_filename,
|
g_assert (gimp_test_get_file_state_verbose (sessionrc_file,
|
||||||
&initial_sessionrc_state));
|
&initial_sessionrc_state));
|
||||||
g_assert (gimp_test_get_file_state_verbose (dockrc_filename,
|
g_assert (gimp_test_get_file_state_verbose (dockrc_file,
|
||||||
&initial_dockrc_state));
|
&initial_dockrc_state));
|
||||||
|
|
||||||
/* Use specific input files when restoring the session */
|
/* Use specific input files when restoring the session */
|
||||||
|
@ -215,18 +222,19 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
|
||||||
g_unsetenv ("GIMP_TESTING_SESSIONRC_NAME");
|
g_unsetenv ("GIMP_TESTING_SESSIONRC_NAME");
|
||||||
g_unsetenv ("GIMP_TESTING_DOCKRC_NAME");
|
g_unsetenv ("GIMP_TESTING_DOCKRC_NAME");
|
||||||
|
|
||||||
g_free (sessionrc_filename);
|
g_object_unref (sessionrc_file);
|
||||||
g_free (dockrc_filename);
|
g_object_unref (dockrc_file);
|
||||||
sessionrc_filename = gimp_personal_rc_file ("sessionrc");
|
|
||||||
dockrc_filename = gimp_personal_rc_file ("dockrc");
|
sessionrc_file = gimp_directory_file ("sessionrc", NULL);
|
||||||
|
dockrc_file = gimp_directory_file ("dockrc", NULL);
|
||||||
|
|
||||||
/* Exit. This includes writing sessionrc and dockrc*/
|
/* Exit. This includes writing sessionrc and dockrc*/
|
||||||
gimp_exit (gimp, TRUE);
|
gimp_exit (gimp, TRUE);
|
||||||
|
|
||||||
/* Now get the new modtimes and MD5s */
|
/* Now get the new modtimes and MD5s */
|
||||||
g_assert (gimp_test_get_file_state_verbose (sessionrc_filename,
|
g_assert (gimp_test_get_file_state_verbose (sessionrc_file,
|
||||||
&final_sessionrc_state));
|
&final_sessionrc_state));
|
||||||
g_assert (gimp_test_get_file_state_verbose (dockrc_filename,
|
g_assert (gimp_test_get_file_state_verbose (dockrc_file,
|
||||||
&final_dockrc_state));
|
&final_dockrc_state));
|
||||||
|
|
||||||
/* If things have gone our way, GIMP will have deserialized
|
/* If things have gone our way, GIMP will have deserialized
|
||||||
|
@ -235,10 +243,10 @@ gimp_test_session_load_and_write_session_files (const gchar *loaded_sessionrc,
|
||||||
* to make sure that their content remains the same we compare their
|
* to make sure that their content remains the same we compare their
|
||||||
* MD5
|
* MD5
|
||||||
*/
|
*/
|
||||||
g_assert (gimp_test_file_state_changes ("sessionrc",
|
g_assert (gimp_test_file_state_changes (g_file_new_for_path ("sessionrc"),
|
||||||
&initial_sessionrc_state,
|
&initial_sessionrc_state,
|
||||||
&final_sessionrc_state));
|
&final_sessionrc_state));
|
||||||
g_assert (gimp_test_file_state_changes ("dockrc",
|
g_assert (gimp_test_file_state_changes (g_file_new_for_path ("dockrc"),
|
||||||
&initial_dockrc_state,
|
&initial_dockrc_state,
|
||||||
&final_dockrc_state));
|
&final_dockrc_state));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1628,11 +1628,11 @@ gimp_prop_profile_combo_box_new (GObject *config,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *filename;
|
GFile *file;
|
||||||
|
|
||||||
filename = gimp_personal_rc_file ("profilerc");
|
file = gimp_directory_file ("profilerc", NULL);
|
||||||
combo = gimp_color_profile_combo_box_new (dialog, filename);
|
combo = gimp_color_profile_combo_box_new (dialog, file);
|
||||||
g_free (filename);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
||||||
|
|
|
@ -799,12 +799,11 @@ gimp_template_editor_template_notify (GimpTemplate *template,
|
||||||
! strcmp (param_spec->name, "precision"))
|
! strcmp (param_spec->name, "precision"))
|
||||||
{
|
{
|
||||||
GtkListStore *profile_store;
|
GtkListStore *profile_store;
|
||||||
GFile *profile;
|
GFile *file;
|
||||||
gchar *filename;
|
|
||||||
|
|
||||||
filename = gimp_personal_rc_file ("profilerc");
|
file = gimp_directory_file ("profilerc", NULL);
|
||||||
profile_store = gimp_color_profile_store_new (filename);
|
profile_store = gimp_color_profile_store_new (file);
|
||||||
g_free (filename);
|
g_object_unref (file);
|
||||||
|
|
||||||
gimp_color_profile_store_add_defaults (GIMP_COLOR_PROFILE_STORE (profile_store),
|
gimp_color_profile_store_add_defaults (GIMP_COLOR_PROFILE_STORE (profile_store),
|
||||||
private->gimp->config->color_management,
|
private->gimp->config->color_management,
|
||||||
|
@ -817,13 +816,13 @@ gimp_template_editor_template_notify (GimpTemplate *template,
|
||||||
g_object_unref (profile_store);
|
g_object_unref (profile_store);
|
||||||
|
|
||||||
g_object_get (template,
|
g_object_get (template,
|
||||||
"color-profile", &profile,
|
"color-profile", &file,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (private->profile_combo),
|
gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (private->profile_combo),
|
||||||
profile, NULL);
|
file, NULL);
|
||||||
|
|
||||||
if (profile)
|
if (file)
|
||||||
g_object_unref (profile);
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,6 @@ EXPORTS
|
||||||
gimp_pdb_error_handler_get_type
|
gimp_pdb_error_handler_get_type
|
||||||
gimp_pdb_proc_type_get_type
|
gimp_pdb_proc_type_get_type
|
||||||
gimp_pdb_status_type_get_type
|
gimp_pdb_status_type_get_type
|
||||||
gimp_personal_rc_file
|
|
||||||
gimp_pixels_to_units
|
gimp_pixels_to_units
|
||||||
gimp_pixpipe_params_build
|
gimp_pixpipe_params_build
|
||||||
gimp_pixpipe_params_free
|
gimp_pixpipe_params_free
|
||||||
|
|
|
@ -736,7 +736,7 @@ gimp_child_file (const gchar *parent,
|
||||||
* @...: a %NULL terminated list of the remaining elements of the path
|
* @...: a %NULL terminated list of the remaining elements of the path
|
||||||
* to the file.
|
* to the file.
|
||||||
*
|
*
|
||||||
* Returns a #GFile in the user's GIMP directory, or the data
|
* Returns a #GFile in the user's GIMP directory, or the GIMP
|
||||||
* directory itself if @first_element is %NULL.
|
* directory itself if @first_element is %NULL.
|
||||||
*
|
*
|
||||||
* See also: gimp_directory().
|
* See also: gimp_directory().
|
||||||
|
@ -915,25 +915,6 @@ gimp_plug_in_directory_file (const gchar *first_element,
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_personal_rc_file:
|
|
||||||
* @basename: The basename of a rc_file.
|
|
||||||
*
|
|
||||||
* Returns the name of a file in the user-specific GIMP settings directory.
|
|
||||||
*
|
|
||||||
* The returned string is newly allocated and should be freed with
|
|
||||||
* g_free() after use. The returned string is in the encoding used for
|
|
||||||
* filenames by GLib, which isn't necessarily UTF-8. (On Windows it
|
|
||||||
* always is UTF-8.)
|
|
||||||
*
|
|
||||||
* Returns: The name of a file in the user-specific GIMP settings directory.
|
|
||||||
**/
|
|
||||||
gchar *
|
|
||||||
gimp_personal_rc_file (const gchar *basename)
|
|
||||||
{
|
|
||||||
return g_build_filename (gimp_directory (), basename, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_path_runtime_fix:
|
* gimp_path_runtime_fix:
|
||||||
* @path: A pointer to a string (allocated with g_malloc) that is
|
* @path: A pointer to a string (allocated with g_malloc) that is
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#ifndef __GIMP_ENV_H__
|
#ifndef __GIMP_ENV_H__
|
||||||
#define __GIMP_ENV_H__
|
#define __GIMP_ENV_H__
|
||||||
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/* For information look into the C source or the html documentation */
|
/* For information look into the C source or the html documentation */
|
||||||
|
@ -69,20 +68,18 @@ GFile * gimp_sysconf_directory_file (const gchar *first_element,
|
||||||
GFile * gimp_plug_in_directory_file (const gchar *first_element,
|
GFile * gimp_plug_in_directory_file (const gchar *first_element,
|
||||||
...) G_GNUC_MALLOC;
|
...) G_GNUC_MALLOC;
|
||||||
|
|
||||||
gchar * gimp_personal_rc_file (const gchar *basename) G_GNUC_MALLOC;
|
GList * gimp_path_parse (const gchar *path,
|
||||||
|
gint max_paths,
|
||||||
|
gboolean check,
|
||||||
|
GList **check_failed);
|
||||||
|
gchar * gimp_path_to_str (GList *path) G_GNUC_MALLOC;
|
||||||
|
void gimp_path_free (GList *path);
|
||||||
|
|
||||||
GList * gimp_path_parse (const gchar *path,
|
gchar * gimp_path_get_user_writable_dir (GList *path) G_GNUC_MALLOC;
|
||||||
gint max_paths,
|
|
||||||
gboolean check,
|
|
||||||
GList **check_failed);
|
|
||||||
gchar * gimp_path_to_str (GList *path) G_GNUC_MALLOC;
|
|
||||||
void gimp_path_free (GList *path);
|
|
||||||
|
|
||||||
gchar * gimp_path_get_user_writable_dir (GList *path) G_GNUC_MALLOC;
|
|
||||||
|
|
||||||
|
|
||||||
/* should be considered private, don't use! */
|
/* should be considered private, don't use! */
|
||||||
void gimp_env_init (gboolean plug_in);
|
void gimp_env_init (gboolean plug_in);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -537,7 +537,7 @@ explorer_dialog (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
GFile *gimprc = gimp_directory_file ("gimprc", NULL);
|
||||||
gchar *full_path = gimp_config_build_data_path ("fractalexplorer");
|
gchar *full_path = gimp_config_build_data_path ("fractalexplorer");
|
||||||
gchar *esc_path = g_strescape (full_path, NULL);
|
gchar *esc_path = g_strescape (full_path, NULL);
|
||||||
g_free (full_path);
|
g_free (full_path);
|
||||||
|
@ -548,9 +548,9 @@ explorer_dialog (void)
|
||||||
"to your %s file."),
|
"to your %s file."),
|
||||||
"fractalexplorer-path",
|
"fractalexplorer-path",
|
||||||
"fractalexplorer-path",
|
"fractalexplorer-path",
|
||||||
esc_path, gimp_filename_to_utf8 (gimprc));
|
esc_path, gimp_file_get_utf8_name (gimprc));
|
||||||
|
|
||||||
g_free (gimprc);
|
g_object_unref (gimprc);
|
||||||
g_free (esc_path);
|
g_free (esc_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ gfig_dialog (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
GFile *gimprc = gimp_directory_file ("gimprc", NULL);
|
||||||
gchar *full_path = gimp_config_build_data_path ("gfig");
|
gchar *full_path = gimp_config_build_data_path ("gfig");
|
||||||
gchar *esc_path = g_strescape (full_path, NULL);
|
gchar *esc_path = g_strescape (full_path, NULL);
|
||||||
g_free (full_path);
|
g_free (full_path);
|
||||||
|
@ -277,9 +277,9 @@ gfig_dialog (void)
|
||||||
"(%s \"%s\")\n"
|
"(%s \"%s\")\n"
|
||||||
"to your %s file."),
|
"to your %s file."),
|
||||||
"gfig-path", "gfig-path", esc_path,
|
"gfig-path", "gfig-path", esc_path,
|
||||||
gimp_filename_to_utf8 (gimprc));
|
gimp_file_get_utf8_name (gimprc));
|
||||||
|
|
||||||
g_free (gimprc);
|
g_object_unref (gimprc);
|
||||||
g_free (esc_path);
|
g_free (esc_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,7 @@ parsepath (void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
GFile *gimprc = gimp_directory_file ("gimprc", NULL);
|
||||||
gchar *full_path = gimp_config_build_data_path ("gimpressionist");
|
gchar *full_path = gimp_config_build_data_path ("gimpressionist");
|
||||||
gchar *esc_path = g_strescape (full_path, NULL);
|
gchar *esc_path = g_strescape (full_path, NULL);
|
||||||
|
|
||||||
|
@ -141,9 +141,9 @@ parsepath (void)
|
||||||
"(%s \"%s\")\n"
|
"(%s \"%s\")\n"
|
||||||
"to your %s file."),
|
"to your %s file."),
|
||||||
"gflare-path", "gflare-path",
|
"gflare-path", "gflare-path",
|
||||||
esc_path, gimp_filename_to_utf8 (gimprc));
|
esc_path, gimp_file_get_utf8_name (gimprc));
|
||||||
|
|
||||||
g_free (gimprc);
|
g_object_unref (gimprc);
|
||||||
g_free (esc_path);
|
g_free (esc_path);
|
||||||
|
|
||||||
rc_path = gimp_config_path_expand (full_path, TRUE, NULL);
|
rc_path = gimp_config_path_expand (full_path, TRUE, NULL);
|
||||||
|
|
|
@ -967,7 +967,7 @@ gflare_run (GimpProcedure *procedure,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
GFile *gimprc = gimp_directory_file ("gimprc", NULL);
|
||||||
gchar *full_path = gimp_config_build_data_path ("gflare");
|
gchar *full_path = gimp_config_build_data_path ("gflare");
|
||||||
gchar *esc_path = g_strescape (full_path, NULL);
|
gchar *esc_path = g_strescape (full_path, NULL);
|
||||||
g_free (full_path);
|
g_free (full_path);
|
||||||
|
@ -977,9 +977,9 @@ gflare_run (GimpProcedure *procedure,
|
||||||
"(%s \"%s\")\n"
|
"(%s \"%s\")\n"
|
||||||
"to your %s file."),
|
"to your %s file."),
|
||||||
"gflare-path", "gflare-path",
|
"gflare-path", "gflare-path",
|
||||||
esc_path, gimp_filename_to_utf8 (gimprc));
|
esc_path, gimp_file_get_utf8_name (gimprc));
|
||||||
|
|
||||||
g_free (gimprc);
|
g_object_unref (gimprc);
|
||||||
g_free (esc_path);
|
g_free (esc_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1529,8 +1529,8 @@ gflare_save (GFlare *gflare)
|
||||||
{
|
{
|
||||||
if (! message_ok)
|
if (! message_ok)
|
||||||
{
|
{
|
||||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
GFile *gimprc = gimp_directory_file ("gimprc", NULL);
|
||||||
gchar *dir = gimp_personal_rc_file ("gflare");
|
GFile *dir = gimp_directory_file ("gflare", NULL);
|
||||||
gchar *gflare_dir;
|
gchar *gflare_dir;
|
||||||
|
|
||||||
gflare_dir =
|
gflare_dir =
|
||||||
|
@ -1541,12 +1541,14 @@ gflare_save (GFlare *gflare)
|
||||||
"(gflare-path \"%s\")\n"
|
"(gflare-path \"%s\")\n"
|
||||||
"and make a folder '%s', then you can save "
|
"and make a folder '%s', then you can save "
|
||||||
"your own GFlares into that folder."),
|
"your own GFlares into that folder."),
|
||||||
gflare->name, gimprc, gflare_dir,
|
gflare->name,
|
||||||
gimp_filename_to_utf8 (dir));
|
gimp_file_get_utf8_name (gimprc),
|
||||||
|
gflare_dir,
|
||||||
|
gimp_file_get_utf8_name (dir));
|
||||||
|
|
||||||
g_free (gimprc);
|
g_object_unref (gimprc);
|
||||||
|
g_object_unref (dir);
|
||||||
g_free (gflare_dir);
|
g_free (gflare_dir);
|
||||||
g_free (dir);
|
|
||||||
|
|
||||||
message_ok = TRUE;
|
message_ok = TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,93 +167,113 @@ parse_line(PreferencesData_t *data, char *line)
|
||||||
gboolean
|
gboolean
|
||||||
preferences_load(PreferencesData_t *data)
|
preferences_load(PreferencesData_t *data)
|
||||||
{
|
{
|
||||||
FILE *in;
|
FILE *in;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
gchar *filename;
|
GFile *file;
|
||||||
|
gchar *filename;
|
||||||
|
|
||||||
filename = gimp_personal_rc_file ("imagemaprc");
|
file = gimp_directory_file ("imagemaprc", NULL);
|
||||||
|
|
||||||
|
filename = g_file_get_path (file);
|
||||||
|
in = g_fopen (filename, "rb");
|
||||||
|
g_free (filename);
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
|
|
||||||
|
if (in)
|
||||||
|
{
|
||||||
|
while (fgets (buf, sizeof (buf), in))
|
||||||
|
{
|
||||||
|
if (*buf != '\n' && *buf != '#')
|
||||||
|
{
|
||||||
|
parse_line (data, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose (in);
|
||||||
|
|
||||||
in = g_fopen(filename, "rb");
|
|
||||||
g_free(filename);
|
|
||||||
if (in) {
|
|
||||||
while (fgets(buf, sizeof(buf), in)) {
|
|
||||||
if (*buf != '\n' && *buf != '#') {
|
|
||||||
parse_line(data, buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(in);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
return FALSE;
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
preferences_save(PreferencesData_t *data)
|
preferences_save(PreferencesData_t *data)
|
||||||
{
|
{
|
||||||
FILE *out;
|
FILE *out;
|
||||||
|
GFile *file;
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
ColorSelData_t *colors = &data->colors;
|
ColorSelData_t *colors = &data->colors;
|
||||||
|
|
||||||
filename = gimp_personal_rc_file ("imagemaprc");
|
file = gimp_directory_file ("imagemaprc", NULL);
|
||||||
|
|
||||||
|
filename = g_file_get_path (file);
|
||||||
out = g_fopen(filename, "wb");
|
out = g_fopen(filename, "wb");
|
||||||
if (out) {
|
g_free (filename);
|
||||||
fprintf(out, "# Image map plug-in resource file\n\n");
|
|
||||||
if (data->default_map_type == NCSA)
|
if (out)
|
||||||
|
{
|
||||||
|
fprintf(out, "# Image map plug-in resource file\n\n");
|
||||||
|
if (data->default_map_type == NCSA)
|
||||||
fprintf(out, "(default-map-type ncsa)\n");
|
fprintf(out, "(default-map-type ncsa)\n");
|
||||||
else if (data->default_map_type == CERN)
|
else if (data->default_map_type == CERN)
|
||||||
fprintf(out, "(default-map-type cern)\n");
|
fprintf(out, "(default-map-type cern)\n");
|
||||||
else
|
else
|
||||||
fprintf(out, "(default-map-type csim)\n");
|
fprintf(out, "(default-map-type csim)\n");
|
||||||
|
|
||||||
fprintf(out, "(prompt-for-area-info %s)\n",
|
fprintf(out, "(prompt-for-area-info %s)\n",
|
||||||
(data->prompt_for_area_info) ? "yes" : "no");
|
(data->prompt_for_area_info) ? "yes" : "no");
|
||||||
fprintf(out, "(require-default-url %s)\n",
|
fprintf(out, "(require-default-url %s)\n",
|
||||||
(data->require_default_url) ? "yes" : "no");
|
(data->require_default_url) ? "yes" : "no");
|
||||||
fprintf(out, "(show-area-handle %s)\n",
|
fprintf(out, "(show-area-handle %s)\n",
|
||||||
(data->show_area_handle) ? "yes" : "no");
|
(data->show_area_handle) ? "yes" : "no");
|
||||||
fprintf(out, "(keep-circles-round %s)\n",
|
fprintf(out, "(keep-circles-round %s)\n",
|
||||||
(data->keep_circles_round) ? "yes" : "no");
|
(data->keep_circles_round) ? "yes" : "no");
|
||||||
fprintf(out, "(show-url-tip %s)\n",
|
fprintf(out, "(show-url-tip %s)\n",
|
||||||
(data->show_url_tip) ? "yes" : "no");
|
(data->show_url_tip) ? "yes" : "no");
|
||||||
fprintf(out, "(use-doublesized %s)\n",
|
fprintf(out, "(use-doublesized %s)\n",
|
||||||
(data->use_doublesized) ? "yes" : "no");
|
(data->use_doublesized) ? "yes" : "no");
|
||||||
|
|
||||||
fprintf(out, "(undo-levels %d)\n", data->undo_levels);
|
fprintf(out, "(undo-levels %d)\n", data->undo_levels);
|
||||||
fprintf(out, "(mru-size %d)\n", data->mru_size);
|
fprintf(out, "(mru-size %d)\n", data->mru_size);
|
||||||
|
|
||||||
fprintf(out, "(normal-fg-color %d %d %d)\n",
|
fprintf(out, "(normal-fg-color %d %d %d)\n",
|
||||||
ROUND (colors->normal_fg.red * 255.0),
|
ROUND (colors->normal_fg.red * 255.0),
|
||||||
ROUND (colors->normal_fg.green * 255.0),
|
ROUND (colors->normal_fg.green * 255.0),
|
||||||
ROUND (colors->normal_fg.blue * 255.0));
|
ROUND (colors->normal_fg.blue * 255.0));
|
||||||
fprintf(out, "(normal-bg-color %d %d %d)\n",
|
fprintf(out, "(normal-bg-color %d %d %d)\n",
|
||||||
ROUND (colors->normal_bg.red * 255.0),
|
ROUND (colors->normal_bg.red * 255.0),
|
||||||
ROUND (colors->normal_bg.green * 255.0),
|
ROUND (colors->normal_bg.green * 255.0),
|
||||||
ROUND (colors->normal_bg.blue * 255.0));
|
ROUND (colors->normal_bg.blue * 255.0));
|
||||||
fprintf(out, "(selected-fg-color %d %d %d)\n",
|
fprintf(out, "(selected-fg-color %d %d %d)\n",
|
||||||
ROUND (colors->selected_fg.red * 255.0),
|
ROUND (colors->selected_fg.red * 255.0),
|
||||||
ROUND (colors->selected_fg.green * 255.0),
|
ROUND (colors->selected_fg.green * 255.0),
|
||||||
ROUND (colors->selected_fg.blue * 255.0));
|
ROUND (colors->selected_fg.blue * 255.0));
|
||||||
fprintf(out, "(selected-bg-color %d %d %d)\n",
|
fprintf(out, "(selected-bg-color %d %d %d)\n",
|
||||||
ROUND (colors->selected_bg.red * 255.0),
|
ROUND (colors->selected_bg.red * 255.0),
|
||||||
ROUND (colors->selected_bg.green * 255.0),
|
ROUND (colors->selected_bg.green * 255.0),
|
||||||
ROUND (colors->selected_bg.blue * 255.0));
|
ROUND (colors->selected_bg.blue * 255.0));
|
||||||
fprintf(out, "(interactive-fg-color %d %d %d)\n",
|
fprintf(out, "(interactive-fg-color %d %d %d)\n",
|
||||||
ROUND (colors->interactive_fg.red * 255.0),
|
ROUND (colors->interactive_fg.red * 255.0),
|
||||||
ROUND (colors->interactive_fg.green * 255.0),
|
ROUND (colors->interactive_fg.green * 255.0),
|
||||||
ROUND (colors->interactive_fg.blue * 255.0));
|
ROUND (colors->interactive_fg.blue * 255.0));
|
||||||
fprintf(out, "(interactive-bg-color %d %d %d)\n",
|
fprintf(out, "(interactive-bg-color %d %d %d)\n",
|
||||||
ROUND (colors->interactive_bg.red * 255.0),
|
ROUND (colors->interactive_bg.red * 255.0),
|
||||||
ROUND (colors->interactive_bg.green * 255.0),
|
ROUND (colors->interactive_bg.green * 255.0),
|
||||||
ROUND (colors->interactive_bg.blue * 255.0));
|
ROUND (colors->interactive_bg.blue * 255.0));
|
||||||
|
|
||||||
mru_write(get_mru(), out);
|
mru_write(get_mru(), out);
|
||||||
|
|
||||||
fclose(out);
|
fclose(out);
|
||||||
} else {
|
}
|
||||||
do_file_error_dialog( _("Couldn't save resource file:"), filename);
|
else
|
||||||
}
|
{
|
||||||
g_free(filename);
|
do_file_error_dialog (_("Couldn't save resource file:"),
|
||||||
|
gimp_file_get_utf8_name (file));
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue