[anjuta] project-wizard: bgo #734719 - unified email id setting
- From: Sebastien Granjoux <sgranjoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [anjuta] project-wizard: bgo #734719 - unified email id setting
- Date: Sun, 17 Aug 2014 20:33:46 +0000 (UTC)
commit e36b302c4c99443d601e3d9e0b2094d94c66ce20
Author: Ritesh Khadgaray <khadgaray gmail com>
Date: Sun Aug 17 22:33:29 2014 +0200
project-wizard: bgo #734719 - unified email id setting
libanjuta/anjuta-utils.c | 36 +++++++++++++++++++-
libanjuta/anjuta-utils.h | 1 +
plugins/project-wizard/druid.c | 6 ++--
...me.anjuta.plugins.project-wizard.gschema.xml.in | 5 ---
src/org.gnome.anjuta.gschema.xml.in | 6 +++
5 files changed, 45 insertions(+), 9 deletions(-)
---
diff --git a/libanjuta/anjuta-utils.c b/libanjuta/anjuta-utils.c
index 36a31db..9f20865 100644
--- a/libanjuta/anjuta-utils.c
+++ b/libanjuta/anjuta-utils.c
@@ -64,6 +64,12 @@
#define FILE_BUFFER_SIZE 1024
+/* Common preferences */
+#define ANJUTA_PREF_SCHEMA "org.gnome.anjuta"
+
+#define LAST_EMAIL "email"
+
+
static gchar *anjuta_prefix = "anjuta";
static void
@@ -2556,9 +2562,37 @@ gchar*
anjuta_util_get_user_mail()
{
/* FIXME: Use libfolks or something like it to query the mail address */
- return g_strconcat(g_get_user_name (), "@", g_get_host_name (), NULL);
+
+ gchar *id;
+ GSettings *settings;
+
+ settings = g_settings_new (ANJUTA_PREF_SCHEMA);
+ id = g_settings_get_string (settings, LAST_EMAIL);
+ g_object_unref (settings);
+
+ if (*id == '\0') {
+ g_free (id);
+ return g_strconcat(g_get_user_name (), "@", g_get_host_name (), NULL);
+ }
+ else
+ return id;
}
+/*
+ * anjuta_util_get_user_mail:
+ * @id: The e-mail address to be used in future
+ *
+ */
+void anjuta_util_set_user_mail(const gchar* id)
+{
+ GSettings *settings;
+
+ settings = g_settings_new (ANJUTA_PREF_SCHEMA);
+ g_settings_set_string (settings, LAST_EMAIL, id);
+ g_object_unref (settings);
+}
+
+
/**
* anjuta_utils_clone_string_gptrarray:
* @source: The source GPtrArray containing items representing strings
diff --git a/libanjuta/anjuta-utils.h b/libanjuta/anjuta-utils.h
index 27b68d9..283c74f 100644
--- a/libanjuta/anjuta-utils.h
+++ b/libanjuta/anjuta-utils.h
@@ -158,6 +158,7 @@ gchar* anjuta_util_get_user_config_file_path (const gchar* path, ...);
/* Get the correct e-mail address */
gchar* anjuta_util_get_user_mail (void);
+void anjuta_util_set_user_mail (const gchar* id);
/* Function for converting GFile objects to string paths
* Free the returned list with anjuta_util_glist_strings_free. */
diff --git a/plugins/project-wizard/druid.c b/plugins/project-wizard/druid.c
index 3c8a91e..0d205a0 100644
--- a/plugins/project-wizard/druid.c
+++ b/plugins/project-wizard/druid.c
@@ -1196,10 +1196,10 @@ npw_druid_save_default_property (NPWDruid* druid)
new_value = g_hash_table_lookup (druid->values, EMAIL_PROPERTY);
if ((new_value != NULL) && (*new_value != '\0'))
{
- old_value = g_settings_get_string (settings, LAST_EMAIL);
+ old_value = anjuta_util_get_user_mail ();
if (strcmp (new_value, old_value) != 0)
{
- g_settings_set_string (settings, LAST_EMAIL, new_value);
+ anjuta_util_set_user_mail (new_value);
}
g_free (old_value);
}
@@ -1335,7 +1335,7 @@ npw_druid_add_default_property (NPWDruid* druid)
g_hash_table_insert (druid->values, g_strdup (USER_NAME_PROPERTY), s);
/* Add Email address */
- s = g_settings_get_string (settings,LAST_EMAIL);
+ s = anjuta_util_get_user_mail ();
g_hash_table_insert (druid->values, g_strdup (EMAIL_ADDRESS_PROPERTY), s);
g_object_unref (settings);
diff --git a/plugins/project-wizard/org.gnome.anjuta.plugins.project-wizard.gschema.xml.in
b/plugins/project-wizard/org.gnome.anjuta.plugins.project-wizard.gschema.xml.in
index 38e2e85..0e5f650 100644
--- a/plugins/project-wizard/org.gnome.anjuta.plugins.project-wizard.gschema.xml.in
+++ b/plugins/project-wizard/org.gnome.anjuta.plugins.project-wizard.gschema.xml.in
@@ -10,10 +10,5 @@
<_summary>Default user name used in new project</_summary>
<_description>If empty, the current user name is used.</_description>
</key>
- <key name="email" type="s">
- <default>""</default>
- <_summary>Default email used in new project</_summary>
- <_description>If empty, current login and machine name is used.</_description>
- </key>
</schema>
</schemalist>
diff --git a/src/org.gnome.anjuta.gschema.xml.in b/src/org.gnome.anjuta.gschema.xml.in
index 848ae1b..6141301 100644
--- a/src/org.gnome.anjuta.gschema.xml.in
+++ b/src/org.gnome.anjuta.gschema.xml.in
@@ -32,6 +32,12 @@
</choices>
<default>"Default"</default>
</key>
+
+ <key name="email" type="s">
+ <default>""</default>
+ <_summary>Default email used in new project</_summary>
+ <_description>If empty, current login and machine name is used.</_description>
+ </key>
</schema>
<schema id="org.gnome.anjuta.editor" path="/org/gnome/anjuta/editor/">
<key name="use-tabs" type="b">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]