Re: [Vala] How to change Gtk.IconView background color



2013/9/4 David Siewert <david0siewert gmail com>

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;
    }
}


Hi,

I think you accidentally posted on the wrong mailing list?
Here is a list of available GTK related ones:
http://www.gtk.org/mailing-lists.php

Jonas


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]