2
* Copyright (C) 2002, 2003 Red Hat, Inc.
3
* Authors: Alexander Larsson, Owen Taylor
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Library General Public License for more details.
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the
17
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
* Boston, MA 02111-1307, USA.
29
g_print ("usage: test-icon-theme lookup <theme name> <icon name> [size]]\n"
31
"usage: test-icon-theme list <theme name> [context]\n"
33
"usage: test-icon-theme display <theme name> <icon name> [size]\n"
39
main (int argc, char *argv[])
41
GtkIconTheme *icon_theme;
42
GtkIconInfo *icon_info;
43
GdkRectangle embedded_rect;
44
GdkPoint *attach_points;
46
const gchar *display_name;
53
gtk_init (&argc, &argv);
63
icon_theme = gtk_icon_theme_new ();
65
gtk_icon_theme_set_custom_theme (icon_theme, themename);
67
if (strcmp (argv[1], "display") == 0)
69
GtkWidget *window, *image;
74
g_object_unref (icon_theme);
80
size = atoi (argv[4]);
82
size = GTK_ICON_SIZE_BUTTON;
84
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
85
image = gtk_image_new_from_icon_name (argv[3], size);
86
gtk_container_add (GTK_CONTAINER (window), image);
87
gtk_widget_show_all (window);
91
else if (strcmp (argv[1], "list") == 0)
98
list = gtk_icon_theme_list_icons (icon_theme,
103
g_print ("%s\n", (char *)list->data);
107
else if (strcmp (argv[1], "lookup") == 0)
111
g_object_unref (icon_theme);
117
size = atoi (argv[4]);
119
icon_info = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size, GTK_ICON_LOOKUP_USE_BUILTIN);
120
g_print ("icon for %s at %dx%d is %s\n", argv[3], size, size,
121
icon_info ? (gtk_icon_info_get_builtin_pixbuf (icon_info) ? "<builtin>" : gtk_icon_info_get_filename (icon_info)) : "<none>");
125
if (gtk_icon_info_get_embedded_rect (icon_info, &embedded_rect))
127
g_print ("Embedded rect: %d,%d %dx%d\n",
128
embedded_rect.x, embedded_rect.y,
129
embedded_rect.width, embedded_rect.height);
132
if (gtk_icon_info_get_attach_points (icon_info, &attach_points, &n_attach_points))
134
g_print ("Attach Points: ");
135
for (i = 0; i < n_attach_points; i++)
139
g_free (attach_points);
143
display_name = gtk_icon_info_get_display_name (icon_info);
146
g_print ("Display name: %s\n", display_name);
148
gtk_icon_info_free (icon_info);
153
g_object_unref (icon_theme);
159
g_object_unref (icon_theme);