diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 69c4ce3f23..d41b32249f 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -788,23 +788,30 @@ static void prefs_profile_combo_notify (GObject *config, prefs_profile_combo_changed (GimpColorProfileComboBox *combo, GObject *config) { - gchar *filename = gimp_color_profile_combo_box_get_active (combo); + GFile *file = gimp_color_profile_combo_box_get_active_file (combo); + gchar *path = NULL; - if (! filename) + if (file) + path = g_file_get_path (file); + + if (! path) g_signal_handlers_block_by_func (config, prefs_profile_combo_notify, combo); g_object_set (config, - g_object_get_data (G_OBJECT (combo), "property-name"), filename, + g_object_get_data (G_OBJECT (combo), "property-name"), path, NULL); - if (! filename) + if (! path) g_signal_handlers_unblock_by_func (config, prefs_profile_combo_notify, combo); - g_free (filename); + g_free (path); + + if (file) + g_object_unref (file); } static void @@ -812,23 +819,31 @@ prefs_profile_combo_notify (GObject *config, const GParamSpec *param_spec, GimpColorProfileComboBox *combo) { - gchar *filename; + gchar *path; + GFile *file = NULL; g_object_get (config, - param_spec->name, &filename, + param_spec->name, &path, NULL); + if (path) + { + file = g_file_new_for_path (path); + g_free (path); + } + g_signal_handlers_block_by_func (combo, prefs_profile_combo_changed, config); - gimp_color_profile_combo_box_set_active (combo, filename, NULL); + gimp_color_profile_combo_box_set_active_file (combo, file, NULL); g_signal_handlers_unblock_by_func (combo, prefs_profile_combo_changed, config); - g_free (filename); + if (file) + g_object_unref (file); } static void @@ -856,10 +871,17 @@ prefs_profile_combo_box_new (GObject *config, { GtkWidget *dialog = gimp_color_profile_chooser_dialog_new (label); GtkWidget *combo; - gchar *filename; + gchar *path; gchar *notify_name; + GFile *file = NULL; - g_object_get (config, property_name, &filename, NULL); + g_object_get (config, property_name, &path, NULL); + + if (path) + { + file = g_file_new_for_path (path); + g_free (path); + } combo = gimp_color_profile_combo_box_new_with_model (dialog, GTK_TREE_MODEL (store)); @@ -867,10 +889,11 @@ prefs_profile_combo_box_new (GObject *config, g_object_set_data (G_OBJECT (combo), "property-name", (gpointer) property_name); - gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo), - filename, NULL); + gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo), + file, NULL); - g_free (filename); + if (file) + g_object_unref (file); g_signal_connect (combo, "changed", G_CALLBACK (prefs_profile_combo_changed), @@ -2377,7 +2400,8 @@ prefs_dialog_new (Gimp *gimp, store = gimp_color_profile_store_new (filename); g_free (filename); - gimp_color_profile_store_add (GIMP_COLOR_PROFILE_STORE (store), NULL, NULL); + gimp_color_profile_store_add_file (GIMP_COLOR_PROFILE_STORE (store), + NULL, NULL); for (i = 0; i < G_N_ELEMENTS (profiles); i++) { diff --git a/libgimpwidgets/gimpcolorprofilecombobox.c b/libgimpwidgets/gimpcolorprofilecombobox.c index c0995e88ba..40e9b37cc9 100644 --- a/libgimpwidgets/gimpcolorprofilecombobox.c +++ b/libgimpwidgets/gimpcolorprofilecombobox.c @@ -376,7 +376,9 @@ gimp_color_profile_combo_box_new_with_model (GtkWidget *dialog, * * This function delegates to the underlying * #GimpColorProfileStore. Please refer to the documentation of - * gimp_color_profile_store_add() for details. + * gimp_color_profile_store_add_file() for details. + * + * Deprecated: use gimp_color_profile_combo_box_add_file() instead. * * Since: 2.4 **/ @@ -385,15 +387,48 @@ gimp_color_profile_combo_box_add (GimpColorProfileComboBox *combo, const gchar *filename, const gchar *label) { - GtkTreeModel *model; + GFile *file = NULL; g_return_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo)); g_return_if_fail (label != NULL || filename == NULL); + if (filename) + file = g_file_new_for_path (filename); + + gimp_color_profile_combo_box_add_file (combo, file, label); + + if (file) + g_object_unref (file); +} + +/** + * gimp_color_profile_combo_box_add_file: + * @combo: a #GimpColorProfileComboBox + * @file: file of the profile to add (or %NULL) + * @label: label to use for the profile + * (may only be %NULL if @file is %NULL) + * + * This function delegates to the underlying + * #GimpColorProfileStore. Please refer to the documentation of + * gimp_color_profile_store_add_file() for details. + * + * Since: 2.10 + **/ +void +gimp_color_profile_combo_box_add_file (GimpColorProfileComboBox *combo, + GFile *file, + const gchar *label) +{ + GtkTreeModel *model; + + g_return_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo)); + g_return_if_fail (label != NULL || file == NULL); + g_return_if_fail (file == NULL || G_IS_FILE (file)); + model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); - gimp_color_profile_store_add (GIMP_COLOR_PROFILE_STORE (model), - filename, label); + gimp_color_profile_store_add_file (GIMP_COLOR_PROFILE_STORE (model), + file, label); } /** @@ -406,29 +441,59 @@ gimp_color_profile_combo_box_add (GimpColorProfileComboBox *combo, * item. If the profile is not listed in the @combo, then it is added * with the given @label (or @filename in case that @label is %NULL). * + * Deprecated: use gimp_color_profile_combo_box_set_active_file() instead. + * * Since: 2.4 **/ void gimp_color_profile_combo_box_set_active (GimpColorProfileComboBox *combo, const gchar *filename, const gchar *label) +{ + GFile *file = NULL; + + g_return_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo)); + + if (filename) + file = g_file_new_for_path (filename); + + gimp_color_profile_combo_box_set_active_file (combo, file, label); + + if (file) + g_object_unref (file); +} + +/** + * gimp_color_profile_combo_box_set_active_file: + * @combo: a #GimpColorProfileComboBox + * @file: file of the profile to select + * @label: label to use when adding a new entry (can be %NULL) + * + * Selects a color profile from the @combo and makes it the active + * item. If the profile is not listed in the @combo, then it is added + * with the given @label (or @file in case that @label is %NULL). + * + * Since: 2.10 + **/ +void +gimp_color_profile_combo_box_set_active_file (GimpColorProfileComboBox *combo, + GFile *file, + const gchar *label) { GimpColorProfile *profile = NULL; GtkTreeModel *model; GtkTreeIter iter; g_return_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo)); + g_return_if_fail (file == NULL || G_IS_FILE (file)); model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); - if (filename && ! (label && *label)) + if (file && ! (label && *label)) { - GFile *file; GError *error = NULL; - file = g_file_new_for_path (filename); profile = gimp_color_profile_new_from_file (file, &error); - g_object_unref (file); if (! profile) { @@ -442,7 +507,7 @@ gimp_color_profile_combo_box_set_active (GimpColorProfileComboBox *combo, } if (_gimp_color_profile_store_history_add (GIMP_COLOR_PROFILE_STORE (model), - filename, label, &iter)) + file, label, &iter)) { gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter); } @@ -455,14 +520,45 @@ gimp_color_profile_combo_box_set_active (GimpColorProfileComboBox *combo, * gimp_color_profile_combo_box_get_active: * @combo: a #GimpColorProfileComboBox * - * Return value: The filename of the currently selected color profile. + * Return value: The filename of the currently selected color profile, * This is a newly allocated string and should be released * using g_free() when it is not any longer needed. * + * Deprecated: use gimp_color_profile_combo_box_get_active_file() inatead. + * * Since: 2.4 **/ gchar * gimp_color_profile_combo_box_get_active (GimpColorProfileComboBox *combo) +{ + GFile *file; + gchar *path = NULL; + + g_return_val_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo), NULL); + + file = gimp_color_profile_combo_box_get_active_file (combo); + + if (file) + { + path = g_file_get_path (file); + g_object_unref (file); + } + + return path; +} + +/** + * gimp_color_profile_combo_box_get_active_file: + * @combo: a #GimpColorProfileComboBox + * + * Return value: The file of the currently selected color profile, + * release using g_object_unref() when it is not any + * longer needed. + * + * Since: 2.10 + **/ +GFile * +gimp_color_profile_combo_box_get_active_file (GimpColorProfileComboBox *combo) { GtkTreeModel *model; GtkTreeIter iter; @@ -473,18 +569,19 @@ gimp_color_profile_combo_box_get_active (GimpColorProfileComboBox *combo) if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter)) { - gchar *filename; + GFile *file; gint type; gtk_tree_model_get (model, &iter, GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, &type, - GIMP_COLOR_PROFILE_STORE_FILENAME, &filename, + GIMP_COLOR_PROFILE_STORE_FILE, &file, -1); if (type == GIMP_COLOR_PROFILE_STORE_ITEM_FILE) - return filename; + return file; - g_free (filename); + if (file) + g_object_unref (file); } return NULL; @@ -519,15 +616,15 @@ gimp_color_profile_combo_dialog_response (GimpColorProfileChooserDialog *dialog, { if (response == GTK_RESPONSE_ACCEPT) { - gchar *filename; + GFile *file; - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); + file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)); - if (filename) + if (file) { - gimp_color_profile_combo_box_set_active (combo, filename, NULL); + gimp_color_profile_combo_box_set_active_file (combo, file, NULL); - g_free (filename); + g_object_unref (file); } } diff --git a/libgimpwidgets/gimpcolorprofilecombobox.h b/libgimpwidgets/gimpcolorprofilecombobox.h index aaa448f064..31f7bc559d 100644 --- a/libgimpwidgets/gimpcolorprofilecombobox.h +++ b/libgimpwidgets/gimpcolorprofilecombobox.h @@ -64,13 +64,25 @@ GtkWidget * gimp_color_profile_combo_box_new (GtkWidget *dialog, GtkWidget * gimp_color_profile_combo_box_new_with_model (GtkWidget *dialog, GtkTreeModel *model); +GIMP_DEPRECATED_FOR (gimp_color_profile_combo_box_add_file) void gimp_color_profile_combo_box_add (GimpColorProfileComboBox *combo, const gchar *filename, const gchar *label); +void gimp_color_profile_combo_box_add_file (GimpColorProfileComboBox *combo, + GFile *file, + const gchar *label); + +GIMP_DEPRECATED_FOR (gimp_color_profile_combo_box_set_active_file) void gimp_color_profile_combo_box_set_active (GimpColorProfileComboBox *combo, const gchar *filename, const gchar *label); +void gimp_color_profile_combo_box_set_active_file (GimpColorProfileComboBox *combo, + GFile *file, + const gchar *label); + +GIMP_DEPRECATED_FOR (gimp_color_profile_combo_box_get_active_file) gchar * gimp_color_profile_combo_box_get_active (GimpColorProfileComboBox *combo); +GFile * gimp_color_profile_combo_box_get_active_file (GimpColorProfileComboBox *combo); G_END_DECLS diff --git a/libgimpwidgets/gimpcolorprofilestore-private.h b/libgimpwidgets/gimpcolorprofilestore-private.h index 12d6826e64..afb19925ab 100644 --- a/libgimpwidgets/gimpcolorprofilestore-private.h +++ b/libgimpwidgets/gimpcolorprofilestore-private.h @@ -35,13 +35,13 @@ typedef enum { GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, GIMP_COLOR_PROFILE_STORE_LABEL, - GIMP_COLOR_PROFILE_STORE_FILENAME, + GIMP_COLOR_PROFILE_STORE_FILE, GIMP_COLOR_PROFILE_STORE_INDEX } GimpColorProfileStoreColumns; G_GNUC_INTERNAL gboolean _gimp_color_profile_store_history_add (GimpColorProfileStore *store, - const gchar *filename, + GFile *file, const gchar *label, GtkTreeIter *iter); diff --git a/libgimpwidgets/gimpcolorprofilestore.c b/libgimpwidgets/gimpcolorprofilestore.c index 815c988ed7..0e57fbd1f7 100644 --- a/libgimpwidgets/gimpcolorprofilestore.c +++ b/libgimpwidgets/gimpcolorprofilestore.c @@ -68,7 +68,7 @@ static void gimp_color_profile_store_get_property (GObject static gboolean gimp_color_profile_store_history_insert (GimpColorProfileStore *store, GtkTreeIter *iter, - const gchar *filename, + GFile *file, const gchar *label, gint index); static void gimp_color_profile_store_get_separator (GimpColorProfileStore *store, @@ -119,10 +119,10 @@ gimp_color_profile_store_init (GimpColorProfileStore *store) { GType types[] = { - G_TYPE_INT, /* GIMP_COLOR_PROFILE_STORE_ITEM_TYPE */ - G_TYPE_STRING, /* GIMP_COLOR_PROFILE_STORE_LABEL */ - G_TYPE_STRING, /* GIMP_COLOR_PROFILE_STORE_FILENAME */ - G_TYPE_INT /* GIMP_COLOR_PROFILE_STORE_INDEX */ + G_TYPE_INT, /* GIMP_COLOR_PROFILE_STORE_ITEM_TYPE */ + G_TYPE_STRING, /* GIMP_COLOR_PROFILE_STORE_LABEL */ + G_TYPE_FILE, /* GIMP_COLOR_PROFILE_STORE_FILE */ + G_TYPE_INT /* GIMP_COLOR_PROFILE_STORE_INDEX */ }; gtk_list_store_set_column_types (GTK_LIST_STORE (store), @@ -262,6 +262,8 @@ gimp_color_profile_store_new (const gchar *history) * @label will be set to the string "None" for you (and translated for * the user). * + * Deprecated: use gimp_color_profile_store_add_file() instead. + * * Since: 2.4 **/ void @@ -269,13 +271,49 @@ gimp_color_profile_store_add (GimpColorProfileStore *store, const gchar *filename, const gchar *label) { - GtkTreeIter separator; - GtkTreeIter iter; + GFile *file = NULL; g_return_if_fail (GIMP_IS_COLOR_PROFILE_STORE (store)); g_return_if_fail (label != NULL || filename == NULL); - if (! filename && ! label) + if (filename) + file = g_file_new_for_path (filename); + + gimp_color_profile_store_add_file (store, file, label); + + g_object_unref (file); +} + +/** + * gimp_color_profile_store_add_file: + * @store: a #GimpColorProfileStore + * @file: file of the profile to add (or %NULL) + * @label: label to use for the profile + * (may only be %NULL if @filename is %NULL) + * + * Adds a color profile item to the #GimpColorProfileStore. Items + * added with this function will be kept at the top, separated from + * the history of last used color profiles. + * + * This function is often used to add a selectable item for the %NULL + * file. If you pass %NULL for both @file and @label, the @label will + * be set to the string "None" for you (and translated for the user). + * + * Since: 2.10 + **/ +void +gimp_color_profile_store_add_file (GimpColorProfileStore *store, + GFile *file, + const gchar *label) +{ + GtkTreeIter separator; + GtkTreeIter iter; + + g_return_if_fail (GIMP_IS_COLOR_PROFILE_STORE (store)); + g_return_if_fail (label != NULL || file == NULL); + g_return_if_fail (file == NULL || G_IS_FILE (file)); + + if (! file && ! label) label = C_("profile", "None"); gimp_color_profile_store_get_separator (store, &separator, TRUE); @@ -284,7 +322,7 @@ gimp_color_profile_store_add (GimpColorProfileStore *store, gtk_list_store_set (GTK_LIST_STORE (store), &iter, GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, GIMP_COLOR_PROFILE_STORE_ITEM_FILE, - GIMP_COLOR_PROFILE_STORE_FILENAME, filename, + GIMP_COLOR_PROFILE_STORE_FILE, file, GIMP_COLOR_PROFILE_STORE_LABEL, label, GIMP_COLOR_PROFILE_STORE_INDEX, -1, -1); @@ -292,10 +330,10 @@ gimp_color_profile_store_add (GimpColorProfileStore *store, /** * _gimp_color_profile_store_history_add: - * @store: a #GimpColorProfileStore - * @filename: filename of the profile to add (or %NULL) - * @label: label to use for the profile (or %NULL) - * @iter: a #GtkTreeIter + * @store: a #GimpColorProfileStore + * @file: file of the profile to add (or %NULL) + * @label: label to use for the profile (or %NULL) + * @iter: a #GtkTreeIter * * Return value: %TRUE if the iter is valid and pointing to the item * @@ -303,7 +341,7 @@ gimp_color_profile_store_add (GimpColorProfileStore *store, **/ gboolean _gimp_color_profile_store_history_add (GimpColorProfileStore *store, - const gchar *filename, + GFile *file, const gchar *label, GtkTreeIter *iter) { @@ -322,7 +360,7 @@ _gimp_color_profile_store_history_add (GimpColorProfileStore *store, { gint type; gint index; - gchar *this; + GFile *this; gtk_tree_model_get (model, iter, GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, &type, @@ -337,11 +375,11 @@ _gimp_color_profile_store_history_add (GimpColorProfileStore *store, /* check if we found a filename match */ gtk_tree_model_get (model, iter, - GIMP_COLOR_PROFILE_STORE_FILENAME, &this, + GIMP_COLOR_PROFILE_STORE_FILE, &this, -1); - if ((this && filename && strcmp (filename, this) == 0) || - (! this && ! filename)) + if ((this && file && g_file_equal (this, file)) || + (! this && ! file)) { /* update the label */ if (label && *label) @@ -349,26 +387,32 @@ _gimp_color_profile_store_history_add (GimpColorProfileStore *store, GIMP_COLOR_PROFILE_STORE_LABEL, label, -1); - g_free (this); + if (this) + g_object_unref (this); + return TRUE; } + + if (this) + g_object_unref (this); } - if (! filename) + if (! file) return FALSE; if (label && *label) { iter_valid = gimp_color_profile_store_history_insert (store, iter, - filename, label, + file, label, ++max); } else { - gchar *basename = g_filename_display_basename (filename); + const gchar *utf8 = gimp_file_get_utf8_name (file); + gchar *basename = g_path_get_basename (utf8); iter_valid = gimp_color_profile_store_history_insert (store, iter, - filename, basename, + file, basename, ++max); g_free (basename); } @@ -438,7 +482,7 @@ _gimp_color_profile_store_history_reorder (GimpColorProfileStore *store, static gboolean gimp_color_profile_store_history_insert (GimpColorProfileStore *store, GtkTreeIter *iter, - const gchar *filename, + GFile *file, const gchar *label, gint index) { @@ -446,7 +490,7 @@ gimp_color_profile_store_history_insert (GimpColorProfileStore *store, GtkTreeIter sibling; gboolean iter_valid; - g_return_val_if_fail (filename != NULL, FALSE); + g_return_val_if_fail (G_IS_FILE (file), FALSE); g_return_val_if_fail (label != NULL, FALSE); g_return_val_if_fail (index > -1, FALSE); @@ -495,9 +539,9 @@ gimp_color_profile_store_history_insert (GimpColorProfileStore *store, gtk_list_store_set (GTK_LIST_STORE (store), iter, GIMP_COLOR_PROFILE_STORE_ITEM_TYPE, GIMP_COLOR_PROFILE_STORE_ITEM_FILE, - GIMP_COLOR_PROFILE_STORE_FILENAME, filename, - GIMP_COLOR_PROFILE_STORE_LABEL, label, - GIMP_COLOR_PROFILE_STORE_INDEX, index, + GIMP_COLOR_PROFILE_STORE_FILE, file, + GIMP_COLOR_PROFILE_STORE_LABEL, label, + GIMP_COLOR_PROFILE_STORE_INDEX, index, -1); return iter_valid; @@ -587,15 +631,19 @@ gimp_color_profile_store_load_profile (GimpColorProfileStore *store, if (gimp_scanner_parse_string (scanner, &label) && gimp_scanner_parse_string (scanner, &uri)) { - gchar *filename = g_filename_from_uri (uri, NULL, NULL); + GFile *file = g_file_new_for_uri (uri); - if (filename && g_file_test (filename, G_FILE_TEST_IS_REGULAR)) + if (file) { - gimp_color_profile_store_history_insert (store, &iter, - filename, label, index); + if (g_file_query_file_type (file, 0, NULL) == G_FILE_TYPE_REGULAR) + { + gimp_color_profile_store_history_insert (store, &iter, + file, label, index); + } + + g_object_unref (file); } - g_free (filename); g_free (label); g_free (uri); @@ -668,8 +716,8 @@ gimp_color_profile_store_save (GimpColorProfileStore *store, GimpConfigWriter *writer; GtkTreeModel *model; GtkTreeIter iter; - gchar *labels[HISTORY_SIZE] = { NULL, }; - gchar *filenames[HISTORY_SIZE] = { NULL, }; + gchar *labels[HISTORY_SIZE] = { NULL, }; + GFile *files[HISTORY_SIZE] = { NULL, }; gboolean iter_valid; gint i; @@ -698,14 +746,14 @@ gimp_color_profile_store_save (GimpColorProfileStore *store, index >= 0 && index < HISTORY_SIZE) { - if (labels[index] || filenames[index]) + if (labels[index] || files[index]) g_warning ("%s: double index %d", G_STRFUNC, index); gtk_tree_model_get (model, &iter, GIMP_COLOR_PROFILE_STORE_LABEL, &labels[index], - GIMP_COLOR_PROFILE_STORE_FILENAME, - &filenames[index], + GIMP_COLOR_PROFILE_STORE_FILE, + &files[index], -1); } } @@ -713,9 +761,9 @@ gimp_color_profile_store_save (GimpColorProfileStore *store, for (i = 0; i < HISTORY_SIZE; i++) { - if (filenames[i] && labels[i]) + if (files[i] && labels[i]) { - gchar *uri = g_filename_to_uri (filenames[i], NULL, NULL); + gchar *uri = g_file_get_uri (files[i]); if (uri) { @@ -728,7 +776,9 @@ gimp_color_profile_store_save (GimpColorProfileStore *store, } } - g_free (filenames[i]); + if (files[i]) + g_object_unref (files[i]); + g_free (labels[i]); } diff --git a/libgimpwidgets/gimpcolorprofilestore.h b/libgimpwidgets/gimpcolorprofilestore.h index ce39a8df44..9293d93720 100644 --- a/libgimpwidgets/gimpcolorprofilestore.h +++ b/libgimpwidgets/gimpcolorprofilestore.h @@ -41,9 +41,9 @@ typedef struct _GimpColorProfileStoreClass GimpColorProfileStoreClass; struct _GimpColorProfileStore { - GtkListStore parent_instance; + GtkListStore parent_instance; - gchar *history; + gchar *history; }; struct _GimpColorProfileStoreClass @@ -61,10 +61,15 @@ GType gimp_color_profile_store_get_type (void) G_GNUC_CONST; GtkListStore * gimp_color_profile_store_new (const gchar *history); +GIMP_DEPRECATED_FOR(gimp_color_profile_store_add_file) void gimp_color_profile_store_add (GimpColorProfileStore *store, const gchar *filename, const gchar *label); +void gimp_color_profile_store_add_file (GimpColorProfileStore *store, + GFile *file, + const gchar *label); + G_END_DECLS diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def index 0ed3842c18..983efb0924 100644 --- a/libgimpwidgets/gimpwidgets.def +++ b/libgimpwidgets/gimpwidgets.def @@ -76,12 +76,16 @@ EXPORTS gimp_color_profile_chooser_dialog_get_type gimp_color_profile_chooser_dialog_new gimp_color_profile_combo_box_add + gimp_color_profile_combo_box_add_file gimp_color_profile_combo_box_get_active + gimp_color_profile_combo_box_get_active_file gimp_color_profile_combo_box_get_type gimp_color_profile_combo_box_new gimp_color_profile_combo_box_new_with_model gimp_color_profile_combo_box_set_active + gimp_color_profile_combo_box_set_active_file gimp_color_profile_store_add + gimp_color_profile_store_add_file gimp_color_profile_store_get_type gimp_color_profile_store_new gimp_color_profile_view_get_type diff --git a/modules/display-filter-proof.c b/modules/display-filter-proof.c index 640a230ff2..d487df2b60 100644 --- a/modules/display-filter-proof.c +++ b/modules/display-filter-proof.c @@ -261,15 +261,22 @@ static void cdisplay_proof_profile_changed (GtkWidget *combo, CdisplayProof *proof) { - gchar *profile; + GFile *file; + gchar *path = NULL; - profile = gimp_color_profile_combo_box_get_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo)); + file = gimp_color_profile_combo_box_get_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo)); + + if (file) + { + path = g_file_get_path (file); + g_object_unref (file); + } g_object_set (proof, - "profile", profile, + "profile", path, NULL); - g_free (profile); + g_free (path); } static GtkWidget * @@ -297,8 +304,13 @@ cdisplay_proof_configure (GimpColorDisplay *display) proof); if (proof->profile) - gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo), - proof->profile, NULL); + { + GFile *file = g_file_new_for_path (proof->profile); + + gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo), + file, NULL); + g_object_unref (file); + } gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Profile:"), 0.0, 0.5, diff --git a/plug-ins/common/lcms.c b/plug-ins/common/lcms.c index ca71e95d35..6526ff80d2 100644 --- a/plug-ins/common/lcms.c +++ b/plug-ins/common/lcms.c @@ -637,16 +637,15 @@ lcms_icc_apply_dialog (gint32 image, } static GtkWidget * -lcms_icc_combo_box_new (GimpColorConfig *config, - const gchar *filename) +lcms_icc_combo_box_new (GimpColorConfig *config) { GtkWidget *combo; GtkWidget *dialog; gchar *history; gchar *label; - const gchar *rgb_filename = NULL; - GimpColorProfile *profile = NULL; - GError *error = NULL; + GFile *rgb_file = NULL; + GimpColorProfile *profile = NULL; + GError *error = NULL; dialog = gimp_color_profile_chooser_dialog_new (_("Select destination profile")); @@ -658,7 +657,7 @@ lcms_icc_combo_box_new (GimpColorConfig *config, if (profile) { - rgb_filename = config->rgb_profile; + rgb_file = g_file_new_for_path (config->rgb_profile); } else if (error) { @@ -674,12 +673,14 @@ lcms_icc_combo_box_new (GimpColorConfig *config, g_object_unref (profile); - gimp_color_profile_combo_box_add (GIMP_COLOR_PROFILE_COMBO_BOX (combo), - rgb_filename, label); + gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo), + rgb_file, label); + if (rgb_file) + g_object_unref (rgb_file); g_free (label); - gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo), - filename, NULL); + gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo), + NULL, NULL); return combo; } @@ -745,7 +746,7 @@ lcms_dialog (GimpColorConfig *config, gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); - combo = lcms_icc_combo_box_new (config, NULL); + combo = lcms_icc_combo_box_new (config); gtk_container_add (GTK_CONTAINER (frame), combo); gtk_widget_show (combo); @@ -793,18 +794,11 @@ lcms_dialog (GimpColorConfig *config, while ((run = gimp_dialog_run (GIMP_DIALOG (dialog))) == GTK_RESPONSE_OK) { - gchar *filename = gimp_color_profile_combo_box_get_active (box); - GFile *file = NULL; + GFile *file = gimp_color_profile_combo_box_get_active_file (box); GimpColorProfile *dest_profile; gtk_widget_set_sensitive (dialog, FALSE); - if (filename) - { - file = g_file_new_for_path (filename); - g_free (filename); - } - if (file) { GError *error = NULL;