Class: Swat::SwatMain
- Inherits:
-
Object
- Object
- Swat::SwatMain
- Defined in:
- lib/swat.rb
Instance Attribute Summary collapse
-
#config_dir ⇒ Object
Returns the value of attribute config_dir.
-
#key_binder ⇒ Object
Returns the value of attribute key_binder.
-
#status_icon ⇒ Object
Returns the value of attribute status_icon.
-
#todo_window ⇒ Object
Returns the value of attribute todo_window.
Instance Method Summary collapse
-
#create_config_directory ⇒ Object
creates configuration files if they don’t exist.
- #display_context_menu(*args) ⇒ Object
-
#initialize ⇒ SwatMain
constructor
A new instance of SwatMain.
- #show_task_list ⇒ Object
Constructor Details
#initialize ⇒ SwatMain
Returns a new instance of SwatMain.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/swat.rb', line 8 def initialize @config_dir = File.join(ENV['HOME'] + '/snippets') create_config_directory @status_icon = Gtk::StatusIcon.new icon_file = Gdk::Pixbuf.new("#{SWAT_APP}/resources/todo.png") @status_icon.pixbuf = icon_file TodoWindow.todo_file_location = File.join(ENV['HOME'], '/snippets/todo.org') TodoWindow.wishlist = File.join(ENV['HOME'], '/snippets/wishlist.org') TodoWindow. = File.join(ENV['HOME'], '/snippets/meta_data.yml') @todo_window = TodoWindow.new("#{SWAT_APP}/resources/todo_window.glade") @status_icon.set_tooltip("Your Task List") @status_icon.visible = true @status_icon.signal_connect('activate') { show_task_list } @status_icon.signal_connect('popup-menu') { |*args| (*args) } @key_binder = KeyBinder.new bind_proc = lambda { show_task_list } @key_binder.bindkey("<Alt>F11",bind_proc) end |
Instance Attribute Details
#config_dir ⇒ Object
Returns the value of attribute config_dir.
7 8 9 |
# File 'lib/swat.rb', line 7 def config_dir @config_dir end |
#key_binder ⇒ Object
Returns the value of attribute key_binder.
6 7 8 |
# File 'lib/swat.rb', line 6 def key_binder @key_binder end |
#status_icon ⇒ Object
Returns the value of attribute status_icon.
5 6 7 |
# File 'lib/swat.rb', line 5 def status_icon @status_icon end |
#todo_window ⇒ Object
Returns the value of attribute todo_window.
4 5 6 |
# File 'lib/swat.rb', line 4 def todo_window @todo_window end |
Instance Method Details
#create_config_directory ⇒ Object
creates configuration files if they don’t exist
37 38 39 40 41 42 43 44 |
# File 'lib/swat.rb', line 37 def create_config_directory if File.exist?(@config_dir) && !File.directory?(@config_dir) raise "A file with same name as configuration directory #{@config_dir} exists in home directory" end unless File.exist?(@config_dir) FileUtils.mkdir(@config_dir) end end |
#display_context_menu(*args) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/swat.rb', line 46 def (*args) w,,activate_time = *args = Gtk::Menu.new = Gtk::MenuItem.new(" Quit ") .signal_connect("activate") { w.set_visible(false) Gtk.main_quit } .append() = Gtk::MenuItem.new(" Hide ") .signal_connect("activate") { @todo_window.hide_window } .append() .show_all .popup(nil,nil,,activate_time) end |
#show_task_list ⇒ Object
32 33 34 |
# File 'lib/swat.rb', line 32 def show_task_list @todo_window.show_window end |