Class: HistoryWindow

Inherits:
Gtk::Window
  • Object
show all
Defined in:
lib/ListHolder/HistoryWindow.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 Method Summary collapse

Constructor Details

#initialize(list_holder) ⇒ HistoryWindow

Returns a new instance of HistoryWindow.



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
# File 'lib/ListHolder/HistoryWindow.rb', line 6

def initialize(list_holder)
	@holder=list_holder
	@row_id=nil
	super()
	set_title('history')
	set_modal(true)
	set_transient_for(@holder.get_ancestor(Gtk::Window))
	set_has_frame(false)
	set_window_position(Gtk::Window::POS_CENTER_ON_PARENT)
	set_size_request(600,300)
	@store=Gtk::TreeStore.new(String,String,String,String,String) #time,nick,operation, header, data
	add(Gtk::VBox.new)
	child.pack_start(Gtk::ScrolledWindow.new.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC).add(hview=Gtk::TreeView.new(@store))).
			pack_start(Gtk::HBox.new.
					pack_start(prevb=Gtk::Button.new(Gtk::Stock::GO_BACK),false,false).
					pack_start(nextb=Gtk::Button.new(Gtk::Stock::GO_FORWARD),false,false).
					pack_start(Gtk::Alignment.new(0,0,0,0),true,true).
					pack_start(closeb=Gtk::Button.new(Gtk::Stock::CLOSE),false,false),
				false,false)
	closeb.signal_connect('clicked'){|me| self.destroy}
	nextb.signal_connect('clicked'){|me| load_history(@row_id+1)}
	prevb.signal_connect('clicked'){|me| load_history(@row_id-1)}
	
	renderer = Gtk::CellRendererText.new
	hview.append_column(Gtk::TreeViewColumn.new("Time", renderer, :text => 0))
	hview.append_column(Gtk::TreeViewColumn.new("User", renderer, :text => 1))
	hview.append_column(op_col=Gtk::TreeViewColumn.new("Operatioin", renderer, :text => 2))
	hview.append_column(Gtk::TreeViewColumn.new("Field", renderer, :text => 3))
	hview.append_column(Gtk::TreeViewColumn.new("History", renderer, :text => 4))
	hview.set_expander_column(op_col).set_enable_tree_lines(true)
	load_history(@holder.list.get_cursor_id)
end

Instance Method Details

#load_history(new_row_id) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/ListHolder/HistoryWindow.rb', line 39

def load_history(new_row_id)
	@store.clear
	@row_id=new_row_id
	set_title("history for #{@holder.list.list_model.base} ##{@row_id}")
	last_u=nil
	piter=nil
	@holder.admin.rows("select history.*,gtkheaders.header from history left join gtkheaders on gtkheaders.id = history.header_id where base='#{@holder.list.list_model.base}' and row_id='#{@row_id}' order by ctime desc").each{|row|
		unless last_u == row["ctime"]
			iter=@store.append(nil)
			piter=iter
			last_u=row["ctime"]
			iter[0]=row["ctime"]
			iter[1]=row["nick"]
			iter[2]=row["operation"]
		end
		if row["operation"] == "u"
			iter=@store.append(piter)
			iter[3]=row["header"]
			iter[4]=row["data"]
		end
	}
	show_all
end