Class: Mylist::MyListHolder

Inherits:
Gtk::Frame
  • Object
show all
Includes:
Conf, ManqodCommon
Defined in:
lib/ListHolder.rb

Direct Known Subclasses

MyRendererEditableList

Defined Under Namespace

Classes: HHolder, VHolder

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 Conf

#get_conf, #load_conf, #save_conf, #set_conf

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

Constructor Details

#initialize(caller) ⇒ MyListHolder

Returns a new instance of MyListHolder.



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
99
100
101
102
103
104
# File 'lib/ListHolder.rb', line 38

def initialize(caller)
	@caller=caller
	@list_id=nil
	@parentM=nil
	@single_mode_child=nil
	@info=Gtk::Label.new('initializing')
	@list=MyEditableList.new(self)
	@list.signal_connect('size-allocate'){|me,alloc|
		me.columns.each{|col|
			list_panel.list_filter.columns[col.data].set_width_request(col.width) unless list_panel.list_filter.columns[col.data].nil? || list_panel.list_filter.columns[col.data].destroyed?
			list_panel.list_sum.renderers[col.data].set_width_request(col.width) unless list_panel.list_sum.renderers[col.data].nil? || list_panel.list_sum.renderers[col.data].destroyed?
		}
	}
	@flistbox=Gtk::VBox.new(false).pack_start(@list_scroller=Gtk::ScrolledWindow.new.add(@list),true,true,0)
	@list_scroller.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_ALWAYS)

	
	@list_panel=ListPanel.new(self)
	@flistbox.pack_end(Gtk::HBox.new.pack_start(list_panel).pack_end(@placeholder_button=Gtk::Button.new.set_relief(Gtk::ReliefStyle::NONE),false,false),false,true,0)
	placeholder_button.set_no_show_all(true)
	@list_scroller.vscrollbar.signal_connect("size-allocate",placeholder_button){|me,alloc,pl|
		pl.set_width_request(alloc.width)
	}
	@buttonholder=ListButtonHolder.new(self,Gtk::ORIENTATION_HORIZONTAL)
	@placeholder_button.
		signal_connect('clicked'){|me|
			menuw=Gtk::Window.new(Gtk::Window::POPUP).add(bar=Gtk::VBox.new.
				add(refresh=Gtk::Button.new.set_image(Gtk::Image.new(Gtk::Stock::REFRESH,Gtk::IconSize::MENU))).
				add(history=Gtk::Button.new.set_image(Gtk::Image.new(Gtk::Stock::INDEX,Gtk::IconSize::MENU))).
				add(cancel=Gtk::Button.new.set_image(Gtk::Image.new(Gtk::Stock::CANCEL,Gtk::IconSize::MENU)))
				)
		refresh.set_relief(Gtk::ReliefStyle::NONE).signal_connect('clicked',menuw,self){|button,menuw,me|
			ManqodDB.instance.manqod_db.reload_moditem(me.list.list_id)
			menuw.hide unless menuw.destroyed?
		}
		history.set_relief(Gtk::ReliefStyle::NONE).signal_connect('clicked',menuw,self){|button,menuw,me|
			history_window
			menuw.hide unless menuw.destroyed?
		}
		cancel.set_relief(Gtk::ReliefStyle::NONE).signal_connect('clicked',menuw,self){|button,menuw,me|
			menuw.hide
		}
		menuw.set_modal(true).set_window_position(Gtk::Window::POS_MOUSE).show_all
=begin
#disabled per current compiz is generating the leave notify event in the wrong order
=end
		menuw.signal_connect('leave-notify-event'){|me,e|
#					me.destroy if e.window == me.window
			me.hide if e.window == me.window
		}
	}

	super()
	set_shadow_type(Gtk::SHADOW_NONE)
	signal_connect('destroy'){|me|
		@notebook.wipe unless @notebook.nil?
		@list.wipe unless @list.nil? || @list.destroyed?
		unless @listbox.nil?
			list_panel.destroy unless list_panel.destroyed?
			@flistbox.destroy unless @flistbox.destroyed?
			@listbox.destroy unless @listbox.destroyed?
			@buttonholder.holder.destroy unless @buttonholder.holder.destroyed?
			@list_panel.destroy unless @list_panel.destroyed?
		end 
		@info.destroy unless @info.destroyed?
	}
