1 /* GIMP - The GNU Image Manipulation Program
2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3 *
4 * GimpImageProfileView
5 * Copyright (C) 2006 Sven Neumann <sven@gimp.org>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21 #include "config.h"
22
23 #include <string.h>
24
25 #include <gegl.h>
26 #include <gtk/gtk.h>
27
28 #include "libgimpconfig/gimpconfig.h"
29 #include "libgimpcolor/gimpcolor.h"
30 #include "libgimpbase/gimpbase.h"
31 #include "libgimpwidgets/gimpwidgets.h"
32
33 #include "widgets-types.h"
34
35 #include "core/gimpimage.h"
36 #include "core/gimpimage-color-profile.h"
37
38 #include "gimpimageprofileview.h"
39
40 #include "gimp-intl.h"
41
42
43 static void gimp_image_profile_view_update (GimpImageParasiteView *view);
44
45
G_DEFINE_TYPE(GimpImageProfileView,gimp_image_profile_view,GIMP_TYPE_IMAGE_PARASITE_VIEW)46 G_DEFINE_TYPE (GimpImageProfileView,
47 gimp_image_profile_view, GIMP_TYPE_IMAGE_PARASITE_VIEW)
48
49 #define parent_class gimp_image_profile_view_parent_class
50
51
52 static void
53 gimp_image_profile_view_class_init (GimpImageProfileViewClass *klass)
54 {
55 GimpImageParasiteViewClass *view_class;
56
57 view_class = GIMP_IMAGE_PARASITE_VIEW_CLASS (klass);
58
59 view_class->update = gimp_image_profile_view_update;
60 }
61
62 static void
gimp_image_profile_view_init(GimpImageProfileView * view)63 gimp_image_profile_view_init (GimpImageProfileView *view)
64 {
65 GtkWidget *scrolled_window;
66 GtkWidget *profile_view;
67
68 scrolled_window = gtk_scrolled_window_new (NULL, NULL);
69 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
70 GTK_POLICY_AUTOMATIC,
71 GTK_POLICY_AUTOMATIC);
72 gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 2);
73 gtk_box_pack_start (GTK_BOX (view), scrolled_window, TRUE, TRUE, 0);
74 gtk_widget_show (scrolled_window);
75
76 profile_view = gimp_color_profile_view_new ();
77 gtk_container_add (GTK_CONTAINER (scrolled_window), profile_view);
78 gtk_widget_show (profile_view);
79
80 view->profile_view = GIMP_COLOR_PROFILE_VIEW (profile_view);
81 }
82
83
84 /* public functions */
85
86 GtkWidget *
gimp_image_profile_view_new(GimpImage * image)87 gimp_image_profile_view_new (GimpImage *image)
88 {
89 g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
90
91 return g_object_new (GIMP_TYPE_IMAGE_PROFILE_VIEW,
92 "image", image,
93 "parasite", GIMP_ICC_PROFILE_PARASITE_NAME,
94 NULL);
95 }
96
97
98 /* private functions */
99
100 static void
gimp_image_profile_view_update(GimpImageParasiteView * view)101 gimp_image_profile_view_update (GimpImageParasiteView *view)
102 {
103 GimpImageProfileView *profile_view = GIMP_IMAGE_PROFILE_VIEW (view);
104 GimpImage *image;
105 GimpColorManaged *managed;
106 GimpColorProfile *profile;
107
108 image = gimp_image_parasite_view_get_image (view);
109 managed = GIMP_COLOR_MANAGED (image);
110
111 profile = gimp_color_managed_get_color_profile (managed);
112
113 gimp_color_profile_view_set_profile (profile_view->profile_view, profile);
114 }
115