/**
 * mcm_dump_profile_filename:
 **/
static gboolean
mcm_dump_profile_filename (const gchar *filename)
{
	gboolean ret;
	GError *error = NULL;
	McmProfile *profile;
	guint profile_kind;
	guint colorspace;
	guint size;
	gboolean has_vcgt;
	const gchar *description;
	const gchar *copyright;
	const gchar *manufacturer;
	const gchar *model;
	const gchar *datetime;
	GFile *file = NULL;

	/* parse profile */
	profile = mcm_profile_default_new ();
	file = g_file_new_for_path (filename);
	ret = mcm_profile_parse (profile, file, &error);
	if (!ret) {
		egg_warning ("failed to parse: %s", error->message);
		g_error_free (error);
		goto out;
	}

	/* print what we know */
	profile_kind = mcm_profile_get_kind (profile);
	g_print ("Kind:\t%s\n", mcm_profile_kind_to_string (profile_kind));
	colorspace = mcm_profile_get_colorspace (profile);
	g_print ("Colorspace:\t%s\n", mcm_colorspace_to_string (colorspace));
	size = mcm_profile_get_size (profile);
	g_print ("Size:\t%i bytes\n", size);
	has_vcgt = mcm_profile_get_has_vcgt (profile);
	g_print ("Has VCGT:\t%s\n", has_vcgt ? "Yes" : "No");
	description = mcm_profile_get_description (profile);
	if (description != NULL)
		g_print ("Description:\t%s\n", description);
	copyright = mcm_profile_get_copyright (profile);
	if (copyright != NULL)
		g_print ("Copyright:\t%s\n", copyright);
	manufacturer = mcm_profile_get_manufacturer (profile);
	if (manufacturer != NULL)
		g_print ("Manufacturer:\t%s\n", manufacturer);
	model = mcm_profile_get_model (profile);
	if (model != NULL)
		g_print ("Model:\t%s\n", model);
	datetime = mcm_profile_get_datetime (profile);
	if (datetime != NULL)
		g_print ("Created:\t%s\n", datetime);
out:
	if (file != NULL)
		g_object_unref (file);
	g_object_unref (profile);
	return ret;
}
Esempio n. 2
0
/**
 * mcm_prefs_setup_space_combobox:
 **/
static void
mcm_prefs_setup_space_combobox (GtkWidget *widget)
{
	McmProfile *profile;
	guint i;
	const gchar *filename;
	McmColorspace colorspace;
	gboolean has_profile = FALSE;
	gboolean has_vcgt;
	gboolean has_colorspace_description;
	gchar *text = NULL;
	GPtrArray *profile_array = NULL;
	GtkTreeIter iter;

	/* get new list */
	profile_array = mcm_profile_store_get_array (profile_store);

	/* update each list */
	for (i=0; i<profile_array->len; i++) {
		profile = g_ptr_array_index (profile_array, i);

		/* only for correct kind */
		has_vcgt = mcm_profile_get_has_vcgt (profile);
		has_colorspace_description = mcm_profile_has_colorspace_description (profile);
		colorspace = mcm_profile_get_colorspace (profile);
		if (!has_vcgt && has_colorspace_description &&
		    colorspace == MCM_COLORSPACE_RGB) {
			mcm_prefs_combobox_add_profile (widget, profile, &iter);

			/* set active option */
			filename = mcm_profile_get_filename (profile);
			if (g_strcmp0 (filename, profile_filename) == 0)
				gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
			has_profile = TRUE;
		}
	}
	if (!has_profile) {
		/* TRANSLATORS: this is when there are no profiles that can be used; the search term is either "RGB" or "CMYK" */
		text = g_strdup_printf (_("No %s color spaces available"),
					mcm_colorspace_to_localised_string (MCM_COLORSPACE_RGB));
		gtk_combo_box_append_text (GTK_COMBO_BOX(widget), text);
		gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
		gtk_widget_set_sensitive (widget, FALSE);
	}
	if (profile_array != NULL)
		g_ptr_array_unref (profile_array);
	g_free (text);
}