Class: Iconify::Program
Instance Method Summary collapse
-
#initialize(argv) ⇒ Program
constructor
A new instance of Program.
- #parse_args!(argv) ⇒ Object
- #run ⇒ Object
- #run_dialog(message) ⇒ Object
Constructor Details
#initialize(argv) ⇒ Program
Returns a new instance of Program.
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 42 43 44 45 46 |
# File 'lib/iconify/program.rb', line 7 def initialize(argv) @start_minimized = false parse_args!(argv) @argv = argv @status_icon = CommandStatusIcon.new(argv[0]) @terminal_window = TerminalWindow.new(argv) @terminal_window.signal_connect('delete-event') do if @status_icon. @terminal_window.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.update(@terminal_window.state) @terminal_window.icon = @status_icon.pixbuf end @terminal_window.show_all GLib::Timeout.add(500) do if @start_minimized 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 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
#parse_args!(argv) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/iconify/program.rb', line 48 def parse_args!(argv) parser = OptionParser.new do |opts| opts. = 'Usage: iconify [OPTIONS] COMMAND [ARGUMENTS...]' opts.on('-m', '--minimized', 'Start minimized') do |m| @start_minimized = m end end parser.parse!(argv) if argv.empty? STDERR.puts parser. exit 1 end rescue OptionParser::InvalidOption => e STDERR.puts e exit 1 end |
#run ⇒ Object
77 78 79 80 |
# File 'lib/iconify/program.rb', line 77 def run @terminal_window.exec Gtk.main end |
#run_dialog(message) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/iconify/program.rb', line 67 def run_dialog() dialog = MessageDialog.new(parent: @terminal_window, flags: DialogFlags::DESTROY_WITH_PARENT, type: MessageType::QUESTION, buttons: ButtonsType::CLOSE, message: ) dialog.run dialog.destroy end |