Class: Swat::TodoWindow
- Inherits:
-
Object
- Object
- Swat::TodoWindow
- Includes:
- ListHelper
- Defined in:
- lib/todo_window.rb
Defined Under Namespace
Classes: TreeItem
Constant Summary collapse
- @@todo_file_location =
nil
- @@meta_data_file =
nil
- @@wish_list =
nil
Instance Attribute Summary collapse
-
#glade ⇒ Object
Returns the value of attribute glade.
-
#todo_data ⇒ Object
Returns the value of attribute todo_data.
-
#todo_window ⇒ Object
Returns the value of attribute todo_window.
Class Method Summary collapse
- .meta_data_file=(file) ⇒ Object
- .todo_file_location=(filename) ⇒ Object
- .wishlist=(filename) ⇒ Object
Instance Method Summary collapse
- #add_to_tasklist(category, todo, priority) ⇒ Object
- #connect_custom_signals ⇒ Object
- #hide_window ⇒ Object
-
#initialize(path) ⇒ TodoWindow
constructor
A new instance of TodoWindow.
- #layout_done_view ⇒ Object
-
#layout_statbar ⇒ Object
layout statistic bar.
- #layout_wishlist ⇒ Object
- #mark_as_done ⇒ Object
- #mark_as_wishlist ⇒ Object
- #on_add_todo_button_clicked ⇒ Object
- #on_reload_button_clicked ⇒ Object
- #on_sync_button_clicked ⇒ Object
- #on_todo_window_delete_event ⇒ Object
- #on_todo_window_destroy_event ⇒ Object
- #on_todo_window_key_press_event(widget, key) ⇒ Object
- #on_toggle_stat_button_clicked ⇒ Object
- #show_window ⇒ Object
Constructor Details
#initialize(path) ⇒ TodoWindow
Returns a new instance of TodoWindow.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/todo_window.rb', line 61 def initialize path @glade = GladeXML.new(path) { |handler| method(handler) } @list_view = @glade.("todo_view") @todo_window = @glade.("todo_window") window_icon = Gdk::Pixbuf.new("#{SWAT_APP}/resources/todo.png") @todo_window.icon_list = [window_icon] @todo_window.title = "Your TaskList" @todo_selection = @list_view.selection @todo_selection.mode = Gtk::SELECTION_SINGLE @meta_data = SwatMetaData.new(@@meta_data_file) @todo_data = TodoData.new(@@todo_file_location) @model = create_model load_available_lists add_columns connect_custom_signals layout_wishlist layout_done_view @list_view. @todo_window.hide end |
Instance Attribute Details
#glade ⇒ Object
Returns the value of attribute glade.
4 5 6 |
# File 'lib/todo_window.rb', line 4 def glade @glade end |
#todo_data ⇒ Object
Returns the value of attribute todo_data.
4 5 6 |
# File 'lib/todo_window.rb', line 4 def todo_data @todo_data end |
#todo_window ⇒ Object
Returns the value of attribute todo_window.
4 5 6 |
# File 'lib/todo_window.rb', line 4 def todo_window @todo_window end |
Class Method Details
.meta_data_file=(file) ⇒ Object
11 |
# File 'lib/todo_window.rb', line 11 def self. (file); @@meta_data_file = file; end |
.todo_file_location=(filename) ⇒ Object
12 |
# File 'lib/todo_window.rb', line 12 def self.todo_file_location= (filename); @@todo_file_location = filename; end |
.wishlist=(filename) ⇒ Object
13 |
# File 'lib/todo_window.rb', line 13 def self.wishlist= (filename); @@wishlist = filename; end |
Instance Method Details
#add_to_tasklist(category, todo, priority) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/todo_window.rb', line 28 def add_to_tasklist(category,todo,priority) @todo_data.insert(category,todo,priority.to_i) @meta_data.todo_added @meta_data.dump @todo_data.dump reload_view @stat_vbox.update_today_label(@meta_data) end |
#connect_custom_signals ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/todo_window.rb', line 106 def connect_custom_signals @todo_context_menu = TodoContextMenu.new @todo_context_menu.append(" Mark As Done ") { mark_as_done } @todo_context_menu.append(" Mark As Wishlist ") { mark_as_wishlist } @todo_context_menu.show @list_view.signal_connect("button_press_event") do |,event| if event.kind_of? Gdk::EventButton and event. == 3 @todo_context_menu..popup(nil, nil, event., event.time) end end @list_view.signal_connect("popup_menu") { @todo_context_menu..popup(nil, nil, 0, Gdk::Event::CURRENT_TIME) } # FIXME: implement fold and unfold of blocks @list_view.signal_connect("key-press-event") do |,event| if event.kind_of? Gdk::EventKey key_str = Gdk::Keyval.to_name(event.keyval) if key_str =~ /Left/i # fold the block elsif key_str =~ /Right/i # unfold the block end end end end |
#hide_window ⇒ Object
167 |
# File 'lib/todo_window.rb', line 167 def hide_window; @todo_window.hide; end |
#layout_done_view ⇒ Object
101 102 103 104 |
# File 'lib/todo_window.rb', line 101 def layout_done_view done_view = @glade.("done_view") @done_tab = CompletedView.new(done_view,self) end |
#layout_statbar ⇒ Object
layout statistic bar
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/todo_window.rb', line 85 def @stat_toggle_button = @glade.("toggle_stat_button") @stat_hbox = @glade.("stat_box") @stat_vbox = StatBox.new(@meta_data) @stat_hbox.pack_end(@stat_vbox.vbox_container,true) = Gtk::Image.new("#{SWAT_APP}/resources/control_rewind_blue.png") @stat_box_status = false @stat_toggle_button.image = end |
#layout_wishlist ⇒ Object
96 97 98 99 |
# File 'lib/todo_window.rb', line 96 def layout_wishlist wish_list_view = @glade.("wish_list_view") @wish_list_tab = WishList.new(@@wishlist,wish_list_view,self) end |
#mark_as_done ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/todo_window.rb', line 132 def mark_as_done selection = @list_view.selection if iter = selection.selected selected_category = iter.parent[0] task_index = iter[3] @todo_data.delete(selected_category,task_index) @list_view.model.remove(iter) @todo_data.dump @meta_data.todo_done @meta_data.dump @stat_vbox.update_today_label(@meta_data) @done_tab.reload_view end end |
#mark_as_wishlist ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/todo_window.rb', line 147 def mark_as_wishlist selection = @list_view.selection if iter = selection.selected selected_category = iter.parent[0] task_index = iter[3] priority = todo_data.get_priority(selected_category,task_index) task_text = todo_data.get_task(selected_category,task_index) @wish_list_tab.add_to_wishlist(selected_category,task_text,priority) @todo_data.remove(selected_category,task_index) @todo_data.dump @list_view.model.remove(iter) end end |
#on_add_todo_button_clicked ⇒ Object
22 23 24 25 26 |
# File 'lib/todo_window.rb', line 22 def AddTodoDialog.new(@todo_data.categories) do |priority,category,todo| add_to_tasklist(category,todo,priority) end end |
#on_reload_button_clicked ⇒ Object
55 56 57 58 |
# File 'lib/todo_window.rb', line 55 def @todo_data = TodoData.new(@@todo_file_location) reload_view end |
#on_sync_button_clicked ⇒ Object
169 170 171 172 |
# File 'lib/todo_window.rb', line 169 def system("svn up #{@@todo_file_location}") system("svn ci #{@@todo_file_location} -m 'foo'") end |
#on_todo_window_delete_event ⇒ Object
15 16 17 18 |
# File 'lib/todo_window.rb', line 15 def on_todo_window_delete_event hide_window return true end |
#on_todo_window_destroy_event ⇒ Object
20 |
# File 'lib/todo_window.rb', line 20 def on_todo_window_destroy_event; return true; end |
#on_todo_window_key_press_event(widget, key) ⇒ Object
51 52 53 |
# File 'lib/todo_window.rb', line 51 def on_todo_window_key_press_event(,key) hide_window if Gdk::Keyval.to_name(key.keyval) =~ /Escape/i end |
#on_toggle_stat_button_clicked ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/todo_window.rb', line 37 def # stat box is hidden unless @stat_box_status = Gtk::Image.new("#{SWAT_APP}/resources/control_end_blue.png") @stat_vbox.show_all # stat box is already shown else = Gtk::Image.new("#{SWAT_APP}/resources/control_rewind_blue.png") @stat_vbox.hide_all end @stat_box_status = !@stat_box_status @stat_toggle_button.image = end |
#show_window ⇒ Object
161 162 163 164 165 |
# File 'lib/todo_window.rb', line 161 def show_window @todo_window = @glade.("todo_window") @todo_window.present @todo_window.show end |