diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2010-11-02 02:44:23 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2010-11-10 06:33:21 +0800 |
commit | 26afa6081c3d9826dbae78236dd712fad8b7c340 (patch) | |
tree | 531e8587a88bc408b91341a98e20fbd934cbb344 /e-util | |
parent | f5460f323b2581af28764b96635b2d3a0f1548c9 (diff) | |
download | gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.gz gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.bz2 gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.lz gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.xz gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.tar.zst gsoc2013-evolution-26afa6081c3d9826dbae78236dd712fad8b7c340.zip |
Utilize the new ESourceSelector:primary-selection property.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/e-util.c | 81 | ||||
-rw-r--r-- | e-util/e-util.h | 16 |
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 |