1 #include <gtk/gtkicontheme.h>
8 g_print ("usage: test-icon-theme lookup <theme name> <icon name> [size]]\n"
10 "usage: test-icon-theme list <theme name> [context]\n");
15 main (int argc, char *argv[])
17 GtkIconTheme *icon_theme;
18 GtkIconInfo *icon_info;
19 GdkRectangle embedded_rect;
20 GdkPoint *attach_points;
22 const gchar *display_name;
39 icon_theme = gtk_icon_theme_new ();
41 gtk_icon_theme_set_custom_theme (icon_theme, themename);
43 if (strcmp (argv[1], "list") == 0)
50 list = gtk_icon_theme_list_icons (icon_theme,
55 g_print ("%s\n", (char *)list->data);
59 else if (strcmp (argv[1], "lookup") == 0)
63 g_object_unref (icon_theme);
69 size = atoi (argv[4]);
71 icon_info = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size, 0);
72 g_print ("icon for %s at %dx%d is %s\n", argv[3], size, size,
73 icon_info ? gtk_icon_info_get_filename (icon_info) : "<none>");
75 if (gtk_icon_info_get_embedded_rect (icon_info, &embedded_rect))
77 g_print ("Embedded rect: %d,%d %dx%d\n",
78 embedded_rect.x, embedded_rect.y,
79 embedded_rect.width, embedded_rect.height);
82 if (gtk_icon_info_get_attach_points (icon_info, &attach_points, &n_attach_points))
84 g_print ("Attach Points: ");
85 for (i = 0; i < n_attach_points; i++)
89 g_free (attach_points);
92 display_name = gtk_icon_info_get_display_name (icon_info);
95 g_print ("Display name: %s\n", display_name);
97 gtk_icon_info_free (icon_info);
101 g_object_unref (icon_theme);
107 g_object_unref (icon_theme);