aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-11-02 02:44:23 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-11-02 02:46:03 +0800
commit7d20b8fd5fd28a90852c737f35cef7ba03a2c116 (patch)
tree0803b787043a9bb825c59ffbbda2da8b328f48a6 /e-util
parent966c22cc9440851d166a530c7e187e0f80633c57 (diff)
downloadgsoc2013-evolution-7d20b8fd5fd28a90852c737f35cef7ba03a2c116.tar
gsoc2013-evolution-7d20b8fd5fd28a90852c737f35cef7ba03a2c116.tar.gz
gsoc2013-evolution-7d20b8fd5fd28a90852c737f35cef7ba03a2c116.tar.bz2
gsoc2013-evolution-7d20b8fd5fd28a90852c737f35cef7ba03a2c116.tar.lz
gsoc2013-evolution-7d20b8fd5fd28a90852c737f35cef7ba03a2c116.tar.xz
gsoc2013-evolution-7d20b8fd5fd28a90852c737f35cef7ba03a2c116.tar.zst
gsoc2013-evolution-7d20b8fd5fd28a90852c737f35cef7ba03a2c116.zip
Utilize the new ESourceSelector:primary-selection property.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c81
-rw-r--r--e-util/e-util.h16
2 files changed, 91 insertions, 6 deletions
diff --git a/e-util/e-util.c b/e-util/e-util.c
index f27b3f3660..abc6ccc377 100644
--- a/e-util/e-util.c
+++ b/e-util/e-util.c
@@ -1507,7 +1507,7 @@ e_util_set_source_combo_box_list (GtkWidget *source_combo_box,
* @binding: a #GBinding
* @source_value: a #GValue of type #GDK_TYPE_COLOR
* @target_value: a #GValue of type #G_TYPE_STRING
- * @user_data: not used
+ * @not_used: not used
*
* Transforms a #GdkColor value to a color string specification.
*
@@ -1517,7 +1517,7 @@ gboolean
e_binding_transform_color_to_string (GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data)
+ gpointer not_used)
{
const GdkColor *color;
gchar *string;
@@ -1537,7 +1537,7 @@ e_binding_transform_color_to_string (GBinding *binding,
* @binding: a #GBinding
* @source_value: a #GValue of type #G_TYPE_STRING
* @target_value: a #GValue of type #GDK_TYPE_COLOR
- * @user_data: not used
+ * @not_used: not used
*
* Transforms a color string specification to a #GdkColor.
*
@@ -1547,7 +1547,7 @@ gboolean
e_binding_transform_string_to_color (GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data)
+ gpointer not_used)
{
GdkColor color;
const gchar *string;
@@ -1563,3 +1563,76 @@ e_binding_transform_string_to_color (GBinding *binding,
return success;
}
+
+/**
+ * e_binding_transform_source_to_uid:
+ * @binding: a #GBinding
+ * @source_value: a #GValue of type #E_TYPE_SOURCE
+ * @target_value: a #GValue of type #G_TYPE_STRING
+ * @source_list: an #ESourceList
+ *
+ * Transforms an #ESource object to its UID string.
+ *
+ * Returns: %TRUE if @source_value was an #ESource object
+ **/
+gboolean
+e_binding_transform_source_to_uid (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list)
+{
+ ESource *source;
+ const gchar *string;
+ gboolean success = FALSE;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), FALSE);
+
+ source = g_value_get_object (source_value);
+ if (E_IS_SOURCE (source)) {
+ string = e_source_peek_uid (source);
+ g_value_set_string (target_value, string);
+ success = TRUE;
+ }
+
+ return success;
+}
+
+/**
+ * e_binding_transform_uid_to_source:
+ * @binding: a #GBinding
+ * @source_value: a #GValue of type #G_TYPE_STRING
+ * @target_value: a #GValue of type #E_TYPE_SOURCe
+ * @source_list: an #ESourceList
+ *
+ * Transforms an #ESource UID string to the corresponding #ESource object
+ * in @source_list.
+ *
+ * Returns: %TRUE if @source_list had an #ESource object with a matching
+ * UID string
+ **/
+gboolean
+e_binding_transform_uid_to_source (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list)
+{
+ ESource *source;
+ const gchar *string;
+ gboolean success = FALSE;
+
+ g_return_val_if_fail (G_IS_BINDING (binding), FALSE);
+ g_return_val_if_fail (E_IS_SOURCE_LIST (source_list), FALSE);
+
+ string = g_value_get_string (source_value);
+ if (string == NULL || *string == '\0')
+ return FALSE;
+
+ source = e_source_list_peek_source_by_uid (source_list, string);
+ if (source != NULL) {
+ g_value_set_object (target_value, source);
+ success = TRUE;
+ }
+
+ return success;
+}
diff --git a/e-util/e-util.h b/e-util/e-util.h
index d4f29c9c34..4e982bf248 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -31,6 +31,8 @@
#include <e-util/e-marshal.h>
#include <e-util/e-util-enums.h>
+#include <libedataserver/e-source-list.h>
+
/* e_get_user_data_dir() used to live here, so #include its new home
* for backward-compatibility (not that we really care about that). */
#include <libedataserver/e-data-server-util.h>
@@ -148,12 +150,22 @@ gboolean e_binding_transform_color_to_string
(GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data);
+ gpointer not_used);
gboolean e_binding_transform_string_to_color
(GBinding *binding,
const GValue *source_value,
GValue *target_value,
- gpointer user_data);
+ gpointer not_used);
+gboolean e_binding_transform_source_to_uid
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list);
+gboolean e_binding_transform_uid_to_source
+ (GBinding *binding,
+ const GValue *source_value,
+ GValue *target_value,
+ ESourceList *source_list);
G_END_DECLS