end

Instance Attribute Details

#buttonholderObject

Returns the value of attribute buttonholder.



108
109
110
# File 'lib/ListHolder.rb', line 108

def buttonholder
  @buttonholder
end

#callerObject (readonly)

Returns the value of attribute caller.



107
108
109
# File 'lib/ListHolder.rb', line 107

def caller
  @caller
end

#child_placementObject

Returns the value of attribute child_placement.



106
107
108
# File 'lib/ListHolder.rb', line 106

def child_placement
  @child_placement
end

#ganttObject (readonly)

Returns the value of attribute gantt.



107
108
109
# File 'lib/ListHolder.rb', line 107

def gantt
  @gantt
end

#infoObject (readonly)

Returns the value of attribute info.



107
108
109
# File 'lib/ListHolder.rb', line 107

def info
  @info
end

#listObject

Returns the value of attribute list.



105
106
107
# File 'lib/ListHolder.rb', line 105

def list
  @list
end

#list_idObject

Returns the value of attribute list_id.



105
106
107
# File 'lib/ListHolder.rb', line 105

def list_id
  @list_id
end

#list_panelObject

Returns the value of attribute list_panel.



105
106
107
# File 'lib/ListHolder.rb', line 105

def list_panel
  @list_panel
end

#list_scrollerObject

Returns the value of attribute list_scroller.



105
106
107
# File 'lib/ListHolder.rb', line 105

def list_scroller
  @list_scroller
end

#notebookObject

Returns the value of attribute notebook.



106
107
108
# File 'lib/ListHolder.rb', line 106

def notebook
  @notebook
end

#parentMObject (readonly)

Returns the value of attribute parentM.



107
108
109
# File 'lib/ListHolder.rb', line 107

def parentM
  @parentM
end

#placeholder_buttonObject

Returns the value of attribute placeholder_button.



108
109
110
# File 'lib/ListHolder.rb', line 108

def placeholder_button
  @placeholder_button
end

#widgetObject (readonly)

Returns the value of attribute widget.



107
108
109
# File 'lib/ListHolder.rb', line 107

def widget
  @widget
end

Instance Method Details

#advanced_filterObject



220
221
222
# File 'lib/ListHolder.rb', line 220

def advanced_filter
	@buttonholder.advanced_filter
end

#archive_buttonObject



226
227
228
# File 'lib/ListHolder.rb', line 226

def archive_button
	@buttonholder.archive_button
end

#child1Object



238
239
240
# File 'lib/ListHolder.rb', line 238

def child1
	@widget.child1
end

#child2Object



241
242
243
# File 'lib/ListHolder.rb', line 241

def child2
	@widget.child2
end

#embedd?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/ListHolder.rb', line 110

def embedd?
	@list.embedd?
end

#history_windowObject



205
206
207
# File 'lib/ListHolder.rb', line 205

def history_window
	HistoryWindow.new(self)
end

#pack1(widget_to_pack) ⇒ Object



229
230
231
# File 'lib/ListHolder.rb', line 229

def pack1(widget_to_pack)
	@widget.pack1(widget_to_pack,true,true)
end

#pack2(widget_to_pack) ⇒ Object



232
233
234
# File 'lib/ListHolder.rb', line 232

def pack2(widget_to_pack)
	@widget.pack2(widget_to_pack,true,true)
end

#pack_child(child_id) ⇒ Object



189
190
191
192
193
194
195
196
197
198
# File 'lib/ListHolder.rb', line 189

def pack_child(child_id)
	remove(@widget)
 	@single_mode_child=Mylist::MyListHolder.new(self)
	@single_mode_child.set_parentM(list)
	@single_mode_child.list.set_back_button(true).set_id(child_id)
	@single_mode_child.update(self)

	
	add(@single_mode_child)
end

#positionObject



235
236
237
# File 'lib/ListHolder.rb', line 235

def position
	@widget.position
end

#progressObject



217
218
219
# File 'lib/ListHolder.rb', line 217

def progress
	SB.instance.progress
end

#repack_selfObject



199
200
201
202
203
# File 'lib/ListHolder.rb', line 199

def repack_self
	remove(@single_mode_child)
	@single_mode_child.destroy unless @single_mode_child.nil? || @single_mode_child.destroyed?
	add(@widget)
