[gnome-color-manager: 65/80] trivial: move GcmProfileStore to libcolor-glib
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager: 65/80] trivial: move GcmProfileStore to libcolor-glib
- Date: Mon, 19 Jul 2010 11:37:55 +0000 (UTC)
commit 5b551de3ef85ee0dd9e2296d18f427b403938930
Author: Richard Hughes <richard hughsie com>
Date: Sun Jul 18 13:09:14 2010 +0100
trivial: move GcmProfileStore to libcolor-glib
libcolor-glib/Makefile.am | 3 ++
libcolor-glib/gcm-clut.c | 1 -
libcolor-glib/gcm-enum.h | 4 ++
{src => libcolor-glib}/gcm-profile-store.c | 52 ++++++++++++++++------------
{src => libcolor-glib}/gcm-profile-store.h | 4 ++
libcolor-glib/gcm-profile.c | 1 -
libcolor-glib/gcm-self-test.c | 36 +++++++++++++++++++
libcolor-glib/libcolor-glib.h | 1 +
src/Makefile.am | 2 -
src/cc-color-panel.c | 8 ++++-
src/gcm-calibrate.c | 25 +++++++++++++-
src/gcm-self-test.c | 35 -------------------
src/gcm-session.c | 9 ++++-
src/gcm-utils.c | 23 ------------
src/gcm-utils.h | 2 -
src/gcm-viewer.c | 9 ++++-
16 files changed, 125 insertions(+), 90 deletions(-)
---
diff --git a/libcolor-glib/Makefile.am b/libcolor-glib/Makefile.am
index 9f81946..b9c40ae 100644
--- a/libcolor-glib/Makefile.am
+++ b/libcolor-glib/Makefile.am
@@ -41,6 +41,7 @@ libcolor_glib_include_HEADERS = \
gcm-edid.h \
gcm-enum.h \
gcm-profile.h \
+ gcm-profile-store.h \
gcm-dmi.h \
gcm-xserver.h \
gcm-version.h \
@@ -80,6 +81,8 @@ libcolor_glib_la_SOURCES = \
gcm-enum.h \
gcm-xyz.c \
gcm-xyz.h \
+ gcm-profile-store.c \
+ gcm-profile-store.h \
gcm-xserver.c \
gcm-xserver.h \
gcm-version.h \
diff --git a/libcolor-glib/gcm-clut.c b/libcolor-glib/gcm-clut.c
index 86f2003..96575ce 100644
--- a/libcolor-glib/gcm-clut.c
+++ b/libcolor-glib/gcm-clut.c
@@ -34,7 +34,6 @@
#include <gio/gio.h>
#include "gcm-clut.h"
-//#include "gcm-utils.h"
#include "egg-debug.h"
diff --git a/libcolor-glib/gcm-enum.h b/libcolor-glib/gcm-enum.h
index 920abc6..9ea48f4 100644
--- a/libcolor-glib/gcm-enum.h
+++ b/libcolor-glib/gcm-enum.h
@@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#if !defined (__LIBCOLOR_GLIB_H_INSIDE__) && !defined (LIBCOLOR_GLIB_COMPILATION)
+#error "Only <libcolor-glib.h> can be included directly."
+#endif
+
#ifndef __GCM_ENUM_H
#define __GCM_ENUM_H
diff --git a/src/gcm-profile-store.c b/libcolor-glib/gcm-profile-store.c
similarity index 95%
rename from src/gcm-profile-store.c
rename to libcolor-glib/gcm-profile-store.c
index a1d9922..71f0e56 100644
--- a/src/gcm-profile-store.c
+++ b/libcolor-glib/gcm-profile-store.c
@@ -33,7 +33,6 @@
#include <gio/gio.h>
#include "gcm-profile-store.h"
-#include "gcm-utils.h"
#include "egg-debug.h"
@@ -52,7 +51,6 @@ struct _GcmProfileStorePrivate
GPtrArray *monitor_array;
GPtrArray *directory_array;
GVolumeMonitor *volume_monitor;
- GSettings *settings;
};
enum {
@@ -324,16 +322,9 @@ gcm_profile_store_search_path (GcmProfileStore *profile_store, const gchar *path
/* add if correct type */
if (g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
- /* check the file actually is a profile */
+ /* check the file actually is a profile when we try to parse it */
file = g_file_new_for_path (path);
- ret = gcm_utils_is_icc_profile (file);
- if (ret) {
- success = gcm_profile_store_add_profile (profile_store, file);
- goto out;
- }
-
- /* invalid file */
- egg_debug ("not recognized as ICC profile: %s", path);
+ success = gcm_profile_store_add_profile (profile_store, file);
goto out;
}
@@ -488,6 +479,29 @@ gcm_profile_store_add_profiles_from_mounted_volumes (GcmProfileStore *profile_st
}
/**
+ * gcm_profile_store_mkdir_with_parents:
+ **/
+static gboolean
+gcm_profile_store_mkdir_with_parents (const gchar *filename, GError **error)
+{
+ gboolean ret;
+ GFile *file = NULL;
+
+ /* ensure desination exists */
+ ret = g_file_test (filename, G_FILE_TEST_EXISTS);
+ if (!ret) {
+ file = g_file_new_for_path (filename);
+ ret = g_file_make_directory_with_parents (file, NULL, error);
+ if (!ret)
+ goto out;
+ }
+out:
+ if (file != NULL)
+ g_object_unref (file);
+ return ret;
+}
+
+/**
* gcm_profile_store_search:
*
* Return value: if any profile were added
@@ -499,7 +513,6 @@ gcm_profile_store_search (GcmProfileStore *profile_store, GcmProfileSearchFlags
gboolean ret;
gboolean success = FALSE;
GError *error;
- GcmProfileStorePrivate *priv = profile_store->priv;
/* get OSX and Linux system-wide profiles */
if (flags == GCM_PROFILE_STORE_SEARCH_ALL ||
@@ -518,21 +531,18 @@ gcm_profile_store_search (GcmProfileStore *profile_store, GcmProfileSearchFlags
/* get OSX and Windows system-wide profiles when using Linux */
if (flags == GCM_PROFILE_STORE_SEARCH_ALL ||
flags & GCM_PROFILE_STORE_SEARCH_VOLUMES) {
- ret = g_settings_get_boolean (priv->settings, GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES);
- if (ret) {
- ret = gcm_profile_store_add_profiles_from_mounted_volumes (profile_store);
- if (ret)
- success = TRUE;
- }
+ ret = gcm_profile_store_add_profiles_from_mounted_volumes (profile_store);
+ if (ret)
+ success = TRUE;
}
/* get Linux per-user profiles */
if (flags == GCM_PROFILE_STORE_SEARCH_ALL ||
flags & GCM_PROFILE_STORE_SEARCH_USER) {
path = g_build_filename (g_get_user_data_dir (), "icc", NULL);
- ret = gcm_utils_mkdir_with_parents (path, &error);
+ ret = gcm_profile_store_mkdir_with_parents (path, &error);
if (!ret) {
- egg_error ("failed to create directory on startup: %s", error->message);
+ egg_warning ("failed to create directory on startup: %s", error->message);
g_error_free (error);
} else {
ret = gcm_profile_store_search_path (profile_store, path);
@@ -626,7 +636,6 @@ gcm_profile_store_init (GcmProfileStore *profile_store)
profile_store->priv->profile_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
profile_store->priv->monitor_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
profile_store->priv->directory_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
- profile_store->priv->settings = g_settings_new (GCM_SETTINGS_SCHEMA);
/* watch for volumes to be connected */
profile_store->priv->volume_monitor = g_volume_monitor_get ();
@@ -649,7 +658,6 @@ gcm_profile_store_finalize (GObject *object)
g_ptr_array_unref (priv->monitor_array);
g_ptr_array_unref (priv->directory_array);
g_object_unref (priv->volume_monitor);
- g_object_unref (priv->settings);
G_OBJECT_CLASS (gcm_profile_store_parent_class)->finalize (object);
}
diff --git a/src/gcm-profile-store.h b/libcolor-glib/gcm-profile-store.h
similarity index 95%
rename from src/gcm-profile-store.h
rename to libcolor-glib/gcm-profile-store.h
index 5a648e6..ee23c51 100644
--- a/src/gcm-profile-store.h
+++ b/libcolor-glib/gcm-profile-store.h
@@ -19,6 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#if !defined (__LIBCOLOR_GLIB_H_INSIDE__) && !defined (LIBCOLOR_GLIB_COMPILATION)
+#error "Only <libcolor-glib.h> can be included directly."
+#endif
+
#ifndef __GCM_PROFILE_STORE_H
#define __GCM_PROFILE_STORE_H
diff --git a/libcolor-glib/gcm-profile.c b/libcolor-glib/gcm-profile.c
index afee80e..a86395e 100644
--- a/libcolor-glib/gcm-profile.c
+++ b/libcolor-glib/gcm-profile.c
@@ -37,7 +37,6 @@
#include "egg-debug.h"
#include "gcm-profile.h"
-//#include "gcm-utils.h"
#include "gcm-xyz.h"
static void gcm_profile_finalize (GObject *object);
diff --git a/libcolor-glib/gcm-self-test.c b/libcolor-glib/gcm-self-test.c
index f3b1f34..926c536 100644
--- a/libcolor-glib/gcm-self-test.c
+++ b/libcolor-glib/gcm-self-test.c
@@ -495,6 +495,41 @@ gcm_test_xyz_func (void)
g_object_unref (xyz);
}
+
+static void
+gcm_test_profile_store_func (void)
+{
+ GcmProfileStore *store;
+ GPtrArray *array;
+ GcmProfile *profile;
+ gboolean ret;
+
+ store = gcm_profile_store_new ();
+ g_assert (store != NULL);
+
+ /* add test files */
+ ret = gcm_profile_store_search_path (store, TESTDATADIR "/.");
+ g_assert (ret);
+
+ /* profile does not exist */
+ profile = gcm_profile_store_get_by_filename (store, "xxxxxxxxx");
+ g_assert (profile == NULL);
+
+ /* profile does exist */
+ profile = gcm_profile_store_get_by_checksum (store, "8e2aed5dac6f8b5d8da75610a65b7f27");
+ g_assert (profile != NULL);
+ g_assert_cmpstr (gcm_profile_get_checksum (profile), ==, "8e2aed5dac6f8b5d8da75610a65b7f27");
+ g_object_unref (profile);
+
+ /* get array of profiles */
+ array = gcm_profile_store_get_array (store);
+ g_assert (array != NULL);
+ g_assert_cmpint (array->len, ==, 3);
+ g_ptr_array_unref (array);
+
+ g_object_unref (store);
+}
+
int
main (int argc, char **argv)
{
@@ -513,6 +548,7 @@ main (int argc, char **argv)
g_test_add_func ("/libcolor-glib/clut", gcm_test_clut_func);
g_test_add_func ("/libcolor-glib/xyz", gcm_test_xyz_func);
g_test_add_func ("/libcolor-glib/dmi", gcm_test_dmi_func);
+ g_test_add_func ("/libcolor-glib/profile_store", gcm_test_profile_store_func);
return g_test_run ();
}
diff --git a/libcolor-glib/libcolor-glib.h b/libcolor-glib/libcolor-glib.h
index 84926b2..18a2944 100644
--- a/libcolor-glib/libcolor-glib.h
+++ b/libcolor-glib/libcolor-glib.h
@@ -42,6 +42,7 @@
#include <gcm-clut.h>
#include <gcm-dmi.h>
#include <gcm-xserver.h>
+#include <gcm-profile-store.h>
#undef __LIBCOLOR_GLIB_H_INSIDE__
diff --git a/src/Makefile.am b/src/Makefile.am
index c8bc7a1..839a5b4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -70,8 +70,6 @@ libgcmshared_a_SOURCES = \
gcm-trc-widget.h \
gcm-gamma-widget.c \
gcm-gamma-widget.h \
- gcm-profile-store.c \
- gcm-profile-store.h \
gcm-calibrate.c \
gcm-calibrate.h \
gcm-calibrate-argyll.c \
diff --git a/src/cc-color-panel.c b/src/cc-color-panel.c
index 4a6081c..31a4649 100644
--- a/src/cc-color-panel.c
+++ b/src/cc-color-panel.c
@@ -2317,9 +2317,15 @@ cc_color_panel_startup_idle_cb (CcColorPanel *panel)
gchar *colorspace_cmyk;
gint intent_display = -1;
gint intent_softproof = -1;
+ GcmProfileSearchFlags search_flags = GCM_PROFILE_STORE_SEARCH_ALL;
+
+ /* volume checking is optional */
+ ret = g_settings_get_boolean (panel->priv->settings, GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES);
+ if (!ret)
+ search_flags &= ~GCM_PROFILE_STORE_SEARCH_VOLUMES;
/* search the disk for profiles */
- gcm_profile_store_search (panel->priv->profile_store, GCM_PROFILE_STORE_SEARCH_ALL);
+ gcm_profile_store_search (panel->priv->profile_store, search_flags);
g_signal_connect (panel->priv->profile_store, "changed", G_CALLBACK(cc_color_panel_profile_store_changed_cb), panel);
/* setup RGB combobox */
diff --git a/src/gcm-calibrate.c b/src/gcm-calibrate.c
index e2af3b0..3658584 100644
--- a/src/gcm-calibrate.c
+++ b/src/gcm-calibrate.c
@@ -104,6 +104,29 @@ enum {
G_DEFINE_TYPE (GcmCalibrate, gcm_calibrate, G_TYPE_OBJECT)
/**
+ * gcm_calibrate_mkdir_with_parents:
+ **/
+static gboolean
+gcm_calibrate_mkdir_with_parents (const gchar *filename, GError **error)
+{
+ gboolean ret;
+ GFile *file = NULL;
+
+ /* ensure desination exists */
+ ret = g_file_test (filename, G_FILE_TEST_EXISTS);
+ if (!ret) {
+ file = g_file_new_for_path (filename);
+ ret = g_file_make_directory_with_parents (file, NULL, error);
+ if (!ret)
+ goto out;
+ }
+out:
+ if (file != NULL)
+ g_object_unref (file);
+ return ret;
+}
+
+/**
* gcm_calibrate_get_model_fallback:
**/
const gchar *
@@ -439,7 +462,7 @@ gcm_calibrate_set_working_path (GcmCalibrate *calibrate, GError **error)
timespec = gcm_calibrate_get_time ();
folder = g_strjoin (" - ", priv->basename, timespec, NULL);
priv->working_path = g_build_filename (g_get_user_config_dir (), "gnome-color-manager", "calibration", folder, NULL);
- ret = gcm_utils_mkdir_with_parents (priv->working_path, error);
+ ret = gcm_calibrate_mkdir_with_parents (priv->working_path, error);
g_free (timespec);
g_free (folder);
return ret;
diff --git a/src/gcm-self-test.c b/src/gcm-self-test.c
index c7b6750..d151d8a 100644
--- a/src/gcm-self-test.c
+++ b/src/gcm-self-test.c
@@ -592,40 +592,6 @@ gcm_test_print_func (void)
}
static void
-gcm_test_profile_store_func (void)
-{
- GcmProfileStore *store;
- GPtrArray *array;
- GcmProfile *profile;
- gboolean ret;
-
- store = gcm_profile_store_new ();
- g_assert (store != NULL);
-
- /* add test files */
- ret = gcm_profile_store_search_path (store, TESTDATADIR "/.");
- g_assert (ret);
-
- /* profile does not exist */
- profile = gcm_profile_store_get_by_filename (store, "xxxxxxxxx");
- g_assert (profile == NULL);
-
- /* profile does exist */
- profile = gcm_profile_store_get_by_checksum (store, "8e2aed5dac6f8b5d8da75610a65b7f27");
- g_assert (profile != NULL);
- g_assert_cmpstr (gcm_profile_get_checksum (profile), ==, "8e2aed5dac6f8b5d8da75610a65b7f27");
- g_object_unref (profile);
-
- /* get array of profiles */
- array = gcm_profile_store_get_array (store);
- g_assert (array != NULL);
- g_assert_cmpint (array->len, ==, 3);
- g_ptr_array_unref (array);
-
- g_object_unref (store);
-}
-
-static void
gcm_test_trc_widget_func (void)
{
GtkWidget *widget;
@@ -844,7 +810,6 @@ main (int argc, char **argv)
g_test_add_func ("/color/exif", gcm_test_exif_func);
g_test_add_func ("/color/utils", gcm_test_utils_func);
g_test_add_func ("/color/device", gcm_test_device_func);
- g_test_add_func ("/color/profile_store", gcm_test_profile_store_func);
g_test_add_func ("/color/calibrate_dialog", gcm_test_calibrate_dialog_func);
if (g_test_thorough ()) {
g_test_add_func ("/color/brightness", gcm_test_brightness_func);
diff --git a/src/gcm-session.c b/src/gcm-session.c
index 6090b3c..eef3dcd 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -700,6 +700,7 @@ main (int argc, char *argv[])
guint poll_id = 0;
GFile *file = NULL;
gchar *introspection_data = NULL;
+ GcmProfileSearchFlags search_flags = GCM_PROFILE_STORE_SEARCH_ALL;
const GOptionEntry options[] = {
{ "no-timed-exit", '\0', 0, G_OPTION_ARG_NONE, &no_timed_exit,
@@ -744,7 +745,13 @@ main (int argc, char *argv[])
/* have access to all profiles */
profile_store = gcm_profile_store_new ();
- gcm_profile_store_search (profile_store, GCM_PROFILE_STORE_SEARCH_ALL);
+
+ /* volume checking is optional */
+ ret = g_settings_get_boolean (settings, GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES);
+ if (!ret)
+ search_flags &= ~GCM_PROFILE_STORE_SEARCH_VOLUMES;
+
+ gcm_profile_store_search (profile_store, search_flags);
timer = g_timer_new ();
/* get all connected devices */
diff --git a/src/gcm-utils.c b/src/gcm-utils.c
index a2e0468..ee89a00 100644
--- a/src/gcm-utils.c
+++ b/src/gcm-utils.c
@@ -296,29 +296,6 @@ gcm_utils_output_is_lcd (const gchar *output_name)
}
/**
- * gcm_utils_mkdir_with_parents:
- **/
-gboolean
-gcm_utils_mkdir_with_parents (const gchar *filename, GError **error)
-{
- gboolean ret;
- GFile *file = NULL;
-
- /* ensure desination exists */
- ret = g_file_test (filename, G_FILE_TEST_EXISTS);
- if (!ret) {
- file = g_file_new_for_path (filename);
- ret = g_file_make_directory_with_parents (file, NULL, error);
- if (!ret)
- goto out;
- }
-out:
- if (file != NULL)
- g_object_unref (file);
- return ret;
-}
-
-/**
* gcm_utils_mkdir_for_filename:
**/
gboolean
diff --git a/src/gcm-utils.h b/src/gcm-utils.h
index d4a9268..a2bcd97 100644
--- a/src/gcm-utils.h
+++ b/src/gcm-utils.h
@@ -83,8 +83,6 @@
gboolean gcm_utils_mkdir_for_filename (const gchar *filename,
GError **error);
-gboolean gcm_utils_mkdir_with_parents (const gchar *filename,
- GError **error);
gboolean gcm_utils_mkdir_and_copy (GFile *source,
GFile *destination,
GError **error);
diff --git a/src/gcm-viewer.c b/src/gcm-viewer.c
index 2a44c5b..67fc46a 100644
--- a/src/gcm-viewer.c
+++ b/src/gcm-viewer.c
@@ -854,12 +854,19 @@ gcm_viewer_set_combo_simple_text (GtkWidget *combo_box)
static gboolean
gcm_viewer_startup_phase1_idle_cb (GcmViewerPrivate *viewer)
{
+ gboolean ret;
GtkWidget *widget;
GtkTreeSelection *selection;
GtkTreePath *path;
+ GcmProfileSearchFlags search_flags = GCM_PROFILE_STORE_SEARCH_ALL;
+
+ /* volume checking is optional */
+ ret = g_settings_get_boolean (viewer->settings, GCM_SETTINGS_USE_PROFILES_FROM_VOLUMES);
+ if (!ret)
+ search_flags &= ~GCM_PROFILE_STORE_SEARCH_VOLUMES;
/* search the disk for profiles */
- gcm_profile_store_search (viewer->profile_store, GCM_PROFILE_STORE_SEARCH_ALL);
+ gcm_profile_store_search (viewer->profile_store, search_flags);
g_signal_connect (viewer->profile_store, "changed", G_CALLBACK(gcm_viewer_profile_store_changed_cb), viewer);
/* update list of profiles */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]