[ Start > PikeModules > Module > GTK2 ] [ Edit this Page | Viewing Version 1 ]

Creating stock icons

To create stock icons, first create an array of mappings like this:

array iconfiles=({
 ([ "file": "icons/actions_wm.png",
    "stock-id": "hdadmin-actions" ]),
 ([ "file": "icons/connect_wm.png",
    "stock-id": "hdadmin-connect" ]),
 ([ "file": "icons/directory_server_wm.png",
    "stock-id": "hdadmin-directory" ]),
 ([ "file": "icons/search_wm.png",
    "stock-id": "hdadmin-search" ])

This isn't really necessary, it just makes it easier.

The stock-id is what you will reference later when creating toolbars and things with ActionGroups.

Then, create an IconFactory:

object iconf=GTK2.IconFactory();

Add each icon to the icon factory. Do this for each icon by creating an IconSet for that icon, then add the IconSet to the IconFactory, associating it with a specific stock-id:

foreach (iconfiles, mapping m) {
  object p1=GTK2.IconSet(GDK2.Pixbuf(m["file"]));

There, they are all added. Now you can reference them when you create ActionGroups.

Powered by PikeWiki2 | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University