app: add basic support for creating images with color profiles
Add "gboolean color_managed" and "GFile *color_profile" to GimpTemplate. Add a toggle and profile combo to GimpTemplateEditor. Honor the new template properties in gimp_image_new_from_template(). Using a GFile property instead of a GIMP_TYPE_CONFIG_PATH is preliminary, see the previous commit. I'd like to use GFile more directly when dealing with config files, this is for testing that.
This commit is contained in:
@ -90,11 +90,12 @@ gimp_image_new_from_template (Gimp *gimp,
|
||||
GimpTemplate *template,
|
||||
GimpContext *context)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
gint width, height;
|
||||
gboolean has_alpha;
|
||||
const gchar *comment;
|
||||
GimpImage *image;
|
||||
GimpLayer *layer;
|
||||
GimpColorProfile *profile;
|
||||
gint width, height;
|
||||
gboolean has_alpha;
|
||||
const gchar *comment;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), NULL);
|
||||
@ -128,6 +129,14 @@ gimp_image_new_from_template (Gimp *gimp,
|
||||
gimp_template_get_resolution_y (template));
|
||||
gimp_image_set_unit (image, gimp_template_get_resolution_unit (template));
|
||||
|
||||
gimp_image_set_is_color_managed (image,
|
||||
gimp_template_get_color_managed (template),
|
||||
FALSE);
|
||||
profile = gimp_template_get_color_profile (template);
|
||||
gimp_image_set_color_profile (image, profile, NULL);
|
||||
if (profile)
|
||||
g_object_unref (profile);
|
||||
|
||||
width = gimp_image_get_width (image);
|
||||
height = gimp_image_get_height (image);
|
||||
|
||||
|
@ -23,10 +23,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cairo.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <gegl.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "core-types.h"
|
||||
@ -53,6 +55,8 @@ enum
|
||||
PROP_RESOLUTION_UNIT,
|
||||
PROP_BASE_TYPE,
|
||||
PROP_PRECISION,
|
||||
PROP_COLOR_MANAGED,
|
||||
PROP_COLOR_PROFILE,
|
||||
PROP_FILL_TYPE,
|
||||
PROP_COMMENT,
|
||||
PROP_FILENAME
|
||||
@ -74,6 +78,9 @@ struct _GimpTemplatePrivate
|
||||
GimpImageBaseType base_type;
|
||||
GimpPrecision precision;
|
||||
|
||||
gboolean color_managed;
|
||||
GFile *color_profile;
|
||||
|
||||
GimpFillType fill_type;
|
||||
|
||||
gchar *comment;
|
||||
@ -181,6 +188,20 @@ gimp_template_class_init (GimpTemplateClass *klass)
|
||||
GIMP_TYPE_PRECISION, GIMP_PRECISION_U8_GAMMA,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_COLOR_MANAGED,
|
||||
"color-managed",
|
||||
_("Color managed"),
|
||||
NULL,
|
||||
TRUE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_OBJECT (object_class, PROP_COLOR_PROFILE,
|
||||
"color-profile",
|
||||
_("Color profile"),
|
||||
NULL,
|
||||
G_TYPE_FILE,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_FILL_TYPE,
|
||||
"fill-type",
|
||||
_("Fill type"),
|
||||
@ -264,6 +285,14 @@ gimp_template_set_property (GObject *object,
|
||||
case PROP_PRECISION:
|
||||
private->precision = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_COLOR_MANAGED:
|
||||
private->color_managed = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_COLOR_PROFILE:
|
||||
if (private->color_profile)
|
||||
g_object_unref (private->color_profile);
|
||||
private->color_profile = g_value_dup_object (value);
|
||||
break;
|
||||
case PROP_FILL_TYPE:
|
||||
private->fill_type = g_value_get_enum (value);
|
||||
break;
|
||||
@ -317,6 +346,12 @@ gimp_template_get_property (GObject *object,
|
||||
case PROP_PRECISION:
|
||||
g_value_set_enum (value, private->precision);
|
||||
break;
|
||||
case PROP_COLOR_MANAGED:
|
||||
g_value_set_boolean (value, private->color_managed);
|
||||
break;
|
||||
case PROP_COLOR_PROFILE:
|
||||
g_value_set_object (value, private->color_profile);
|
||||
break;
|
||||
case PROP_FILL_TYPE:
|
||||
g_value_set_enum (value, private->fill_type);
|
||||
break;
|
||||
@ -480,6 +515,29 @@ gimp_template_get_precision (GimpTemplate *template)
|
||||
return GET_PRIVATE (template)->precision;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_template_get_color_managed (GimpTemplate *template)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), FALSE);
|
||||
|
||||
return GET_PRIVATE (template)->color_managed;
|
||||
}
|
||||
|
||||
GimpColorProfile *
|
||||
gimp_template_get_color_profile (GimpTemplate *template)
|
||||
{
|
||||
GimpTemplatePrivate *private;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), FALSE);
|
||||
|
||||
private = GET_PRIVATE (template);
|
||||
|
||||
if (private->color_profile)
|
||||
return gimp_color_profile_new_from_file (private->color_profile, NULL);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GimpFillType
|
||||
gimp_template_get_fill_type (GimpTemplate *template)
|
||||
{
|
||||
|
@ -80,6 +80,9 @@ GimpUnit gimp_template_get_resolution_unit (GimpTemplate *template);
|
||||
GimpImageBaseType gimp_template_get_base_type (GimpTemplate *template);
|
||||
GimpPrecision gimp_template_get_precision (GimpTemplate *template);
|
||||
|
||||
gboolean gimp_template_get_color_managed (GimpTemplate *template);
|
||||
GimpColorProfile * gimp_template_get_color_profile (GimpTemplate *template);
|
||||
|
||||
GimpFillType gimp_template_get_fill_type (GimpTemplate *template);
|
||||
|
||||
const gchar * gimp_template_get_comment (GimpTemplate *template);
|
||||
|
@ -142,6 +142,7 @@ gimp_template_editor_constructed (GObject *object)
|
||||
GtkWidget *xres;
|
||||
GtkWidget *yres;
|
||||
GtkWidget *combo;
|
||||
GtkWidget *toggle;
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *text_view;
|
||||
GtkTextBuffer *text_buffer;
|
||||
@ -393,10 +394,27 @@ gimp_template_editor_constructed (GObject *object)
|
||||
_("_Precision:"), 0.0, 0.5,
|
||||
combo, 1, FALSE);
|
||||
|
||||
toggle = gimp_prop_check_button_new (G_OBJECT (template),
|
||||
"color-managed",
|
||||
_("Color manage this image"));
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
||||
NULL, 0.0, 0.5,
|
||||
toggle, 1, FALSE);
|
||||
|
||||
combo = gimp_prop_profile_combo_box_new (G_OBJECT (template),
|
||||
"color-profile",
|
||||
NULL,
|
||||
_("Choose A Color Profile"));
|
||||
gimp_color_profile_combo_box_add_file (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
||||
NULL, NULL);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 5,
|
||||
_("Color _profile:"), 0.0, 0.5,
|
||||
combo, 1, FALSE);
|
||||
|
||||
combo = gimp_prop_enum_combo_box_new (G_OBJECT (template),
|
||||
"fill-type",
|
||||
0, 0);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 6,
|
||||
_("_Fill with:"), 0.0, 0.5,
|
||||
combo, 1, FALSE);
|
||||
|
||||
@ -406,7 +424,7 @@ gimp_template_editor_constructed (GObject *object)
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 5,
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 7,
|
||||
_("Comme_nt:"), 0.0, 0.0,
|
||||
scrolled_window, 1, FALSE);
|
||||
|
||||
|
Reference in New Issue
Block a user