Class: MyNotebook

Inherits:
Gtk::Notebook
  • Object
show all
Includes:
Conf, ManqodCommon, Observable
Defined in:
lib/mynotebook.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])

Constant Summary

Constants included from ManqodCommon

ManqodCommon::CRITICAL, ManqodCommon::DEBUG, ManqodCommon::ERROR, ManqodCommon::INFO, ManqodCommon::NORMAL, ManqodCommon::WARNING

Constants included from Eprint

Eprint::DOMAIN, Eprint::LEVEL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ManqodCommon

#add_where, #admin, #admin_cache, #admin_qrow, #admin_rows, #backtrace_to_debug, #cache, #changed_ids_of_base, #client, #client_fields, #client_image_of_id, #client_qrow, #client_query, #client_rows, #eeval, #escape_string, #getBinding, #guess_base, #guess_table, #image_of_id, #lzero, #manqod_db, #measure, #myexec, #nick, #nick_id, #number_format, #qrow, #query, #reconnect_manqod_db, #rows, #run_events, #send_message, #sendmail, #set_manqod_db_uri, #set_nick

Methods included from Eprint

#ecode, #edebug, #eerror, #einfo, #enormal, #eprint, #ewarn, #gtk_set_edebug, #set_edebug, #tell_exception

Methods included from Conf

#get_conf, #load_conf, #save_conf, #set_conf

Constructor Details

#initialize(parentM) ⇒ MyNotebook

Returns a new instance of MyNotebook.



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

def initialize(parentM)
	@parentM=parentM
	@list_id=nil
	@mypages=Array.new
	@list_count=0
	super()
	set_enable_popup(false)
	set_scrollable(true)
#		set_show_border(false)
#		set_tab_border(0)
	parentM.list.add_observer(self)
end

Instance Attribute Details

#list_countObject (readonly)

Returns the value of attribute list_count.



22
23
24
# File 'lib/mynotebook.rb', line 22

def list_count
  @list_count
end

#list_idObject

Returns the value of attribute list_id.



21
22
23
# File 'lib/mynotebook.rb', line 21

def list_id
  @list_id
end

#notifierObject

Returns the value of attribute notifier.



21
22
23
# File 'lib/mynotebook.rb', line 21

def notifier
  @notifier
end

#parentMObject

Returns the value of attribute parentM.



21
22
23
# File 'lib/mynotebook.rb', line 21

def parentM
  @parentM
end

Instance Method Details

#listsObject

yield child ListHolders



113
114
115
116
117
# File 'lib/mynotebook.rb', line 113

def lists
	each{|submoditem|
		yield submoditem if submoditem.class.name == "Mylist::MyListHolder"
	}
end

#moditem_by_id(mid) ⇒ Object

update



100
101
102
103
104
105
106
107
108
109
110
# File 'lib/mynotebook.rb', line 100

def moditem_by_id(mid)
	found_item=nil
	each{|submoditem|
		case submoditem.class.name
			when "Mylist::MyListHolder" then found_item=submoditem.list if submoditem.list.get_id.to_i == mid.to_i
			when "MyFormHolder" then found_item=submoditem.form if submoditem.form.get_id.to_i == mid.to_i
			else edebug("unknown submoditem: #{submoditem.class.name}","notebook","warning")
		end
	}
	found_item
end

#myObject



124
125
126
# File 'lib/mynotebook.rb', line 124

def my
	@@my
end

#to_sObject



127
128
129
# File 'lib/mynotebook.rb', line 127

def to_s
	"Notebook of #{@parentM}"
end

#update(notifier) ⇒ Object



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
89
90
91
92
93
94
95
96
97
98
# File 'lib/mynotebook.rb', line 24

def update(notifier)
	set_conf(notifier.list_id,0,"page",self.page) if self.page>-1
=begin
#		set_conf(list_id,0,"position",@parentM.widget.position) if @parentM.widget.position > 0
	if (position=get_conf(notifier.list_id,0,"position")||0) !=0
		ecode("#{position}=>#{parentM.widget.position}")
 		parentM.widget.set_position(position.to_i)
 		parentM.widget.set_position_set(true)
	end
=end
	if @list_id != notifier.list_id
		wipe
		@mypages=Array.new
		@list_count=0
		case (notifier.class.name)
  		when 'MyEditableList'
				parentid=notifier.get_id
				edebug("notifier changed: #{notifier}, repacking","sub-list","debug")
  		else
				edebug("unknown routing: "+notifier.class.name,"sub-list","warning")
		end
		if parentid 
				notifier.list_model.drbmodel.childs.each{|moditem|
	  		case moditem['modname']
					when 'listing'
							submoditem_holder=Mylist::MyListHolder.new(self)
						submoditem_holder.set_parentM(notifier)
						submoditem=submoditem_holder.list
		    		submoditem.set_id(moditem['id'])
						submoditem_holder.update(notifier)
						@list_count+=1
					when 'form'
			  		submoditem_holder=Myform::MyFormHolder.new("embedded",self,"modify",moditem['id']).holder
			  		submoditem_holder.holder.set_parentM(notifier)
			  		submoditem=submoditem_holder.form
#				  		submoditem.title=moditem['display']
#				  		submoditem.set_id(moditem['id'])
			  		submoditem.update(notifier,parentid)
	  		end
	  		@mypages.push(submoditem_holder)
				submoditem.is_embedded=submoditem.embedd?
   			if submoditem.is_embedded
					insert_page(submoditem.moditem["oid"].to_i,submoditem_holder,Gtk::Label.new(submoditem.title))
				end
			}
		end
		show_all if n_pages > 0
		set_page(get_conf(notifier.list_id,0,"page").to_i) if get_conf(notifier.list_id,0,"page")
		@list_id=notifier.list_id
	else
		edebug("notifier: #{notifier}, calling update in childs","sub-list","info")
		@mypages.each{|submoditem_holder|
			case submoditem_holder.class.name
				when "Mylist::MyListHolder" then 
					submoditem=submoditem_holder.list
					submoditem.update(notifier)
				when "Myform::MyFormHolder::EmbeddedFormHolder" then 
					submoditem=submoditem_holder.form
					submoditem_holder.update(notifier,notifier.get_cursor_id)
				else edebug("unknown subitem: "+submoditem_holder.class.name,"sub-list","warning")
			end
			if submoditem
   			if submoditem.embedd? != submoditem.is_embedded
   				if submoditem.embedd?
						insert_page(submoditem.moditem["oid"].to_i,submoditem_holder,Gtk::Label.new(submoditem.title))
						else
						remove_page(page_num(submoditem_holder))
					end
					submoditem.is_embedded=submoditem.embedd?
				end
   		end
		}
  		show_all
	end
end

#wipeObject



119
120
121
122
# File 'lib/mynotebook.rb', line 119

def wipe
	@mypages.each{|sublist| sublist.destroy}
	while n_pages>0 do remove_page(-1) end
end