Re: [Rhythmbox-devel] Python Plugin and UI



On Wed, 2007-07-04 at 17:02 +0200, Patrick Sernetz wrote:
> I am still writing my Wikipedia Plugin and I can view the Artist page
> inside rb.. it works rather nicely.. Just a short question. While
> using the gtk.action to create the toolbar button I want to display a
> custom icon.

Hi Patrick,

Useful reference: http://www.pygtk.org/docs/pygtk/class-gtkaction.html -
the method create_icon() does not set the icon for the gtk.Action. You
need to specify the stock_id in the constructor.

>From what I can tell, although GtkAction in C can be created with named
icons, in PyGTK 2.4 you can use only stock icons. This sucks a little,
making everything more complicated. (Confirmations/denials welcome.)

Here is some example code for adding a custom stock icon, ripped
brutally out of context:

        # Add "new podcast" icon.
        icon_file_name = self.__plugin.find_file("podcast-new.png")
        iconsource = gtk.IconSource()
        iconsource.set_filename(icon_file_name)
        iconset = gtk.IconSet()
        iconset.add_source(iconsource)
        
        iconfactory = gtk.IconFactory()
        iconfactory.add("rhythmbox-podcast-new", iconset)
        iconfactory.add_default()

You can then use the string "rhythmbox-podcast-new" as the icon's
stock_id when creating the gtk.Action or gtk.ActionGroup.

-- 
Tim Retout <tim retout co uk>



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