Hi, 

Now I've translated chapter toolbar of the Ruby/GTK documentation
in <URL:http://ruby.freak.ne.jp/gtk/>. Check it out!

-- 
SUGIHARA Hiroshi
maili31s / clio.ne.jp

Ruby/Gtk Tutorial ToDo 19991119 #====================================================================== ...skip #====================================================================== /nextfile toolbar.html /chap Toolbar <u>Toolbar</u> has become standard in the recent GUI applications, which have a set of common-use buttons, or so.<br> On Gtk, the toolbar is a kind of the container widget, and it can place the buttons with icon and/or the other optional widgets, vertically or horizontally. #---------------------------------------------------------------------- /section A sample of the toolbar Here is a tiny sample of the toolbar. (Excuse its a-bit-small scale ;-) <p> /proginsert toolbar.rb Execution result:<br> <p> Illustration of the program above:<br> <ul> =c pix, mask = Gdk::Pixmap::create_from_xpm(window.window, nil, "test.xpm") It generates an icon (pixmap) put on the button of the toolbar. Only one icon is generated here and is common with all buttons, but actually they each wants their own icons. =c toolbar = Gtk::Toolbar.new(Gtk::ORIENTATION_HORIZONTAL, Gtk::TOOLBAR_BOTH) It generates a toolbar widget. First argument desinates the orientation of the toolbar widget. Either of the two below will be chosen: <ul> <li>Gtk::ORIENTATION_HORIZONTAL (...horizontal) <li>Gtk::ORIENTATION_VERTICAL (...vertical) </ul> Second argument specifies the style of the button, and is either of the followings: <ul> <li>Gtk::TOOLBAR_TEXT (...only text) <li>Gtk::TOOLBAR_ICONS (...only icons) <li>Gtk::TOOLBAR_BOTH (...both) </ul> This style is applied to the button made by following `append_item'.<br> [Example] The case to designate Gtk::TOOLBAR_TEXT<br> =c toolbar.append_item('Open', 'Open File', nil, Gtk::Pixmap::new(pix, mask), nil) {} It appends an item to the toolbar. Button is the item at here. Each of the arguments (many) have a following role; from the head, <ol> <li>text on the button, <li>string displayed as tooltips, <li>discriminator (string) used on the tooltip; although `nil' should be OK, <li>`pixmap' used for the icon, <li>and callback `proc' at the time the button is pushed. </ol> `append_item' is a iterator (but it doesn't forced to iterate...), and it can give the callback closure as the block (it cannot skip)ĄŁ The first item `Open' is empty, so nothing happens when the button is pushed. <br> Rest two buttons can be made in the same way, while this time the following sentence is written in the block.<br> <code>toolbar.set_button_relief(Gtk::RELIEF_NORMAL)</code><br> `set_button_relief' is a method of the toolbar widget, and change its relief style of the button on the item.<br> <ul> <li>Gtk::RELIEF_NORMAL (same as the normal button; default) <li>Gtk::RELIEF_NONE (no relief) </ul> Push the button `Borders' or `Borderles', and the relief style of the item of the toolbar changes.<br> [Example] push `Borderless' button:<br> </ul> #---------------------------------------------------------------------- /section Other methods <dl> =d <code><b>prepend_item</b></code>(<i>text, tooltip_text, tooltip_private_text, icon, callback</i>) =d <code><b>insert_item</b></code>(<i>text, tooltip_text, tooltip_private_text, icon, callback, pos</i>) <dd> `prepend_item' is almost the same as `append_item', but it appends the item before the location. `insert_item' appends it on the location specified by `pos'. =d <code><b>set_orientation</b></code>(<i>orientation</i>) <dd> It designates the orientation of the toolbar. <i>orientation</i> The argument is either of the followings: <ul> <li>Gtk::ORIENTATION_HORIZONTAL (...horizontal) <li>Gtk::ORIENTATION_VERTICAL (...vertical) </ul> This designation will be promptly reflected on the toolbar. =d <code><b>set_style</b></code>(<i>style</i>) <dd> Specify the style of the items (buttons). The argument is either of the followings: <ul> <li>Gtk::TOOLBAR_TEXT (...only text) <li>Gtk::TOOLBAR_ICONS (...only icons) <li>Gtk::TOOLBAR_BOTH (...both) </ul> Each of these designations will be promptly reflected on the toolbar. =d <code><b>set_tooltips</b></code>(<i>enable</i>) <dd> It designates whether tooltips should be effective or not. The argument is either `true' or `false'. This designation will be promptly reflected on the toolbar. =d <code><b>append_space</b></code> =d <code><b>prepend_space</b></code> =d <code><b>insert_space</b></code>(<i>pos</i>) <dd> Each of them inserts the space as a pause of the items, where `append_space': before; `prepend_space': after; `insert_space': on the specified, location. =d <code><b>set_space_size</b></code>(<i>space_size</i>) <dd> It designates the size of the space by integer value. This designation will be promptly reflected on the toolbar. =d <code><b>set_space_style</b></code>(<i>style</i>) <dd> Specify the style of the spaces. <ul> <li>Gtk::Toolbar::SPACE_EMPTY (...empty at all) <li>Gtk::Toolbar::SPACE_LINE (...lined) </ul> =d <code><b>append_widget</b></code>(<i>widget, tooltips_text, tooltips_private_text</i>) =d <code><b>prepend_widget</b></code>(<i>widget, tooltips_text, tooltips_private_text</i>) =d <code><b>insert_widget</b></code>(<i>widget, tooltips_text, tooltips_private_text</i>, pos) <dd> Add an arbitrary widget (not an item). </dl> #/write #====================================================================== /nextfile gtkrc.html