Re: How to add a custom cell renderer to a Gtk::IconView



Thank you so much for your time and help! It worked as you suggested.

On 11/22/2009 11:38 PM, Jos Alburquerque wrote:
On Sun, 2009-11-22 at 20:57 -0500, Todor Todorov wrote:
Thanks again for the reply.

It is not a problem to implement the renderer in gtkmm - as a matter of
fact that's the first thing I did. As you know though, I can't add it to
a Gtk::IconView, because it does not implement the CellLayout interface.
That bit of info was in your first reply.
Yes, I did mention the problem with Gtk::IconView not yet implementing
the Gtk::CellLayout interface.  I could be wrong, but what I was sort of
suggesting is that if you have the gtkmm cell renderer, you use it's
gobj() where necessary in your posted code.  For example, your code
would look like the following (the lines that have been modified are
distinguished with an asterisk as the first character):

      ...
      Gtk::IconView *browser = 0;
      builder->get_widget( "browser", browser );
      {
          GtkIconView *view = browser->gobj();
*        Gtk::CellRenderer *cell = Gtk::CellRendererThumb::create();
*        gtk_cell_layout_pack_start( GTK_CELL_LAYOUT( view ),
cell->gobj(), FALSE );

*        // Set cell renderer properties here using gtkmm

*        gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT( view ),
cell->gobj(),
                                          "thumb-name", 0, "thumb-date",
1,
                                          "thumb-image", 2,
                                          "thumb-checked", 3,
                                          "thumb-duplicate", 4, NULL );

*        // Connect to cell signals here using sigc
      }
      browser->set_model( thumblist );
      ...

Now, of course, I'm by far not an expert so I'm just guessing.

I guess I will have to look into subclassing Gtk::IconView itself ... Do
you know of any examples for that? I suspect deriving from Gtk::ListView
will be easier, and I'll find more code I could look up and take a note
from, but I have no idea how to make the new class order the items in
multiple columns.
I don't have examples but others may.  The online book has good
information on custom widgets in chapter 25[1].  Also the
gtkmm-documentation package[2] has examples.

[1]
http://library.gnome.org/devel/gtkmm-tutorial/unstable/chapter-customwidgets.html.en
[2]http://ftp.gnome.org/pub/GNOME/sources/gtkmm-documentation/



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