[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-mnstbs-mnui

アーカイブの一覧に戻る

ruby-****@sourc***** ruby-****@sourc*****
2012年 10月 30日 (火) 22:42:42 JST


-------------------------
REMOTE_ADDR = 74.14.158.59
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-mnui
-------------------------
@@ -40,51 +40,51 @@
     As you can see this can become rather involved, for deeper menu hierarchies. The main point to remember here is that, there are two kinds of menu items, namely, final menu items, and sub-menu menu items, which must all be defined as Gtk::MenuItem objects in their respective menus (Gtk::Menu objects), however, the sub-menu items themselves are again defined as Gtk::Menu objects.
 
 
-For the completeness let me include the complete program example, for what we discussed above:
-
-((*mechanics-of-building-submenus.rb*))
-
- require 'gtk2'
+    For the completeness let me include the complete program example, for what we discussed above:
+    
+    ((*mechanics-of-building-submenus.rb*))
+    
+     require 'gtk2'
  
- menu = Gtk::Menu.new
- top_mitem1 = Gtk::MenuItem.new("Top Item 1 (final)")
- top_mitem2 = Gtk::MenuItem.new("Top Item 2 (submenu)")
- menu.append(top_mitem1)
- menu.append(top_mitem2)
- 
- submenu = Gtk::Menu.new
- ['Sub Item 1 (final)', 'Sub Item 2 (final)', 'Sub Item 3 (final)'].each do |mi|
-   menuitem = Gtk::MenuItem.new(mi)
-   submenu.append(menuitem)
-   menuitem.show
- end
- submenu.show
- 
- top_mitem2.submenu = submenu
- menu.show_all
+     menu = Gtk::Menu.new
+     top_mitem1 = Gtk::MenuItem.new("Top Item 1 (final)")
+     top_mitem2 = Gtk::MenuItem.new("Top Item 2 (submenu)")
+     menu.append(top_mitem1)
+     menu.append(top_mitem2)
+         
+     submenu = Gtk::Menu.new
+     ['Sub Item 1 (final)', 'Sub Item 2 (final)', 'Sub Item 3 (final)'].each do |mi|
+       menuitem = Gtk::MenuItem.new(mi)
+       submenu.append(menuitem)
+       menuitem.show
+     end
+     submenu.show
  
- window = Gtk::Window.new("Mechanics Of Building Submenus")
- # Make window sensitive to Right-mouse-click, to open the pop-up menu.
- window.add_events(Gdk::Event::BUTTON_PRESS_MASK)
- window.signal_connect("button_press_event") do |widget, event|
-   menu.popup(nil, nil, event.button, event.time) if (event.button == 3)
- end
- # Make window sensitive to <Shift+F10> accelerator keys. These
- # accelerator keys generate the 'popup-menu' signal for window,
- # which opens the popup-menu.
- window.signal_connect("popup_menu") do |w|
-   menu.popup(nil, nil, 0, Gdk::Event::CURRENT_TIME)
- end
- window.set_default_size(330, 100).show_all
- window.signal_connect('destroy') { Gtk.main_quit }
- window.add(Gtk::Label.new("'Right-click' me to see submenus"))
- window.show_all
- Gtk.main
+     top_mitem2.submenu = submenu
+     menu.show_all
+     
+     window = Gtk::Window.new("Mechanics Of Building Submenus")
+     # Make window sensitive to Right-mouse-click, to open the pop-up menu.
+     window.add_events(Gdk::Event::BUTTON_PRESS_MASK)
+     window.signal_connect("button_press_event") do |widget, event|
+       menu.popup(nil, nil, event.button, event.time) if (event.button == 3)
+     end
+     # Make window sensitive to <Shift+F10> accelerator keys. These
+     # accelerator keys generate the 'popup-menu' signal for window,
+     # which opens the popup-menu.
+     window.signal_connect("popup_menu") do |w|
+       menu.popup(nil, nil, 0, Gdk::Event::CURRENT_TIME)
+     end
+     window.set_default_size(330, 100).show_all
+     window.signal_connect('destroy') { Gtk.main_quit }
+     window.add(Gtk::Label.new("'Right-click' me to see submenus"))
+     window.show_all
+     Gtk.main
 
 
 
-:Note:
-    In order to clearly present and expose the relationships between different Gtk menu widgets we intentionally omitted the signal handling code in the above 'sub-menu building' code segment. We'll talk about this shortly in the second of the following two program examples called 'menuitems-n-submenus-2.rb'.
+    :Note:
+        In order to clearly present and expose the relationships between different Gtk menu widgets we intentionally omitted the signal handling code in the above 'sub-menu building' code segment. We'll talk about this shortly in the second of the following two program examples called 'menuitems-n-submenus-2.rb'.
 
 
 {{br}}




ruby-gnome2-cvs メーリングリストの案内
アーカイブの一覧に戻る