class BarMenu
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
last[RW]
mainrouter[R]
Public Class Methods
new(mainrouter,pack_dir="horizontal")
click to toggle source
Calls superclass method
# File lib/BarMenu.rb, line 10 def initialize(mainrouter,pack_dir="horizontal") super() set_pack_direction(if pack_dir=="vertical" then Gtk::MenuBar::PACK_DIRECTION_TTB; else Gtk::MenuBar::PACK_DIRECTION_LTR;end) @mainrouter=mainrouter @last=nil reinitialize end
Public Instance Methods
inspect()
click to toggle source
# File lib/BarMenu.rb, line 73 def inspect to_s end
reinitialize()
click to toggle source
# File lib/BarMenu.rb, line 20 def reinitialize def remove_main_menu_items(pmenu) pmenu.each{|menu_item| pmenu.remove(menu_item) } end def recmenuitem(parentid,pmenu) admin_rows("select gtkmenu.*, ifnull(childcnt.cnt,'0') as childs from gtkmenu left join (select count(id) as cnt,parent from gtkmenu group by parent) as childcnt on childcnt.parent=gtkmenu.id left join (select count(id) as cnt,userid,groupid from usergroups group by groupid,userid) as ugrp on ugrp.groupid = gtkmenu.groupid where gtkmenu.parent='#{parentid}' and userid='#{nick_id}' and ugrp.cnt>0 order by oid"){|row| menuitem=BarMenuItem.new(self,row['id']) @last=menuitem if row['id']==get_conf(0,0,"lastmenu") if row['childs'].to_i > 0 menuitem.submenu=Gtk::Menu.new() recmenuitem(row['id'],if row['parent'].to_i==-1 then pmenu else menuitem.submenu end) end pmenu.append(menuitem) unless row['parent'].to_i == -1 } end remove_main_menu_items(self) recmenuitem(-1,self) show_all end
to_s()
click to toggle source
# File lib/BarMenu.rb, line 70 def to_s "Main Menu" end
update(notifier)
click to toggle source
# File lib/BarMenu.rb, line 48 def update(notifier) case notifier.class.name when 'MyWindow' reinitialize @mainrouter.update(last) if last when 'BarMenuItem' if notifier.target last=notifier set_conf(0,0,"lastmenu",notifier.id) if notifier.modname != "quit" edebug("#{last.target} emiting signal","menu","debug") #setting the window insensitive so user can't interact while destroying and reiniting stuff # get_ancestor(Gtk::Window).set_sensitive(false) set_sensitive(false) @mainrouter.update(last) set_sensitive(true) unless destroyed? # get_ancestor(Gtk::Window).set_sensitive(true) if !self.destroyed? end else edebug("unknown routing: #{notifier.class.name}","menu","warning") end end