class ListButtonHolder

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Attributes

advanced_buttons[R]
advanced_filter[R]
archive_button[R]
groups[R]
holder[R]
legends_button[R]
list_buttons[R]
list_holder[R]
sum_button[R]

Public Class Methods

new(list_holder,orientation) click to toggle source
# 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

Public Instance Methods

activate_default() click to toggle source
# 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_buttons() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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