mirror of https://github.com/GNOME/gimp.git
libgimpwidgets: make GimpColorProfileComboBox use lcms
and improve gimp_color_profile_combo_box_set_active() to get the profile's label from the ICC file if no label was provided. Simplifies all its callers and removes code duplication.
This commit is contained in:
parent
80a71f1e50
commit
3f826d02fa
|
@ -19,10 +19,6 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h> /* lcms.h uses the "inline" keyword */
|
||||
|
||||
#include <lcms2.h>
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
@ -780,26 +776,6 @@ prefs_table_new (gint rows,
|
|||
return table;
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_profile_combo_box_set_active (GimpColorProfileComboBox *combo,
|
||||
const gchar *filename)
|
||||
{
|
||||
cmsHPROFILE profile = NULL;
|
||||
gchar *label = NULL;
|
||||
|
||||
if (filename)
|
||||
profile = cmsOpenProfileFromFile (filename, "r");
|
||||
|
||||
if (profile)
|
||||
{
|
||||
label = gimp_lcms_profile_get_label (profile);
|
||||
cmsCloseProfile (profile);
|
||||
}
|
||||
|
||||
gimp_color_profile_combo_box_set_active (combo, filename, label);
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
static void
|
||||
prefs_profile_combo_dialog_response (GimpColorProfileChooserDialog *dialog,
|
||||
gint response,
|
||||
|
@ -813,7 +789,7 @@ prefs_profile_combo_dialog_response (GimpColorProfileChooserDialog *dialog,
|
|||
|
||||
if (filename)
|
||||
{
|
||||
prefs_profile_combo_box_set_active (combo, filename);
|
||||
gimp_color_profile_combo_box_set_active (combo, filename, NULL);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,15 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib.h> /* lcms.h uses the "inline" keyword */
|
||||
|
||||
#include <lcms2.h>
|
||||
|
||||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimpcolorprofilecombobox.h"
|
||||
|
@ -388,14 +395,42 @@ gimp_color_profile_combo_box_set_active (GimpColorProfileComboBox *combo,
|
|||
{
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
gchar *l = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_PROFILE_COMBO_BOX (combo));
|
||||
|
||||
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
|
||||
|
||||
if (filename && ! (label && *label))
|
||||
{
|
||||
cmsHPROFILE profile;
|
||||
GError *error = NULL;
|
||||
|
||||
profile = gimp_lcms_profile_open_from_file (filename, &error);
|
||||
|
||||
if (! profile)
|
||||
{
|
||||
g_message ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
else
|
||||
{
|
||||
l = gimp_lcms_profile_get_label (profile);
|
||||
cmsCloseProfile (profile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
l = g_strdup (label);
|
||||
}
|
||||
|
||||
if (_gimp_color_profile_store_history_add (GIMP_COLOR_PROFILE_STORE (model),
|
||||
filename, label, &iter))
|
||||
filename, l, &iter))
|
||||
{
|
||||
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo), &iter);
|
||||
}
|
||||
|
||||
g_free (l);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -259,26 +259,6 @@ cdisplay_proof_convert_buffer (GimpColorDisplay *display,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cdisplay_proof_combo_box_set_active (GimpColorProfileComboBox *combo,
|
||||
const gchar *filename)
|
||||
{
|
||||
cmsHPROFILE profile = NULL;
|
||||
gchar *label = NULL;
|
||||
|
||||
if (filename)
|
||||
profile = cmsOpenProfileFromFile (filename, "r");
|
||||
|
||||
if (profile)
|
||||
{
|
||||
label = gimp_lcms_profile_get_label (profile);
|
||||
cmsCloseProfile (profile);
|
||||
}
|
||||
|
||||
gimp_color_profile_combo_box_set_active (combo, filename, label);
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
static void
|
||||
cdisplay_proof_file_chooser_dialog_response (GtkFileChooser *dialog,
|
||||
gint response,
|
||||
|
@ -290,7 +270,7 @@ cdisplay_proof_file_chooser_dialog_response (GtkFileChooser *dialog,
|
|||
|
||||
if (filename)
|
||||
{
|
||||
cdisplay_proof_combo_box_set_active (combo, filename);
|
||||
gimp_color_profile_combo_box_set_active (combo, filename, NULL);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
@ -343,8 +323,8 @@ cdisplay_proof_configure (GimpColorDisplay *display)
|
|||
proof);
|
||||
|
||||
if (proof->profile)
|
||||
cdisplay_proof_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
||||
proof->profile);
|
||||
gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
||||
proof->profile, NULL);
|
||||
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
||||
_("_Profile:"), 0.0, 0.5,
|
||||
|
|
|
@ -1237,36 +1237,6 @@ lcms_icc_apply_dialog (gint32 image,
|
|||
return run;
|
||||
}
|
||||
|
||||
static void
|
||||
lcms_icc_combo_box_set_active (GimpColorProfileComboBox *combo,
|
||||
const gchar *filename)
|
||||
{
|
||||
cmsHPROFILE profile = NULL;
|
||||
gchar *label = NULL;
|
||||
|
||||
if (filename)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
profile = gimp_lcms_profile_open_from_file (filename, &error);
|
||||
|
||||
if (! profile)
|
||||
{
|
||||
g_message ("%s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
if (profile)
|
||||
{
|
||||
label = gimp_lcms_profile_get_label (profile);
|
||||
cmsCloseProfile (profile);
|
||||
}
|
||||
|
||||
gimp_color_profile_combo_box_set_active (combo, filename, label);
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
static void
|
||||
lcms_icc_file_chooser_dialog_response (GtkFileChooser *dialog,
|
||||
gint response,
|
||||
|
@ -1278,7 +1248,7 @@ lcms_icc_file_chooser_dialog_response (GtkFileChooser *dialog,
|
|||
|
||||
if (filename)
|
||||
{
|
||||
lcms_icc_combo_box_set_active (combo, filename);
|
||||
gimp_color_profile_combo_box_set_active (combo, filename, NULL);
|
||||
|
||||
g_free (filename);
|
||||
}
|
||||
|
@ -1347,11 +1317,8 @@ lcms_icc_combo_box_new (GimpColorConfig *config,
|
|||
rgb_filename, label);
|
||||
g_free (label);
|
||||
|
||||
if (filename)
|
||||
lcms_icc_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
||||
filename);
|
||||
else
|
||||
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
|
||||
gimp_color_profile_combo_box_set_active (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
||||
filename, NULL);
|
||||
|
||||
return combo;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue