Class: CustomPluginWindow

Inherits:
Object
  • Object
show all
Defined in:
lib/gui/custom_plugin_window.rb

Instance Method Summary collapse

Constructor Details

#initializeCustomPluginWindow

Returns a new instance of CustomPluginWindow.



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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/gui/custom_plugin_window.rb', line 17

def initialize()
		window=Gtk::Window.new
 	window.set_title("Custom Plugin Configuration")
		window.set_size_request(500, 300)

      window.signal_connect("key_press_event") {|w,e|
     	if e.keyval == Gdk::Keyval::GDK_Escape
  window.destroy
      end
		}

		frame = Gtk::Frame::new
		frame.border_width=5
		frame.show
		vbox_root=Gtk::VBox::new
		vbox_root.show
		window.add vbox_root
		vbox_root.add frame

		vbox = Gtk::VBox.new(false,0)
		vbox.show
		frame.add vbox

             @custom_ref_ls = Gtk::ListStore.new(String, String)
             @custom_ref_view = Gtk::TreeView.new(@custom_ref_ls)
		@custom_ref_view.show
column1 = Gtk::TreeViewColumn.new("Name",
		Gtk::CellRendererText.new, {:text => 0})
	column1.set_sort_column_id(0)
	column2 = Gtk::TreeViewColumn.new("Description",
		Gtk::CellRendererText.new, {:text => 1})
	column2.set_sort_column_id(1)

	@custom_ref_view.append_column(column1)
	@custom_ref_view.append_column(column2)
	
		scroll = Gtk::ScrolledWindow.new(nil, nil)
		scroll.border_width=2
		scroll.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC)  
		scroll.add @custom_ref_view
		scroll.show
		
		populate_ls()
		vbox.add(scroll)

		bbox = Gtk::HBox::new(FALSE, 10)
		bbox.border_width=10
		bbox.show

		ok_button = Gtk::Button.new(Gtk::Stock::OK)
		ok_button.show
		ok_button.signal_connect("clicked") {
window.destroy
		}

		cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
		cancel_button.show
		cancel_button.signal_connect("clicked") {
                window.destroy
		}
		ok_button.set_flags(Gtk::Widget::CAN_DEFAULT)
		bbox.pack_start(ok_button, TRUE, TRUE, 0)
		cancel_button.set_flags(Gtk::Widget::CAN_DEFAULT)
		bbox.pack_start(cancel_button, TRUE, TRUE, 0)

		separator = Gtk::HSeparator::new()
		separator.show
		vbox_root.pack_start(separator, FALSE, TRUE, 0)
		vbox_root.pack_start(bbox, FALSE, TRUE, 0)

		window.show
end

Instance Method Details

#populate_lsObject

populate listview with saved values



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/gui/custom_plugin_window.rb', line 4

def populate_ls()
  	$custom_monitor.each do |name|
	  iter = @custom_ref_ls.append
	  iter[0] = name
	  descr = "No description available"
	  begin
	    descr = Object.const_get(name).name()
	  rescue		    
	  end
	  iter[1] = descr		  
	end
end