[gnome-color-manager/colord: 34/72] Port gcm-picker to colord
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager/colord: 34/72] Port gcm-picker to colord
- Date: Tue, 8 Mar 2011 11:26:12 +0000 (UTC)
commit a46124cec092ae32d66d036f4e071add828c007a
Author: Richard Hughes <richard hughsie com>
Date: Mon Jan 31 10:50:35 2011 +0000
Port gcm-picker to colord
src/gcm-picker.c | 70 ++++++++++++++++++++++++++++++++++--------------------
src/gcm-utils.c | 2 +-
2 files changed, 45 insertions(+), 27 deletions(-)
---
diff --git a/src/gcm-picker.c b/src/gcm-picker.c
index 6e96fb3..8f4b2bb 100644
--- a/src/gcm-picker.c
+++ b/src/gcm-picker.c
@@ -34,23 +34,22 @@
#include "gcm-calibrate-argyll.h"
#include "gcm-sensor-client.h"
-#include "gcm-profile-store.h"
#include "gcm-utils.h"
#include "gcm-color.h"
#include "gcm-debug.h"
-static GtkBuilder *builder = NULL;
-static GtkWidget *info_bar_hardware = NULL;
-static GtkWidget *info_bar_hardware_label = NULL;
-static GcmCalibrate *calibrate = NULL;
-static GcmProfileStore *profile_store = NULL;
+static CdClient *client = NULL;
static const gchar *profile_filename = NULL;
static gboolean done_measure = FALSE;
-static GcmSensor *sensor = NULL;
+static GcmCalibrate *calibrate = NULL;
static GcmColorXYZ last_sample;
+static GcmSensorClient *sensor_client = NULL;
+static GcmSensor *sensor = NULL;
static gdouble last_ambient = -1.0f;
+static GtkBuilder *builder = NULL;
+static GtkWidget *info_bar_hardware_label = NULL;
+static GtkWidget *info_bar_hardware = NULL;
static guint xid = 0;
-static GcmSensorClient *sensor_client = NULL;
enum {
GCM_PREFS_COMBO_COLUMN_TEXT,
@@ -401,7 +400,7 @@ gcm_prefs_space_combo_changed_cb (GtkWidget *widget, gpointer data)
gboolean ret;
GtkTreeIter iter;
GtkTreeModel *model;
- GcmProfile *profile = NULL;
+ CdProfile *profile = NULL;
/* no selection */
ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX(widget), &iter);
@@ -416,7 +415,7 @@ gcm_prefs_space_combo_changed_cb (GtkWidget *widget, gpointer data)
if (profile == NULL)
goto out;
- profile_filename = gcm_profile_get_filename (profile);
+ profile_filename = cd_profile_get_filename (profile);
g_debug ("changed picker space %s", profile_filename);
gcm_picker_refresh_results ();
@@ -434,7 +433,7 @@ gcm_prefs_set_combo_simple_text (GtkWidget *combo_box)
GtkCellRenderer *renderer;
GtkListStore *store;
- store = gtk_list_store_new (2, G_TYPE_STRING, GCM_TYPE_PROFILE);
+ store = gtk_list_store_new (2, G_TYPE_STRING, CD_TYPE_PROFILE);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), GCM_PREFS_COMBO_COLUMN_TEXT, GTK_SORT_ASCENDING);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (store));
g_object_unref (store);
@@ -455,7 +454,7 @@ gcm_prefs_set_combo_simple_text (GtkWidget *combo_box)
* gcm_prefs_combobox_add_profile:
**/
static void
-gcm_prefs_combobox_add_profile (GtkWidget *widget, GcmProfile *profile, GtkTreeIter *iter)
+gcm_prefs_combobox_add_profile (GtkWidget *widget, CdProfile *profile, GtkTreeIter *iter)
{
GtkTreeModel *model;
GtkTreeIter iter_tmp;
@@ -467,7 +466,7 @@ gcm_prefs_combobox_add_profile (GtkWidget *widget, GcmProfile *profile, GtkTreeI
/* also add profile */
model = gtk_combo_box_get_model (GTK_COMBO_BOX(widget));
- description = gcm_profile_get_description (profile);
+ description = cd_profile_get_title (profile);
gtk_list_store_append (GTK_LIST_STORE(model), iter);
gtk_list_store_set (GTK_LIST_STORE(model), iter,
GCM_PREFS_COMBO_COLUMN_TEXT, description,
@@ -481,35 +480,44 @@ gcm_prefs_combobox_add_profile (GtkWidget *widget, GcmProfile *profile, GtkTreeI
static void
gcm_prefs_setup_space_combobox (GtkWidget *widget)
{
- GcmProfile *profile;
- guint i;
- const gchar *filename;
CdColorspace colorspace;
+ CdProfile *profile;
+ const gchar *filename;
+ gboolean has_colorspace_description;
gboolean has_profile = FALSE;
gboolean has_vcgt;
- gboolean has_colorspace_description;
gchar *text = NULL;
+ GError *error = NULL;
GPtrArray *profile_array = NULL;
GtkTreeIter iter;
GtkTreeModel *model;
+ guint i;
/* get new list */
-// profile_array = gcm_profile_store_get_array (profile_store);
+ profile_array = cd_client_get_profiles_sync (client,
+ NULL,
+ &error);
+ if (profile_array == NULL) {
+ g_warning ("failed to get profiles: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
/* 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 = gcm_profile_get_has_vcgt (profile);
+ has_vcgt = cd_profile_get_has_vcgt (profile);
has_colorspace_description = gcm_profile_has_colorspace_description (profile);
- colorspace = gcm_profile_get_colorspace (profile);
+ colorspace = cd_profile_get_colorspace (profile);
if (!has_vcgt && has_colorspace_description &&
colorspace == CD_COLORSPACE_RGB) {
gcm_prefs_combobox_add_profile (widget, profile, &iter);
/* set active option */
- filename = gcm_profile_get_filename (profile);
+ filename = cd_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;
@@ -527,6 +535,7 @@ gcm_prefs_setup_space_combobox (GtkWidget *widget)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0);
gtk_widget_set_sensitive (widget, FALSE);
}
+out:
if (profile_array != NULL)
g_ptr_array_unref (profile_array);
g_free (text);
@@ -549,10 +558,11 @@ gcm_picker_activate_cb (GApplication *application, gpointer user_data)
static void
gcm_picker_startup_cb (GApplication *application, gpointer user_data)
{
- guint retval = 0;
+ gboolean ret;
GError *error = NULL;
GtkWidget *main_window;
GtkWidget *widget;
+ guint retval = 0;
/* get UI */
builder = gtk_builder_new ();
@@ -622,8 +632,16 @@ gcm_picker_startup_cb (GApplication *application, gpointer user_data)
gcm_picker_sensor_client_setup_ui (sensor_client);
/* maintain a list of profiles */
- profile_store = gcm_profile_store_new ();
- gcm_profile_store_search (profile_store);
+ client = cd_client_new ();
+ ret = cd_client_connect_sync (client,
+ NULL,
+ &error);
+ if (!ret) {
+ g_warning ("failed to connect to colord: %s",
+ error->message);
+ g_error_free (error);
+ goto out;
+ }
/* default to AdobeRGB */
profile_filename = "/usr/share/color/icc/Argyll/ClayRGB1998.icm";
@@ -696,8 +714,8 @@ main (int argc, char *argv[])
status = g_application_run (G_APPLICATION (application), argc, argv);
g_object_unref (application);
- if (profile_store != NULL)
- g_object_unref (profile_store);
+ if (client != NULL)
+ g_object_unref (client);
if (sensor_client != NULL)
g_object_unref (sensor_client);
if (calibrate != NULL)
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index 1b346d8..057ca97 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -551,7 +551,7 @@ gcm_profile_has_colorspace_description (CdProfile *profile)
CdColorspace colorspace;
const gchar *description;
- g_return_val_if_fail (GCM_IS_PROFILE (profile), FALSE);
+ g_return_val_if_fail (CD_IS_PROFILE (profile), FALSE);
/* for each profile type */
colorspace = cd_profile_get_colorspace (profile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]