[gimp] Bug 790002 - Remember last-used "Select color profile from disk" location
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 790002 - Remember last-used "Select color profile from disk" location
- Date: Tue, 2 Jan 2018 22:15:37 +0000 (UTC)
commit 135f58d3ae2bb28eeb2fa1b745ad257156efb5b3
Author: Michael Natterer <mitch gimp org>
Date: Tue Jan 2 23:09:00 2018 +0100
Bug 790002 - Remember last-used "Select color profile from disk" location
Add "color-profile-path" to GimpDialogConfig to remember the last-used
path in any profile chooser dialog.
Whenever a GimpColorProfileChooserDialog is created, call a new
gimpwidgets-utils helper function that connects to the dialog's "show"
and "response" signals and makes sure "color-profile-path" is set on
the dialog if it doesn't have a current folder already, and sets the
property back to the config object when a profile was actually chosen
from disk.
app/actions/image-commands.c | 4 +
app/config/gimpdialogconfig.c | 29 ++++++++-
app/config/gimpdialogconfig.h | 2 +
app/config/gimprc-blurbs.h | 3 +
app/dialogs/color-profile-dialog.c | 4 +
app/dialogs/preferences-dialog-utils.c | 8 ++-
app/dialogs/preferences-dialog-utils.h | 4 +-
app/dialogs/preferences-dialog.c | 25 ++++++--
app/widgets/gimppropwidgets.c | 9 +++-
app/widgets/gimppropwidgets.h | 4 +-
app/widgets/gimptemplateeditor.c | 4 +-
app/widgets/gimpwidgets-utils.c | 102 ++++++++++++++++++++++++++++++++
app/widgets/gimpwidgets-utils.h | 5 ++
13 files changed, 189 insertions(+), 14 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index 8d92302..c7af7b7 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -599,6 +599,10 @@ image_color_profile_save_cmd_callback (GtkAction *action,
toplevel,
GTK_FILE_CHOOSER_ACTION_SAVE);
+ gimp_color_profile_chooser_dialog_connect_path (dialog,
+ G_OBJECT (image->gimp->config),
+ "color-profile-path");
+
basename = g_strconcat (gimp_color_profile_get_label (profile),
".icc", NULL);
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index 6588585..61ab19c 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -48,6 +48,8 @@ enum
PROP_COLOR_PROFILE_POLICY,
+ PROP_COLOR_PROFILE_PATH,
+
PROP_IMAGE_CONVERT_PROFILE_INTENT,
PROP_IMAGE_CONVERT_PROFILE_BPC,
@@ -174,6 +176,14 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
GIMP_COLOR_PROFILE_POLICY_ASK,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_PATH (object_class, PROP_COLOR_PROFILE_PATH,
+ "color-profile-path",
+ "Default color profile folder path",
+ COLOR_PROFILE_PATH_BLURB,
+ GIMP_CONFIG_PATH_FILE,
+ NULL,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_ENUM (object_class, PROP_IMAGE_CONVERT_PROFILE_INTENT,
"image-convert-profile-intent",
"Default rendering intent fo color profile conversion",
@@ -558,9 +568,12 @@ gimp_dialog_config_finalize (GObject *object)
{
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (object);
- g_clear_pointer (&config->layer_new_name, g_free);
- g_clear_pointer (&config->channel_new_name, g_free);
- g_clear_pointer (&config->vectors_new_name, g_free);
+ g_clear_pointer (&config->color_profile_path, g_free);
+ g_clear_pointer (&config->layer_new_name, g_free);
+ g_clear_pointer (&config->channel_new_name, g_free);
+ g_clear_pointer (&config->vectors_new_name, g_free);
+ g_clear_pointer (&config->vectors_export_path, g_free);
+ g_clear_pointer (&config->vectors_import_path, g_free);
g_clear_object (&config->fill_options);
g_clear_object (&config->stroke_options);
@@ -587,6 +600,12 @@ gimp_dialog_config_set_property (GObject *object,
config->color_profile_policy = g_value_get_enum (value);
break;
+ case PROP_COLOR_PROFILE_PATH:
+ if (config->color_profile_path)
+ g_free (config->color_profile_path);
+ config->color_profile_path = g_value_dup_string (value);
+ break;
+
case PROP_IMAGE_CONVERT_PROFILE_INTENT:
config->image_convert_profile_intent = g_value_get_enum (value);
break;
@@ -778,6 +797,10 @@ gimp_dialog_config_get_property (GObject *object,
g_value_set_enum (value, config->color_profile_policy);
break;
+ case PROP_COLOR_PROFILE_PATH:
+ g_value_set_string (value, config->color_profile_path);
+ break;
+
case PROP_IMAGE_CONVERT_PROFILE_INTENT:
g_value_set_enum (value, config->image_convert_profile_intent);
break;
diff --git a/app/config/gimpdialogconfig.h b/app/config/gimpdialogconfig.h
index a040ce1..f933824 100644
--- a/app/config/gimpdialogconfig.h
+++ b/app/config/gimpdialogconfig.h
@@ -46,6 +46,8 @@ struct _GimpDialogConfig
GimpColorProfilePolicy color_profile_policy;
+ gchar *color_profile_path;
+
GimpColorRenderingIntent image_convert_profile_intent;
gboolean image_convert_profile_bpc;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 599b044..58b17ed 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -42,6 +42,9 @@ _("Specifies how the area around the image should be drawn.")
#define COLOR_PROFILE_POLICY_BLURB \
_("How to handle embedded color profiles when opening a file.")
+#define COLOR_PROFILE_PATH_BLURB \
+_("Sets the default folder path for all color profile file dialogs.")
+
#define CURSOR_MODE_BLURB \
_("Sets the type of mouse pointers to use.")
diff --git a/app/dialogs/color-profile-dialog.c b/app/dialogs/color-profile-dialog.c
index cf816d8..d06a444 100644
--- a/app/dialogs/color-profile-dialog.c
+++ b/app/dialogs/color-profile-dialog.c
@@ -387,6 +387,10 @@ color_profile_combo_box_new (ProfileDialog *private)
NULL,
GTK_FILE_CHOOSER_ACTION_OPEN);
+ gimp_color_profile_chooser_dialog_connect_path (chooser,
+ G_OBJECT (private->image->gimp->config),
+ "color-profile-path");
+
combo = gimp_color_profile_combo_box_new_with_model (chooser,
GTK_TREE_MODEL (store));
g_object_unref (store);
diff --git a/app/dialogs/preferences-dialog-utils.c b/app/dialogs/preferences-dialog-utils.c
index 9da01b9..a55dab1 100644
--- a/app/dialogs/preferences-dialog-utils.c
+++ b/app/dialogs/preferences-dialog-utils.c
@@ -367,12 +367,16 @@ prefs_profile_combo_box_add (GObject *config,
const gchar *label,
GtkTable *table,
gint table_row,
- GtkSizeGroup *group)
+ GtkSizeGroup *group,
+ GObject *profile_path_config,
+ const gchar *profile_path_property_name)
{
GtkWidget *combo = gimp_prop_profile_combo_box_new (config,
property_name,
profile_store,
- dialog_title);
+ dialog_title,
+ profile_path_config,
+ profile_path_property_name);
if (combo)
prefs_widget_add_aligned (combo, label, table, table_row, FALSE, group);
diff --git a/app/dialogs/preferences-dialog-utils.h b/app/dialogs/preferences-dialog-utils.h
index 8185039..dde0a5b 100644
--- a/app/dialogs/preferences-dialog-utils.h
+++ b/app/dialogs/preferences-dialog-utils.h
@@ -120,7 +120,9 @@ GtkWidget * prefs_profile_combo_box_add (GObject *config,
const gchar *label,
GtkTable *table,
gint table_row,
- GtkSizeGroup *group);
+ GtkSizeGroup *group,
+ GObject *profile_path_config,
+ const gchar *profile_path_property_name);
#endif /* __PREFERENCES_DIALOG_H__ */
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index bffe23b..5cfd5c0 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1253,7 +1253,8 @@ prefs_dialog_new (Gimp *gimp,
store,
_("Select Monitor Color Profile"),
_("_Monitor profile:"),
- GTK_TABLE (table), row++, size_group);
+ GTK_TABLE (table), row++, size_group,
+ object, "color-profile-path");
button = gimp_prop_check_button_new (color_config,
"display-profile-from-gdk",
@@ -1297,7 +1298,8 @@ prefs_dialog_new (Gimp *gimp,
store,
_("Select Soft-Proofing Color Profile"),
_("_Soft-proofing profile:"),
- GTK_TABLE (table), row++, size_group);
+ GTK_TABLE (table), row++, size_group,
+ object, "color-profile-path");
prefs_enum_combo_box_add (color_config,
"simulation-rendering-intent", 0, 0,
@@ -1352,21 +1354,24 @@ prefs_dialog_new (Gimp *gimp,
store,
_("Select Preferred RGB Color Profile"),
_("_RGB profile:"),
- GTK_TABLE (table), row++, size_group);
+ GTK_TABLE (table), row++, size_group,
+ object, "color-profile-path");
prefs_profile_combo_box_add (color_config,
"gray-profile",
store,
_("Select Preferred Grayscale Color Profile"),
_("_Grayscale profile:"),
- GTK_TABLE (table), row++, size_group);
+ GTK_TABLE (table), row++, size_group,
+ object, "color-profile-path");
prefs_profile_combo_box_add (color_config,
"cmyk-profile",
store,
_("Select CMYK Color Profile"),
_("_CMYK profile:"),
- GTK_TABLE (table), row++, size_group);
+ GTK_TABLE (table), row++, size_group,
+ object, "color-profile-path");
/* Policies */
vbox2 = prefs_frame_new (_("Policies"), GTK_CONTAINER (vbox),
@@ -2003,6 +2008,16 @@ prefs_dialog_new (Gimp *gimp,
_("Color profile policy:"),
GTK_TABLE (table), 0, size_group);
+ /* All color profile chooser dialogs */
+ vbox2 = prefs_frame_new (_("Color Profile File Dialogs"), GTK_CONTAINER (vbox),
+ FALSE);
+ table = prefs_table_new (1, GTK_CONTAINER (vbox2));
+
+ prefs_file_chooser_button_add (object, "color-profile-path",
+ _("Profile folder:"),
+ _("Select Default Folder for Color Profiles"),
+ GTK_TABLE (table), 0, size_group);
+
/* Convert to Color Profile Dialog */
vbox2 = prefs_frame_new (_("Convert to Color Profile Dialog"),
GTK_CONTAINER (vbox), FALSE);
diff --git a/app/widgets/gimppropwidgets.c b/app/widgets/gimppropwidgets.c
index c5a8ec2..bda9fd4 100644
--- a/app/widgets/gimppropwidgets.c
+++ b/app/widgets/gimppropwidgets.c
@@ -1536,7 +1536,9 @@ GtkWidget *
gimp_prop_profile_combo_box_new (GObject *config,
const gchar *property_name,
GtkListStore *profile_store,
- const gchar *dialog_title)
+ const gchar *dialog_title,
+ GObject *profile_path_config,
+ const gchar *profile_path_property_name)
{
GParamSpec *param_spec;
GtkWidget *dialog;
@@ -1564,6 +1566,11 @@ gimp_prop_profile_combo_box_new (GObject *config,
dialog = gimp_color_profile_chooser_dialog_new (dialog_title, NULL,
GTK_FILE_CHOOSER_ACTION_OPEN);
+ if (profile_path_config && profile_path_property_name)
+ gimp_color_profile_chooser_dialog_connect_path (dialog,
+ profile_path_config,
+ profile_path_property_name);
+
if (G_IS_PARAM_SPEC_STRING (param_spec))
{
gchar *path;
diff --git a/app/widgets/gimppropwidgets.h b/app/widgets/gimppropwidgets.h
index f31b2f5..f8e4be4 100644
--- a/app/widgets/gimppropwidgets.h
+++ b/app/widgets/gimppropwidgets.h
@@ -111,7 +111,9 @@ GtkWidget * gimp_prop_language_entry_new (GObject *config,
GtkWidget * gimp_prop_profile_combo_box_new (GObject *config,
const gchar *property_name,
GtkListStore *profile_store,
- const gchar *dialog_title);
+ const gchar *dialog_title,
+ GObject *profile_path_config,
+ const gchar *profile_path_property_name);
GtkWidget * gimp_prop_icon_picker_new (GimpViewable *viewable,
Gimp *gimp);
diff --git a/app/widgets/gimptemplateeditor.c b/app/widgets/gimptemplateeditor.c
index 259399b..c27f40b 100644
--- a/app/widgets/gimptemplateeditor.c
+++ b/app/widgets/gimptemplateeditor.c
@@ -438,7 +438,9 @@ gimp_template_editor_constructed (GObject *object)
gimp_prop_profile_combo_box_new (G_OBJECT (template),
"color-profile",
NULL,
- _("Choose A Color Profile"));
+ _("Choose A Color Profile"),
+ G_OBJECT (private->gimp->config),
+ "color-profile-path");
gimp_table_attach_aligned (GTK_TABLE (table), 0, row++,
_("Co_lor profile:"), 0.0, 0.5,
private->profile_combo, 1, FALSE);
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index ff3552a..02d160e 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -1704,3 +1704,105 @@ gimp_color_profile_store_add_defaults (GimpColorProfileStore *store,
return TRUE;
}
+
+static void
+connect_path_show (GimpColorProfileChooserDialog *dialog)
+{
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
+ GFile *file = gtk_file_chooser_get_file (chooser);
+
+ if (file)
+ {
+ /* if something is already selected in this dialog,
+ * leave it alone
+ */
+ g_object_unref (file);
+ }
+ else
+ {
+ GObject *config;
+ const gchar *property;
+ gchar *path = NULL;
+
+ config = g_object_get_data (G_OBJECT (dialog), "profile-path-config");
+ property = g_object_get_data (G_OBJECT (dialog), "profile-path-property");
+
+ g_object_get (config, property, &path, NULL);
+
+ if (path)
+ {
+ GFile *folder = gimp_file_new_for_config_path (path, NULL);
+
+ if (folder)
+ {
+ gtk_file_chooser_set_current_folder_file (chooser, folder, NULL);
+ g_object_unref (folder);
+ }
+
+ g_free (path);
+ }
+ }
+}
+
+static void
+connect_path_response (GimpColorProfileChooserDialog *dialog,
+ gint response)
+{
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (dialog);
+ GFile *file = gtk_file_chooser_get_file (chooser);
+
+ if (file)
+ {
+ GFile *folder = gtk_file_chooser_get_current_folder_file (chooser);
+
+ if (folder)
+ {
+ GObject *config;
+ const gchar *property;
+ gchar *path = NULL;
+
+ config = g_object_get_data (G_OBJECT (dialog),
+ "profile-path-config");
+ property = g_object_get_data (G_OBJECT (dialog),
+ "profile-path-property");
+
+ path = gimp_file_get_config_path (folder, NULL);
+
+ g_object_set (config, property, path, NULL);
+
+ if (path)
+ g_free (path);
+
+ g_object_unref (folder);
+ }
+
+ g_object_unref (file);
+ }
+ }
+}
+
+void
+gimp_color_profile_chooser_dialog_connect_path (GtkWidget *dialog,
+ GObject *config,
+ const gchar *property_name)
+{
+ g_return_if_fail (GIMP_IS_COLOR_PROFILE_CHOOSER_DIALOG (dialog));
+ g_return_if_fail (G_IS_OBJECT (config));
+ g_return_if_fail (property_name != NULL);
+
+ g_object_set_data_full (G_OBJECT (dialog), "profile-path-config",
+ g_object_ref (config),
+ (GDestroyNotify) g_object_unref);
+ g_object_set_data_full (G_OBJECT (dialog), "profile-path-property",
+ g_strdup (property_name),
+ (GDestroyNotify) g_free);
+
+ g_signal_connect (dialog, "show",
+ G_CALLBACK (connect_path_show),
+ NULL);
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (connect_path_response),
+ NULL);
+}
diff --git a/app/widgets/gimpwidgets-utils.h b/app/widgets/gimpwidgets-utils.h
index bd7ca6f..2098fe1 100644
--- a/app/widgets/gimpwidgets-utils.h
+++ b/app/widgets/gimpwidgets-utils.h
@@ -121,5 +121,10 @@ gboolean gimp_color_profile_store_add_defaults
GimpPrecision precision,
GError **error);
+void gimp_color_profile_chooser_dialog_connect_path
+ (GtkWidget *dialog,
+ GObject *config,
+ const gchar *property_name);
+
#endif /* __APP_GIMP_WIDGETS_UTILS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]