[GTK] Toolbar, Gdk::Pixmap::create_from_xpm_d

Hi,

This is my code:

#v+
#!/usr/bin/env ruby

require ‘gtk’

$reload_xpm = [
“16 14 3 1”,
". c None",
“a c #000000”,
"# c #7b7b7b",
"…##aaa#…",
"…#aaaaaaa…",
"…#aa#…#a…",
"…aa#…",
"…aaa…a…",
“aaaaaaa…aaa…”,
".aaaaa…aaaaa.",
"…aaa…aaaaaaa",
"…a…aaa…",
"…#aa…",
"…a#…#aa#…",
"…aaaaaaa#…",
"…#aaa##…",
"…"
]

window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
vbox = Gtk::VBox.new(false, 0)
toolbar = Gtk::Toolbar.new
toolbar.set_style Gtk::TOOLBAR_ICONS
pixmap, mask = Gdk::Pixmap::create_from_xpm_d(window.window, nil, $reload_xpm)
pixmapwid = Gtk::Pixmap.new(pixmap, mask)
toolbar.append_item(“Reload”, “Reload”, “Reload”, pixmapwid, nil) {
puts “hello”
}
window.add vbox
vbox.pack_start toolbar, false, false, 0
toolbar.show
vbox.show
window.show
Gtk.main
#v-

When I run it, the following message is displayed:

Gdk-WARNING **: Creating pixmap from xpm with NULL window and colormap

Moreover, when I change the lines

toolbar.show
vbox.show
window.show

to

window.show_all

toolbar.set_style has no effect an more; both text and icons are
displayed, even if Gtk::TOOLBAR_ICONS is used.

What’s wrong?

I use:
GTK 1.2.8
Ruby-GTK 0.24
Ruby 1.6.4

Johannes

···


http://www.grimmenstein.gv.at
http://ffgrimmenstein.feuerwehr.org

Hi,

This is my code:

#v+
#!/usr/bin/env ruby

require ‘gtk’

$reload_xpm = [
“16 14 3 1”,
". c None",
“a c #000000”,
"# c #7b7b7b",
"…##aaa#…",
"…#aaaaaaa…",
"…#aa#…#a…",
"…aa#…",
"…aaa…a…",
“aaaaaaa…aaa…”,
".aaaaa…aaaaa.",
"…aaa…aaaaaaa",
"…a…aaa…",
"…#aa…",
"…a#…#aa#…",
"…aaaaaaa#…",
"…#aaa##…",
"…"
]

window = Gtk::Window.new(Gtk::WINDOW_TOPLEVEL)
vbox = Gtk::VBox.new(false, 0)
toolbar = Gtk::Toolbar.new
toolbar.set_style Gtk::TOOLBAR_ICONS
pixmap, mask = Gdk::Pixmap::create_from_xpm_d(window.window, nil, $reload_xpm)
pixmapwid = Gtk::Pixmap.new(pixmap, mask)
toolbar.append_item(“Reload”, “Reload”, “Reload”, pixmapwid, nil) {
puts “hello”
}
window.add vbox
vbox.pack_start toolbar, false, false, 0
toolbar.show
vbox.show
window.show
Gtk.main
#v-

When I run it, the following message is displayed:

Gdk-WARNING **: Creating pixmap from xpm with NULL window and colormap

Before creating a pixmap with default window settings, you must realize
the window:

window.realize

Moreover, when I change the lines

toolbar.show
vbox.show
window.show

to

window.show_all

toolbar.set_style has no effect an more; both text and icons are
displayed, even if Gtk::TOOLBAR_ICONS is used.

I dont’t know why, but use

toolbar.append_item(nil, “Reload”, nil, pixmapwid, nil)

instead.

What’s wrong?

I use:
GTK 1.2.8
Ruby-GTK 0.24
Ruby 1.6.4

Harald Große

···

Am Die, 2002-08-06 um 01.59 schrieb Johannes Tanzler: