[geary/wip/712895-sig-gustavo] First patches from Gustavo Rubio
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/712895-sig-gustavo] First patches from Gustavo Rubio
- Date: Mon, 12 May 2014 23:54:42 +0000 (UTC)
commit 7246c5f2e8174739b8b4b31a3361cb63f116786e
Author: Jim Nelson <jim yorba org>
Date: Mon May 12 16:54:04 2014 -0700
First patches from Gustavo Rubio
src/client/accounts/add-edit-page.vala | 41 +++++++++++++
src/client/composer/composer-window.vala | 19 ++++++
src/engine/api/geary-account-information.vala | 23 +++++++-
ui/login.glade | 79 ++++++++++++++++++++-----
4 files changed, 147 insertions(+), 15 deletions(-)
---
diff --git a/src/client/accounts/add-edit-page.vala b/src/client/accounts/add-edit-page.vala
index 2a5539a..cf7e09b 100644
--- a/src/client/accounts/add-edit-page.vala
+++ b/src/client/accounts/add-edit-page.vala
@@ -49,7 +49,21 @@ public class AddEditPage : Gtk.Box {
get { return check_remember_password.active; }
set { check_remember_password.active = value; }
}
+
+ public bool use_email_signature {
+ get { return check_use_email_signature.active; }
+ set { check_use_email_signature.active = value;}
+ }
+ public string email_signature {
+ owned get {
+ return textview_email_signature.buffer.text;
+ }
+ set {
+ textview_email_signature.buffer.text = value;
+ }
+ }
+
public bool save_sent_mail {
get { return check_save_sent_mail.active; }
set { check_save_sent_mail.active = value; }
@@ -150,6 +164,10 @@ public class AddEditPage : Gtk.Box {
private Gtk.ComboBoxText combo_service;
private Gtk.CheckButton check_remember_password;
private Gtk.CheckButton check_save_sent_mail;
+
+ //Signature
+ private Gtk.CheckButton check_use_email_signature;
+ private Gtk.TextView textview_email_signature;
private Gtk.Alignment other_info;
@@ -211,6 +229,8 @@ public class AddEditPage : Gtk.Box {
entry_password = (Gtk.Entry) builder.get_object("entry: password");
check_remember_password = (Gtk.CheckButton) builder.get_object("check: remember_password");
check_save_sent_mail = (Gtk.CheckButton) builder.get_object("check: save_sent_mail");
+ check_use_email_signature = (Gtk.CheckButton) builder.get_object("check: use_email_signature");
+ textview_email_signature = (Gtk.TextView) builder.get_object("textview: email_signature");
label_error = (Gtk.Label) builder.get_object("label: error");
@@ -284,6 +304,8 @@ public class AddEditPage : Gtk.Box {
entry_smtp_port.insert_text.connect(on_port_insert_text);
entry_nickname.insert_text.connect(on_nickname_insert_text);
+
+ check_use_email_signature.toggled.connect(() => on_use_signature_changed());
// Reset the "first update" flag when the window is mapped.
map.connect(() => { first_ui_update = true; });
@@ -313,6 +335,8 @@ public class AddEditPage : Gtk.Box {
info.default_smtp_use_imap_credentials,
info.default_smtp_server_noauth,
info.prefetch_period_days,
+ info.use_email_signature,
+ info.email_signature,
result);
}
@@ -340,6 +364,8 @@ public class AddEditPage : Gtk.Box {
bool initial_default_smtp_use_imap_credentials = false,
bool initial_default_smtp_noauth = false,
int prefetch_period_days = Geary.AccountInformation.DEFAULT_PREFETCH_PERIOD_DAYS,
+ bool initial_use_email_signature = false,
+ string? initial_email_signature = null,
Geary.Engine.ValidationResult result = Geary.Engine.ValidationResult.OK) {
// Set defaults
@@ -353,6 +379,10 @@ public class AddEditPage : Gtk.Box {
set_service_provider((Geary.ServiceProvider) initial_service_provider);
combo_imap_encryption.active = Encryption.NONE; // Must be default; set to real value below.
combo_smtp_encryption.active = Encryption.NONE;
+ use_email_signature = initial_use_email_signature;
+ email_signature = initial_email_signature;
+
+
// Set defaults for IMAP info
imap_host = initial_default_imap_host ?? "";
@@ -507,6 +537,15 @@ public class AddEditPage : Gtk.Box {
}
}
+ private void on_use_signature_changed() {
+ if(check_use_email_signature.active == true) {
+ textview_email_signature.sensitive = true;
+ } else {
+ textview_email_signature.buffer.text = "";
+ textview_email_signature.sensitive = false;
+ }
+ }
+
private uint16 get_default_smtp_port() {
switch (combo_smtp_encryption.active) {
case Encryption.SSL:
@@ -594,6 +633,8 @@ public class AddEditPage : Gtk.Box {
account_information.default_smtp_use_imap_credentials = smtp_use_imap_credentials;
account_information.default_smtp_server_noauth = smtp_noauth;
account_information.prefetch_period_days = get_storage_length();
+ account_information.use_email_signature = use_email_signature;
+ account_information.email_signature = email_signature;
if (smtp_noauth)
account_information.smtp_credentials = null;
diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala
index 85efee8..a171dc6 100644
--- a/src/client/composer/composer-window.vala
+++ b/src/client/composer/composer-window.vala
@@ -374,6 +374,10 @@ public class ComposerWindow : Gtk.Window {
}
}
+ //only add signature if the option is actually set
+ if(account.information.use_email_signature)
+ add_signature();
+
editor = new WebKit.WebView();
edit_fixer = new WebViewEditFixer(editor);
@@ -667,6 +671,21 @@ public class ComposerWindow : Gtk.Window {
update_from_field();
}
+ private void add_signature() {
+
+ string signature = account.information.email_signature;
+ signature = Geary.HTML.escape_markup(signature);
+
+ if (body_html == null)
+ {
+ body_html = Geary.HTML.preserve_whitespace("\n\n" + signature);
+ }
+ else
+ {
+ body_html = body_html + Geary.HTML.preserve_whitespace("\n\n" + signature);
+ }
+ }
+
private bool can_save() {
return (drafts_folder != null && drafts_folder.get_open_state() == Geary.Folder.OpenState.BOTH
&& !drafts_folder.properties.create_never_returns_id && editor.can_undo());
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index 0c0e4e9..e3e1874 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -32,6 +32,8 @@ public class Geary.AccountInformation : BaseObject {
private const string SENT_MAIL_FOLDER_KEY = "sent_mail_folder";
private const string SPAM_FOLDER_KEY = "spam_folder";
private const string TRASH_FOLDER_KEY = "trash_folder";
+ private const string USE_EMAIL_SIGNATURE_KEY = "use_email_signature";
+ private const string EMAIL_SIGNATURE_KEY = "email_signature";
//
// "Retired" keys
@@ -86,6 +88,8 @@ public class Geary.AccountInformation : BaseObject {
public bool default_smtp_server_starttls { get; set; }
public bool default_smtp_use_imap_credentials { get; set; }
public bool default_smtp_server_noauth { get; set; }
+ public bool use_email_signature { get; set; }
+ public string email_signature {get; set; }
public Geary.FolderPath? drafts_folder_path { get; set; default = null; }
public Geary.FolderPath? sent_mail_folder_path { get; set; default = null; }
@@ -130,7 +134,10 @@ public class Geary.AccountInformation : BaseObject {
DEFAULT_PREFETCH_PERIOD_DAYS);
save_sent_mail = get_bool_value(key_file, GROUP, SAVE_SENT_MAIL_KEY, true);
ordinal = get_int_value(key_file, GROUP, ORDINAL_KEY, default_ordinal++);
-
+ use_email_signature = get_bool_value(key_file, GROUP, USE_EMAIL_SIGNATURE_KEY);
+ email_signature = get_escaped_string(key_file, GROUP, EMAIL_SIGNATURE_KEY);
+
+
if (ordinal >= default_ordinal)
default_ordinal = ordinal + 1;
@@ -195,6 +202,8 @@ public class Geary.AccountInformation : BaseObject {
sent_mail_folder_path = from.sent_mail_folder_path;
spam_folder_path = from.spam_folder_path;
trash_folder_path = from.trash_folder_path;
+ use_email_signature = from.use_email_signature;
+ email_signature = from.email_signature;
}
/**
@@ -508,6 +517,16 @@ public class Geary.AccountInformation : BaseObject {
return def;
}
+
+ private string get_escaped_string(KeyFile key_file, string group, string key, string def = "") {
+ try {
+ return key_file.get_string(group, key);
+ } catch (KeyFileError err) {
+ //ignore
+ }
+
+ return def;
+ }
private Gee.List<string> get_string_list_value(KeyFile key_file, string group, string key) {
try {
@@ -581,6 +600,8 @@ public class Geary.AccountInformation : BaseObject {
key_file.set_boolean(GROUP, SMTP_REMEMBER_PASSWORD_KEY, smtp_remember_password);
key_file.set_integer(GROUP, PREFETCH_PERIOD_DAYS_KEY, prefetch_period_days);
key_file.set_boolean(GROUP, SAVE_SENT_MAIL_KEY, save_sent_mail);
+ key_file.set_boolean(GROUP, USE_EMAIL_SIGNATURE_KEY, use_email_signature);
+ key_file.set_string(GROUP, EMAIL_SIGNATURE_KEY, email_signature);
if (service_provider == ServiceProvider.OTHER) {
key_file.set_value(GROUP, IMAP_HOST, default_imap_server_host);
diff --git a/ui/login.glade b/ui/login.glade
index ab090eb..1aa9f6d 100644
--- a/ui/login.glade
+++ b/ui/login.glade
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.0 on Thu May 8 15:52:51 2014 -->
<interface>
- <!-- interface-requires gtk+ 3.0 -->
+ <!-- interface-requires gtk+ 3.10 -->
+ <object class="GtkAdjustment" id="adjustment1">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkTextBuffer" id="buffer: email_signature"/>
<object class="GtkBox" id="container">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -75,7 +82,6 @@
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
<property name="width_chars">0</property>
- <property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="placeholder_text">email example com</property>
@@ -95,7 +101,6 @@
<property name="visibility">False</property>
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
- <property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="placeholder_text" translatable="yes">Password</property>
@@ -192,7 +197,6 @@
<property name="hexpand">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
- <property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
</object>
@@ -246,7 +250,6 @@
<property name="max_length">255</property>
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
- <property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="placeholder_text" translatable="yes">Work, Home, etc.</property>
@@ -277,6 +280,63 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="label: email_signature">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Signature:</property>
+ <property name="selectable">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">7</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="check: use_email_signature">
+ <property name="label" translatable="yes">_Use email signature</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">7</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTextView" id="textview: email_signature">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="wrap_mode">word</property>
+ <property name="buffer">buffer: email_signature</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">8</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
@@ -374,7 +434,6 @@
<property name="activates_default">True</property>
<property name="width_chars">5</property>
<property name="text">993</property>
- <property name="invisible_char_set">True</property>
</object>
<packing>
<property name="left_attach">3</property>
@@ -389,7 +448,6 @@
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
- <property name="invisible_char_set">True</property>
<property name="placeholder_text">smtp.example.com</property>
</object>
<packing>
@@ -407,7 +465,6 @@
<property name="activates_default">True</property>
<property name="width_chars">5</property>
<property name="text">587</property>
- <property name="invisible_char_set">True</property>
</object>
<packing>
<property name="left_attach">3</property>
@@ -642,8 +699,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">1</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
<items>
<item translatable="yes">None</item>
<item translatable="yes">SSL/TLS</item>
@@ -662,8 +717,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">2</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
<items>
<item translatable="yes">None</item>
<item translatable="yes">SSL/TLS</item>
@@ -838,8 +891,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
- <property name="entry_text_column">0</property>
- <property name="id_column">1</property>
</object>
<packing>
<property name="left_attach">1</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]