[gtk/wip/otte/color-profiles: 14/30] Revamp the color profile demo
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/color-profiles: 14/30] Revamp the color profile demo
- Date: Sun, 26 Sep 2021 14:54:27 +0000 (UTC)
commit 376e76c01ee5b963161ff8e0acd9e571685e6c62
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Sep 23 08:21:37 2021 -0400
Revamp the color profile demo
Add an explicit 'no profile' image.
.../ICC Rendering Intent Test (cLUT only).jpg | Bin 276191 -> 0 bytes
.../ICC Rendering Intent Test (cLUT only).png | Bin 119811 -> 0 bytes
...Rendering-Intent-Test-expected-result-no-cm.png | Bin 0 -> 24543 bytes
demos/gtk-demo/ICC-Rendering-Intent-Test.jpg | Bin 0 -> 297456 bytes
demos/gtk-demo/ICC-Rendering-Intent-Test.png | Bin 0 -> 123151 bytes
...LUT only).tif => ICC-Rendering-Intent-Test.tif} | Bin 211731 -> 216166 bytes
demos/gtk-demo/colorprofiles.c | 53 ++++-
demos/gtk-demo/colorprofiles.ui | 222 +++++++--------------
demos/gtk-demo/demo.gresource.xml | 8 +-
demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png | Bin 0 -> 5283 bytes
10 files changed, 126 insertions(+), 157 deletions(-)
---
diff --git a/demos/gtk-demo/ICC-Rendering-Intent-Test-expected-result-no-cm.png
b/demos/gtk-demo/ICC-Rendering-Intent-Test-expected-result-no-cm.png
new file mode 100644
index 0000000000..efafad94bf
Binary files /dev/null and b/demos/gtk-demo/ICC-Rendering-Intent-Test-expected-result-no-cm.png differ
diff --git a/demos/gtk-demo/ICC-Rendering-Intent-Test.jpg b/demos/gtk-demo/ICC-Rendering-Intent-Test.jpg
new file mode 100644
index 0000000000..7f318cd73b
Binary files /dev/null and b/demos/gtk-demo/ICC-Rendering-Intent-Test.jpg differ
diff --git a/demos/gtk-demo/ICC-Rendering-Intent-Test.png b/demos/gtk-demo/ICC-Rendering-Intent-Test.png
new file mode 100644
index 0000000000..27819f0dd5
Binary files /dev/null and b/demos/gtk-demo/ICC-Rendering-Intent-Test.png differ
diff --git a/demos/gtk-demo/ICC Rendering Intent Test (cLUT only).tif
b/demos/gtk-demo/ICC-Rendering-Intent-Test.tif
similarity index 63%
rename from demos/gtk-demo/ICC Rendering Intent Test (cLUT only).tif
rename to demos/gtk-demo/ICC-Rendering-Intent-Test.tif
index 529cbdb41a..fe1030ca0f 100644
Binary files a/demos/gtk-demo/ICC Rendering Intent Test (cLUT only).tif and
b/demos/gtk-demo/ICC-Rendering-Intent-Test.tif differ
diff --git a/demos/gtk-demo/colorprofiles.c b/demos/gtk-demo/colorprofiles.c
index dd1f382a45..7df623fa87 100644
--- a/demos/gtk-demo/colorprofiles.c
+++ b/demos/gtk-demo/colorprofiles.c
@@ -8,7 +8,43 @@
#include <gtk/gtk.h>
+static GtkWidget *jpeg;
+static GtkWidget *png;
+static GtkWidget *tiff;
+static GtkWidget *noprofile;
+static GtkWidget *test1;
+static GtkWidget *test2;
+static void
+on_changed (GtkCheckButton *button,
+ gpointer user_data)
+{
+ GdkTexture *texture;
+ const char *extension = NULL;
+ char *path;
+
+ if (!gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
+ return;
+
+ if (gtk_check_button_get_active (GTK_CHECK_BUTTON (jpeg)))
+ extension = ".jpg";
+ else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (png)))
+ extension = ".png";
+ else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (tiff)))
+ extension = ".tif";
+ else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (noprofile)))
+ extension = "-expected-result-no-cm.png";
+
+ path = g_strconcat ("/colorprofiles/sRGB_Gray", extension, NULL);
+ texture = gdk_texture_new_from_resource (path);
+ gtk_picture_set_paintable (GTK_PICTURE (test1), GDK_PAINTABLE (texture));
+ g_object_unref (texture);
+
+ path = g_strconcat ("/colorprofiles/ICC-Rendering-Intent-Test", extension, NULL);
+ texture = gdk_texture_new_from_resource (path);
+ gtk_picture_set_paintable (GTK_PICTURE (test2), GDK_PAINTABLE (texture));
+ g_object_unref (texture);
+}
GtkWidget*
do_colorprofiles (GtkWidget *do_widget)
@@ -18,14 +54,27 @@ do_colorprofiles (GtkWidget *do_widget)
if (!window)
{
GtkBuilder *builder;
+ GtkBuilderScope *scope;
- builder = gtk_builder_new_from_resource ("/colorprofiles/colorprofiles.ui");
+ scope = gtk_builder_cscope_new ();
+ gtk_builder_cscope_add_callback_symbol (GTK_BUILDER_CSCOPE (scope),
+ "on_changed", G_CALLBACK (on_changed));
+
+ builder = gtk_builder_new ();
+ gtk_builder_set_scope (builder, scope);
+ gtk_builder_add_from_resource (builder, "/colorprofiles/colorprofiles.ui", NULL);
window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+ jpeg = GTK_WIDGET (gtk_builder_get_object (builder, "jpeg"));
+ png = GTK_WIDGET (gtk_builder_get_object (builder, "png"));
+ tiff = GTK_WIDGET (gtk_builder_get_object (builder, "tiff"));
+ noprofile = GTK_WIDGET (gtk_builder_get_object (builder, "noprofile"));
+ test1 = GTK_WIDGET (gtk_builder_get_object (builder, "test1"));
+ test2 = GTK_WIDGET (gtk_builder_get_object (builder, "test2"));
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
g_object_unref (builder);
-
+ g_object_unref (scope);
}
if (!gtk_widget_get_visible (window))
diff --git a/demos/gtk-demo/colorprofiles.ui b/demos/gtk-demo/colorprofiles.ui
index 9ae03ab798..05416e51c8 100644
--- a/demos/gtk-demo/colorprofiles.ui
+++ b/demos/gtk-demo/colorprofiles.ui
@@ -5,167 +5,85 @@
<property name="resizable">false</property>
<property name="title">Color Profiles</property>
<child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
+ <object class="GtkScrolledWindow">
<child>
- <object class="GtkStackSwitcher">
- <property name="stack">stack</property>
- </object>
- </child>
- <child>
- <object class="GtkStack" id="stack">
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">10</property>
+ <property name="margin-top">10</property>
+ <property name="margin-bottom">10</property>
+ <property name="margin-start">10</property>
+ <property name="margin-end">10</property>
<child>
- <object class="GtkStackPage">
- <property name="name">page1</property>
- <property name="title">JPEG</property>
- <property name="child">
- <object class="GtkScrolledWindow">
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="spacing">10</property>
- <property name="margin-top">10</property>
- <property name="margin-bottom">10</property>
- <child>
- <object class="GtkLabel">
- <property name="label">Test 1: Matrix-based profile</property>
- <style>
- <class name="title-3"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkPicture">
- <property name="hexpand">1</property>
- <property name="vexpand">1</property>
- <property name="can-shrink">1</property>
- <property name="keep-aspect-ratio">1</property>
- <property name="file">resource:///colorprofiles/sRGB_Gray.jpg</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label">Test 2: Lookup table-based profile</property>
- <style>
- <class name="title-3"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkPicture">
- <property name="hexpand">1</property>
- <property name="vexpand">1</property>
- <property name="can-shrink">1</property>
- <property name="keep-aspect-ratio">1</property>
- <property name="file">resource:///colorprofiles/ICC Rendering Intent Test (cLUT
only).jpg</property>
- </object>
- </child>
- </object>
- </child>
+ <object class="GtkBox">
+ <property name="spacing">10</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">File format:</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="jpeg">
+ <property name="label">JPEG</property>
+ <property name="active">1</property>
+ <signal name="notify::active" handler="on_changed"/>
</object>
- </property>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="png">
+ <property name="label">PNG</property>
+ <property name="group">jpeg</property>
+ <signal name="notify::active" handler="on_changed"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="tiff">
+ <property name="label">TIFF</property>
+ <property name="group">png</property>
+ <signal name="notify::active" handler="on_changed"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="noprofile">
+ <property name="label">No profile</property>
+ <property name="group">tiff</property>
+ <signal name="notify::active" handler="on_changed"/>
+ </object>
+ </child>
</object>
</child>
<child>
- <object class="GtkStackPage">
- <property name="name">page2</property>
- <property name="title">PNG</property>
- <property name="child">
- <object class="GtkScrolledWindow">
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="spacing">10</property>
- <property name="margin-top">10</property>
- <property name="margin-bottom">10</property>
- <child>
- <object class="GtkLabel">
- <property name="label">Test 1: Matrix-based profile</property>
- <style>
- <class name="title-3"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkPicture">
- <property name="hexpand">1</property>
- <property name="vexpand">1</property>
- <property name="can-shrink">1</property>
- <property name="keep-aspect-ratio">1</property>
- <property name="file">resource:///colorprofiles/sRGB_Gray.png</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label">Test 2: Lookup table-based profile</property>
- <style>
- <class name="title-3"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkPicture">
- <property name="hexpand">1</property>
- <property name="vexpand">1</property>
- <property name="can-shrink">1</property>
- <property name="keep-aspect-ratio">1</property>
- <property name="file">resource:///colorprofiles/ICC Rendering Intent Test (cLUT
only).png</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </property>
+ <object class="GtkLabel">
+ <property name="label">Test 1: Matrix-based profile</property>
+ <style>
+ <class name="title-3"/>
+ </style>
</object>
</child>
<child>
- <object class="GtkStackPage">
- <property name="name">page3</property>
- <property name="title">TIFF</property>
- <property name="child">
- <object class="GtkScrolledWindow">
- <child>
- <object class="GtkBox">
- <property name="orientation">vertical</property>
- <property name="spacing">10</property>
- <property name="margin-top">10</property>
- <property name="margin-bottom">10</property>
- <child>
- <object class="GtkLabel">
- <property name="label">Test 1: Matrix-based profile</property>
- <style>
- <class name="title-3"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkPicture">
- <property name="hexpand">1</property>
- <property name="can-shrink">1</property>
- <property name="keep-aspect-ratio">1</property>
- <property name="file">resource:///colorprofiles/sRGB_Gray.tif</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="label">Test 2: Lookup table-based profile</property>
- <style>
- <class name="title-3"/>
- </style>
- </object>
- </child>
- <child>
- <object class="GtkPicture">
- <property name="hexpand">1</property>
- <property name="can-shrink">1</property>
- <property name="keep-aspect-ratio">1</property>
- <property name="file">resource:///colorprofiles/ICC Rendering Intent Test (cLUT
only).tif</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </property>
+ <object class="GtkPicture" id="test1">
+ <property name="hexpand">1</property>
+ <property name="vexpand">1</property>
+ <property name="can-shrink">1</property>
+ <property name="keep-aspect-ratio">1</property>
+ <property name="file">resource:///colorprofiles/sRGB_Gray.jpg</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="label">Test 2: Lookup table-based profile</property>
+ <style>
+ <class name="title-3"/>
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkPicture" id="test2">
+ <property name="hexpand">1</property>
+ <property name="vexpand">1</property>
+ <property name="can-shrink">1</property>
+ <property name="keep-aspect-ratio">1</property>
+ <property name="file">resource:///colorprofiles/ICC-Rendering-Intent-Test.jpg</property>
</object>
</child>
</object>
diff --git a/demos/gtk-demo/demo.gresource.xml b/demos/gtk-demo/demo.gresource.xml
index 0979453830..ec509c7aff 100644
--- a/demos/gtk-demo/demo.gresource.xml
+++ b/demos/gtk-demo/demo.gresource.xml
@@ -23,9 +23,11 @@
<file>sRGB_Gray.jpg</file>
<file>sRGB_Gray.png</file>
<file>sRGB_Gray.tif</file>
- <file>ICC Rendering Intent Test (cLUT only).jpg</file>
- <file>ICC Rendering Intent Test (cLUT only).png</file>
- <file>ICC Rendering Intent Test (cLUT only).tif</file>
+ <file>sRGB_Gray-expected-result-no-cm.png</file>
+ <file>ICC-Rendering-Intent-Test.png</file>
+ <file>ICC-Rendering-Intent-Test.jpg</file>
+ <file>ICC-Rendering-Intent-Test.tif</file>
+ <file>ICC-Rendering-Intent-Test-expected-result-no-cm.png</file>
</gresource>
<gresource prefix="/constraints_builder">
<file>constraints_builder.ui</file>
diff --git a/demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png
b/demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png
new file mode 100644
index 0000000000..cc9873f283
Binary files /dev/null and b/demos/gtk-demo/sRGB_Gray-expected-result-no-cm.png differ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]