Toolbar

Toolbar has become standard in the recent GUI applications, which have a set of common-use buttons, or so.
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.
A sample of the toolbar

Here is a tiny sample of the toolbar. (Excuse its a-bit-small scale ;-)

Program toolbar.rb:

require 'gtk'

window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
window.realize

pix, mask = Gdk::Pixmap::create_from_xpm(window.window,
					 nil,
					 "test.xpm")

toolbar = Gtk::Toolbar.new(Gtk::ORIENTATION_HORIZONTAL, Gtk::TOOLBAR_BOTH)
toolbar.append_item('Open', 'Open File', nil,
		    Gtk::Pixmap::new(pix, mask), nil) {}
toolbar.append_item('Borders', 'Show Borders', nil,
		    Gtk::Pixmap::new(pix, mask), nil) {
  toolbar.set_button_relief(Gtk::RELIEF_NORMAL)
}
toolbar.append_item('Borderless', 'Hide Borders', nil,
		    Gtk::Pixmap::new(pix, mask), nil) {
  toolbar.set_button_relief(Gtk::RELIEF_NONE)
}

window.add toolbar
toolbar.show
window.show
Gtk.main

Execution result:

Illustration of the program above:


Other methods

prepend_item(text, tooltip_text, tooltip_private_text, icon, callback)
insert_item(text, tooltip_text, tooltip_private_text, icon, callback, pos)
`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'.
set_orientation(orientation)
It designates the orientation of the toolbar. orientation The argument is either of the followings: This designation will be promptly reflected on the toolbar.
set_style(style)
Specify the style of the items (buttons). The argument is either of the followings: Each of these designations will be promptly reflected on the toolbar.
set_tooltips(enable)
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.
append_space
prepend_space
insert_space(pos)
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.
set_space_size(space_size)
It designates the size of the space by integer value. This designation will be promptly reflected on the toolbar.
set_space_style(style)
Specify the style of the spaces.
append_widget(widget, tooltips_text, tooltips_private_text)
prepend_widget(widget, tooltips_text, tooltips_private_text)
insert_widget(widget, tooltips_text, tooltips_private_text, pos)
Add an arbitrary widget (not an item).
Next
[TOP]
Written by akaishi@ruby.freak.ne.jp