diff options
author | Richard Hughes <richard@hughsie.com> | 2012-06-18 09:46:29 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2012-06-18 12:10:09 +0100 |
commit | fca4196ed897e086fd917f489c38d95278e4b1df (patch) | |
tree | ec4dca172c12fe547ab4ff9f1796f6438805b081 | |
parent | 2b137cda24973f64656f8ef9081e6f7d04b9da0e (diff) | |
download | colord-fca4196ed897e086fd917f489c38d95278e4b1df.tar.gz |
Split out colord-gtk to a new sub-project to prevent a dep loop
At the moment GTK requires colord to build, but colord-gtk needs GTK to build.
This makes bootstrapping a distro (or using jhbuild) harder than it needs to be.
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | client/Makefile.am | 23 | ||||
-rw-r--r-- | client/cd-convert.c | 390 | ||||
-rw-r--r-- | configure.ac | 19 | ||||
-rw-r--r-- | contrib/colord.spec.in | 10 | ||||
-rw-r--r-- | libcolord-gtk/Makefile.am | 127 | ||||
-rw-r--r-- | libcolord-gtk/cd-sample-window.c | 273 | ||||
-rw-r--r-- | libcolord-gtk/cd-sample-window.h | 59 | ||||
-rw-r--r-- | libcolord-gtk/cd-self-test.c | 135 | ||||
-rw-r--r-- | libcolord-gtk/cd-window-sync.c | 101 | ||||
-rw-r--r-- | libcolord-gtk/cd-window-sync.h | 41 | ||||
-rw-r--r-- | libcolord-gtk/cd-window.c | 579 | ||||
-rw-r--r-- | libcolord-gtk/cd-window.h | 103 | ||||
-rw-r--r-- | libcolord-gtk/colord-gtk.h | 49 | ||||
-rw-r--r-- | libcolord-gtk/colord-gtk.pc.in | 11 | ||||
-rw-r--r-- | po/POTFILES.in | 1 |
16 files changed, 1 insertions, 1927 deletions
diff --git a/Makefile.am b/Makefile.am index f648f28..58b8986 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,12 +12,7 @@ SUBDIRS = \ rules \ po -if HAVE_GTK -SUBDIRS += \ - libcolord-gtk -endif - -# this needs libcolord and libcolord-gtk +# this needs libcolord SUBDIRS += \ client \ contrib \ diff --git a/client/Makefile.am b/client/Makefile.am index 2e972d5..55f1581 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -3,7 +3,6 @@ INCLUDES = \ $(GTK_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/libcolord \ - -I$(top_srcdir)/libcolord-gtk \ -DG_LOG_DOMAIN=\"Cd\" \ -DCD_COMPILATION \ -DLIBEXECDIR=\"$(libexecdir)\" \ @@ -15,9 +14,6 @@ INCLUDES = \ COLORD_LIBS = \ $(top_builddir)/libcolord/libcolord.la -COLORD_GTK_LIBS = \ - $(top_builddir)/libcolord-gtk/libcolord-gtk.la - noinst_LIBRARIES = libclientprivate.a libclientprivate_a_SOURCES = \ cd-common.c \ @@ -66,25 +62,6 @@ cd_create_profile_LDADD = \ cd_create_profile_CFLAGS = \ $(WARNINGFLAGS_C) -if HAVE_GTK -noinst_PROGRAMS = \ - colord-convert - -colord_convert_SOURCES = \ - cd-convert.c - -colord_convert_LDADD = \ - $(LCMS_LIBS) \ - $(COLORD_LIBS) \ - $(COLORD_GTK_LIBS) \ - $(GTK_LIBS) \ - $(GLIB_LIBS) \ - -lm - -colord_convert_CFLAGS = \ - $(WARNINGFLAGS_C) -endif - bashcompletiondir = ${sysconfdir}/bash_completion.d dist_bashcompletion_DATA = colormgr-completion.bash diff --git a/client/cd-convert.c b/client/cd-convert.c deleted file mode 100644 index e7a493b..0000000 --- a/client/cd-convert.c +++ /dev/null @@ -1,390 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2012 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <glib.h> -#include <stdlib.h> -#include <gtk/gtk.h> -#include <glib/gi18n.h> -#include <gio/gio.h> -#include <locale.h> - -#include "cd-sensor-sync.h" -#include "cd-device-sync.h" -#include "cd-client-sync.h" -#include "cd-it8-utils.h" -#include "cd-sample-window.h" - -/** - * cd_convert_ti3_ti3_to_ccmx: - **/ -static gboolean -cd_convert_ti3_ti3_to_ccmx (const gchar *reference_fn, - const gchar *measured_fn, - const gchar *device_fn, - GError **error) -{ - CdIt8 *it8_ccmx = NULL; - CdIt8 *it8_measured = NULL; - CdIt8 *it8_reference = NULL; - gboolean ret; - GFile *file_ccmx = NULL; - GFile *file_measured = NULL; - GFile *file_reference = NULL; - - /* load reference */ - it8_reference = cd_it8_new (); - file_reference = g_file_new_for_path (reference_fn); - ret = cd_it8_load_from_file (it8_reference, - file_reference, - error); - if (!ret) - goto out; - - /* load measured */ - it8_measured = cd_it8_new (); - file_measured = g_file_new_for_path (measured_fn); - ret = cd_it8_load_from_file (it8_measured, - file_measured, - error); - if (!ret) - goto out; - - /* calculate calibration matrix */ - it8_ccmx = cd_it8_new_with_kind (CD_IT8_KIND_CCMX); - ret = cd_it8_utils_calculate_ccmx (it8_reference, - it8_measured, - it8_ccmx, - error); - if (!ret) - goto out; - - /* save file */ - file_ccmx = g_file_new_for_path (device_fn); - cd_it8_set_title (it8_ccmx, "Factory Calibration"); - cd_it8_set_originator (it8_ccmx, "cd-convert"); - cd_it8_add_option (it8_ccmx, "TYPE_FACTORY"); - ret = cd_it8_save_to_file (it8_ccmx, file_ccmx, error); - if (!ret) - goto out; -out: - if (file_reference != NULL) - g_object_unref (file_reference); - if (file_measured != NULL) - g_object_unref (file_measured); - if (file_ccmx != NULL) - g_object_unref (file_ccmx); - if (it8_reference != NULL) - g_object_unref (it8_reference); - if (it8_measured != NULL) - g_object_unref (it8_measured); - if (it8_ccmx != NULL) - g_object_unref (it8_ccmx); - return ret; -} - -/** - * cd_convert_setup_sensor: - **/ -static CdSensor * -cd_convert_setup_sensor (CdClient *client, - GError **error) -{ - CdSensor *sensor = NULL; - CdSensor *sensor_tmp; - gboolean ret; - GPtrArray *sensors = NULL; - - /* get sensor */ - sensors = cd_client_get_sensors_sync (client, NULL, error); - if (sensors == NULL) { - ret = FALSE; - goto out; - } - if (sensors->len == 0) { - ret = FALSE; - g_set_error_literal (error, 1, 0, - "No native sensors plugged in!"); - goto out; - } - sensor_tmp = g_ptr_array_index (sensors, 0); - ret = cd_sensor_connect_sync (sensor_tmp, NULL, error); - if (!ret) - goto out; - sensor = g_object_ref (sensor_tmp); -out: - if (sensors != NULL) - g_ptr_array_unref (sensors); - return sensor; -} - -/** - * cd_convert_idle_delay_cb: - **/ -static gboolean -cd_convert_idle_delay_cb (gpointer user_data) -{ - GMainLoop *loop = (GMainLoop *) user_data; - g_main_loop_quit (loop); - return FALSE; -} - -/** - * cd_convert_idle_delay: - **/ -static void -cd_convert_idle_delay (guint ms) -{ - GMainLoop *loop; - loop = g_main_loop_new (NULL, FALSE); - g_timeout_add (ms, cd_convert_idle_delay_cb, loop); - g_main_loop_run (loop); - g_main_loop_unref (loop); -} - -/** - * cd_convert_ti1_to_ti3: - **/ -static gboolean -cd_convert_ti1_to_ti3 (const gchar *patches_fn, - const gchar *measured_fn, - CdSensor *sensor, - GError **error) -{ - CdColorRGB rgb; - CdColorXYZ *xyz_tmp; - CdIt8 *it8_measured = NULL; - CdIt8 *it8_patches = NULL; - gboolean ret; - GFile *file_measured = NULL; - GFile *file_patches = NULL; - GtkWindow *sample_window = NULL; - guint i; - guint size; - - /* load patches */ - it8_patches = cd_it8_new (); - file_patches = g_file_new_for_path (patches_fn); - ret = cd_it8_load_from_file (it8_patches, - file_patches, - error); - if (!ret) - goto out; - - /* lock the sensor */ - ret = cd_sensor_lock_sync (sensor, - NULL, - error); - if (!ret) - goto out; - - /* create measurement file */ - sample_window = cd_sample_window_new (); - gtk_window_present (sample_window); - it8_measured = cd_it8_new_with_kind (CD_IT8_KIND_TI3); - size = cd_it8_get_data_size (it8_patches); - for (i = 0; i < size; i++) { - cd_it8_get_data_item (it8_patches, i, &rgb, NULL); - cd_sample_window_set_color (CD_SAMPLE_WINDOW (sample_window), &rgb); - cd_sample_window_set_fraction (CD_SAMPLE_WINDOW (sample_window), - (gdouble) i / (gdouble) size); - cd_convert_idle_delay (200); - - /* get the sample using the default matrix */ - xyz_tmp = cd_sensor_get_sample_sync (sensor, - CD_SENSOR_CAP_LCD, - NULL, - error); - if (xyz_tmp == NULL) { - ret = FALSE; - goto out; - } - - /* add to measured sheet */ - cd_it8_add_data (it8_measured, &rgb, xyz_tmp); - cd_color_xyz_free (xyz_tmp); - } - - /* unlock the sensor */ - ret = cd_sensor_unlock_sync (sensor, - NULL, - error); - if (!ret) - goto out; - - /* save file */ - file_measured = g_file_new_for_path (measured_fn); - cd_it8_set_title (it8_measured, "Calibration"); - cd_it8_set_originator (it8_measured, "cd-convert"); - cd_it8_set_instrument (it8_measured, cd_sensor_get_model (sensor)); - ret = cd_it8_save_to_file (it8_measured, file_measured, error); - if (!ret) - goto out; -out: - if (file_patches != NULL) - g_object_unref (file_patches); - if (file_measured != NULL) - g_object_unref (file_measured); - if (it8_patches != NULL) - g_object_unref (it8_patches); - if (it8_measured != NULL) - g_object_unref (it8_measured); - return ret; -} - -/** - * main: - **/ -int -main (int argc, char **argv) -{ - CdClient *client = NULL; - CdDevice *device = NULL; - CdSensor *sensor = NULL; - gboolean ret; - gchar *device_id = NULL; - GError *error = NULL; - gint retval = EXIT_FAILURE; - GOptionContext *context; - guint xid = 0; - - const GOptionEntry options[] = { - { "device", '\0', 0, G_OPTION_ARG_STRING, &device_id, - /* TRANSLATORS: command line option */ - _("Use this device for profiling"), NULL }, - { "xid", '\0', 0, G_OPTION_ARG_INT, &xid, - /* TRANSLATORS: command line option */ - _("Make the window modal to this XID"), NULL }, - { NULL} - }; - - setlocale (LC_ALL, ""); - - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - gtk_init (&argc, &argv); - - /* TRANSLATORS: just dumps the EDID to disk */ - context = g_option_context_new (_("gcm-dispread")); - g_option_context_add_main_entries (context, options, NULL); - g_option_context_add_group (context, gtk_get_option_group (TRUE)); - ret = g_option_context_parse (context, &argc, &argv, &error); - if (!ret) - goto out; - - /* get client */ - client = cd_client_new (); - ret = cd_client_connect_sync (client, NULL, &error); - if (!ret) - goto out; - - /* check device */ - if (device_id != NULL) { - device = cd_client_find_device_sync (client, - device_id, - NULL, - &error); - if (device == NULL) { - ret = FALSE; - goto out; - } - ret = cd_device_connect_sync (device, - NULL, - &error); - if (!ret) - goto out; - } - - /* create a .ccmx from two .ti3 files */ - if (argc == 4 && - g_str_has_suffix (argv[1], ".ti3") && - g_str_has_suffix (argv[2], ".ti3") && - g_str_has_suffix (argv[3], ".ccmx")) { - ret = cd_convert_ti3_ti3_to_ccmx (argv[1], - argv[2], - argv[3], - &error); - if (!ret) { - g_print ("failed to create ccmx: %s", error->message); - g_error_free (error); - goto out; - } - } else if (argc == 3 && - g_str_has_suffix (argv[1], ".ti1") && - g_str_has_suffix (argv[2], ".ti3")) { - - /* get sensor */ - sensor = cd_convert_setup_sensor (client, &error); - if (sensor == NULL) { - ret = FALSE; - goto out; - } - - /* mark device to be profiled in colord */ - if (device != NULL) { - ret = cd_device_profiling_inhibit_sync (device, - NULL, - &error); - if (!ret) - goto out; - } - - /* run the samples */ - ret = cd_convert_ti1_to_ti3 (argv[1], - argv[2], - sensor, - &error); - if (!ret) { - g_print ("failed to create ti3: %s", error->message); - g_error_free (error); - goto out; - } - } else { - ret = FALSE; - g_set_error_literal (&error, 1, 0, - "Specify one of:\n" - "patches.ti1 measured.ti3\n" - "reference.ti3 measured.ti3 device.ccmx"); - goto out; - } - - /* success */ - retval = EXIT_SUCCESS; -out: - if (!ret) { - g_print ("%s: %s\n", - _("Failed to calibrate"), - error->message); - g_error_free (error); - } - g_option_context_free (context); - if (device != NULL) - g_object_unref (device); - if (client != NULL) - g_object_unref (client); - if (sensor != NULL) - g_object_unref (sensor); - g_free (device_id); - return retval; -} diff --git a/configure.ac b/configure.ac index bfa94c5..9c1d2f0 100644 --- a/configure.ac +++ b/configure.ac @@ -274,23 +274,6 @@ else fi AC_SUBST(slashlibdir) -dnl **** Check for GTK **** -AC_ARG_ENABLE(gtk, AS_HELP_STRING([--enable-gtk],[Enable GTK support]), - enable_gtk=$enableval) -has_gtk=no -if test x$enable_gtk != xno; then - PKG_CHECK_MODULES(GTK, gtk+-3.0, has_gtk=yes, has_gtk=no) - if test $has_gtk = "no"; then - if test x$enable_gtk = xyes -a $has_gtk = "no"; then - AC_MSG_ERROR([--enable-gtk was specified and GTK was not found]) - fi - fi -fi -AM_CONDITIONAL(HAVE_GTK, test x$has_gtk = xyes) -if test x$has_gtk = xyes; then - AC_DEFINE(HAVE_GTK,1,[Use GTK support]) -fi - # per-machine directory AC_SUBST(CD_SYSTEM_PROFILES_DIR, "\$(localstatedir)/lib/colord/icc") @@ -322,8 +305,6 @@ client/Makefile libcolord/cd-version.h libcolord/colord.pc libcolord/Makefile -libcolord-gtk/colord-gtk.pc -libcolord-gtk/Makefile ]) AC_OUTPUT diff --git a/contrib/colord.spec.in b/contrib/colord.spec.in index dbfcf66..814f012 100644 --- a/contrib/colord.spec.in +++ b/contrib/colord.spec.in @@ -135,12 +135,6 @@ exit 0 %dir %{_datadir}/gtk-doc/html/colord %{_datadir}/gtk-doc/html/colord/* -%files gtk-devel -%defattr(-,root,root,-) -%{_libdir}/libcolord-gtk.so -%{_libdir}/pkgconfig/colord-gtk.pc -%{_datadir}/gir-1.0/ColordGtk-1.0.gir - %files sane %defattr(-,root,root,-) %{_datadir}/dbus-1/interfaces/org.freedesktop.colord.sane.xml @@ -149,10 +143,6 @@ exit 0 %{_libexecdir}/colord-sane %{_sysconfdir}/dbus-1/system.d/org.freedesktop.colord-sane.conf -%files gtk -%defattr(-,root,root,-) -%{_libdir}/libcolord-gtk.so.* - %changelog * #LONGDATE# Richard Hughes <richard@hughsie.com> #VERSION#-0.#BUILD##ALPHATAG# - Update from git diff --git a/libcolord-gtk/Makefile.am b/libcolord-gtk/Makefile.am deleted file mode 100644 index 1faa50e..0000000 --- a/libcolord-gtk/Makefile.am +++ /dev/null @@ -1,127 +0,0 @@ -if HAVE_INTROSPECTION --include $(INTROSPECTION_MAKEFILE) -INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \ - --add-include-path=$(top_builddir)/libcolord -INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) \ - --includedir=$(top_srcdir)/libcolord \ - --includedir=$(top_builddir)/libcolord -endif - -INCLUDES = \ - $(GLIB_CFLAGS) \ - $(GTK_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/libcolord \ - -DCD_COMPILATION \ - -DG_LOG_DOMAIN=\"libcolord-gtk\" \ - -DTESTDATADIR=\""$(top_srcdir)/data/tests"\" \ - -DPACKAGE_DATA_DIR=\""$(datadir)"\" - -lib_LTLIBRARIES = \ - libcolord-gtk.la - -libcolord_includedir = $(includedir)/colord-1 -libcolord_include_HEADERS = \ - colord-gtk.h - -libcolordgtkbase_includedir = $(libcolord_includedir)/colord-gtk -libcolordgtkbase_include_HEADERS = \ - cd-sample-window.h \ - cd-window.h \ - cd-window-sync.h - -libcolord_gtk_la_SOURCES = \ - cd-sample-window.c \ - cd-window.c \ - cd-window-sync.c - -libcolord_gtk_la_LIBADD = \ - $(GTK_LIBS) \ - $(top_builddir)/libcolord/libcolord.la \ - $(GLIB_LIBS) - -libcolord_gtk_la_LDFLAGS = \ - -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ - -export-dynamic \ - -no-undefined \ - -export-symbols-regex '^cd_.*' - -libcolord_gtk_la_CFLAGS = \ - $(WARNINGFLAGS_C) - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = colord-gtk.pc - -check_PROGRAMS = \ - cd-self-test - -cd_self_test_SOURCES = \ - cd-self-test.c - -cd_self_test_LDADD = \ - $(GLIB_LIBS) \ - $(GTK_LIBS) \ - $(lib_LTLIBRARIES) - -cd_self_test_CFLAGS = $(WARNINGFLAGS_C) - -TESTS = cd-self-test - -EXTRA_DIST = \ - colord-gtk.pc.in - -MAINTAINERCLEANFILES = \ - $(noinst_LIBRARIES) - -CLEANFILES = $(BUILT_SOURCES) - -if HAVE_INTROSPECTION -introspection_sources = \ - $(libcolordgtk_la_SOURCES) \ - $(libcolordgtkbase_include_HEADERS) - -ColordGtk-1.0.gir: libcolord-gtk.la -ColordGtk_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 Gtk-3.0 Colord-1.0 -ColordGtk_1_0_gir_CFLAGS = $(INCLUDES) -ColordGtk_1_0_gir_SCANNERFLAGS = --identifier-prefix=Cd \ - --symbol-prefix=cd_ \ - --warn-all \ - --add-include-path=$(srcdir) \ - --add-include-path=$(top_srcdir)/libcolord \ - --c-include="colord-gtk.h" -ColordGtk_1_0_gir_EXPORT_PACKAGES = colord-gtk -ColordGtk_1_0_gir_LIBS = libcolord-gtk.la -ColordGtk_1_0_gir_FILES = $(introspection_sources) -INTROSPECTION_GIRS += ColordGtk-1.0.gir - -girdir = $(datadir)/gir-1.0 -gir_DATA = $(INTROSPECTION_GIRS) - -typelibdir = $(libdir)/girepository-1.0 -typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib) - -CLEANFILES += $(gir_DATA) $(typelib_DATA) - -if FALSE -if HAVE_VAPIGEN -colord-gtk.vapi: ColordGtk-1.0.gir - $(MAKE) $(AM_MAKEFLAGS) ColordGtk-1.0.gir - $(AM_V_GEN)$(VAPIGEN) $(VAPIGENFLAGS) \ - --library colord-gtk \ - --pkg gio-2.0 \ - ColordGtk-1.0.gir - touch $@ -vapidir = $(datadir)/vala/vapi -dist_vapi_DATA = \ - colord-gtk.vapi -CLEANFILES += $(dist_vapi_DATA) -endif -endif - -endif - -clean-local: - rm -f *~ - --include $(top_srcdir)/git.mk diff --git a/libcolord-gtk/cd-sample-window.c b/libcolord-gtk/cd-sample-window.c deleted file mode 100644 index 890dfd5..0000000 --- a/libcolord-gtk/cd-sample-window.c +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2009-2012 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <glib-object.h> - -#include "cd-color.h" -#include "cd-sample-window.h" - -static void cd_sample_window_finalize (GObject *object); - -#define CD_SAMPLE_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CD_TYPE_SAMPLE_WINDOW, CdSampleWindowPrivate)) -#define CD_SAMPLE_WINDOW_PULSE_DELAY 80 /* ms */ - -/** - * CdSampleWindowPrivate: - * - * Private #CdSampleWindow data - **/ -struct _CdSampleWindowPrivate -{ - GtkWidget *image; - GtkWidget *progress_bar; - guint pulse_id; -}; - -G_DEFINE_TYPE (CdSampleWindow, cd_sample_window, GTK_TYPE_WINDOW) - -/** - * cd_sample_window_pulse_cb: - **/ -static gboolean -cd_sample_window_pulse_cb (CdSampleWindow *sample_window) -{ - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (sample_window->priv->progress_bar)); - return TRUE; -} - -/** - * cd_sample_window_set_fraction: - * @sample_window: a valid #CdSampleWindow instance - * @percentage: the fraction value to show, or -1 for pulsing. - * - * Sets the percentage value on the window. - **/ -void -cd_sample_window_set_fraction (CdSampleWindow *sample_window, - gdouble fraction) -{ - CdSampleWindowPrivate *priv = sample_window->priv; - - /* make pulse */ - if (fraction == -1) { - if (priv->pulse_id == 0) { - priv->pulse_id = g_timeout_add (CD_SAMPLE_WINDOW_PULSE_DELAY, - (GSourceFunc) cd_sample_window_pulse_cb, - sample_window); - } - return; - } - - /* no more pulsing */ - if (priv->pulse_id != 0) { - g_source_remove (priv->pulse_id); - priv->pulse_id = 0; - } - - /* set static value */ - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (sample_window->priv->progress_bar), fraction); -} - -/** - * cd_sample_window_set_color: - * @sample_window: a valid #CdSampleWindow instance - * @red: the red color value - * @green: the green color value - * @blue: the blue color value - * - * Sets the window to a specific color. - **/ -void -cd_sample_window_set_color (CdSampleWindow *sample_window, - const CdColorRGB *color) -{ - GdkPixbuf *pixbuf; - gint width; - gint height; - gint i; - guchar *data; - guchar *pixels; - GtkWindow *window = GTK_WINDOW (sample_window); - - /* get the window size */ - gtk_window_get_size (window, &width, &height); - - /* if no pixbuf, create it */ - g_debug ("setting RGB: %f, %f, %f", color->R, color->G, color->B); - pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (sample_window->priv->image)); - if (pixbuf == NULL) { - data = g_new0 (guchar, width * height * 3); - pixbuf = gdk_pixbuf_new_from_data (data, - GDK_COLORSPACE_RGB, - FALSE, - 8, - width, - height, - width * 3, - (GdkPixbufDestroyNotify) g_free, - NULL); - gtk_image_set_from_pixbuf (GTK_IMAGE (sample_window->priv->image), - pixbuf); - } - - /* get the pixbuf size */ - height = gdk_pixbuf_get_height (pixbuf); - width = gdk_pixbuf_get_width (pixbuf); - - /* set the pixel array */ - pixels = gdk_pixbuf_get_pixels (pixbuf); - for (i = 0; i < width * height * 3; i += 3) { - pixels[i+0] = (guchar) (color->R * 255.0f); - pixels[i+1] = (guchar) (color->G * 255.0f); - pixels[i+2] = (guchar) (color->B * 255.0f); - } - - /* force redraw */ - gtk_widget_set_visible (sample_window->priv->image, FALSE); - gtk_widget_set_visible (sample_window->priv->image, TRUE); -} - -/** - * cd_sample_window_class_init: - **/ -static void -cd_sample_window_class_init (CdSampleWindowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = cd_sample_window_finalize; - g_type_class_add_private (klass, sizeof (CdSampleWindowPrivate)); -} - -/** - * cd_sample_window_enter_notify_cb: - **/ -static gboolean -cd_sample_window_enter_notify_cb (GtkWidget *widget, GdkEventCrossing *event, CdSampleWindow *sample_window) -{ - GdkCursor *cursor; - - /* hide cursor */ - cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_BLANK_CURSOR); - gdk_window_set_cursor (gtk_widget_get_window (widget), cursor); - g_object_unref (cursor); - - return FALSE; -} - -/** - * cd_sample_window_leave_notify_cb: - **/ -static gboolean -cd_sample_window_leave_notify_cb (GtkWidget *widget, GdkEventCrossing *event, - CdSampleWindow *sample_window) -{ - /* restore cursor */ - gdk_window_set_cursor (gtk_widget_get_window (widget), NULL); - return FALSE; -} - -static gboolean -cd_sample_window_visibility_notify_cb (GtkWidget *widget, GdkEventVisibility *event, - CdSampleWindow *sample_window) -{ - /* reshow it */ - gtk_window_present (GTK_WINDOW (widget)); - return TRUE; -} - -/** - * cd_sample_window_init: - **/ -static void -cd_sample_window_init (CdSampleWindow *sample_window) -{ - GtkWindow *window = GTK_WINDOW (sample_window); - GtkWidget *vbox; - sample_window->priv = CD_SAMPLE_WINDOW_GET_PRIVATE (sample_window); - sample_window->priv->image = gtk_image_new (); - sample_window->priv->progress_bar = gtk_progress_bar_new (); - - /* pack in two widgets into the window */ - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_container_add (GTK_CONTAINER (sample_window), vbox); - gtk_box_pack_start (GTK_BOX (vbox), sample_window->priv->image, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), sample_window->priv->progress_bar, FALSE, FALSE, 0); - gtk_widget_set_size_request (sample_window->priv->image, 400, 400); - gtk_widget_show_all (vbox); - - /* be clever and allow the colorimeter to do it's job */ - g_signal_connect (window, "enter-notify-event", - G_CALLBACK(cd_sample_window_enter_notify_cb), - sample_window); - g_signal_connect (window, "leave-notify-event", - G_CALLBACK(cd_sample_window_leave_notify_cb), - sample_window); - g_signal_connect (window, "visibility-notify-event", - G_CALLBACK(cd_sample_window_visibility_notify_cb), - sample_window); - - /* show on all virtual desktops */ - gtk_window_stick (window); -} - -/** - * cd_sample_window_finalize: - **/ -static void -cd_sample_window_finalize (GObject *object) -{ - CdSampleWindow *sample_window = CD_SAMPLE_WINDOW (object); - CdSampleWindowPrivate *priv = sample_window->priv; - - if (priv->pulse_id != 0) - g_source_remove (priv->pulse_id); - - G_OBJECT_CLASS (cd_sample_window_parent_class)->finalize (object); -} - -/** - * cd_sample_window_new: - * - * Return value: a new #CdSampleWindow object. - **/ -GtkWindow * -cd_sample_window_new (void) -{ - CdSampleWindow *sample_window; - sample_window = g_object_new (CD_TYPE_SAMPLE_WINDOW, - "accept-focus", FALSE, - "decorated", FALSE, - "default-height", 400, - "default-width", 400, - "deletable", FALSE, - "destroy-with-parent", TRUE, - "icon-name", "icc-profile", - "resizable", FALSE, - "skip-pager-hint", TRUE, - "skip-taskbar-hint", TRUE, - "title", "calibration square", - "type-hint", GDK_WINDOW_TYPE_HINT_SPLASHSCREEN, - "urgency-hint", TRUE, - NULL); - return GTK_WINDOW (sample_window); -} diff --git a/libcolord-gtk/cd-sample-window.h b/libcolord-gtk/cd-sample-window.h deleted file mode 100644 index 137a229..0000000 --- a/libcolord-gtk/cd-sample-window.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2010-2012 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU General Public License Version 2 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __CD_SAMPLE_WINDOW_H -#define __CD_SAMPLE_WINDOW_H - -#include <glib-object.h> -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define CD_TYPE_SAMPLE_WINDOW (cd_sample_window_get_type ()) -#define CD_SAMPLE_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CD_TYPE_SAMPLE_WINDOW, CdSampleWindow)) -#define CD_IS_SAMPLE_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CD_TYPE_SAMPLE_WINDOW)) - -typedef struct _CdSampleWindowPrivate CdSampleWindowPrivate; -typedef struct _CdSampleWindow CdSampleWindow; -typedef struct _CdSampleWindowClass CdSampleWindowClass; - -struct _CdSampleWindow -{ - GtkWindow parent; - CdSampleWindowPrivate *priv; -}; - -struct _CdSampleWindowClass -{ - GtkWindowClass parent_class; -}; - -GType cd_sample_window_get_type (void); -GtkWindow *cd_sample_window_new (void); -void cd_sample_window_set_color (CdSampleWindow *sample_window, - const CdColorRGB *color); -void cd_sample_window_set_fraction (CdSampleWindow *sample_window, - gdouble fraction); - -G_END_DECLS - -#endif /* __CD_SAMPLE_WINDOW_H */ - diff --git a/libcolord-gtk/cd-self-test.c b/libcolord-gtk/cd-self-test.c deleted file mode 100644 index a200025..0000000 --- a/libcolord-gtk/cd-self-test.c +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2010 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#include <glib.h> -#include <glib-object.h> -#include <gtk/gtk.h> - -#include "../libcolord/cd-color.h" -#include "../libcolord/cd-profile.h" -#include "cd-sample-window.h" -#include "cd-window.h" - -static void -cd_window_get_profile_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - CdWindow *window = CD_WINDOW (source); - GtkWidget *widget = GTK_WIDGET (user_data); - GError *error = NULL; - CdProfile *profile; - - profile = cd_window_get_profile_finish (window, - res, - &error); - g_assert_no_error (error); - g_assert (profile != NULL); - g_debug ("profile was %s", cd_profile_get_filename (profile)); - g_object_unref (profile); - - /* kill the dialog */ - gtk_widget_destroy (widget); -} - -static void -map_cb (GtkWidget *this_widget, gpointer user_data) -{ - CdWindow *window = CD_WINDOW (user_data); - - /* get the profile for this widget */ - cd_window_get_profile (window, - this_widget, - NULL, - cd_window_get_profile_cb, - this_widget); -} - -static void -colord_window_func (void) -{ - CdWindow *window; - GtkWidget *dialog; - - window = cd_window_new (); - dialog = gtk_message_dialog_new (NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - "%s", "Hello world"); - g_signal_connect (dialog, "map", - G_CALLBACK (map_cb), - window); - gtk_dialog_run (GTK_DIALOG (dialog)); - g_object_unref (window); -} - -static gboolean -colord_sample_window_loop_cb (GMainLoop *loop) -{ - g_main_loop_quit (loop); - return FALSE; -} - -static void -colord_sample_window_func (void) -{ - GtkWindow *window; - GMainLoop *loop; - CdColorRGB source; - - window = cd_sample_window_new (); - g_assert (window != NULL); - source.R = 1.0f; - source.G = 1.0f; - source.B = 0.0f; - cd_sample_window_set_color (CD_SAMPLE_WINDOW (window), &source); - cd_sample_window_set_fraction (CD_SAMPLE_WINDOW (window), -1); - - /* move to the center of device lvds1 */ - gtk_window_present (window); - - loop = g_main_loop_new (NULL, FALSE); - g_timeout_add_seconds (2, (GSourceFunc) colord_sample_window_loop_cb, loop); - g_main_loop_run (loop); - - g_main_loop_unref (loop); - gtk_widget_destroy (GTK_WIDGET (window)); -} - -int -main (int argc, char **argv) -{ - g_type_init (); - g_test_init (&argc, &argv, NULL); - gtk_init (&argc, &argv); - - /* only critical and error are fatal */ - g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); - - /* tests go here */ - g_test_add_func ("/colord/window", colord_window_func); - g_test_add_func ("/colors/sample-window", colord_sample_window_func); - return g_test_run (); -} - diff --git a/libcolord-gtk/cd-window-sync.c b/libcolord-gtk/cd-window-sync.c deleted file mode 100644 index 9bdfc33..0000000 --- a/libcolord-gtk/cd-window-sync.c +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2012 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * SECTION:cd-window-sync - * @short_description: Sync helpers for #CdWindow - * - * These helper functions provide a simple way to use the async functions - * in command line tools. - * - * See also: #CdWindow - */ - -#include "config.h" - -#include <glib.h> -#include <gio/gio.h> - -#include "cd-profile.h" -#include "cd-window.h" -#include "cd-window-sync.h" - -/* tiny helper to help us do the async operation */ -typedef struct { - GError **error; - GMainLoop *loop; - CdProfile *profile; - CdWindow *window; -} CdWindowHelper; - -/**********************************************************************/ - -static void -cd_window_get_profile_finish_sync (CdWindow *window, - GAsyncResult *res, - CdWindowHelper *helper) -{ - helper->profile = cd_window_get_profile_finish (window, - res, - helper->error); - g_main_loop_quit (helper->loop); -} - -/** - * cd_window_get_profile_sync: - * @window: a #CdWindow instance. - * @widget: a #GtkWidget - * @cancellable: a #GCancellable or %NULL - * @error: a #GError, or %NULL. - * - * Gets the screen profile that should be used for the widget, - * which corresponds to the screen output the widget most covers. - * - * WARNING: This function is synchronous, and may block. - * Do not use it in GUI applications. - * - * Return value: (transfer full): a #CdProfile or %NULL - * - * Since: 0.1.20 - **/ -CdProfile * -cd_window_get_profile_sync (CdWindow *window, - GtkWidget *widget, - GCancellable *cancellable, - GError **error) -{ - CdWindowHelper helper; - - /* create temp object */ - helper.loop = g_main_loop_new (NULL, FALSE); - helper.error = error; - - /* run async method */ - cd_window_get_profile (window, widget, cancellable, - (GAsyncReadyCallback) cd_window_get_profile_finish_sync, - &helper); - g_main_loop_run (helper.loop); - - /* free temp object */ - g_main_loop_unref (helper.loop); - - return helper.profile; -} diff --git a/libcolord-gtk/cd-window-sync.h b/libcolord-gtk/cd-window-sync.h deleted file mode 100644 index 6afe83b..0000000 --- a/libcolord-gtk/cd-window-sync.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2012 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined (__COLORD_H_INSIDE__) && !defined (CD_COMPILATION) -#error "Only <colord.h> can be included directly." -#endif - -#ifndef __CD_WINDOW_SYNC_H -#define __CD_WINDOW_SYNC_H - -#include <glib-object.h> - -G_BEGIN_DECLS - -CdProfile *cd_window_get_profile_sync (CdWindow *window, - GtkWidget *widget, - GCancellable *cancellable, - GError **error); - -G_END_DECLS - -#endif /* __CD_WINDOW_SYNC_H */ - diff --git a/libcolord-gtk/cd-window.c b/libcolord-gtk/cd-window.c deleted file mode 100644 index 277c09b..0000000 --- a/libcolord-gtk/cd-window.c +++ /dev/null @@ -1,579 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2012 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * SECTION:cd-window - * @short_description: Additional helper classes for working with GTK - * - * These functions are useful when GTK is being used alongside colord and - * are just provided for convenience. - * - * See also: #CdDevice - */ - -#include "config.h" - -#include <gio/gio.h> -#include <glib.h> -#include <gtk/gtk.h> -#include <gdk/gdkx.h> - -#include "cd-client.h" -#include "cd-window.h" -#include "cd-device.h" -#include "cd-profile.h" - -static void cd_window_class_init (CdWindowClass *klass); -static void cd_window_init (CdWindow *window); -static void cd_window_finalize (GObject *object); - -#define CD_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CD_TYPE_WINDOW, CdWindowPrivate)) - -/** - * CdWindowPrivate: - * - * Private #CdWindow data - **/ -struct _CdWindowPrivate -{ - CdClient *client; - CdDevice *device; - CdProfile *profile; - gchar *plug_name; - GtkWidget *widget; - guint device_changed_id; -}; - -enum { - SIGNAL_CHANGED, - SIGNAL_LAST -}; - -enum { - PROP_0, - PROP_PROFILE, - PROP_LAST -}; - -static guint signals [SIGNAL_LAST] = { 0 }; - -G_DEFINE_TYPE (CdWindow, cd_window, G_TYPE_OBJECT) - -/** - * cd_window_error_quark: - * - * Return value: An error quark. - * - * Since: 0.1.20 - **/ -GQuark -cd_window_error_quark (void) -{ - static GQuark quark = 0; - if (!quark) { - quark = g_quark_from_static_string ("cd_window_error"); - } - return quark; -} - -/** - * cd_window_get_last_profile: - * @window: a #CdWindow instance. - * - * Gets the color profile to use for this widget. - * - * Return value: (transfer none): a #CdProfile - * - * Since: 0.1.20 - **/ -CdProfile * -cd_window_get_last_profile (CdWindow *window) -{ - g_return_val_if_fail (CD_IS_WINDOW (window), NULL); - return window->priv->profile; -} - -typedef struct { - CdWindow *window; - GCancellable *cancellable; - GSimpleAsyncResult *res; -} CdWindowSetWidgetHelper; - -/** - * cd_window_get_profile_finish: - * @window: a #CdWindow instance. - * @res: the #GAsyncResult - * @error: A #GError or %NULL - * - * Gets the result from the asynchronous function. - * - * Return value: (transfer full): a #CdProfile or %NULL - * - * Since: 0.1.20 - **/ -CdProfile * -cd_window_get_profile_finish (CdWindow *window, - GAsyncResult *res, - GError **error) -{ - GSimpleAsyncResult *simple; - - g_return_val_if_fail (CD_IS_WINDOW (window), NULL); - g_return_val_if_fail (G_IS_SIMPLE_ASYNC_RESULT (res), NULL); - g_return_val_if_fail (error == NULL || *error == NULL, NULL); - - simple = G_SIMPLE_ASYNC_RESULT (res); - if (g_simple_async_result_propagate_error (simple, error)) - return NULL; - - return g_object_ref (g_simple_async_result_get_op_res_gpointer (simple)); -} - -static void -cd_window_import_free_helper (CdWindowSetWidgetHelper *helper) -{ - if (helper->cancellable != NULL) - g_object_unref (helper->cancellable); - g_object_unref (helper->window); - g_object_unref (helper->res); - g_free (helper); -} - -static void cd_window_get_profile_new_data (CdWindowSetWidgetHelper *helper); - -static void -cd_window_get_profile_client_connect_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - CdClient *client = CD_CLIENT (source); - CdWindowSetWidgetHelper *helper = (CdWindowSetWidgetHelper *) user_data; - gboolean ret; - GError *error = NULL; - - ret = cd_client_connect_finish (client, res, &error); - if (!ret) { - g_simple_async_result_set_error (helper->res, - CD_WINDOW_ERROR, - CD_WINDOW_ERROR_FAILED, - "failed to connect to colord: %s", - error->message); - g_simple_async_result_complete_in_idle (helper->res); - cd_window_import_free_helper (helper); - g_error_free (error); - return; - } - cd_window_get_profile_new_data (helper); -} - -static void -cd_window_get_profile_device_connect_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - CdDevice *device = CD_DEVICE (source); - CdWindowSetWidgetHelper *helper = (CdWindowSetWidgetHelper *) user_data; - CdWindowPrivate *priv = helper->window->priv; - gboolean ret; - GError *error = NULL; - - ret = cd_device_connect_finish (device, res, &error); - if (!ret) { - g_simple_async_result_set_error (helper->res, - CD_WINDOW_ERROR, - CD_WINDOW_ERROR_FAILED, - "failed to connect to device: %s", - error->message); - g_simple_async_result_complete_in_idle (helper->res); - cd_window_import_free_helper (helper); - g_error_free (error); - return; - } - - /* get the default profile for the device */ - priv->profile = cd_device_get_default_profile (priv->device); - if (priv->profile == NULL) { - g_simple_async_result_set_error (helper->res, - CD_WINDOW_ERROR, - CD_WINDOW_ERROR_FAILED, - "no default profile for device: %s", - priv->plug_name); - g_simple_async_result_complete_in_idle (helper->res); - cd_window_import_free_helper (helper); - return; - } - - cd_window_get_profile_new_data (helper); -} - -static void -cd_window_get_profile_profile_connect_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - CdProfile *profile = CD_PROFILE (source); - CdWindowSetWidgetHelper *helper = (CdWindowSetWidgetHelper *) user_data; - CdWindowPrivate *priv = helper->window->priv; - const gchar *filename; - gboolean ret; - GError *error = NULL; - - ret = cd_profile_connect_finish (profile, res, &error); - if (!ret) { - g_simple_async_result_set_error (helper->res, - CD_WINDOW_ERROR, - CD_WINDOW_ERROR_FAILED, - "failed to connect to profile: %s", - error->message); - g_simple_async_result_complete_in_idle (helper->res); - cd_window_import_free_helper (helper); - g_error_free (error); - return; - } - - /* get the filename of the profile */ - filename = cd_profile_get_filename (priv->profile); - if (filename == NULL) { - g_simple_async_result_set_error (helper->res, - CD_WINDOW_ERROR, - CD_WINDOW_ERROR_FAILED, - "profile has no physical file, must be virtual"); - g_simple_async_result_complete_in_idle (helper->res); - cd_window_import_free_helper (helper); - return; - } - - /* SUCCESS! */ - g_simple_async_result_set_op_res_gpointer (helper->res, - g_object_ref (priv->profile), - (GDestroyNotify) g_object_unref); - g_simple_async_result_complete_in_idle (helper->res); - cd_window_import_free_helper (helper); -} - -static void -cd_window_get_profile_device_find_cb (GObject *source, - GAsyncResult *res, - gpointer user_data) -{ - CdClient *client = CD_CLIENT (source); - CdWindowSetWidgetHelper *helper = (CdWindowSetWidgetHelper *) user_data; - CdWindowPrivate *priv = helper->window->priv; - GError *error = NULL; - - priv->device = cd_client_find_device_by_property_finish (client, - res, - &error); - if (priv->device == NULL) { - g_simple_async_result_set_error (helper->res, - CD_WINDOW_ERROR, - CD_WINDOW_ERROR_FAILED, - "no device with that property: %s", - error->message); - g_simple_async_result_complete_in_idle (helper->res); - cd_window_import_free_helper (helper); - g_error_free (error); - return; - } - cd_window_get_profile_new_data (helper); -} - -static void -cd_window_device_changed_cb (CdDevice *device, CdWindow *window) -{ - CdProfile *profile; - - /* no device set yet */ - if (window->priv->device == NULL) - return; - - /* the same device */ - if (!cd_device_equal (device, window->priv->device)) - return; - - /* get new default profile */ - profile = cd_device_get_default_profile (window->priv->device); - if (cd_profile_equal (profile, window->priv->profile)) - return; - - /* replace profile instance and emit if changed */ - if (window->priv->profile != NULL) - g_object_unref (window->priv->profile); - window->priv->profile = g_object_ref (profile); - g_signal_emit (window, signals[SIGNAL_CHANGED], 0, - window->priv->profile); -} - -static void -cd_window_get_profile_new_data (CdWindowSetWidgetHelper *helper) -{ - CdWindowPrivate *priv = helper->window->priv; - - /* connect to the daemon */ - if (priv->client == NULL) { - priv->client = cd_client_new (); - priv->device_changed_id = - g_signal_connect (priv->client, "device-changed", - G_CALLBACK (cd_window_device_changed_cb), - helper->window); - cd_client_connect (priv->client, - helper->cancellable, - cd_window_get_profile_client_connect_cb, - helper); - goto out; - } - - /* find the new device */ - if (priv->device == NULL && priv->plug_name != NULL) { - cd_client_find_device_by_property (priv->client, - CD_DEVICE_METADATA_XRANDR_NAME, - priv->plug_name, - helper->cancellable, - cd_window_get_profile_device_find_cb, - helper); - goto out; - } - - /* connect to the device */ - if (priv->device != NULL && !cd_device_get_connected (priv->device)) { - cd_device_connect (priv->device, - helper->cancellable, - cd_window_get_profile_device_connect_cb, - helper); - goto out; - } - - /* connect to the profile */ - if (priv->profile != NULL && !cd_profile_get_connected (priv->profile)) { - cd_profile_connect (priv->profile, - helper->cancellable, - cd_window_get_profile_profile_connect_cb, - helper); - goto out; - } -out: - return; -} - -static void -cd_window_update_widget_plug_name (CdWindow *window, - GtkWidget *widget) -{ - CdWindowPrivate *priv = window->priv; - const gchar *plug_name; - GdkScreen *screen; - GdkWindow *gdk_window; - gint monitor_num; - - /* use the largest bounding area */ - gdk_window = gtk_widget_get_window (widget); - screen = gdk_window_get_screen (gdk_window); - - monitor_num = gdk_screen_get_monitor_at_window (screen, - gdk_window); - plug_name = gdk_screen_get_monitor_plug_name (screen, monitor_num); - - /* ignoring MAP as plug_name has not changed */ - if (g_strcmp0 (plug_name, priv->plug_name) == 0) - return; - - /* refresh data */ - g_free (priv->plug_name); - priv->plug_name = g_strdup (plug_name); - if (priv->device != NULL) { - g_object_unref (priv->device); - priv->device = NULL; - } - if (priv->profile != NULL) { - g_object_unref (priv->profile); - priv->profile = NULL; - } -} - -/** - * cd_window_get_profile: - * @window: a #CdWindow instance. - * @widget: a #GtkWidget - * @cancellable: a #GCancellable or %NULL - * @callback: the function to run on completion - * @user_data: the data to pass to @callback - * - * Gets the screen profile that should be used for the widget, - * which corresponds to the screen output the widget most covers. - * - * This method should be called when the widget has mapped, i.e. - * g_signal_connect (dialog, "map", G_CALLBACK (map_cb), priv); - * - * Note, the returned profile from cd_client_get_profile_for_widget_finish() - * has already been connected to, as is ready to use. - * - * Since: 0.1.20 - **/ -void -cd_window_get_profile (CdWindow *window, - GtkWidget *widget, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - CdWindowSetWidgetHelper *helper; - - g_return_if_fail (CD_IS_WINDOW (window)); - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); - - helper = g_new0 (CdWindowSetWidgetHelper, 1); - helper->window = g_object_ref (window); - helper->res = g_simple_async_result_new (G_OBJECT (window), - callback, - user_data, - cd_window_get_profile); - if (cancellable != NULL) - helper->cancellable = g_object_ref (cancellable); - - /* intially set the plug name */ - window->priv->widget = g_object_ref (widget); - cd_window_update_widget_plug_name (window, widget); - cd_window_get_profile_new_data (helper); -} - -/**********************************************************************/ - -/* - * cd_window_get_property: - */ -static void -cd_window_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - CdWindow *window = CD_WINDOW (object); - - switch (prop_id) { - case PROP_PROFILE: - g_value_set_object (value, window->priv->profile); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* - * cd_window_class_init: - */ -static void -cd_window_class_init (CdWindowClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = cd_window_get_property; - object_class->finalize = cd_window_finalize; - - /** - * CdWindow:profile: - * - * The window profile. - * - * Since: 0.1.20 - */ - g_object_class_install_property (object_class, - PROP_PROFILE, - g_param_spec_string ("Profile", - "Color profile", - NULL, - NULL, - G_PARAM_READABLE)); - - /** - * CdWindow::changed: - * @window: the #CdDevice instance that emitted the signal - * - * The ::changed signal is emitted when the device profile has - * changed. The #CdProfile that is referenced in the callback - * has not been connected to, and you will need to call - * cd_profile_connect() if the ICC filename is required. - * - * Since: 0.1.20 - **/ - signals [SIGNAL_CHANGED] = - g_signal_new ("changed", - G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CdWindowClass, changed), - NULL, NULL, g_cclosure_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, CD_TYPE_PROFILE); - - g_type_class_add_private (klass, sizeof (CdWindowPrivate)); -} - -/* - * cd_window_init: - */ -static void -cd_window_init (CdWindow *window) -{ - window->priv = CD_WINDOW_GET_PRIVATE (window); - - /* ensure the remote errors are registered */ - cd_window_error_quark (); -} - -/* - * cd_window_finalize: - */ -static void -cd_window_finalize (GObject *object) -{ - CdWindow *window = CD_WINDOW (object); - - g_return_if_fail (CD_IS_WINDOW (object)); - - if (window->priv->client != NULL) { - g_signal_handler_disconnect (window->priv->client, - window->priv->device_changed_id); - g_object_unref (window->priv->client); - } - if (window->priv->device != NULL) - g_object_unref (window->priv->device); - if (window->priv->profile != NULL) - g_object_unref (window->priv->profile); - g_free (window->priv->plug_name); - - G_OBJECT_CLASS (cd_window_parent_class)->finalize (object); -} - -/** - * cd_window_new: - * - * Creates a new #CdWindow object. - * - * Return value: a new CdWindow object. - * - * Since: 0.1.20 - **/ -CdWindow * -cd_window_new (void) -{ - CdWindow *window; - window = g_object_new (CD_TYPE_WINDOW, NULL); - return CD_WINDOW (window); -} diff --git a/libcolord-gtk/cd-window.h b/libcolord-gtk/cd-window.h deleted file mode 100644 index 3b993a8..0000000 --- a/libcolord-gtk/cd-window.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2012 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined (__COLORD_H_INSIDE__) && !defined (CD_COMPILATION) -#error "Only <colord-gtk.h> can be included directly." -#endif - -#ifndef __CD_WINDOW_H -#define __CD_WINDOW_H - -#include <glib-object.h> -#include <gio/gio.h> -#include <gtk/gtk.h> - -#include "cd-window.h" - -G_BEGIN_DECLS - -#define CD_TYPE_WINDOW (cd_window_get_type ()) -#define CD_WINDOW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CD_TYPE_WINDOW, CdWindow)) -#define CD_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), CD_TYPE_WINDOW, CdWindowClass)) -#define CD_IS_WINDOW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), CD_TYPE_WINDOW)) -#define CD_IS_WINDOW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), CD_TYPE_WINDOW)) -#define CD_WINDOW_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CD_TYPE_WINDOW, CdWindowClass)) -#define CD_WINDOW_ERROR (cd_window_error_quark ()) -#define CD_WINDOW_TYPE_ERROR (cd_window_error_get_type ()) - -typedef struct _CdWindowPrivate CdWindowPrivate; - -typedef struct -{ - GObject parent; - CdWindowPrivate *priv; -} CdWindow; - -typedef struct -{ - GObjectClass parent_class; - void (*changed) (CdWindow *window, - CdProfile *profile); - /*< private >*/ - /* Padding for future expansion */ - void (*_cd_window_reserved1) (void); - void (*_cd_window_reserved2) (void); - void (*_cd_window_reserved3) (void); - void (*_cd_window_reserved4) (void); - void (*_cd_window_reserved5) (void); - void (*_cd_window_reserved6) (void); - void (*_cd_window_reserved7) (void); - void (*_cd_window_reserved8) (void); -} CdWindowClass; - -/** - * CdWindowError: - * @CD_WINDOW_ERROR_FAILED: the transaction failed for an unknown reason - * - * Errors that can be thrown - */ -typedef enum -{ - CD_WINDOW_ERROR_FAILED, - CD_WINDOW_ERROR_LAST -} CdWindowError; - -GType cd_window_get_type (void); -GQuark cd_window_error_quark (void); -CdWindow *cd_window_new (void); - -/* async */ -void cd_window_get_profile (CdWindow *window, - GtkWidget *widget, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -CdProfile *cd_window_get_profile_finish (CdWindow *window, - GAsyncResult *res, - GError **error); - -/* getters */ -CdProfile *cd_window_get_last_profile (CdWindow *window); - -G_END_DECLS - -#endif /* __CD_WINDOW_H */ - diff --git a/libcolord-gtk/colord-gtk.h b/libcolord-gtk/colord-gtk.h deleted file mode 100644 index d2a7adf..0000000 --- a/libcolord-gtk/colord-gtk.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com> - * - * Licensed under the GNU Lesser General Public License Version 2.1 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * SECTION:colord - * @short_description: Client objects for accessing colord with GTK - * - * These objects allow client programs to get access to profiles. - * - * See also: #CdClient, #CdDevice - */ - -#ifndef __COLORD_GTK_H__ -#define __COLORD_GTK_H__ - -#define __COLORD_H_INSIDE__ - -#include <gtk/gtk.h> - -#include <colord/cd-client.h> -#include <colord/cd-device.h> -#include <colord/cd-profile.h> -#include <colord/cd-color.h> -#include <colord-gtk/cd-sample-window.h> -#include <colord-gtk/cd-window.h> -#include <colord-gtk/cd-window-sync.h> - -#undef __COLORD_H_INSIDE__ - -#endif /* __COLORD_GTK_H__ */ - diff --git a/libcolord-gtk/colord-gtk.pc.in b/libcolord-gtk/colord-gtk.pc.in deleted file mode 100644 index 72e3eca..0000000 --- a/libcolord-gtk/colord-gtk.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: colord-gtk -Description: colord-gtk is GTK integration for libcolord -Version: @VERSION@ -Requires: colord, gtk+-3.0 -Libs: -L${libdir} -lcolord-gtk -Cflags: -I${includedir}/colord-1 diff --git a/po/POTFILES.in b/po/POTFILES.in index 34044eb..aebed89 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,4 +1,3 @@ -client/cd-convert.c client/cd-create-profile.c client/cd-fix-profile.c client/cd-util.c |