21
21
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22
22
* file for a list of people on the GTK+ Team. See the ChangeLog
23
23
* files for a list of changes. These files are distributed with
24
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
24
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27
27
#include "config.h"
150
150
GtkIconFactory *factory = GTK_ICON_FACTORY (object);
152
152
all_icon_factories = g_slist_remove (all_icon_factories, factory);
154
154
g_hash_table_foreach (factory->icons, free_icon_set, NULL);
156
156
g_hash_table_destroy (factory->icons);
158
158
G_OBJECT_CLASS (gtk_icon_factory_parent_class)->finalize (object);
174
174
* gtk_icon_factory_remove_default(). Applications with icons should
175
175
* add a default icon factory with their icons, which will allow
176
176
* themes to override the icons for the application.
178
178
* Return value: a new #GtkIconFactory
181
181
gtk_icon_factory_new (void)
199
199
* override your application's default icons. If an icon already
200
200
* existed in @factory for @stock_id, it is unreferenced and replaced
201
201
* with the new @icon_set.
205
204
gtk_icon_factory_add (GtkIconFactory *factory,
206
205
const gchar *stock_id,
212
211
g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
213
212
g_return_if_fail (stock_id != NULL);
214
g_return_if_fail (icon_set != NULL);
213
g_return_if_fail (icon_set != NULL);
216
215
g_hash_table_lookup_extended (factory->icons, stock_id,
217
216
&old_key, &old_value);
219
218
if (old_value == icon_set)
222
221
gtk_icon_set_ref (icon_set);
224
223
/* GHashTable key memory management is so fantastically broken. */
235
234
* gtk_icon_factory_lookup:
236
235
* @factory: a #GtkIconFactory
237
236
* @stock_id: an icon name
239
238
* Looks up @stock_id in the icon factory, returning an icon set
240
239
* if found, otherwise %NULL. For display to the user, you should
241
240
* use gtk_style_lookup_icon_set() on the #GtkStyle for the
242
241
* widget that will display the icon, instead of using this
243
242
* function directly, so that themes are taken into account.
245
244
* Return value: icon set of @stock_id.
248
247
gtk_icon_factory_lookup (GtkIconFactory *factory,
249
248
const gchar *stock_id)
251
250
g_return_val_if_fail (GTK_IS_ICON_FACTORY (factory), NULL);
252
251
g_return_val_if_fail (stock_id != NULL, NULL);
254
253
return g_hash_table_lookup (factory->icons, stock_id);
261
260
* gtk_icon_factory_add_default:
262
261
* @factory: a #GtkIconFactory
264
263
* Adds an icon factory to the list of icon factories searched by
265
264
* gtk_style_lookup_icon_set(). This means that, for example,
266
265
* gtk_image_new_from_stock() will be able to find icons in @factory.
267
266
* There will normally be an icon factory added for each library or
268
267
* application that comes with icons. The default icon factories
269
268
* can be overridden by themes.
273
271
gtk_icon_factory_add_default (GtkIconFactory *factory)
275
273
g_return_if_fail (GTK_IS_ICON_FACTORY (factory));
277
275
g_object_ref (factory);
279
277
default_factories = g_slist_prepend (default_factories, factory);
286
284
* Removes an icon factory from the list of default icon
287
285
* factories. Not normally used; you might use it for a library that
288
286
* can be unloaded or shut down.
292
289
gtk_icon_factory_remove_default (GtkIconFactory *factory)
318
315
* the #GtkStyle for the widget that will display the icon, instead of
319
316
* using this function directly, so that themes are taken into
323
319
* Return value: a #GtkIconSet, or %NULL
326
322
gtk_icon_factory_lookup_default (const gchar *stock_id)
328
324
GSList *tmp_list;
330
326
g_return_val_if_fail (stock_id != NULL, NULL);
332
328
tmp_list = default_factories;
333
329
while (tmp_list != NULL)
357
353
source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
358
354
source.source.icon_name = (gchar *)stock_id;
359
355
gtk_icon_set_add_source (set, &source);
361
357
gtk_icon_factory_add (factory, stock_id, set);
362
358
gtk_icon_set_unref (set);
375
371
source.source.icon_name = (gchar *)stock_id_ltr;
376
372
source.direction = GTK_TEXT_DIR_LTR;
377
373
gtk_icon_set_add_source (set, &source);
379
375
source.type = GTK_ICON_SOURCE_STATIC_ICON_NAME;
380
376
source.source.icon_name = (gchar *)stock_id_rtl;
381
377
source.direction = GTK_TEXT_DIR_RTL;
382
378
gtk_icon_set_add_source (set, &source);
384
380
gtk_icon_factory_add (factory, stock_id, set);
385
381
gtk_icon_set_unref (set);
416
412
register_stock_icon (factory, GTK_STOCK_GO_DOWN);
417
413
register_stock_icon (factory, GTK_STOCK_EXECUTE);
418
414
register_stock_icon (factory, GTK_STOCK_QUIT);
419
register_bidi_stock_icon (factory,
420
GTK_STOCK_GOTO_FIRST,
421
GTK_STOCK_GOTO_FIRST "-ltr",
415
register_bidi_stock_icon (factory,
416
GTK_STOCK_GOTO_FIRST,
417
GTK_STOCK_GOTO_FIRST "-ltr",
422
418
GTK_STOCK_GOTO_FIRST "-rtl");
423
419
register_stock_icon (factory, GTK_STOCK_SELECT_FONT);
424
420
register_stock_icon (factory, GTK_STOCK_FULLSCREEN);
427
423
register_stock_icon (factory, GTK_STOCK_HELP);
428
424
register_stock_icon (factory, GTK_STOCK_HOME);
429
425
register_stock_icon (factory, GTK_STOCK_INFO);
430
register_bidi_stock_icon (factory,
426
register_bidi_stock_icon (factory,
431
427
GTK_STOCK_JUMP_TO,
432
428
GTK_STOCK_JUMP_TO "-ltr",
433
429
GTK_STOCK_JUMP_TO "-rtl");
434
register_bidi_stock_icon (factory,
430
register_bidi_stock_icon (factory,
435
431
GTK_STOCK_GOTO_LAST,
436
432
GTK_STOCK_GOTO_LAST "-ltr",
437
433
GTK_STOCK_GOTO_LAST "-rtl");
438
register_bidi_stock_icon (factory,
434
register_bidi_stock_icon (factory,
439
435
GTK_STOCK_GO_BACK,
440
436
GTK_STOCK_GO_BACK "-ltr",
441
437
GTK_STOCK_GO_BACK "-rtl");
457
453
register_stock_icon (factory, GTK_STOCK_PRINT_REPORT);
458
454
register_stock_icon (factory, GTK_STOCK_PRINT_WARNING);
459
455
register_stock_icon (factory, GTK_STOCK_PROPERTIES);
460
register_bidi_stock_icon (factory,
456
register_bidi_stock_icon (factory,
462
458
GTK_STOCK_REDO "-ltr",
463
459
GTK_STOCK_REDO "-rtl");
464
460
register_stock_icon (factory, GTK_STOCK_REMOVE);
465
461
register_stock_icon (factory, GTK_STOCK_REFRESH);
466
register_bidi_stock_icon (factory,
462
register_bidi_stock_icon (factory,
467
463
GTK_STOCK_REVERT_TO_SAVED,
468
464
GTK_STOCK_REVERT_TO_SAVED "-ltr",
469
465
GTK_STOCK_REVERT_TO_SAVED "-rtl");
470
register_bidi_stock_icon (factory,
466
register_bidi_stock_icon (factory,
471
467
GTK_STOCK_GO_FORWARD,
472
468
GTK_STOCK_GO_FORWARD "-ltr",
473
469
GTK_STOCK_GO_FORWARD "-rtl");
484
480
register_stock_icon (factory, GTK_STOCK_ITALIC);
485
481
register_stock_icon (factory, GTK_STOCK_STRIKETHROUGH);
486
482
register_stock_icon (factory, GTK_STOCK_UNDERLINE);
487
register_bidi_stock_icon (factory,
483
register_bidi_stock_icon (factory,
488
484
GTK_STOCK_INDENT,
489
485
GTK_STOCK_INDENT "-ltr",
490
486
GTK_STOCK_INDENT "-rtl");
491
register_bidi_stock_icon (factory,
487
register_bidi_stock_icon (factory,
492
488
GTK_STOCK_UNINDENT,
493
489
GTK_STOCK_UNINDENT "-ltr",
494
490
GTK_STOCK_UNINDENT "-rtl");
495
491
register_stock_icon (factory, GTK_STOCK_GOTO_TOP);
496
492
register_stock_icon (factory, GTK_STOCK_DELETE);
497
register_bidi_stock_icon (factory,
493
register_bidi_stock_icon (factory,
498
494
GTK_STOCK_UNDELETE,
499
495
GTK_STOCK_UNDELETE "-ltr",
500
496
GTK_STOCK_UNDELETE "-rtl");
501
register_bidi_stock_icon (factory,
497
register_bidi_stock_icon (factory,
503
499
GTK_STOCK_UNDO "-ltr",
504
500
GTK_STOCK_UNDO "-rtl");
510
506
register_stock_icon (factory, GTK_STOCK_DISCONNECT);
511
507
register_stock_icon (factory, GTK_STOCK_EDIT);
512
508
register_stock_icon (factory, GTK_STOCK_CAPS_LOCK_WARNING);
513
register_bidi_stock_icon (factory,
509
register_bidi_stock_icon (factory,
514
510
GTK_STOCK_MEDIA_FORWARD,
515
511
GTK_STOCK_MEDIA_FORWARD "-ltr",
516
512
GTK_STOCK_MEDIA_FORWARD "-rtl");
517
register_bidi_stock_icon (factory,
513
register_bidi_stock_icon (factory,
518
514
GTK_STOCK_MEDIA_NEXT,
519
515
GTK_STOCK_MEDIA_NEXT "-ltr",
520
516
GTK_STOCK_MEDIA_NEXT "-rtl");
521
517
register_stock_icon (factory, GTK_STOCK_MEDIA_PAUSE);
522
register_bidi_stock_icon (factory,
518
register_bidi_stock_icon (factory,
523
519
GTK_STOCK_MEDIA_PLAY,
524
520
GTK_STOCK_MEDIA_PLAY "-ltr",
525
521
GTK_STOCK_MEDIA_PLAY "-rtl");
526
register_bidi_stock_icon (factory,
522
register_bidi_stock_icon (factory,
527
523
GTK_STOCK_MEDIA_PREVIOUS,
528
524
GTK_STOCK_MEDIA_PREVIOUS "-ltr",
529
525
GTK_STOCK_MEDIA_PREVIOUS "-rtl");
530
526
register_stock_icon (factory, GTK_STOCK_MEDIA_RECORD);
531
register_bidi_stock_icon (factory,
527
register_bidi_stock_icon (factory,
532
528
GTK_STOCK_MEDIA_REWIND,
533
529
GTK_STOCK_MEDIA_REWIND "-ltr",
534
530
GTK_STOCK_MEDIA_REWIND "-rtl");
591
587
icon_aliases = g_hash_table_new (g_str_hash, g_str_equal);
593
589
icon_sizes = g_new (IconSize, NUM_BUILTIN_SIZES);
594
590
icon_sizes_allocated = NUM_BUILTIN_SIZES;
595
591
icon_sizes_used = NUM_BUILTIN_SIZES;
604
600
* Even if we did I suppose removing the builtin sizes would be
608
604
icon_sizes[GTK_ICON_SIZE_MENU].size = GTK_ICON_SIZE_MENU;
609
605
icon_sizes[GTK_ICON_SIZE_MENU].name = "gtk-menu";
610
606
icon_sizes[GTK_ICON_SIZE_MENU].width = 16;
619
615
icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].name = "gtk-small-toolbar";
620
616
icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].width = 18;
621
617
icon_sizes[GTK_ICON_SIZE_SMALL_TOOLBAR].height = 18;
623
619
icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].size = GTK_ICON_SIZE_LARGE_TOOLBAR;
624
620
icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].name = "gtk-large-toolbar";
625
621
icon_sizes[GTK_ICON_SIZE_LARGE_TOOLBAR].width = 24;
695
691
if (size == GTK_ICON_SIZE_INVALID)
696
692
/* Reserve a place */
697
693
size = icon_size_register_intern (size_name, -1, -1);
699
695
settings_sizes = get_settings_sizes (settings, NULL);
700
696
if (size >= settings_sizes->len)
845
841
"notify::gtk-icon-sizes",
846
842
G_CALLBACK (icon_size_settings_changed),
849
845
icon_size_set_all_from_settings (settings);
853
849
icon_size_lookup_intern (GtkSettings *settings,
854
850
GtkIconSize size,
875
871
gboolean initial = FALSE;
877
873
settings_sizes = get_settings_sizes (settings, &initial);
879
876
icon_sizes_init_for_settings (settings);
881
878
if (size < settings_sizes->len)
883
880
SettingsIconSize *settings_size;
885
882
settings_size = &g_array_index (settings_sizes, SettingsIconSize, size);
887
884
width_for_settings = settings_size->width;
888
885
height_for_settings = settings_size->height;
907
904
* @height: location to store icon height
909
906
* Obtains the pixel size of a semantic icon size, possibly
910
* modified by user preferences for a particular
907
* modified by user preferences for a particular
911
908
* #GtkSettings. Normally @size would be
912
909
* #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function
913
910
* isn't normally needed, gtk_widget_render_icon() is the usual
916
913
* the width/height returned by gtk_icon_size_lookup(), because themes
917
914
* are free to render the pixbuf however they like, including changing
918
915
* the usual size.
920
917
* Return value: %TRUE if @size was a valid size
925
922
gtk_icon_size_lookup_for_settings (GtkSettings *settings,
926
923
GtkIconSize size,
949
946
* the width/height returned by gtk_icon_size_lookup(), because themes
950
947
* are free to render the pixbuf however they like, including changing
951
948
* the usual size.
953
950
* Return value: %TRUE if @size was a valid size
956
953
gtk_icon_size_lookup (GtkIconSize size,
1028
1024
g_return_val_if_fail (name != NULL, 0);
1029
1025
g_return_val_if_fail (width > 0, 0);
1030
1026
g_return_val_if_fail (height > 0, 0);
1032
1028
return icon_size_register_intern (name, width, height);
1040
1036
* Registers @alias as another name for @target.
1041
1037
* So calling gtk_icon_size_from_name() with @alias as argument
1042
1038
* will return @target.
1046
1041
gtk_icon_size_register_alias (const gchar *alias,
1047
1042
GtkIconSize target)
1051
1046
g_return_if_fail (alias != NULL);
1053
1048
init_icon_sizes ();
1081
1076
* gtk_icon_size_from_name:
1082
1077
* @name: the name to look up.
1083
1078
* @returns: the icon size with the given name.
1085
1080
* Looks up the icon size associated with @name.
1088
1083
gtk_icon_size_from_name (const gchar *name)
1092
1087
init_icon_sizes ();
1094
1089
ia = g_hash_table_lookup (icon_aliases, name);
1096
1091
if (ia && icon_sizes[ia->target].width > 0)
1103
1098
* gtk_icon_size_get_name:
1104
1099
* @size: a #GtkIconSize.
1105
1100
* @returns: the name of the given icon size.
1107
* Gets the canonical name of the given icon size. The returned string
1102
* Gets the canonical name of the given icon size. The returned string
1108
1103
* is statically allocated and should not be freed.
1110
1105
G_CONST_RETURN gchar*
1111
1106
gtk_icon_size_get_name (GtkIconSize size)
1189
1184
icon_set->cache = NULL;
1190
1185
icon_set->cache_size = 0;
1191
1186
icon_set->cache_serial = cache_serial;
1193
1188
return icon_set;
1197
1192
* gtk_icon_set_new_from_pixbuf:
1198
1193
* @pixbuf: a #GdkPixbuf
1200
1195
* Creates a new #GtkIconSet with @pixbuf as the default/fallback
1201
1196
* source image. If you don't add any additional #GtkIconSource to the
1202
1197
* icon set, all variants of the icon will be created from @pixbuf,
1203
1198
* using scaling, pixelation, etc. as required to adjust the icon size
1204
1199
* or make the icon look insensitive/prelighted.
1206
1201
* Return value: a new #GtkIconSet
1209
1204
gtk_icon_set_new_from_pixbuf (GdkPixbuf *pixbuf)
1219
1214
gtk_icon_source_set_pixbuf (&source, pixbuf);
1220
1215
gtk_icon_set_add_source (set, &source);
1221
1216
gtk_icon_source_set_pixbuf (&source, NULL);
1247
1242
* gtk_icon_set_unref:
1248
1243
* @icon_set: a #GtkIconSet
1250
1245
* Decrements the reference count on @icon_set, and frees memory
1251
1246
* if the reference count reaches 0.
1254
1249
gtk_icon_set_unref (GtkIconSet *icon_set)
1279
1274
gtk_icon_set_get_type (void)
1281
1276
static GType our_type = 0;
1283
1278
if (our_type == 0)
1284
1279
our_type = g_boxed_type_register_static (I_("GtkIconSet"),
1285
1280
(GBoxedCopyFunc) gtk_icon_set_ref,
1362
1357
* multiple matches for a given "wildness" then the RC file contained
1363
1358
* dumb stuff, and we end up with an arbitrary matching source)
1367
1362
tmp_list = icon_set->sources;
1368
1363
while (tmp_list != NULL)
1370
1365
GtkIconSource *s = tmp_list->data;
1372
1367
if ((s->any_direction || (s->direction == direction)) &&
1373
1368
(s->any_state || (s->state == state)) &&
1374
1369
(s->any_size || size == (GtkIconSize)-1 || (sizes_equivalent (size, s->size))))
1393
1388
if (source->filename_pixbuf == NULL)
1395
1390
GError *error = NULL;
1397
1392
source->filename_pixbuf = gdk_pixbuf_new_from_file (source->source.filename, &error);
1399
1394
if (source->filename_pixbuf == NULL)
1401
1396
/* Remove this icon source so we don't keep trying to
1404
1399
g_warning (_("Error loading icon: %s"), error->message);
1405
1400
g_error_free (error);
1407
1402
icon_set->sources = g_slist_remove (icon_set->sources, source);
1409
1404
gtk_icon_source_free (source);
1418
1413
static GdkPixbuf *
1419
1414
render_icon_name_pixbuf (GtkIconSource *icon_source,
1420
1415
GtkStyle *style,
1433
1428
gint width, height, pixel_size;
1434
1429
gint *sizes, *s, dist;
1435
1430
GError *error = NULL;
1437
1432
if (widget && gtk_widget_has_screen (widget))
1438
1433
screen = gtk_widget_get_screen (widget);
1439
1434
else if (style && style->colormap)
1453
1448
if (size == (GtkIconSize)-1)
1455
/* Find an available size close to 48
1450
/* Find an available size close to 48 */
1457
1451
sizes = gtk_icon_theme_get_icon_sizes (icon_theme, icon_source->source.icon_name);
1459
1453
width = height = 48;
1501
1495
if (!tmp_pixbuf)
1503
g_warning ("Error loading theme icon '%s' for stock: %s",
1504
icon_source->source.icon_name, error->message);
1505
g_error_free (error);
1497
g_warning ("Error loading theme icon '%s' for stock: %s",
1498
icon_source->source.icon_name, error ? error->message : "");
1500
g_error_free (error);
1509
1504
tmp_source = *icon_source;
1510
1505
tmp_source.type = GTK_ICON_SOURCE_PIXBUF;
1511
1506
tmp_source.source.pixbuf = tmp_pixbuf;
1636
1631
* @detail: detail to pass to the theme engine, or %NULL.
1637
1632
* Note that passing a detail of anything but %NULL
1638
1633
* will disable caching.
1640
1635
* Renders an icon using gtk_style_render_icon(). In most cases,
1641
1636
* gtk_widget_render_icon() is better, since it automatically provides
1642
1637
* most of the arguments from the current widget settings. This
1643
1638
* function never returns %NULL; if the icon can't be rendered
1644
1639
* (perhaps because an image file fails to load), a default "missing
1645
1640
* image" icon will be returned instead.
1647
1642
* Return value: a #GdkPixbuf to be displayed
1650
1645
gtk_icon_set_render_icon (GtkIconSet *icon_set,
1651
1646
GtkStyle *style,
1726
1721
* gtk_icon_set_render_icon(), but #GtkIconSet needs base images to
1727
1722
* work with. The base images and when to use them are described by
1728
1723
* a #GtkIconSource.
1730
1725
* This function copies @source, so you can reuse the same source immediately
1731
1726
* without affecting the icon set.
1746
1741
* gtk_icon_set_new_from_pixbuf() creates a new icon set with a
1747
1742
* default icon source based on the given pixbuf.
1751
gtk_icon_set_add_source (GtkIconSet *icon_set,
1745
gtk_icon_set_add_source (GtkIconSet *icon_set,
1752
1746
const GtkIconSource *source)
1754
1748
g_return_if_fail (icon_set != NULL);
1783
1776
GSList *tmp_list;
1784
1777
gboolean all_sizes = FALSE;
1785
1778
GSList *specifics = NULL;
1787
1780
g_return_if_fail (icon_set != NULL);
1788
1781
g_return_if_fail (sizes != NULL);
1789
1782
g_return_if_fail (n_sizes != NULL);
1791
1784
tmp_list = icon_set->sources;
1792
1785
while (tmp_list != NULL)
1814
1807
init_icon_sizes ();
1816
1809
*sizes = g_new (GtkIconSize, icon_sizes_used);
1817
1810
*n_sizes = icon_sizes_used - 1;
1820
1813
while (i < icon_sizes_used)
1822
1815
(*sizes)[i - 1] = icon_sizes[i].size;
1849
1842
* gtk_icon_source_new:
1851
1844
* Creates a new #GtkIconSource. A #GtkIconSource contains a #GdkPixbuf (or
1852
1845
* image filename) that serves as the base image for one or more of the
1853
1846
* icons in a #GtkIconSet, along with a specification for which icons in the
1854
1847
* icon set will be based on that pixbuf or image file. An icon set contains
1855
1848
* a set of icons that represent "the same" logical concept in different states,
1856
1849
* different global text directions, and different sizes.
1858
1851
* So for example a web browser's "Back to Previous Page" icon might
1859
1852
* point in a different direction in Hebrew and in English; it might
1860
1853
* look different when insensitive; and it might change size depending
1861
1854
* on toolbar mode (small/large icons). So a single icon set would
1862
1855
* contain all those variants of the icon. #GtkIconSet contains a list
1863
1856
* of #GtkIconSource from which it can derive specific icon variants in
1866
1859
* In the simplest case, #GtkIconSet contains one source pixbuf from
1867
1860
* which it derives all variants. The convenience function
1876
1869
* By default, the icon source has all parameters wildcarded. That is,
1877
1870
* the icon source will be used as the base icon for any desired text
1878
1871
* direction, widget state, or icon size.
1880
1873
* Return value: a new #GtkIconSource
1883
1876
gtk_icon_source_new (void)
1885
1878
GtkIconSource *src;
1887
1880
src = g_new0 (GtkIconSource, 1);
1889
1882
src->direction = GTK_TEXT_DIR_NONE;
1890
1883
src->size = GTK_ICON_SIZE_INVALID;
1891
1884
src->state = GTK_STATE_NORMAL;
1893
1886
src->any_direction = TRUE;
1894
1887
src->any_state = TRUE;
1895
1888
src->any_size = TRUE;
1901
1894
* gtk_icon_source_copy:
1902
1895
* @source: a #GtkIconSource
1904
1897
* Creates a copy of @source; mostly useful for language bindings.
1906
1899
* Return value: a new #GtkIconSource
1909
1902
gtk_icon_source_copy (const GtkIconSource *source)
1911
1904
GtkIconSource *copy;
1913
1906
g_return_val_if_fail (source != NULL, NULL);
1915
1908
copy = g_new (GtkIconSource, 1);
1917
1910
*copy = *source;
1919
1912
switch (copy->type)
1921
1914
case GTK_ICON_SOURCE_EMPTY:
1946
1939
* gtk_icon_source_free:
1947
1940
* @source: a #GtkIconSource
1949
1942
* Frees a dynamically-allocated icon source, along with its
1950
1943
* filename, size, and pixbuf fields if those are not %NULL.
1953
1946
gtk_icon_source_free (GtkIconSource *source)
1962
1955
gtk_icon_source_get_type (void)
1964
1957
static GType our_type = 0;
1966
1959
if (our_type == 0)
1967
1960
our_type = g_boxed_type_register_static (I_("GtkIconSource"),
1968
1961
(GBoxedCopyFunc) gtk_icon_source_copy,
2012
2005
* @filename: image file to use
2014
2007
* Sets the name of an image file to use as a base image when creating
2015
* icon variants for #GtkIconSet. The filename must be absolute.
2008
* icon variants for #GtkIconSet. The filename must be absolute.
2018
2011
gtk_icon_source_set_filename (GtkIconSource *source,
2019
2012
const gchar *filename)
2072
2065
* Sets a pixbuf to use as a base image when creating icon variants
2073
2066
* for #GtkIconSet.
2076
2069
gtk_icon_source_set_pixbuf (GtkIconSource *source,
2077
2070
GdkPixbuf *pixbuf)
2079
2072
g_return_if_fail (source != NULL);
2080
2073
g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
2082
2075
if (source->type == GTK_ICON_SOURCE_PIXBUF &&
2083
2076
source->source.pixbuf == pixbuf)
2086
2079
icon_source_clear (source);
2088
2081
if (pixbuf != NULL)
2090
2083
source->type = GTK_ICON_SOURCE_PIXBUF;
2096
2089
* gtk_icon_source_get_filename:
2097
2090
* @source: a #GtkIconSource
2099
2092
* Retrieves the source filename, or %NULL if none is set. The
2100
2093
* filename is not a copy, and should not be modified or expected to
2101
2094
* persist beyond the lifetime of the icon source.
2103
2096
* Return value: image filename. This string must not be modified
2106
2099
G_CONST_RETURN gchar*
2107
2100
gtk_icon_source_get_filename (const GtkIconSource *source)
2118
2111
* gtk_icon_source_get_icon_name:
2119
2112
* @source: a #GtkIconSource
2121
2114
* Retrieves the source icon name, or %NULL if none is set. The
2122
2115
* icon_name is not a copy, and should not be modified or expected to
2123
2116
* persist beyond the lifetime of the icon source.
2125
2118
* Return value: icon name. This string must not be modified or freed.
2127
2120
G_CONST_RETURN gchar*
2128
2121
gtk_icon_source_get_icon_name (const GtkIconSource *source)
2140
2133
* gtk_icon_source_get_pixbuf:
2141
2134
* @source: a #GtkIconSource
2143
2136
* Retrieves the source pixbuf, or %NULL if none is set.
2144
2137
* In addition, if a filename source is in use, this
2145
2138
* function in some cases will return the pixbuf from
2147
2140
* for the GtkIconSource passed to the GtkStyle::render_icon()
2148
2141
* virtual function. The reference count on the pixbuf is
2149
2142
* not incremented.
2151
2144
* Return value: source pixbuf
2154
2147
gtk_icon_source_get_pixbuf (const GtkIconSource *source)
2156
2149
g_return_val_if_fail (source != NULL, NULL);
2158
2151
if (source->type == GTK_ICON_SOURCE_PIXBUF)
2159
2152
return source->source.pixbuf;
2160
2153
else if (source->type == GTK_ICON_SOURCE_FILENAME)
2206
2198
* produce an appropriate icon for a given state, for example
2207
2199
* lightening an image on prelight, but will not modify source images
2208
2200
* that match exactly.
2211
2203
gtk_icon_source_set_state_wildcarded (GtkIconSource *source,
2212
2204
gboolean setting)
2234
2226
* #GtkIconSet will normally scale wildcarded source images to produce
2235
2227
* an appropriate icon at a given size, but will not change the size
2236
2228
* of source images that match exactly.
2239
2231
gtk_icon_source_set_size_wildcarded (GtkIconSource *source,
2240
2232
gboolean setting)
2242
2234
g_return_if_fail (source != NULL);
2244
source->any_size = setting != FALSE;
2236
source->any_size = setting != FALSE;
2248
2240
* gtk_icon_source_get_size_wildcarded:
2249
2241
* @source: a #GtkIconSource
2251
2243
* Gets the value set by gtk_icon_source_set_size_wildcarded().
2253
2245
* Return value: %TRUE if this icon source is a base for any icon size variant
2256
2248
gtk_icon_source_get_size_wildcarded (const GtkIconSource *source)
2258
2250
g_return_val_if_fail (source != NULL, TRUE);
2260
2252
return source->any_size;
2264
2256
* gtk_icon_source_get_state_wildcarded:
2265
2257
* @source: a #GtkIconSource
2267
2259
* Gets the value set by gtk_icon_source_set_state_wildcarded().
2269
2261
* Return value: %TRUE if this icon source is a base for any widget state variant
2272
2264
gtk_icon_source_get_state_wildcarded (const GtkIconSource *source)
2280
2272
* gtk_icon_source_get_direction_wildcarded:
2281
2273
* @source: a #GtkIconSource
2283
2275
* Gets the value set by gtk_icon_source_set_direction_wildcarded().
2285
2277
* Return value: %TRUE if this icon source is a base for any text direction variant
2288
2280
gtk_icon_source_get_direction_wildcarded (const GtkIconSource *source)
2300
2292
* Sets the text direction this icon source is intended to be used
2303
2295
* Setting the text direction on an icon source makes no difference
2304
2296
* if the text direction is wildcarded. Therefore, you should usually
2305
2297
* call gtk_icon_source_set_direction_wildcarded() to un-wildcard it
2306
2298
* in addition to calling this function.
2310
2301
gtk_icon_source_set_direction (GtkIconSource *source,
2311
2302
GtkTextDirection direction)
2323
2314
* Sets the widget state this icon source is intended to be used
2326
2317
* Setting the widget state on an icon source makes no difference
2327
2318
* if the state is wildcarded. Therefore, you should usually
2328
2319
* call gtk_icon_source_set_state_wildcarded() to un-wildcard it
2329
2320
* in addition to calling this function.
2333
2323
gtk_icon_source_set_state (GtkIconSource *source,
2334
2324
GtkStateType state)
2346
2336
* Sets the icon size this icon source is intended to be used
2349
2339
* Setting the icon size on an icon source makes no difference
2350
2340
* if the size is wildcarded. Therefore, you should usually
2351
2341
* call gtk_icon_source_set_size_wildcarded() to un-wildcard it
2352
2342
* in addition to calling this function.
2356
2345
gtk_icon_source_set_size (GtkIconSource *source,
2357
2346
GtkIconSize size)
2365
2354
* gtk_icon_source_get_direction:
2366
2355
* @source: a #GtkIconSource
2368
2357
* Obtains the text direction this icon source applies to. The return
2369
* value is only useful/meaningful if the text direction is <emphasis>not</emphasis>
2358
* value is only useful/meaningful if the text direction is <emphasis>not</emphasis>
2372
2361
* Return value: text direction this source matches
2374
2363
GtkTextDirection
2375
2364
gtk_icon_source_get_direction (const GtkIconSource *source)
2383
2372
* gtk_icon_source_get_state:
2384
2373
* @source: a #GtkIconSource
2386
2375
* Obtains the widget state this icon source applies to. The return
2387
2376
* value is only useful/meaningful if the widget state is <emphasis>not</emphasis>
2390
2379
* Return value: widget state this source matches
2393
2382
gtk_icon_source_get_state (const GtkIconSource *source)
2401
2390
* gtk_icon_source_get_size:
2402
2391
* @source: a #GtkIconSource
2404
2393
* Obtains the icon size this source applies to. The return value
2405
2394
* is only useful/meaningful if the icon size is <emphasis>not</emphasis> wildcarded.
2407
2396
* Return value: icon size this source matches.
2410
2399
gtk_icon_source_get_size (const GtkIconSource *source)
2528
2517
if (icon->style)
2529
2518
attach_to_style (icon_set, icon->style);
2531
2520
if (icon_set->cache_size >= NUM_CACHED_ICONS)
2533
2522
/* Remove oldest item in the cache */
2534
2523
GSList *tmp_list;
2536
2525
tmp_list = icon_set->cache;
2538
2527
/* Find next-to-last link */
2613
2602
attach_to_style (copy_recipient, icon_copy->style);
2614
2603
g_object_ref (icon_copy->style);
2617
2606
g_object_ref (icon_copy->pixbuf);
2619
2608
icon_copy->size = icon->size;
2621
copy = g_slist_prepend (copy, icon_copy);
2610
copy = g_slist_prepend (copy, icon_copy);
2623
2612
tmp_list = g_slist_next (tmp_list);
2681
2670
style_dnotify (gpointer data)
2683
2672
GHashTable *table = data;
2685
2674
g_hash_table_foreach (table, iconsets_foreach, NULL);
2687
2676
g_hash_table_destroy (table);
2698
2687
* _gtk_icon_factory_list_ids:
2700
2689
* Gets all known IDs stored in an existing icon factory.
2701
2690
* The strings in the returned list aren't copied.
2702
2691
* The list itself should be freed.
2704
2693
* Return value: List of ids in icon factories
2707
2696
_gtk_icon_factory_list_ids (void)
2714
2703
_gtk_icon_factory_ensure_default_icons ();
2716
2705
tmp_list = all_icon_factories;
2717
2706
while (tmp_list != NULL)
2719
2708
GList *these_ids;
2721
2710
GtkIconFactory *factory = GTK_ICON_FACTORY (tmp_list->data);
2723
2712
these_ids = g_hash_table_get_keys (factory->icons);
2725
2714
ids = g_list_concat (ids, these_ids);
2727
2716
tmp_list = g_slist_next (tmp_list);