Class: ListButtonHolder

Inherits:
Object
  • Object
show all
Includes:
ManqodCommon
Defined in:
lib/ListHolder/ListButtonHolder.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

Constructor Details

#initialize(list_holder, orientation) ⇒ ListButtonHolder

Returns a new instance of ListButtonHolder.



8
9
10
11
12
13
14
15
16
# File 'lib/ListHolder/ListButtonHolder.rb', line 8

def initialize(list_holder,orientation)
	@list_holder=list_holder
	@list_id=nil
	@default=nil
	@groups=Hash.new
	set_orientation(orientation)
#		list_buttons.set_layout_style(Gtk::ButtonBox::SPREAD)
	list_holder.list.add_observer(self)
end

Instance Attribute Details

#advanced_buttonsObject (readonly)

Returns the value of attribute advanced_buttons.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def advanced_buttons
  @advanced_buttons
end

#advanced_filterObject (readonly)

Returns the value of attribute advanced_filter.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def advanced_filter
  @advanced_filter
end

#archive_buttonObject (readonly)

Returns the value of attribute archive_button.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def archive_button
  @archive_button
end

#groupsObject (readonly)

Returns the value of attribute groups.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def groups
  @groups
end

#holderObject (readonly)

Returns the value of attribute holder.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def holder
  @holder
end

#legends_buttonObject (readonly)

Returns the value of attribute legends_button.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def legends_button
  @legends_button
end

#list_buttonsObject (readonly)

Returns the value of attribute list_buttons.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def list_buttons
  @list_buttons
end

#list_holderObject (readonly)

Returns the value of attribute list_holder.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def list_holder
  @list_holder
end

#sum_buttonObject (readonly)

Returns the value of attribute sum_button.



17
18
19
# File 'lib/ListHolder/ListButtonHolder.rb', line 17

def sum_button
  @sum_button
end

Instance Method Details

#activate_defaultObject



91
92
93
# File 'lib/ListHolder/ListButtonHolder.rb', line 91

def activate_default
	@default.clicked if @default && !@list_holder.list.list_model.locked?(@list_holder.list.get_cursor_id) && @default.sensitive?
end

#load_buttonsObject



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

def load_buttons
	@default=nil
	@groups.clear
	list_buttons.each{|button| button.destroy unless button.destroyed?}
#		admin_rows("select * from buttons where moditemid='#{list_holder.list.get_id}' and (grp_id in (-1,0) or (select count(id) from usergroups where userid='#{nick_id}' and groupid=grp_id)>0) order by oid"){|row|
	return if list_holder.list.list_model.drbmodel.nil?
	@archive_button.update
	@legends_button.update
	@up_button.update
	@down_button.update
	list_holder.list.list_model.drbmodel.buttons(nick_id).each{|row|
		button=MyButton.new(row.rehash,list_holder,self)
		if button.group && !@groups.has_key?(button.group)
			@groups[button.group]=ButtonGroup.new(self,button.group)
			list_buttons.pack_start(@groups[button.group])
		end
		if button.group
			button.group_widget.pack_start(button)
			else
			list_buttons.pack_start(button)
		end
		button.update(list_holder.list)
		@default=button if @default.nil? and button.function != 'add'
	 }
	holder.show_all
end

#set_orientation(new_orientation) ⇒ Object



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

def set_orientation(new_orientation)
	unless new_orientation == @orientation
		@orientation = new_orientation
		@holder.remove(advanced_buttons).remove(list_buttons) unless @holder.nil?
		@holder.destroy unless @holder.nil? or @holder.destroyed?
		if advanced_buttons.nil? or advanced_buttons.destroyed?
			@advanced_buttons=Gtk::HBox.new.set_homogeneous(false)
			advanced_buttons.pack_start(@advanced_filter=AdvancedFilterButton.new(@list_holder))
			advanced_buttons.pack_start(@sum_button=SumPanelButton.new(@list_holder))
			advanced_buttons.pack_start(@legends_button=LegendsButton.new(@list_holder))
			advanced_buttons.pack_start(@archive_button=ArchiveButton.new(@list_holder))
			advanced_buttons.pack_start(@up_button=OrderingButton.new(@list_holder,Gtk::Stock::GO_UP))
			advanced_buttons.pack_start(@down_button=OrderingButton.new(@list_holder,Gtk::Stock::GO_DOWN))
		end
		case @orientation
			when Gtk::ORIENTATION_VERTICAL
				@holder=Gtk::VBox.new
				@list_buttons=Gtk::VBox.new#.set_homogeneous(false).set_layout_style(Gtk::ButtonBox::START)
				holder.pack_start(list_buttons,false,false,0)
				holder.pack_start(list_holder.info,true,true)
				holder.pack_start(advanced_buttons,false,false,0)
			else
#				when Gtk::ORIENTATION_HORIZONTAL
				@holder=Gtk::HBox.new
				@list_buttons=Gtk::HBox.new#.set_homogeneous(false).set_layout_style(Gtk::ButtonBox::END)
				holder.pack_start(advanced_buttons,false,false,0)
				holder.pack_start(list_holder.info,true,true)
				holder.pack_end(list_buttons,false,false,0)
		end
		load_buttons
	@holder.signal_connect('destroy'){|me|
		@holder.remove(list_holder.info) unless list_holder.info.destroyed?
	}
	end
end

#update(notifier, reload = false) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/ListHolder/ListButtonHolder.rb', line 19

def update(notifier,reload=false)
	if notifier.list_id == @list_id && !reload
		list_buttons.each{|button| button.update(notifier)}
		else
		@list_id=notifier.list_id
		load_buttons
	end
	self
end