Method: Iconify::Program#initialize

Defined in:
lib/iconify/program.rb

#initialize(argv) ⇒ Program

Returns a new instance of 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.embedded?
      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.embedded?
      @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.embedded?
      @terminal_window.hide
    else
      @terminal_window.show
    end
  end
end