mirror of https://github.com/GNOME/gimp.git
app: use a GimpColorProfileView in GimpImageProfileView
and parse the profile in gimpimageprofileview.c instead of calling the lcms plug-in. Make the app link against lcms. This is WIP because the widget is of course the wrong place for such profile parsing code.
This commit is contained in:
parent
76f47708fa
commit
ed13993aff
|
@ -179,6 +179,7 @@ gimpconsoleldadd = \
|
||||||
$(GEGL_LIBS) \
|
$(GEGL_LIBS) \
|
||||||
$(GLIB_LIBS) \
|
$(GLIB_LIBS) \
|
||||||
$(GEXIV2_LIBS) \
|
$(GEXIV2_LIBS) \
|
||||||
|
$(LCMS_LIBS) \
|
||||||
$(INTLLIBS) \
|
$(INTLLIBS) \
|
||||||
$(RT_LIBS)
|
$(RT_LIBS)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ AM_CPPFLAGS = \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_builddir)/app \
|
-I$(top_builddir)/app \
|
||||||
-I$(top_srcdir)/app \
|
-I$(top_srcdir)/app \
|
||||||
|
$(LCMS_CFLAGS) \
|
||||||
$(GEGL_CFLAGS) \
|
$(GEGL_CFLAGS) \
|
||||||
$(GTK_CFLAGS) \
|
$(GTK_CFLAGS) \
|
||||||
-I$(includedir)
|
-I$(includedir)
|
||||||
|
|
|
@ -22,26 +22,30 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <glib.h> /* lcms.h uses the "inline" keyword */
|
||||||
|
|
||||||
|
#include <lcms2.h>
|
||||||
|
|
||||||
#include <gegl.h>
|
#include <gegl.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpconfig/gimpconfig.h"
|
||||||
|
#include "libgimpcolor/gimpcolor.h"
|
||||||
#include "libgimpbase/gimpbase.h"
|
#include "libgimpbase/gimpbase.h"
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
|
||||||
#include "widgets-types.h"
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#include "config/gimpcoreconfig.h"
|
||||||
|
|
||||||
#include "core/gimp.h"
|
#include "core/gimp.h"
|
||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
|
|
||||||
#include "plug-in/plug-in-icc-profile.h"
|
|
||||||
|
|
||||||
#include "gimpimageprofileview.h"
|
#include "gimpimageprofileview.h"
|
||||||
|
|
||||||
#include "gimp-intl.h"
|
#include "gimp-intl.h"
|
||||||
|
|
||||||
|
|
||||||
static void gimp_image_profile_view_dispose (GObject *object);
|
|
||||||
|
|
||||||
static void gimp_image_profile_view_update (GimpImageParasiteView *view);
|
static void gimp_image_profile_view_update (GimpImageParasiteView *view);
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,21 +58,18 @@ G_DEFINE_TYPE (GimpImageProfileView,
|
||||||
static void
|
static void
|
||||||
gimp_image_profile_view_class_init (GimpImageProfileViewClass *klass)
|
gimp_image_profile_view_class_init (GimpImageProfileViewClass *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
||||||
GimpImageParasiteViewClass *view_class;
|
GimpImageParasiteViewClass *view_class;
|
||||||
|
|
||||||
view_class = GIMP_IMAGE_PARASITE_VIEW_CLASS (klass);
|
view_class = GIMP_IMAGE_PARASITE_VIEW_CLASS (klass);
|
||||||
|
|
||||||
object_class->dispose = gimp_image_profile_view_dispose;
|
view_class->update = gimp_image_profile_view_update;
|
||||||
|
|
||||||
view_class->update = gimp_image_profile_view_update;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_image_profile_view_init (GimpImageProfileView *view)
|
gimp_image_profile_view_init (GimpImageProfileView *view)
|
||||||
{
|
{
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
GtkWidget *text_view;
|
GtkWidget *profile_view;
|
||||||
|
|
||||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||||
|
@ -78,43 +79,11 @@ gimp_image_profile_view_init (GimpImageProfileView *view)
|
||||||
gtk_box_pack_start (GTK_BOX (view), scrolled_window, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (view), scrolled_window, TRUE, TRUE, 0);
|
||||||
gtk_widget_show (scrolled_window);
|
gtk_widget_show (scrolled_window);
|
||||||
|
|
||||||
text_view = gtk_text_view_new ();
|
profile_view = gimp_color_profile_view_new ();
|
||||||
|
gtk_container_add (GTK_CONTAINER (scrolled_window), profile_view);
|
||||||
|
gtk_widget_show (profile_view);
|
||||||
|
|
||||||
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);
|
view->profile_view = GIMP_COLOR_PROFILE_VIEW (profile_view);
|
||||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
|
|
||||||
|
|
||||||
gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (text_view), 6);
|
|
||||||
gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text_view), 6);
|
|
||||||
gtk_text_view_set_right_margin (GTK_TEXT_VIEW (text_view), 6);
|
|
||||||
|
|
||||||
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
|
|
||||||
gtk_widget_show (text_view);
|
|
||||||
|
|
||||||
view->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
|
|
||||||
|
|
||||||
gtk_text_buffer_create_tag (view->buffer, "strong",
|
|
||||||
"weight", PANGO_WEIGHT_BOLD,
|
|
||||||
"scale", PANGO_SCALE_LARGE,
|
|
||||||
NULL);
|
|
||||||
gtk_text_buffer_create_tag (view->buffer, "emphasis",
|
|
||||||
"style", PANGO_STYLE_OBLIQUE,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
view->idle_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_image_profile_view_dispose (GObject *object)
|
|
||||||
{
|
|
||||||
GimpImageProfileView *view = GIMP_IMAGE_PROFILE_VIEW (object);
|
|
||||||
|
|
||||||
if (view->idle_id)
|
|
||||||
{
|
|
||||||
g_source_remove (view->idle_id);
|
|
||||||
view->idle_id = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,78 +103,54 @@ gimp_image_profile_view_new (GimpImage *image)
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gimp_image_profile_view_query (GimpImageProfileView *view)
|
|
||||||
{
|
|
||||||
GimpImage *image;
|
|
||||||
gchar *name = NULL;
|
|
||||||
gchar *desc = NULL;
|
|
||||||
gchar *info = NULL;
|
|
||||||
GError *error = NULL;
|
|
||||||
GtkTextIter iter;
|
|
||||||
|
|
||||||
gtk_text_buffer_set_text (view->buffer, "", 0);
|
|
||||||
gtk_text_buffer_get_start_iter (view->buffer, &iter);
|
|
||||||
|
|
||||||
image = gimp_image_parasite_view_get_image (GIMP_IMAGE_PARASITE_VIEW (view));
|
|
||||||
|
|
||||||
if (plug_in_icc_profile_info (image,
|
|
||||||
gimp_get_user_context (image->gimp),
|
|
||||||
NULL,
|
|
||||||
&name, &desc, &info,
|
|
||||||
&error))
|
|
||||||
{
|
|
||||||
if ((desc && strlen (desc)) ||
|
|
||||||
(name && strlen (name)))
|
|
||||||
{
|
|
||||||
const gchar *title;
|
|
||||||
|
|
||||||
if (desc && strlen (desc))
|
|
||||||
title = desc;
|
|
||||||
else
|
|
||||||
title = name;
|
|
||||||
|
|
||||||
gtk_text_buffer_insert_with_tags_by_name (view->buffer, &iter,
|
|
||||||
title, -1,
|
|
||||||
"strong", NULL);
|
|
||||||
gtk_text_buffer_insert (view->buffer, &iter, "\n", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info)
|
|
||||||
gtk_text_buffer_insert (view->buffer, &iter, info, -1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_text_buffer_insert_with_tags_by_name (view->buffer, &iter,
|
|
||||||
error->message, -1,
|
|
||||||
"emphasis", NULL);
|
|
||||||
g_clear_error (&error);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (name);
|
|
||||||
g_free (desc);
|
|
||||||
g_free (info);
|
|
||||||
|
|
||||||
view->idle_id = 0;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_image_profile_view_update (GimpImageParasiteView *view)
|
gimp_image_profile_view_update (GimpImageParasiteView *view)
|
||||||
{
|
{
|
||||||
GimpImageProfileView *profile_view = GIMP_IMAGE_PROFILE_VIEW (view);
|
GimpImageProfileView *profile_view = GIMP_IMAGE_PROFILE_VIEW (view);
|
||||||
GtkTextIter iter;
|
GimpImage *image;
|
||||||
|
GimpColorConfig *config;
|
||||||
|
const GimpParasite *parasite;
|
||||||
|
GimpColorProfile *profile = NULL;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
gtk_text_buffer_set_text (profile_view->buffer, "", 0);
|
image = gimp_image_parasite_view_get_image (view);
|
||||||
gtk_text_buffer_get_start_iter (profile_view->buffer, &iter);
|
parasite = gimp_image_parasite_view_get_parasite (view);
|
||||||
gtk_text_buffer_insert_with_tags_by_name (profile_view->buffer, &iter,
|
|
||||||
_("Querying..."), -1,
|
|
||||||
"emphasis", NULL);
|
|
||||||
|
|
||||||
if (profile_view->idle_id)
|
config = image->gimp->config->color_management;
|
||||||
g_source_remove (profile_view->idle_id);
|
|
||||||
|
|
||||||
profile_view->idle_id =
|
if (parasite)
|
||||||
g_idle_add ((GSourceFunc) gimp_image_profile_view_query, profile_view);
|
{
|
||||||
|
profile = gimp_lcms_profile_open_from_data (gimp_parasite_data (parasite),
|
||||||
|
gimp_parasite_data_size (parasite),
|
||||||
|
NULL, &error);
|
||||||
|
if (! profile)
|
||||||
|
{
|
||||||
|
g_message (_("Error parsing 'icc-profile': %s"), error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (config->rgb_profile)
|
||||||
|
{
|
||||||
|
profile = gimp_lcms_profile_open_from_file (config->rgb_profile,
|
||||||
|
NULL, &error);
|
||||||
|
if (! profile)
|
||||||
|
{
|
||||||
|
g_message ("%s", error->message);
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (profile && ! gimp_lcms_profile_is_rgb (profile))
|
||||||
|
{
|
||||||
|
g_message (_("Color profile is not for RGB color space (skipping)"));
|
||||||
|
cmsCloseProfile (profile);
|
||||||
|
profile = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! profile)
|
||||||
|
profile = gimp_lcms_create_srgb_profile ();
|
||||||
|
|
||||||
|
gimp_color_profile_view_set_profile (profile_view->profile_view, profile);
|
||||||
|
|
||||||
|
cmsCloseProfile (profile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,7 @@ struct _GimpImageProfileView
|
||||||
{
|
{
|
||||||
GimpImageParasiteView parent_instance;
|
GimpImageParasiteView parent_instance;
|
||||||
|
|
||||||
GtkTextBuffer *buffer;
|
GimpColorProfileView *profile_view;
|
||||||
|
|
||||||
guint idle_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpImageProfileViewClass
|
struct _GimpImageProfileViewClass
|
||||||
|
|
Loading…
Reference in New Issue