[gnome-color-manager] Add a trivial binary to dump out a profile to the screen
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add a trivial binary to dump out a profile to the screen
- Date: Fri, 4 Dec 2009 17:41:57 +0000 (UTC)
commit d2282b776d2b3f20c8e93102d6a49cd75cb6e549
Author: Richard Hughes <richard hughsie com>
Date: Fri Dec 4 17:37:03 2009 +0000
Add a trivial binary to dump out a profile to the screen
po/POTFILES.in | 1 +
src/.gitignore | 1 +
src/Makefile.am | 16 ++++++
src/gcm-dump-profile.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 159 insertions(+), 0 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2cf6b5c..19b35dc 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -13,4 +13,5 @@ src/gcm-prefs.c
src/gcm-profile.c
src/gcm-utils.c
src/gcm-session.c
+src/gcm-dump-profile.c
diff --git a/src/.gitignore b/src/.gitignore
index 6d6bbc7..92146d9 100644
--- a/src/.gitignore
+++ b/src/.gitignore
@@ -8,6 +8,7 @@ gcm-prefs
gcm-inspect
gcm-session
gcm-dump-edid
+gcm-dump-profile
gcm-self-test
org.gnome.ColorManager.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 6440611..d03050c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,6 +48,7 @@ libgcmshared_a_CFLAGS = \
noinst_PROGRAMS = \
gcm-inspect \
+ gcm-dump-profile \
gcm-dump-edid
gcm_dump_edid_SOURCES = \
@@ -66,6 +67,21 @@ gcm_dump_edid_LDADD = \
gcm_dump_edid_CFLAGS = \
$(WARNINGFLAGS_C)
+gcm_dump_profile_SOURCES = \
+ gcm-dump-profile.c
+
+gcm_dump_profile_LDADD = \
+ libgcmshared.a \
+ $(GLIB_LIBS) \
+ $(GNOMEDESKTOP_LIBS) \
+ $(GCONF_LIBS) \
+ $(GUDEV_LIBS) \
+ $(XORG_LIBS) \
+ $(DBUS_GLIB_LIBS) \
+ $(GTK_LIBS)
+
+gcm_dump_profile_CFLAGS = \
+ $(WARNINGFLAGS_C)
bin_PROGRAMS = \
gcm-apply \
diff --git a/src/gcm-dump-profile.c b/src/gcm-dump-profile.c
new file mode 100644
index 0000000..e6bf989
--- /dev/null
+++ b/src/gcm-dump-profile.c
@@ -0,0 +1,141 @@
+/* -*- 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 <gtk/gtk.h>
+#include <locale.h>
+
+#include "egg-debug.h"
+
+#include "gcm-profile.h"
+
+/**
+ * gcm_dump_profile_filename:
+ **/
+static gboolean
+gcm_dump_profile_filename (const gchar *filename)
+{
+ gboolean ret;
+ GError *error = NULL;
+ GcmProfile *profile;
+ guint profile_type;
+ guint colorspace;
+ guint size;
+ gchar *description = NULL;
+ gchar *copyright = NULL;
+ gchar *manufacturer = NULL;
+ gchar *model = NULL;
+ gchar *datetime = NULL;
+
+ /* parse profile */
+ profile = gcm_profile_new ();
+ ret = gcm_profile_parse (profile, filename, &error);
+ if (!ret) {
+ egg_warning ("failed to parse: %s", error->message);
+ g_error_free (error);
+ goto out;
+ }
+
+ /* get data */
+ g_object_get (profile,
+ "type", &profile_type,
+ "colorspace", &colorspace,
+ "size", &size,
+ "description", &description,
+ "copyright", ©right,
+ "manufacturer", &manufacturer,
+ "model", &model,
+ "datetime", &datetime,
+ NULL);
+
+ /* print what we know */
+ g_print ("Type:\t%s\n", gcm_profile_type_to_text (profile_type));
+ g_print ("Colorspace:\t%s\n", gcm_profile_colorspace_to_text (colorspace));
+ g_print ("Size:\t%i bytes\n", size);
+ if (description != NULL)
+ g_print ("Description:\t%s\n", description);
+ if (copyright != NULL)
+ g_print ("Copyright:\t%s\n", copyright);
+ if (manufacturer != NULL)
+ g_print ("Manufacturer:\t%s\n", manufacturer);
+ if (model != NULL)
+ g_print ("Model:\t%s\n", model);
+ if (datetime != NULL)
+ g_print ("Created:\t%s\n", datetime);
+
+out:
+ g_object_unref (profile);
+ g_free (description);
+ g_free (copyright);
+ g_free (manufacturer);
+ g_free (model);
+ g_free (datetime);
+ return ret;
+}
+
+/**
+ * main:
+ **/
+int
+main (int argc, char **argv)
+{
+ guint i;
+ guint retval = 0;
+ GOptionContext *context;
+ gchar **files = NULL;
+
+ const GOptionEntry options[] = {
+ { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &files,
+ /* TRANSLATORS: command line option: a list of files to install */
+ _("Profiles to view"), NULL },
+ { NULL}
+ };
+
+ setlocale (LC_ALL, "");
+
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ gtk_init (&argc, &argv);
+
+ /* TRANSLATORS: this just dumps the profile to the screen */
+ context = g_option_context_new (_("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));
+ 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_dump_profile_filename (files[i]);
+out:
+ g_strfreev (files);
+ return retval;
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]