1a0554 | 2005-07-28 | Martin Nilsson | | require gtk24;
class GTK2.IconTheme;
inherit G.Object;
signal changed;
void create();
//! Creates a new icon theme object. Icon theme objects are used to lookup
//! an icon by name in a particular icon theme. Usually you'll want to use
//! get_default() rather than creating a new icon theme object from scratch.
void set_search_path(array(string) path)
//! Sets the search path for the icon theme object. When looking for an icon
//! theme, GTK2+ will search for a subdirectory of one or more of the
//! directories in path with the same name as the icon theme. (Themes from
//! multiple of the path elemets are combined to allow themes to be extended
//! by adding icons in the user's home directory.)
//! <p>
//! In addition if an icon found isn't found either in the current icon theme
//! or the default icon theme, and an image file with the right name is found
//! directly in one of the elements of path, then that image will be used for
//! the icon name. (This is a legacy feature, and new icons should be put into
//! the default icon theme, which is called DEFAULT_THEME_NAME, rather than
//! directly on the icon path.)
{
pgtk_verify_inited();
{
struct array *a;
const gchar **path;
int i,num;
get_all_args("set_search_path",args,"%A",&a);
if (a==NULL || a->size<1)
Pike_error("Invalid array.\n");
path=(const gchar **)g_malloc(sizeof(const gchar *)*a->size);
if (path==NULL)
SIMPLE_OUT_OF_MEMORY_ERROR("set_search_path",sizeof(const gchar *)*a->size);
for (i=num=0; i<a->size; i++) {
if ((ITEM(a)+i)->type!=PIKE_T_STRING)
continue;
path[num++]=(const gchar *)STR0((ITEM(a)+i)->u.string);
}
gtk_icon_theme_set_search_path(GTK_ICON_THEME(THIS->obj),
path,num);
}
RETURN_THIS();
}
array(string) get_search_path()
//! Gets the current search path.
{
pgtk_verify_inited();
my_pop_n_elems(args);
{
gchar **path;
int n,i;
gtk_icon_theme_get_search_path(GTK_ICON_THEME(THIS->obj),&path,&n);
for (i=0; i<n; i++)
PGTK_PUSH_GCHAR(path[i]);
f_aggregate(n);
g_strfreev(path);
}
}
void append_search_path(string path);
//! Appends a directory to the search path.
void prepend_search_path(string path);
//! Prepends a directory to the search path.
void set_custom_theme(string theme_name);
//! Sets the name of the icon theme that the GTK2.IconTheme object uses
//! overriding system configuration. This function cannot be called on the
//! icon theme objects return from get_default().
int has_icon(string icon_name);
//! Checks whether this icon theme includes an icon for a particular name.
GTK2.IconInfo lookup_icon(string name, int size, int flags)
//! Looks up a named icon and returns an object containing information such as
//! the filename of the icon. The icon can then be rendered into a pixbuf
//! using GTK2.IconInfo->load_icon().
{
pgtk_verify_inited();
{
char *name;
int size,flags;
GtkIconInfo *gi;
get_all_args("lookup_icon",args,"%s%i%i",&name,&size,&flags);
gi=gtk_icon_theme_lookup_icon(GTK_ICON_THEME(THIS->obj),name,size,flags);
my_pop_n_elems(args);
if (gi)
push_gobjectclass(gi,pgtk_icon_info_program);
else
push_int(0);
}
}
GDK2.Pixbuf load_icon(string name, int size, int flags)
//! Looks up an icon in an icon theme, scales it to the given size and renders
//! it into a pixbuf.
{
pgtk_verify_inited();
{
GdkPixbuf *pixbuf;
char *name;
int size,flags;
get_all_args("load_icon",args,"%s%i%i",&name,&size,&flags);
pixbuf=gtk_icon_theme_load_icon(GTK_ICON_THEME(THIS->obj),name,size,flags,NULL);
my_pop_n_elems(args);
push_gobject(pixbuf);
}
}
array(string) list_icons(?string context)
//! Lists the icons in the current icon theme. Only a subset of the icons can
//! be listed by providing a context string. The set of values for the
//! context string is system dependent, but will typically include such values
//! as 'apps' and 'mimetypes'.
{
pgtk_verify_inited();
{
char *context=NULL;
GList *gl,*g2;
int i;
if (args)
get_all_args("list_icons",args,"%s",&context);
gl=g2=gtk_icon_theme_list_icons(GTK_ICON_THEME(THIS->obj),context);
|
1a0554 | 2005-07-28 | Martin Nilsson | | while (g2) {
PGTK_PUSH_GCHAR(g2->data);
g_free(g2->data);
i++;
g2=g_list_next(g2);
}
f_aggregate(i);
g_list_free(gl);
}
}
require gtk26;
array(int) get_icon_sizes(string name)
//! Returns an array of integers describing the sizes at which the icon is
//! available without scaling. A size of -1 means that the icon is available
//! in a scalable format.
{
pgtk_verify_inited();
{
char *name;
gint *gt,*g2;
int i=0;
get_all_args("get_icon_sizes",args,"%s",&name);
gt=g2=gtk_icon_theme_get_icon_sizes(GTK_ICON_THEME(THIS->obj),name);
my_pop_n_elems(args);
while (g2) {
PGTK_PUSH_INT(*g2);
g2++;
i++;
}
f_aggregate(i);
g_free(gt);
}
}
endrequire;
string get_example_icon_name();
//! Gets the name of an icon that is representative of the current theme (for
//! instance, to use when presenting a list of themes to the user.)
int rescan_if_needed();
//! Checks to see if the icon theme has changed; if it has, any currently
//! cached information is discarded and will be reloaded next time this theme
//! is accessed.
endrequire;
|