[geary/wip/712895-sig-martin] First patches from Martin P öhlmann
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/712895-sig-martin] First patches from Martin P öhlmann
- Date: Mon, 12 May 2014 23:46:34 +0000 (UTC)
commit cc1f65ba8e15d27a080c13676a33baedc8e38ce0
Author: Jim Nelson <jim yorba org>
Date: Mon May 12 16:45:31 2014 -0700
First patches from Martin Pöhlmann
src/client/composer/composer-window.vala | 20 ++++++++++++++++
src/engine/api/geary-account-information.vala | 31 +++++++++++++++++++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/src/client/composer/composer-window.vala b/src/client/composer/composer-window.vala
index 85efee8..2c7a28c 100644
--- a/src/client/composer/composer-window.vala
+++ b/src/client/composer/composer-window.vala
@@ -374,6 +374,8 @@ public class ComposerWindow : Gtk.Window {
}
}
+ add_signature();
+
editor = new WebKit.WebView();
edit_fixer = new WebViewEditFixer(editor);
@@ -1406,6 +1408,24 @@ public class ComposerWindow : Gtk.Window {
return html_to_flowed_text(editor.get_dom_document());
}
+ private void add_signature() {
+ string? signature = account.information.get_signature();
+ if (signature == null)
+ {
+ return;
+ }
+
+ signature = Geary.HTML.escape_markup(signature);
+ if (body_html == null)
+ {
+ body_html = Geary.HTML.preserve_whitespace("\n\n" + signature);
+ }
+ else
+ {
+ body_html = Geary.HTML.preserve_whitespace("\n\n" + signature) + body_html;
+ }
+ }
+
private bool on_navigation_policy_decision_requested(WebKit.WebFrame frame,
WebKit.NetworkRequest request, WebKit.WebNavigationAction navigation_action,
WebKit.WebPolicyDecision policy_decision) {
diff --git a/src/engine/api/geary-account-information.vala b/src/engine/api/geary-account-information.vala
index 0c0e4e9..ddbebab 100644
--- a/src/engine/api/geary-account-information.vala
+++ b/src/engine/api/geary-account-information.vala
@@ -681,6 +681,37 @@ public class Geary.AccountInformation : BaseObject {
return new RFC822.MailboxAddresses.single(get_mailbox_address());
}
+ /**
+ * Returns the signature for this account of null if no signature is defined.
+ */
+ public string? get_signature()
+ {
+ // try signature file in sttrings folder
+ File signature_file = settings_dir.get_child("signature");
+ if (!signature_file.query_exists()) {
+ // if not found try .signature file in home directory
+ signature_file = File.new_for_path(Environment.get_home_dir()).get_child(".signature");
+ }
+ if (!signature_file.query_exists()) {
+ return null;
+ }
+
+ string signature = null;
+ try
+ {
+ FileUtils.get_contents(signature_file.get_path(), out signature);
+ } catch (Error error) {
+ debug("Error reading signature file %s: %s", signature_file.get_path(), error.message);
+ return null;
+ }
+
+ if (Geary.String.is_empty_or_whitespace(signature)) {
+ return null;
+ }
+
+ return signature;
+ }
+
public static int compare_ascending(AccountInformation a, AccountInformation b) {
int diff = a.ordinal - b.ordinal;
if (diff != 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]