Class: Iconify::Program
- Inherits:
-
Object
- Object
- Iconify::Program
- Defined in:
- lib/iconify/program.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Program
constructor
A new instance of Program.
- #run ⇒ Object
- #run_dialog(message) ⇒ Object
Constructor Details
#initialize(argv) ⇒ Program
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/iconify/program.rb', line 4 def initialize(argv) if argv.size < 1 STDERR.puts "arg" exit 1 end @argv = argv @status_icon = CommandStatusIcon.new(argv[0]) @terminal_window = TerminalWindow.new(argv) @terminal_window.signal_connect('delete-event') do if @status_icon. hide else run_dialog("The status icon is not embedded in a notification area. The window cannot be hidden.") end true # do not close end @terminal_window.signal_connect('changed') do @status_icon.set_state(@terminal_window.state) @terminal_window.icon = @status_icon.pixbuf end @terminal_window.show_all Gtk.timeout_add(500) do if @status_icon. @terminal_window.hide else run_dialog("Iconify has detected its status icon is not embedded in a notification area. The window cannot be hidden.") end false # one time end @status_icon.signal_connect("activate") do if @terminal_window.visible? && @status_icon. @terminal_window.hide else @terminal_window.show end end end |
Instance Method Details
#run ⇒ Object
53 54 55 56 |
# File 'lib/iconify/program.rb', line 53 def run @terminal_window.exec Gtk.main end |
#run_dialog(message) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/iconify/program.rb', line 43 def run_dialog() dialog = Gtk::MessageDialog.new(@terminal_window, Gtk::Dialog::DESTROY_WITH_PARENT, Gtk::MessageDialog::QUESTION, Gtk::MessageDialog::BUTTONS_CLOSE, ) dialog.run dialog.destroy end |