Re: Custom icons and Gtk::IconTheme
- From: "Juan A. Moreno" <jamf gm gmail com>
- To: José Alburquerque <jaalburquerque cox net>
- Cc: gtkmm-list gnome org
- Subject: Re: Custom icons and Gtk::IconTheme
- Date: Fri, 24 Jul 2009 20:59:01 +0200
Yes, if you use Gtk::Stock icons, your program update automatically when the user change the theme.
But if you need a custom icon, then you need to get the icon and add it to the stock, for example:
// Create a pixbuf from a stock icon
pixbuf = icon_theme->load_icon("stock_calendar", 48, Gtk::ICON_LOOKUP_USE_BUILTIN);
// Saturate and pixelate it so it is diferent from stock_calendar
pixbuf->saturate_and_pixelate(pixbuf, 0, true);
// Add the new pixbuf as a new icon with a custom method
addStockIcon(pixbuf, "test-customicon", "test-customicon");
When the user change the theme, "stock_calendar" will be updated automatically but not "test-customicon".
Now if you run again the same code, the new pixbuf is diferent from the
previous one and the widgets that were using "test-customicon" have a
reference to the first version. This is why I think I have to do:
// Get the new version of stock_calendar
p = icon_theme->load_icon("stock_calendar", 48, Gtk::ICON_LOOKUP_USE_BUILTIN);
p->saturate_and_pixelate(p, 0, true);
// Replace image in pixbuf without replace the Gtk::Pixbuf
p->copy_area(0, 0, p->get_width(), p->get_height(), pixbuf, 0, 0);
In this way, I think pixbuf is the same all time and only change it's content, but I don't know if this is the correct way to do it.
--
jamf
gelide.sf.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]