1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
/* -*- C -*- */ 
require gtk24; 
 
class GTK2.IconTheme; 
inherit G.Object; 
 
//! Looking up icons by name. 
 
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.) 
{ 
  pgtk2_verify_inited(); 
  { 
    struct array *a; 
    const gchar **path; 
    int i,num; 
    get_all_args(NULL,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 (TYPEOF(ITEM(a)[i]) != 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. 
{ 
  pgtk2_verify_inited(); 
  pgtk2_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(). 
{ 
  pgtk2_verify_inited(); 
  { 
    char *name; 
    INT_TYPE size,flags; 
    GtkIconInfo *gi; 
    get_all_args(NULL,args,"%s%i%i",&name,&size,&flags); 
    gi=gtk_icon_theme_lookup_icon(GTK_ICON_THEME(THIS->obj),name,size,flags); 
    pgtk2_pop_n_elems(args); 
    if (gi) 
      push_pgdk2object(gi,pgtk2_icon_info_program,1); 
    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. 
{ 
  pgtk2_verify_inited(); 
  { 
    GdkPixbuf *pixbuf; 
    char *name; 
    INT_TYPE size,flags; 
    get_all_args(NULL,args,"%s%i%i",&name,&size,&flags); 
    pixbuf=gtk_icon_theme_load_icon(GTK_ICON_THEME(THIS->obj),name,size,flags,NULL); 
    pgtk2_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'. 
{ 
  pgtk2_verify_inited(); 
  { 
    char *context=NULL; 
    GList *gl,*g2; 
    int i = 0; 
    if (args) 
      get_all_args(NULL,args,"%s",&context); 
    gl=g2=gtk_icon_theme_list_icons(GTK_ICON_THEME(THIS->obj),context); 
    pgtk2_pop_n_elems(args); 
    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. 
{ 
  pgtk2_verify_inited(); 
  { 
    char *name; 
    gint *gt,*g2; 
    int i=0; 
    get_all_args(NULL,args,"%s",&name); 
    gt=g2=gtk_icon_theme_get_icon_sizes(GTK_ICON_THEME(THIS->obj),name); 
    pgtk2_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;