Class: HelpIndex

Inherits:
Gtk::ScrolledWindow
  • Object
show all
Defined in:
lib/ManqodHelp/HelpIndex.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(help) ⇒ HelpIndex

Returns a new instance of HelpIndex.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ManqodHelp/HelpIndex.rb', line 6

def initialize(help)
	@help=help
	@path=Array.new
	super()
	set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC)
	@data=Gtk::ListStore.new(String,TrueClass)
	@filter=Gtk::TreeModelFilter.new(@data)
	@filter.set_visible_column(1)
	@sorter=Gtk::TreeModelSort.new(@filter).set_sort_column_id(0)
	@widget=Gtk::TreeView.new(@sorter)
	column=Gtk::TreeViewColumn.new("Index",renderer=Gtk::CellRendererText.new, {:text => 0}).set_sort_column_id(0)
	@widget.append_column(column)
	add_with_viewport(@widget)
	@widget.signal_connect("cursor-changed"){|me|
		if me.cursor
			item=@sorter.get_iter(me.cursor[0])[0]
			@path.push(item) if help.browser.load_item(item)
			@help.update_back_button
		end
	}

end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



28
29
30
# File 'lib/ManqodHelp/HelpIndex.rb', line 28

def help
  @help
end

Instance Method Details

#can_go_back?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/ManqodHelp/HelpIndex.rb', line 58

def can_go_back?
	@path.size > 1
end

#go_backObject



51
52
53
54
55
56
57
# File 'lib/ManqodHelp/HelpIndex.rb', line 51

def go_back
	if can_go_back?
		@path.pop
		set_cursor(@path.pop)
		@help.update_back_button
	end
end

#populateObject



29
30
31
32
33
34
35
36
37
# File 'lib/ManqodHelp/HelpIndex.rb', line 29

def populate
	@data.clear
	@help.browser.items.each_key{|key|
		i=@data.append
		i[0]=key
		i[1]=true
	}
	self
end

#refilterObject



38
39
40
41
42
43
# File 'lib/ManqodHelp/HelpIndex.rb', line 38

def refilter
	@data.each{|model,path,iter|
		iter[1]=iter[0].upcase.index(@help.filter.text.upcase) != nil
	}
	@filter.refilter
end

#set_cursor(item) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/ManqodHelp/HelpIndex.rb', line 44

def set_cursor(item)
	found=nil
	loaded=false
	@data.each{|model,path,iter| found=path if item.upcase == iter[0].upcase}
	loaded=@widget.set_cursor(@sorter.convert_child_path_to_path(@filter.convert_child_path_to_path(found)),nil,false) if found
	loaded
end