summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/colord/cd-self-test.c12
-rw-r--r--src/cd-profile-array.c37
-rw-r--r--src/org.freedesktop.ColorManager.xml3
3 files changed, 51 insertions, 1 deletions
diff --git a/lib/colord/cd-self-test.c b/lib/colord/cd-self-test.c
index 302c595..2af972c 100644
--- a/lib/colord/cd-self-test.c
+++ b/lib/colord/cd-self-test.c
@@ -704,6 +704,7 @@ colord_profile_file_func (void)
CdProfile *profile;
CdProfile *profile_tmp;
gboolean ret;
+ gchar *basename;
gchar *filename;
gchar *profile_id;
GError *error = NULL;
@@ -761,6 +762,16 @@ colord_profile_file_func (void)
g_assert_cmpstr (cd_profile_get_id (profile), ==, profile_id);
g_assert_cmpstr (cd_profile_get_format (profile), ==, "ColorSpace..");
+ /* check we can find profile based on basename */
+ basename = g_path_get_basename (filename);
+ profile_tmp = cd_client_find_profile_by_filename_sync (client,
+ basename,
+ NULL,
+ &error);
+ g_assert_no_error (error);
+ g_assert (profile_tmp != NULL);
+ g_object_unref (profile_tmp);
+
/* check we can find profile based on filename */
profile_tmp = cd_client_find_profile_by_filename_sync (client,
filename,
@@ -803,6 +814,7 @@ colord_profile_file_func (void)
g_assert (ret);
g_free (profile_id);
+ g_free (basename);
g_free (filename);
g_hash_table_unref (profile_props);
g_object_unref (profile);
diff --git a/src/cd-profile-array.c b/src/cd-profile-array.c
index 2386595..7e3f253 100644
--- a/src/cd-profile-array.c
+++ b/src/cd-profile-array.c
@@ -107,6 +107,34 @@ out:
/**
* cd_profile_array_get_by_filename:
**/
+static CdProfile *
+cd_profile_array_get_by_basename (CdProfileArray *profile_array,
+ const gchar *filename)
+{
+ CdProfileArrayPrivate *priv = profile_array->priv;
+ CdProfile *profile = NULL;
+ CdProfile *profile_tmp;
+ const gchar *tmp;
+ gchar *basename;
+ guint i;
+
+ /* find profile */
+ for (i = 0; i < priv->array->len && profile == NULL; i++) {
+ profile_tmp = g_ptr_array_index (priv->array, i);
+ tmp = cd_profile_get_filename (profile_tmp);
+ if (tmp == NULL)
+ continue;
+ basename = g_path_get_basename (tmp);
+ if (g_strcmp0 (basename, filename) == 0)
+ profile = g_object_ref (profile_tmp);
+ g_free (basename);
+ }
+ return profile;
+}
+
+/**
+ * cd_profile_array_get_by_filename:
+ **/
CdProfile *
cd_profile_array_get_by_filename (CdProfileArray *profile_array,
const gchar *filename)
@@ -116,6 +144,14 @@ cd_profile_array_get_by_filename (CdProfileArray *profile_array,
CdProfile *profile_tmp;
guint i;
+ g_return_val_if_fail (filename != NULL, NULL);
+
+ /* support getting the file without the path */
+ if (filename[0] != '/') {
+ profile = cd_profile_array_get_by_basename (profile_array, filename);
+ goto out;
+ }
+
/* find profile */
for (i = 0; i < priv->array->len; i++) {
profile_tmp = g_ptr_array_index (priv->array, i);
@@ -125,6 +161,7 @@ cd_profile_array_get_by_filename (CdProfileArray *profile_array,
break;
}
}
+out:
return profile;
}
diff --git a/src/org.freedesktop.ColorManager.xml b/src/org.freedesktop.ColorManager.xml
index ba59e03..bf976b3 100644
--- a/src/org.freedesktop.ColorManager.xml
+++ b/src/org.freedesktop.ColorManager.xml
@@ -266,7 +266,8 @@
<doc:doc>
<doc:description>
<doc:para>
- Gets a profile path for the profile filename.
+ Gets a profile path for the profile filename, either a fully-qualified
+ filename with path or just the basename of the profile.
</doc:para>
</doc:description>
</doc:doc>