[evolution-data-server] Bug 228772 - Allow to specify a default language for a given identity
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 228772 - Allow to specify a default language for a given identity
- Date: Mon, 8 Oct 2018 16:51:38 +0000 (UTC)
commit df4bdbcb5c78fad7b609d6e39235b436573ebee4
Author: Milan Crha <mcrha redhat com>
Date: Mon Oct 8 18:51:30 2018 +0200
Bug 228772 - Allow to specify a default language for a given identity
Closes https://bugzilla.gnome.org/show_bug.cgi?id=228772
.../evolution-data-server-docs.sgml.in | 4 +
src/libedataserver/e-source-mail-composition.c | 115 ++++++++++++++++++++-
src/libedataserver/e-source-mail-composition.h | 7 ++
3 files changed, 125 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
b/docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
index d9673b592..3e7913468 100644
--- a/docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
+++ b/docs/reference/evolution-data-server/evolution-data-server-docs.sgml.in
@@ -348,6 +348,10 @@
<title>Index of deprecated symbols</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
</index>
+ <index id="api-index-3-32" role="3.32">
+ <title>Index of new symbols in 3.32</title>
+ <xi:include href="xml/api-index-3.32.xml"><xi:fallback /></xi:include>
+ </index>
<index id="api-index-3-30" role="3.30">
<title>Index of new symbols in 3.30</title>
<xi:include href="xml/api-index-3.30.xml"><xi:fallback /></xi:include>
diff --git a/src/libedataserver/e-source-mail-composition.c b/src/libedataserver/e-source-mail-composition.c
index 80b964040..ced0c6224 100644
--- a/src/libedataserver/e-source-mail-composition.c
+++ b/src/libedataserver/e-source-mail-composition.c
@@ -50,6 +50,7 @@ struct _ESourceMailCompositionPrivate {
gchar **cc;
gchar *drafts_folder;
gchar *templates_folder;
+ gchar *language;
gboolean sign_imip;
ESourceMailCompositionReplyStyle reply_style;
EThreeState start_bottom;
@@ -65,7 +66,8 @@ enum {
PROP_SIGN_IMIP,
PROP_TEMPLATES_FOLDER,
PROP_START_BOTTOM,
- PROP_TOP_SIGNATURE
+ PROP_TOP_SIGNATURE,
+ PROP_LANGUAGE
};
G_DEFINE_TYPE (
@@ -98,6 +100,12 @@ source_mail_composition_set_property (GObject *object,
g_value_get_string (value));
return;
+ case PROP_LANGUAGE:
+ e_source_mail_composition_set_language (
+ E_SOURCE_MAIL_COMPOSITION (object),
+ g_value_get_string (value));
+ return;
+
case PROP_REPLY_STYLE:
e_source_mail_composition_set_reply_style (
E_SOURCE_MAIL_COMPOSITION (object),
@@ -160,6 +168,13 @@ source_mail_composition_get_property (GObject *object,
E_SOURCE_MAIL_COMPOSITION (object)));
return;
+ case PROP_LANGUAGE:
+ g_value_take_string (
+ value,
+ e_source_mail_composition_dup_language (
+ E_SOURCE_MAIL_COMPOSITION (object)));
+ return;
+
case PROP_REPLY_STYLE:
g_value_set_enum (
value,
@@ -210,6 +225,7 @@ source_mail_composition_finalize (GObject *object)
g_strfreev (priv->cc);
g_free (priv->drafts_folder);
g_free (priv->templates_folder);
+ g_free (priv->language);
/* Chain up to parent's finalize() method. */
G_OBJECT_CLASS (e_source_mail_composition_parent_class)->
@@ -339,6 +355,19 @@ e_source_mail_composition_class_init (ESourceMailCompositionClass *class)
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS |
E_SOURCE_PARAM_SETTING));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_LANGUAGE,
+ g_param_spec_string (
+ "language",
+ "Language",
+ "Preferred language",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS |
+ E_SOURCE_PARAM_SETTING));
}
static void
@@ -873,3 +902,87 @@ e_source_mail_composition_set_top_signature (ESourceMailComposition *extension,
g_object_notify (G_OBJECT (extension), "top-signature");
}
+
+/**
+ * e_source_mail_composition_get_language:
+ * @extension: an #ESourceMailComposition
+ *
+ * Returns a string identifying the preferred language, like "en_US".
+ *
+ * Returns: (nullable): an identifier for the preferred language, or %NULL for none
+ *
+ * Since: 3.32
+ **/
+const gchar *
+e_source_mail_composition_get_language (ESourceMailComposition *extension)
+{
+ g_return_val_if_fail (E_IS_SOURCE_MAIL_COMPOSITION (extension), NULL);
+
+ return extension->priv->language;
+}
+
+/**
+ * e_source_mail_composition_dup_language:
+ * @extension: an #ESourceMailComposition
+ *
+ * Thread-safe variation of e_source_mail_composition_get_language().
+ * Use this function when accessing @extension from multiple threads.
+ *
+ * The returned string should be freed with g_free() when no longer needed.
+ *
+ * Returns: a newly-allocated copy of #ESourceMailComposition:language
+ *
+ * Since: 3.32
+ **/
+gchar *
+e_source_mail_composition_dup_language (ESourceMailComposition *extension)
+{
+ const gchar *protected;
+ gchar *duplicate;
+
+ g_return_val_if_fail (E_IS_SOURCE_MAIL_COMPOSITION (extension), NULL);
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
+
+ protected = e_source_mail_composition_get_language (extension);
+ duplicate = g_strdup (protected);
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
+
+ return duplicate;
+}
+
+/**
+ * e_source_mail_composition_set_language:
+ * @extension: an #ESourceMailComposition
+ * @language: (nullable): an identifier for the preferred language, or %NULL
+ *
+ * Sets the preferred language by an identifier string, like "en_US".
+ * Use %NULL to unset any previous value.
+ *
+ * The internal copy of @language is automatically stripped of
+ * leading and trailing whitespace. If the resulting string is empty,
+ * %NULL is set instead.
+ *
+ * Since: 3.32
+ **/
+void
+e_source_mail_composition_set_language (ESourceMailComposition *extension,
+ const gchar *language)
+{
+ g_return_if_fail (E_IS_SOURCE_MAIL_COMPOSITION (extension));
+
+ e_source_extension_property_lock (E_SOURCE_EXTENSION (extension));
+
+ if (g_strcmp0 (extension->priv->language, language) == 0) {
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
+ return;
+ }
+
+ g_free (extension->priv->language);
+ extension->priv->language = e_util_strdup_strip (language);
+
+ e_source_extension_property_unlock (E_SOURCE_EXTENSION (extension));
+
+ g_object_notify (G_OBJECT (extension), "language");
+}
diff --git a/src/libedataserver/e-source-mail-composition.h b/src/libedataserver/e-source-mail-composition.h
index bd682e442..9a23797c8 100644
--- a/src/libedataserver/e-source-mail-composition.h
+++ b/src/libedataserver/e-source-mail-composition.h
@@ -131,6 +131,13 @@ EThreeState e_source_mail_composition_get_top_signature
void e_source_mail_composition_set_top_signature
(ESourceMailComposition *extension,
EThreeState top_signature);
+const gchar * e_source_mail_composition_get_language
+ (ESourceMailComposition *extension);
+gchar * e_source_mail_composition_dup_language
+ (ESourceMailComposition *extension);
+void e_source_mail_composition_set_language
+ (ESourceMailComposition *extension,
+ const gchar *language);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]