[Xfce4-commits] <postler:master> Wait for a grace period before sending
Christian Dywan
noreply at xfce.org
Mon Jan 31 03:52:02 CET 2011
Updating branch refs/heads/master
to 357bc34a1db8804c944fa8ddc5f68e0483147bbf (commit)
from 8c38cb47553b5b693e81389575a197cc28e7dbb6 (commit)
commit 357bc34a1db8804c944fa8ddc5f68e0483147bbf
Author: Christian Dywan <christian at twotoasts.de>
Date: Mon Jan 31 03:07:04 2011 +0100
Wait for a grace period before sending
A progressbar shows up when hitting Send, all widgets become
insensitive and Cancel appears. To give the user a chance
to cancel in case he realises he didn't want to send yet.
postler/postler-composer.vala | 61 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/postler/postler-composer.vala b/postler/postler-composer.vala
index c15db6c..a49b2a1 100644
--- a/postler/postler-composer.vala
+++ b/postler/postler-composer.vala
@@ -19,12 +19,15 @@ public class Postler.Composer : Gtk.Window {
Gtk.VBox shelf;
Gtk.Toolbar toolbar;
+ Gtk.ProgressBar progressbar;
Postler.Content content;
Postler.Attachments attachments;
Gtk.ComboBox combo_from;
Gtk.Entry entry_to;
Gtk.Entry entry_copy;
Gtk.Entry entry_subject;
+ Gtk.Button button_send;
+ uint grace_period_timer = 0;
public string subject { get { return entry_subject.text; } }
int part = 0;
@@ -73,7 +76,50 @@ public class Postler.Composer : Gtk.Window {
return null;
}
+ void toggle_sensitivity (bool state) {
+ combo_from.sensitive = state;
+ entry_to.sensitive = state;
+ entry_copy.sensitive = state;
+ entry_subject.sensitive = state;
+ content.sensitive = state;
+ attachments.sensitive = state;
+ foreach (var child in toolbar.get_children ())
+ child.sensitive = state;
+
+ if (state) {
+ button_send.label = STOCK_MAIL_SEND;
+ progressbar.hide ();
+ grace_period_timer = 0;
+ }
+ else {
+ button_send.label = Gtk.STOCK_CANCEL;
+ button_send.parent.sensitive = true;
+ }
+ }
+
+ bool send_grace_period_timer () {
+ progressbar.fraction += 0.2;
+ if (progressbar.fraction == 1.0) {
+ send_message ();
+ return false;
+ }
+ return true;
+ }
+
void action_mail_send () {
+ if (grace_period_timer > 0) {
+ GLib.Source.remove (grace_period_timer);
+ toggle_sensitivity (true);
+ return;
+ }
+
+ toggle_sensitivity (false);
+ progressbar.fraction = 0.0;
+ progressbar.show ();
+ grace_period_timer = GLib.Timeout.add_seconds (1, send_grace_period_timer);
+ }
+
+ void send_message () {
if (entry_subject.text == "") {
var dialog = new Gtk.MessageDialog (this, 0,
Gtk.MessageType.WARNING, Gtk.ButtonsType.NONE,
@@ -238,6 +284,7 @@ public class Postler.Composer : Gtk.Window {
destroy ();
} catch (GLib.Error error) {
GLib.critical (_("Failed to send message: %s"), error.message);
+ toggle_sensitivity (true);
}
}
@@ -457,6 +504,16 @@ public class Postler.Composer : Gtk.Window {
toolbar = ui.get_widget ("/toolbar") as Gtk.Toolbar;
toolbar.set_icon_size (Gtk.IconSize.BUTTON);
+ /* Grace period progress after activating Send */
+ var toolitem = new Gtk.ToolItem ();
+ var align = new Gtk.Alignment (0.0f, 0.5f, 1.0f, 0.1f);
+ align.left_padding = 8;
+ progressbar = new Gtk.ProgressBar ();
+ progressbar.set_no_show_all (true);
+ align.add (progressbar);
+ toolitem.add (align);
+ toolbar.insert (toolitem, toolbar.get_n_items () - 1);
+
Gtk.rc_parse_string ("""
style "postler-widebutton"
{
@@ -466,7 +523,7 @@ public class Postler.Composer : Gtk.Window {
"""
);
- var toolitem = new Gtk.ToolItem ();
+ toolitem = new Gtk.ToolItem ();
toolitem.set_border_width (4);
var button = new Gtk.Button.from_stock (Gtk.STOCK_SAVE);
button.name = "PostlerWideButton";
@@ -479,7 +536,7 @@ public class Postler.Composer : Gtk.Window {
toolbar.insert (toolitem, -1);
toolitem = new Gtk.ToolItem ();
toolitem.set_border_width (4);
- var button_send = new Gtk.Button.from_stock (STOCK_MAIL_SEND);
+ button_send = new Gtk.Button.from_stock (STOCK_MAIL_SEND);
button_send.name = "PostlerWideButton";
toolitem.add (button_send);
var send = actions.get_action ("MessageSend");
More information about the Xfce4-commits
mailing list