Class: Clipcellar::Window

Inherits:
Gtk::Window
  • Object
show all
Defined in:
lib/clipcellar/window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(records) ⇒ Window

Returns a new instance of Window.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/clipcellar/window.rb', line 25

def initialize(records)
  super()
  @records = records
  self.title = "Clipcellar"
  set_default_size(640, 480)
  signal_connect("destroy") do
    Gtk.main_quit
  end

  @vbox = Gtk::VBox.new
  add(@vbox)

  @scrolled_window = Gtk::ScrolledWindow.new
  @scrolled_window.set_policy(:automatic, :automatic)
  @vbox.pack_start(@scrolled_window, true, true, 0)

  @tree_view = TreeView.new(records)
  @scrolled_window.add(@tree_view)

  @label = Gtk::Label.new
  @label.text = "Double Click or Press Return: Copy to Clipboard / Ctrl+d: Delete from Data Store"
  @vbox.pack_start(@label, false, false, 0)

  @tree_view.signal_connect("row-activated") do |tree_view, path, column|
    Clipboard.copy_to_clipboard(@tree_view.selected_text)
  end

  define_key_bindings
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



24
25
26
# File 'lib/clipcellar/window.rb', line 24

def text
  @text
end

Instance Method Details

#runObject



55
56
57
58
# File 'lib/clipcellar/window.rb', line 55

def run
  show_all
  Gtk.main
end