diff --git a/tests/.cvsignore b/tests/.cvsignore index 4b764519c8..d75a8e3c7e 100644 --- a/tests/.cvsignore +++ b/tests/.cvsignore @@ -14,6 +14,7 @@ simple testcalendar testdnd testgtk +testicontheme testinput testmenus testmultidisplay @@ -21,6 +22,7 @@ testmultiscreen testrgb testselection testtext +testtoolbar testtreeedit testtreeview testtreecolumns diff --git a/tests/Makefile.am b/tests/Makefile.am index 3cd09889d8..fbf6674edf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -31,6 +31,7 @@ noinst_PROGRAMS = \ testcalendar \ testdnd \ testgtk \ + testicontheme \ testinput \ testmenus \ testmultidisplay \ @@ -55,6 +56,7 @@ noinst_PROGRAMS = \ pixbuf-random simple_DEPENDENCIES = $(TEST_DEPS) +testicontheme_DEPENDENCIES = $(TEST_DEPS) testcalendar_DEPENDENCIES = $(TEST_DEPS) testdnd_DEPENDENCIES = $(TEST_DEPS) testgtk_DEPENDENCIES = $(TEST_DEPS) @@ -81,6 +83,7 @@ simple_LDADD = $(LDADDS) testcalendar_LDADD = $(LDADDS) testdnd_LDADD = $(LDADDS) testgtk_LDADD = $(LDADDS) +testicontheme_LDADD = $(LDADDS) testinput_LDADD = $(LDADDS) testmenus_LDADD = $(LDADDS) testmultidisplay_LDADD = $(LDADDS) diff --git a/tests/testicontheme.c b/tests/testicontheme.c new file mode 100644 index 0000000000..0290443f53 --- /dev/null +++ b/tests/testicontheme.c @@ -0,0 +1,110 @@ +#include +#include +#include + +static void +usage (void) +{ + g_print ("usage: test-icon-theme lookup [size]]\n" + " or\n" + "usage: test-icon-theme list [context]\n"); +} + + +int +main (int argc, char *argv[]) +{ + GtkIconTheme *icon_theme; + GtkIconInfo *icon_info; + GdkRectangle embedded_rect; + GdkPoint *attach_points; + int n_attach_points; + const gchar *display_name; + char *context; + char *themename; + GList *list; + int size = 48; + int i; + + g_type_init (); + + if (argc < 3) + { + usage (); + return 1; + } + + themename = argv[2]; + + icon_theme = gtk_icon_theme_new (); + + gtk_icon_theme_set_custom_theme (icon_theme, themename); + + if (strcmp (argv[1], "list") == 0) + { + if (argc >= 4) + context = argv[3]; + else + context = NULL; + + list = gtk_icon_theme_list_icons (icon_theme, + context); + + while (list) + { + g_print ("%s\n", (char *)list->data); + list = list->next; + } + } + else if (strcmp (argv[1], "lookup") == 0) + { + if (argc < 4) + { + g_object_unref (icon_theme); + usage (); + return 1; + } + + if (argc >= 5) + size = atoi (argv[4]); + + icon_info = gtk_icon_theme_lookup_icon (icon_theme, argv[3], size, 0); + g_print ("icon for %s at %dx%d is %s\n", argv[3], size, size, + icon_info ? gtk_icon_info_get_filename (icon_info) : ""); + + if (gtk_icon_info_get_embedded_rect (icon_info, &embedded_rect)) + { + g_print ("Embedded rect: %d,%d %dx%d\n", + embedded_rect.x, embedded_rect.y, + embedded_rect.width, embedded_rect.height); + } + + if (gtk_icon_info_get_attach_points (icon_info, &attach_points, &n_attach_points)) + { + g_print ("Attach Points: "); + for (i = 0; i < n_attach_points; i++) + g_print ("%d, %d; ", + attach_points[i].x, + attach_points[i].y); + g_free (attach_points); + } + + display_name = gtk_icon_info_get_display_name (icon_info); + + if (display_name) + g_print ("Display name: %s\n", display_name); + + gtk_icon_info_free (icon_info); + } + else + { + g_object_unref (icon_theme); + usage (); + return 1; + } + + + g_object_unref (icon_theme); + + return 0; +}