[Vala] How to change Gtk.IconView background color
- From: David Siewert <david0siewert gmail com>
- To: vala-list gnome org
- Subject: [Vala] How to change Gtk.IconView background color
- Date: Wed, 4 Sep 2013 11:48:10 +0200
Hi,
i am trying to change the background color of Gtk.IconView
normally i would do it with:
.override_background_color(Gtk.StateFlags.NORMAL,color);
but it doesn't work that way...
is there i a better/working or obvious way of doing it, that i have missed?
if it isn't to much of a hassle, could you provide the answer by
modifying following code example:
public class Application : Gtk.Window {
public Application () {
this.title = "My Gtk.IconView";
this.window_position = Gtk.WindowPosition.CENTER;
this.destroy.connect (Gtk.main_quit);
Gtk.ListStore model = new Gtk.ListStore (2, typeof
(Gdk.Pixbuf), typeof (string));
Gtk.TreeIter iter;
Gtk.IconView view = new Gtk.IconView.with_model (model);
view.set_pixbuf_column (0);
view.set_text_column (1);
this.add (view);
// Data:
Gdk.Pixbuf pixbuf = view.render_icon (Gtk.Stock.ABOUT,
Gtk.IconSize.DIALOG, null);
model.append (out iter);
model.set (iter, 0, pixbuf, 1, "Dialog");
pixbuf = view.render_icon (Gtk.Stock.PRINT, Gtk.IconSize.DIALOG, null);
model.append (out iter);
model.set (iter, 0, pixbuf, 1, "Print");
pixbuf = view.render_icon (Gtk.Stock.CANCEL, Gtk.IconSize.DIALOG, null);
model.append (out iter);
model.set (iter, 0, pixbuf, 1, "Cancel");
Gdk.RGBA color = {Random.next_double()
,Random.next_double(),Random.next_double(),1};
view.override_background_color(Gtk.StateFlags.NORMAL,color);
// <- this line does nothing
}
public static int main (string[] args) {
Gtk.init (ref args);
Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]