Skip to content

Commit

Permalink
Add option to bottom-post
Browse files Browse the repository at this point in the history
  • Loading branch information
PJMODOS committed Jun 4, 2015
1 parent 04f7bbf commit 1dd5857
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 15 deletions.
5 changes: 5 additions & 0 deletions desktop/org.yorba.geary.gschema.xml
Expand Up @@ -73,6 +73,11 @@
<summary>enable inline spell checking</summary>
<description>True to spell check while typing.</description>
</key>
<key name="reply-placement" type="s">
<default>"AUTO"</default>
<summary>initial reply placement</summary>
<description>Acceptable values are AUTO, TOP, BOTTOM.</description>
</key>
<key name="play-sounds" type="b">
<default>true</default>
<summary>enable notification sounds</summary>
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -354,6 +354,7 @@ client/composer/composer-window.vala
client/composer/contact-entry-completion.vala
client/composer/contact-list-store.vala
client/composer/email-entry.vala
client/composer/reply-placement.vala
client/composer/scrollable-overlay.vala
client/composer/webview-edit-fixer.vala

Expand Down
6 changes: 6 additions & 0 deletions src/client/application/geary-config.vala
Expand Up @@ -18,6 +18,7 @@ public class Configuration {
public const string AUTOSELECT_KEY = "autoselect";
public const string DISPLAY_PREVIEW_KEY = "display-preview";
public const string SPELL_CHECK_KEY = "spell-check";
public const string REPLY_PLACEMENT_KEY = "reply-placement";
public const string PLAY_SOUNDS_KEY = "play-sounds";
public const string SHOW_NOTIFICATIONS_KEY = "show-notifications";
public const string STARTUP_NOTIFICATIONS_KEY = "startup-notifications";
Expand Down Expand Up @@ -78,6 +79,11 @@ public class Configuration {
public bool spell_check {
get { return settings.get_boolean(SPELL_CHECK_KEY); }
}

public Geary.ReplyPlacement reply_placement {
get { return Geary.ReplyPlacement.from_string(settings.get_string(REPLY_PLACEMENT_KEY)); }
set { settings.set_string(REPLY_PLACEMENT_KEY, value.to_string()); }
}

public bool play_sounds {
get { return settings.get_boolean(PLAY_SOUNDS_KEY); }
Expand Down
14 changes: 8 additions & 6 deletions src/client/composer/composer-widget.vala
Expand Up @@ -260,7 +260,8 @@ public class ComposerWidget : Gtk.EventBox {
private Geary.RFC822.MailboxAddresses reply_cc_addresses;
private string reply_subject = "";
private string forward_subject = "";
private bool top_posting = true;
private Geary.ReplyPlacement reply_placement = GearyApplication.instance.config.reply_placement;
private bool top_posting = GearyApplication.instance.config.reply_placement != Geary.ReplyPlacement.BOTTOM;
private string? last_quote = null;

private Geary.App.DraftManager? draft_manager = null;
Expand Down Expand Up @@ -499,7 +500,8 @@ public class ComposerWidget : Gtk.EventBox {
Geary.RFC822.TextFormat.HTML);
pending_attachments = referred.attachments;
if (quote != null)
top_posting = false;
if (reply_placement == Geary.ReplyPlacement.AUTO)
top_posting = false;
else
can_delete_quote = true;
break;
Expand Down Expand Up @@ -1069,16 +1071,16 @@ public class ComposerWidget : Gtk.EventBox {
if (body_html == null)
body_html = CURSOR + "<br /><br />" + signature;
else if (top_posting)
body_html = CURSOR + "<br /><br />" + signature + body_html;
body_html = CURSOR + "<br /><br />" + signature + "<br /><br />" + body_html;
else
body_html = body_html + CURSOR + "<br /><br />" + signature;
body_html = body_html + "<br /><br />" + CURSOR + "<br /><br />" + signature;
}

private void set_cursor() {
if (top_posting)
body_html = CURSOR + body_html;
body_html = CURSOR + "<br /><br />" + body_html;
else
body_html = body_html + CURSOR;
body_html = body_html + "<br /><br />" + CURSOR;
}

private bool can_save() {
Expand Down
83 changes: 83 additions & 0 deletions src/client/composer/reply-placement.vala
@@ -0,0 +1,83 @@
/* Copyright 2011-2015 Yorba Foundation
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/

/**
* A representation of the top posting options
*/

public enum Geary.ReplyPlacement {
AUTO,
TOP,
BOTTOM;

public static ReplyPlacement[] get_placemens() {
return { AUTO, TOP, BOTTOM };
}

/**
* Returns the option in a serialized form.
*
* @see from_string
*/
public string to_string() {
switch (this) {
case AUTO:
return "AUTO";

case TOP:
return "TOP";

case BOTTOM:
return "BOTTOM";

default:
assert_not_reached();
}
}

/**
* Returns the option name in a translated UTF-8 string suitable for display to the
* user.
*/
public string display_name() {
switch (this) {
case AUTO:
return _("Auto");

case TOP:
return _("Top");

case BOTTOM:
return _("Bottom");

default:
assert_not_reached();
}
}

/**
* Converts a string form of the option (returned by {@link to_string} to a
* {@link ReplyPlacement} value.
*
* @see to_string
*/
public static ReplyPlacement from_string(string str) {
switch (str.up()) {
case "AUTO":
return AUTO;

case "TOP":
return TOP;

case "BOTTOM":
return BOTTOM;

default:
assert_not_reached();
}
}
}

29 changes: 28 additions & 1 deletion src/client/dialogs/preferences-dialog.vala
Expand Up @@ -6,6 +6,8 @@

public class PreferencesDialog : Object {
private Gtk.Dialog dialog;
private Gtk.ComboBoxText combo_reply_placement;
private Configuration config;

public PreferencesDialog(Gtk.Window parent) {
Gtk.Builder builder = GearyApplication.instance.create_builder("preferences.glade");
Expand All @@ -14,8 +16,12 @@ public class PreferencesDialog : Object {
dialog = builder.get_object("dialog") as Gtk.Dialog;
dialog.set_transient_for(parent);
dialog.set_modal(true);

combo_reply_placement = (Gtk.ComboBoxText) builder.get_object("combo: reply_placement");
foreach (Geary.ReplyPlacement p in Geary.ReplyPlacement.get_placemens())
combo_reply_placement.append_text(p.display_name());

Configuration config = GearyApplication.instance.config;
config = GearyApplication.instance.config;
config.bind(Configuration.AUTOSELECT_KEY, builder.get_object("autoselect"), "active");
config.bind(Configuration.DISPLAY_PREVIEW_KEY, builder.get_object("display_preview"), "active");
config.bind(Configuration.FOLDER_LIST_PANE_HORIZONTAL_KEY,
Expand All @@ -24,6 +30,9 @@ public class PreferencesDialog : Object {
config.bind(Configuration.PLAY_SOUNDS_KEY, builder.get_object("play_sounds"), "active");
config.bind(Configuration.SHOW_NOTIFICATIONS_KEY, builder.get_object("show_notifications"), "active");
config.bind(Configuration.STARTUP_NOTIFICATIONS_KEY, builder.get_object("startup_notifications"), "active");

set_reply_placement(config.reply_placement);
combo_reply_placement.changed.connect(on_reply_placement_changed);
}

public void run() {
Expand All @@ -33,5 +42,23 @@ public class PreferencesDialog : Object {
dialog.run();
dialog.destroy();
}

private void on_reply_placement_changed() {
config.reply_placement = get_reply_placement();
}

private Geary.ReplyPlacement get_reply_placement() {
return (Geary.ReplyPlacement) combo_reply_placement.get_active();
}

private void set_reply_placement(Geary.ReplyPlacement placement) {
foreach (Geary.ReplyPlacement p in Geary.ReplyPlacement.get_placemens()) {
if (p == placement)
combo_reply_placement.set_active(p);
}

if (combo_reply_placement.get_active() == -1)
combo_reply_placement.set_active(0);
}
}

5 changes: 1 addition & 4 deletions src/engine/rfc822/rfc822-utils.vala
Expand Up @@ -208,7 +208,7 @@ public string quote_email_for_reply(Geary.Email email, string? quote, TextFormat
if (email.body == null && quote == null)
return "";

string quoted = (quote == null) ? "<br /><br />" : "";
string quoted = "";

/// Format for the datetime that a message being replied to was received
/// See http://developer.gnome.org/glib/2.32/glib-GDateTime.html#g-date-time-format
Expand Down Expand Up @@ -239,9 +239,6 @@ public string quote_email_for_reply(Geary.Email email, string? quote, TextFormat

quoted += "\n" + quote_body(email, quote, true, format);

if (quote != null)
quoted += "<br /><br />\n";

return quoted;
}

Expand Down
47 changes: 43 additions & 4 deletions ui/preferences.glade
Expand Up @@ -62,6 +62,7 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand All @@ -81,6 +82,7 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand All @@ -100,6 +102,7 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand All @@ -118,6 +121,7 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand All @@ -137,6 +141,37 @@
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label: reply placement">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">6</property>
<property name="label" translatable="yes">Reply placement:</property>
<property name="use_underline">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="width">1</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="combo: reply_placement">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">6</property>
<property name="width">1</property>
</packing>
</child>
<child>
Expand All @@ -154,7 +189,8 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="top_attach">7</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand All @@ -173,7 +209,8 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">7</property>
<property name="top_attach">8</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand All @@ -192,7 +229,8 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">8</property>
<property name="top_attach">9</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand All @@ -212,7 +250,8 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">9</property>
<property name="top_attach">10</property>
<property name="width">2</property>
</packing>
</child>
<child>
Expand Down

0 comments on commit 1dd5857

Please sign in to comment.