end

#repack_widgetObject



186
187
# File 'lib/ListHolder.rb', line 186

def repack_widget
end

#set_id(new_list_id) ⇒ Object



209
210
211
# File 'lib/ListHolder.rb', line 209

def set_id(new_list_id)
	@list_id=new_list_id
end

#set_parentM(parentM) ⇒ Object



212
213
214
215
# File 'lib/ListHolder.rb', line 212

def set_parentM(parentM)
	@parentM=parentM
	list.set_parentM(parentM)
end

#set_position(pos) ⇒ Object



247
248
249
# File 'lib/ListHolder.rb', line 247

def set_position(pos)
	@widget.set_position(pos)
end

#set_position_set(set_pos) ⇒ Object



244
245
246
# File 'lib/ListHolder.rb', line 244

def set_position_set(set_pos)
	@widget.set_position_set(set_pos)
end

#sum_buttonObject



223
224
225
# File 'lib/ListHolder.rb', line 223

def sum_button
	@buttonholder.sum_button
end

#titleObject



250
251
252
# File 'lib/ListHolder.rb', line 250

def title
	@list.title || 'none'
end

#to_sObject



254
255
256
# File 'lib/ListHolder.rb', line 254

def to_s
	"Holder of #{@list}"
end

#update(notifier) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/ListHolder.rb', line 114

def update(notifier)
	case notifier.class.name 
		when 'BarMenuItem', 'ButtonMenuItem', 'MyRendererButton'
			list.set_id(@list_id=notifier.target)
		when 'MyEditableList', 'Mylist::MyListHolder'
			list.set_id(@list_id) #preserve the last id
		else
			edebug("unknown routing: #{notifier.class.name}","list","warning")
	end

	@child_placement=list.gtk_attribute('child_placement') || 'bottom'
	@button_placement=list.gtk_attribute('button_placement') || 'bottom'
	@gantt_start=list.gtk_attribute('gantt_start')
	@gantt_duration=list.gtk_attribute('gantt_duration')
		
	@listbox.remove(@flistbox).remove(@buttonholder.holder) unless @listbox.nil?
	@gantt.destroy unless @gantt.nil?
	@gantt=nil
	unless @widget.nil?
		@widget.remove(child1) unless child1.nil?
		@widget.remove(child2) unless child2.nil?
		@widget.destroy
	end

	@buttonholder.set_orientation((@button_placement == 'right' ? Gtk::ORIENTATION_VERTICAL : Gtk::ORIENTATION_HORIZONTAL))
		
	@widget=if @child_placement == 'right' then HHolder.new(self) else VHolder.new(self) end
	@listbox=if @button_placement == 'right' then Gtk::HBox.new else Gtk::VBox.new end
	@listbox.pack_start(@flistbox,true,true,0).pack_start(@buttonholder.holder,false,false,0)
		
	if @gantt_start.nil?
		gantt_box=@listbox
		else
		gantt_box=Gtk::HPaned.new.add1(@listbox).add2(@gantt=GanttHolder.new(self))
		if gpos=get_conf(@list.get_id,0,"gantt_position")
			gantt_box.set_position(gpos.to_i).set_position_set(true)
		end
		gantt_box.signal_connect("size-allocate"){|me,alloc|
			set_conf(@list.get_id,0,"gantt_position",me.position)
		}
	end

	@widget.pack1(gantt_box,true,true)
	@widget.signal_connect("size_allocate"){|me,alloc|
		set_conf(@list.get_id,0,"position",me.position) unless me.position == 0
	}

	add(@widget)
	
	#children
	@submodules=list.list_model.drbmodel.childs.size
		if @submodules>0 && !list.single_list_mode
		@notebook=MyNotebook.new(self)
  		@notebook.show_all
		pack2(@notebook)
		if (position=get_conf(list_id,0,"position")||0) !=0
			widget.set_position(position.to_i)
			widget.set_position_set(true)
		end
  	else
  		@notebook.wipe if @notebook
  		@notebook=nil
		@widget.remove(child2) unless child2.nil?
	end

	show_all
	list_panel.set_visibility
	@notebook.update(@list) if @submodules>0 && !list.single_list_mode
	@list.load_data(notifier)
	@gantt.update unless @gantt.nil?
end