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



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

def initialize(caller)
  @caller=caller
  @list_id=nil
  @parentM=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.



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

def buttonholder
  @buttonholder
end

#callerObject (readonly)

Returns the value of attribute caller.



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

def caller
  @caller
end

#child_placementObject

Returns the value of attribute child_placement.



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

def child_placement
  @child_placement
end

#ganttObject (readonly)

Returns the value of attribute gantt.



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

def gantt
  @gantt
end

#infoObject (readonly)

Returns the value of attribute info.



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

def info
  @info
end

#listObject

Returns the value of attribute list.



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

def list
  @list
end

#list_idObject

Returns the value of attribute list_id.



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

def list_id
  @list_id
end

#list_panelObject

Returns the value of attribute list_panel.



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

def list_panel
  @list_panel
end

#list_scrollerObject

Returns the value of attribute list_scroller.



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

def list_scroller
  @list_scroller
end

#notebookObject

Returns the value of attribute notebook.



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

def notebook
  @notebook
end

#parentMObject (readonly)

Returns the value of attribute parentM.



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

def parentM
  @parentM
end

#placeholder_buttonObject

Returns the value of attribute placeholder_button.



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

def placeholder_button
  @placeholder_button
end

#widgetObject (readonly)

Returns the value of attribute widget.



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

def widget
  @widget
end

Instance Method Details

#advanced_filterObject



203
204
205
# File 'lib/ListHolder.rb', line 203

def advanced_filter
  @buttonholder.advanced_filter
end

#archive_buttonObject



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

def archive_button
  @buttonholder.archive_button
end

#child1Object



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

def child1
  @widget.child1
end

#child2Object



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

def child2
  @widget.child2
end

#embedd?Boolean



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

def embedd?
  @list.embedd?
end

#history_windowObject



188
189
190
# File 'lib/ListHolder.rb', line 188

def history_window
  HistoryWindow.new(self)
end

#pack1(widget_to_pack) ⇒ Object



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

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

#pack2(widget_to_pack) ⇒ Object



215
216
217
# File 'lib/ListHolder.rb', line 215

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

#positionObject



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

def position
  @widget.position
end

#progressObject



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

def progress
  SB.instance.progress
end

#repack_widgetObject



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

def repack_widget
end

#set_id(new_list_id) ⇒ Object



192
193
194
# File 'lib/ListHolder.rb', line 192

def set_id(new_list_id)
  @list_id=new_list_id
end

#set_parentM(parentM) ⇒ Object



195
196
197
198
# File 'lib/ListHolder.rb', line 195

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

#set_position(pos) ⇒ Object



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

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

#set_position_set(set_pos) ⇒ Object



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

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

#sum_buttonObject



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

def sum_button
  @buttonholder.sum_button
end

#titleObject



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

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

#to_sObject



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

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

#update(notifier) ⇒ Object



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

def update(notifier)
  case notifier.class.name 
    when 'BarMenuItem', 'ButtonMenuItem', 'MyRendererButton'
      list.set_id(@list_id=notifier.target)
    when 'MyEditableList' 
      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
    @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.load_data(notifier)
  @gantt.update unless @gantt.nil?
end