commit 98fdfb3b2114145537ee10fe9b060074d34d2a8d
parent 1832dc23c68d69a7d36e57e372dd9acc4a7b3c34
Author: mish <mish@mishtop.(none)>
Date: Wed, 9 Feb 2011 21:48:14 +0000
Merge branch 'rerun_crypto_selector' into next
Diffstat:
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/lib/sup/horizontal-selector.rb b/lib/sup/horizontal-selector.rb
@@ -1,7 +1,7 @@
module Redwood
class HorizontalSelector
- attr_accessor :label
+ attr_accessor :label, :changed_by_user
def initialize label, vals, labels, base_color=:horizontal_selector_unselected_color, selected_color=:horizontal_selector_selected_color
@label = label
@@ -10,6 +10,7 @@ class HorizontalSelector
@base_color = base_color
@selected_color = selected_color
@selection = 0
+ @changed_by_user = false
end
def set_to val; @selection = @vals.index(val) end
@@ -37,10 +38,12 @@ class HorizontalSelector
def roll_left
@selection = (@selection - 1) % @labels.length
+ @changed_by_user = true
end
def roll_right
@selection = (@selection + 1) % @labels.length
+ @changed_by_user = true
end
end
diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
@@ -179,6 +179,7 @@ EOS
header, @body = parse_file @file.path
@header = header - NON_EDITABLE_HEADERS
handle_new_text @header, @body
+ rerun_crypto_selector_hook
update
@edited
@@ -215,6 +216,12 @@ EOS
protected
+ def rerun_crypto_selector_hook
+ if @crypto_selector && !@crypto_selector.changed_by_user
+ HookManager.run "crypto-mode", :header => @header, :body => @body, :crypto_selector => @crypto_selector
+ end
+ end
+
def mime_encode string
string = [string].pack('M') # basic quoted-printable
string.gsub!(/=\n/,'') # .. remove trailing newline
diff --git a/lib/sup/modes/reply-mode.rb b/lib/sup/modes/reply-mode.rb
@@ -165,6 +165,7 @@ protected
if @headers[@type_selector.val] != self.header
self.header = @headers[@type_selector.val]
self.body = @bodies[@type_selector.val] unless @edited
+ rerun_crypto_selector_hook
update
end
end
@@ -174,6 +175,7 @@ protected
if @headers[@type_selector.val] != self.header
self.header = @headers[@type_selector.val]
self.body = @bodies[@type_selector.val] unless @edited
+ rerun_crypto_selector_hook
update
end
end