Class: Rediscover::Frame::Main

Inherits:
Wx::Frame
  • Object
show all
Includes:
Wx
Defined in:
lib/rediscover/frame/main.rb

Constant Summary collapse

WINDOW_WIDTH =
600
WINDOW_HEIGHT =
400

Instance Method Summary collapse

Constructor Details

#initializeMain

Returns a new instance of Main.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rediscover/frame/main.rb', line 9

def initialize
  super(nil, -1, 'Rediscover', DEFAULT_POSITION, Size.new(WINDOW_WIDTH, WINDOW_HEIGHT))

  @redis = get_app.redis
  @logger = get_app.logger

  set_icon(Rediscover::Icon.new('application'))

  setup_status_bar
  setup_notebook
  show
end

Instance Method Details

#setup_notebookObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/rediscover/frame/main.rb', line 22

def setup_notebook
  @notebook = Notebook.new(self)

  @server_page = Panel::Server.new(@notebook)
  @browser_page = Panel::Browser.new(@notebook)
  @browser_page.on_status_change { |status| update_status_bar(status) }

  @notebook.add_page(@server_page, 'Server Info', false)
  @notebook.add_page(@browser_page, 'Key Browser', true)
end

#setup_status_barObject



33
34
35
36
37
# File 'lib/rediscover/frame/main.rb', line 33

def setup_status_bar
  @status_bar = create_status_bar(2)
  @status_bar.set_status_widths([-3, -1]) # set fields to variable widths
  update_status_bar
end

#update_status_bar(status = nil) ⇒ Object



39
40
41
42
# File 'lib/rediscover/frame/main.rb', line 39

def update_status_bar(status = nil)
  @status_bar.set_status_text(@redis.to_s, 0) # connection info in left field
  @status_bar.set_status_text(status, 1) if status # key count in right field
end