Class: MenuHolder
- Inherits:
-
Gtk::Alignment
- Object
- Gtk::Alignment
- MenuHolder
- Includes:
- Conf, ManqodCommon, Observable
- Defined in:
- lib/ButtonMenu.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
Instance Attribute Summary collapse
-
#holder ⇒ Object
Returns the value of attribute holder.
-
#last ⇒ Object
Returns the value of attribute last.
-
#pack_dir ⇒ Object
Returns the value of attribute pack_dir.
-
#parent_menu ⇒ Object
Returns the value of attribute parent_menu.
Instance Method Summary collapse
- #hide_items(except_this = nil) ⇒ Object
- #hide_tree ⇒ Object
-
#initialize(parent_menu, pack_dir = "horizontal") ⇒ MenuHolder
constructor
A new instance of MenuHolder.
- #inspect ⇒ Object
- #recmenuitem(parentid, pmenu) ⇒ Object
- #reinitialize ⇒ Object
- #remove_main_menu_items(pmenu) ⇒ Object
- #show_items(new_size, caller) ⇒ Object
- #to_s ⇒ Object
- #update(notifier) ⇒ Object
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(parent_menu, pack_dir = "horizontal") ⇒ MenuHolder
Returns a new instance of MenuHolder.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ButtonMenu.rb', line 10 def initialize(,pack_dir="horizontal") @parent_menu= @pack_dir=pack_dir @last=nil if pack_dir=="vertical" then super(1,1,0,1);else super(1,1,1,0);end @holder=if pack_dir=="vertical" then Gtk::VBox.new; else Gtk::HBox.new;end holder.set_homogeneous(false) holder.set_border_width(0) add(holder) # add(Gtk::Frame.new.add(holder)) # set_layout_style(Gtk::ButtonBox::SPREAD) # set_icon_size_set(true) # set_icon_size(Gtk::IconSize.from_name("gtk-small-toolbar")) reinitialize end |
Instance Attribute Details
#holder ⇒ Object
Returns the value of attribute holder.
27 28 29 |
# File 'lib/ButtonMenu.rb', line 27 def holder @holder end |
#last ⇒ Object
Returns the value of attribute last.
25 26 27 |
# File 'lib/ButtonMenu.rb', line 25 def last @last end |
#pack_dir ⇒ Object
Returns the value of attribute pack_dir.
28 29 30 |
# File 'lib/ButtonMenu.rb', line 28 def pack_dir @pack_dir end |
#parent_menu ⇒ Object
Returns the value of attribute parent_menu.
26 27 28 |
# File 'lib/ButtonMenu.rb', line 26 def @parent_menu end |
Instance Method Details
#hide_items(except_this = nil) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/ButtonMenu.rb', line 103 def hide_items(except_this=nil) holder.each{|| if ==except_this .show edebug(.inspect+" showing","menu","debug") else .hide edebug(.inspect+" hiding","menu","debug") end #if menuitem.class.name == "MenuItem" # end } end |
#hide_tree ⇒ Object
96 97 98 99 100 101 |
# File 'lib/ButtonMenu.rb', line 96 def hide_tree holder.each{|| ..hide_items if .class.name=="ButtonMenuItem" and . } hide_items end |
#inspect ⇒ Object
146 147 148 149 150 |
# File 'lib/ButtonMenu.rb', line 146 def inspect ret="ButtonMenuHolder" ret=ret+" of "+.text if .class.name == "ButtonMenuItem" ret end |
#recmenuitem(parentid, pmenu) ⇒ Object
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 |
# File 'lib/ButtonMenu.rb', line 34 def (parentid,) =nil admin_rows("select gtkmenu.*, ifnull(childs.cnt,0) as child_cnt from gtkmenu left join (select count(id) as cnt,parent from gtkmenu group by gtkmenu.parent) as childs on childs.parent = gtkmenu.id left join (select count(id) as cnt, groupid from usergroups where userid='#{nick_id}' group by groupid) as perm on perm.groupid = gtkmenu.groupid where gtkmenu.parent='#{parentid}' and (perm.cnt>0) order by oid"){|row| =ButtonMenuItem.new(row['id'],) if .nil? .add_observer(self) else .add_observer() end @last= if row['id'].to_i==get_conf(0,0,"lastmenu").to_i if row['child_cnt'].to_i > 0 .=MenuHolder.new(,pack_dir) @last=..last if ..last end holder.pack_start(,false,true) holder.pack_start(.,false,true) if . } edebug("#{.inspect}(parentid: #{parentid}) added","menu","debug") # unless menuitem.nil? end |
#reinitialize ⇒ Object
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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ButtonMenu.rb', line 30 def reinitialize def () .holder.each{|| .remove()} end def (parentid,) =nil admin_rows("select gtkmenu.*, ifnull(childs.cnt,0) as child_cnt from gtkmenu left join (select count(id) as cnt,parent from gtkmenu group by gtkmenu.parent) as childs on childs.parent = gtkmenu.id left join (select count(id) as cnt, groupid from usergroups where userid='#{nick_id}' group by groupid) as perm on perm.groupid = gtkmenu.groupid where gtkmenu.parent='#{parentid}' and (perm.cnt>0) order by oid"){|row| =ButtonMenuItem.new(row['id'],) if .nil? .add_observer(self) else .add_observer() end @last= if row['id'].to_i==get_conf(0,0,"lastmenu").to_i if row['child_cnt'].to_i > 0 .=MenuHolder.new(,pack_dir) @last=..last if ..last end holder.pack_start(,false,true) holder.pack_start(.,false,true) if . } edebug("#{.inspect}(parentid: #{parentid}) added","menu","debug") # unless menuitem.nil? end (self) case .class.name when 'MainRouter' =(-1,nil) add_observer() if last.nil? begin .show_up() rescue =>err tell_exception("no main menu!",backtrace_to_debug(err),"menu","error",false,false,"you might not have permission to view the main menu") end else last.show_up(last) end when 'ButtonMenuItem' holder.pack_start(StartSeparator.new(pack_dir),true,true) if !..nil? (.,) holder.pack_end(EndSeparator.new(pack_dir),true,true) if !..nil? else edebug("reinitialize: unknown routing(#{caller.class.name})","menu","warning") end # show_all end |
#remove_main_menu_items(pmenu) ⇒ Object
31 32 33 |
# File 'lib/ButtonMenu.rb', line 31 def () .holder.each{|| .remove()} end |
#show_items(new_size, caller) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/ButtonMenu.rb', line 84 def show_items(new_size,caller) before_caller=true holder.each{|| .resize_image(new_size) if .class.name == "ButtonMenuItem" # set_child_packing(menuitem,false,true,1,Gtk::PackType::START) if before_caller # set_child_packing(menuitem,false,true,1,Gtk::PackType::END) if !before_caller .show before_caller=false if caller == edebug("#{} showing","menu") } end |
#to_s ⇒ Object
151 152 153 |
# File 'lib/ButtonMenu.rb', line 151 def to_s inspect end |
#update(notifier) ⇒ Object
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 |
# File 'lib/ButtonMenu.rb', line 116 def update(notifier) case notifier.class.name when 'MyWindow' edebug(inspect+" emiting signal","menu","debug") # reinitialize if last last.show_up(last) changed notify_observers(last) end when 'ButtonMenuItem' if notifier.target @last=notifier set_conf(0,0,"lastmenu",notifier.) if notifier.modname != "quit" edebug(inspect+" emiting signal","menu","debug") changed #focused=get_ancestor(Gtk::Window).focus #setting the window insensitive so user can't interact while destroying and reinitint stuff # get_ancestor(Gtk::Window). set_sensitive(false) measure(last,"cyan"){notify_observers(last)} # get_ancestor(Gtk::Window). set_sensitive(true) unless destroyed? #.set_focus(focused) end else edebug(".update: unknown routing(#{notifier.class.name})","menu","warning") end end |