[gnome-color-manager] Add gcm-fix-profile to load and then re-save existing profiles using lcms
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add gcm-fix-profile to load and then re-save existing profiles using lcms
- Date: Wed, 6 Jan 2010 14:43:45 +0000 (UTC)
commit 380e6a37f3ea6503a88add8a2eb011fadab72525
Author: Richard Hughes <richard hughsie com>
Date: Wed Jan 6 12:44:57 2010 +0000
Add gcm-fix-profile to load and then re-save existing profiles using lcms
src/.gitignore | 1 +
src/Makefile.am | 12 ++++++
src/gcm-dump-profile.c | 4 +-
src/gcm-fix-profile.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++
src/gcm-inspect.c | 4 +-
5 files changed, 107 insertions(+), 4 deletions(-)
---
diff --git a/src/.gitignore b/src/.gitignore
index 293e34e..c431a4c 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -9,6 +9,7 @@ gcm-inspect
gcm-session
gcm-dump-edid
gcm-dump-profile
+gcm-fix-profile
gcm-self-test
gcm-install-system-wide
org.gnome.ColorManager.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 7c8695b..a9b8f12 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,6 +65,7 @@ sbin_PROGRAMS = \
bin_PROGRAMS = \
gcm-inspect \
gcm-dump-profile \
+ gcm-fix-profile \
gcm-dump-edid \
gcm-apply \
gcm-prefs \
@@ -114,6 +115,17 @@ gcm_dump_profile_LDADD = \
gcm_dump_profile_CFLAGS = \
$(WARNINGFLAGS_C)
+gcm_fix_profile_SOURCES = \
+ gcm-fix-profile.c
+
+gcm_fix_profile_LDADD = \
+ $(GLIB_LIBS) \
+ $(LCMS_LIBS) \
+ $(GTK_LIBS)
+
+gcm_fix_profile_CFLAGS = \
+ $(WARNINGFLAGS_C)
+
gcm_inspect_SOURCES = \
gcm-inspect.c
diff --git a/src/gcm-dump-profile.c b/src/gcm-dump-profile.c
index 0bb3951..71a5d72 100644
--- a/src/gcm-dump-profile.c
+++ b/src/gcm-dump-profile.c
@@ -85,7 +85,7 @@ gcm_dump_profile_filename (const gchar *filename)
g_print ("Model:\t%s\n", model);
if (datetime != NULL)
g_print ("Created:\t%s\n", datetime);
-
+gcm_profile_save (profile, "/tmp/moo.icc", NULL);
out:
g_object_unref (profile);
g_free (description);
@@ -123,7 +123,7 @@ main (int argc, char **argv)
gtk_init (&argc, &argv);
/* TRANSLATORS: this just dumps the profile to the screen */
- context = g_option_context_new (_("Profile dump program"));
+ context = g_option_context_new (_("ICC profile dump program"));
g_option_context_add_main_entries (context, options, NULL);
g_option_context_add_group (context, egg_debug_get_option_group ());
g_option_context_add_group (context, gtk_get_option_group (TRUE));
diff --git a/src/gcm-fix-profile.c b/src/gcm-fix-profile.c
new file mode 100644
index 0000000..9ff0a65
--- /dev/null
+++ b/src/gcm-fix-profile.c
@@ -0,0 +1,90 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2009 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 profile.
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <glib/gi18n.h>
+#include <locale.h>
+#include <lcms.h>
+
+/**
+ * gcm_fix_profile_filename:
+ **/
+static void
+gcm_fix_profile_filename (const gchar *filename, const gchar *description)
+{
+ cmsHPROFILE lcms_profile;
+ lcms_profile = cmsOpenProfileFromFile (filename, "rw");
+ if (lcms_profile == NULL)
+ return;
+ if (description != NULL)
+ _cmsAddTextTag (lcms_profile, icSigProfileDescriptionTag, description);
+ _cmsSaveProfile (lcms_profile, filename);
+ cmsCloseProfile (lcms_profile);
+}
+
+/**
+ * main:
+ **/
+int
+main (int argc, char **argv)
+{
+ guint i;
+ guint retval = 0;
+ GOptionContext *context;
+ gchar **files = NULL;
+ gchar *description = NULL;
+
+ const GOptionEntry options[] = {
+ { "desc", '\0', 0, G_OPTION_ARG_STRING, &description,
+ /* TRANSLATORS: command line option */
+ _("The description for the profile"), NULL },
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
+ /* TRANSLATORS: command line option: a list of icc files to fix */
+ _("Profiles to fix"), NULL },
+ { NULL}
+ };
+
+ setlocale (LC_ALL, "");
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ /* TRANSLATORS: this fixes broken profiles */
+ context = g_option_context_new (_("ICC profile fix program"));
+ g_option_context_add_main_entries (context, options, NULL);
+ g_option_context_parse (context, &argc, &argv, NULL);
+ g_option_context_free (context);
+
+ /* nothing specified */
+ if (files == NULL)
+ goto out;
+
+ /* show each profile */
+ for (i=0; files[i] != NULL; i++)
+ gcm_fix_profile_filename (files[i], description);
+out:
+ g_free (description);
+ g_strfreev (files);
+ return retval;
+}
+
diff --git a/src/gcm-inspect.c b/src/gcm-inspect.c
index 87dd050..25a56ae 100644
--- a/src/gcm-inspect.c
+++ b/src/gcm-inspect.c
@@ -392,10 +392,10 @@ main (int argc, char **argv)
{ "x11", 'x', 0, G_OPTION_ARG_NONE, &x11,
/* TRANSLATORS: command line option */
_("Show X11 properties"), NULL },
- { "device", '\0', 0, G_OPTION_ARG_FILENAME, &sysfs_path,
+ { "device", '\0', 0, G_OPTION_ARG_STRING, &sysfs_path,
/* TRANSLATORS: command line option */
_("Get the profiles for a specific device"), NULL },
- { "type", '\0', 0, G_OPTION_ARG_FILENAME, &type,
+ { "type", '\0', 0, G_OPTION_ARG_STRING, &type,
/* TRANSLATORS: command line option */
_("Get the profiles for a specific device type"), NULL },
{ "dump", 'd', 0, G_OPTION_ARG_NONE, &dump,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]