mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-26 13:41:07 +00:00
54b45a19b9
Fri Nov 19 15:18:51 2004 Manish Singh <yosh@gimp.org> * modules/engines/ms-windows/msw_rc_style.c * modules/engines/ms-windows/msw_style.c * modules/engines/ms-windows/msw_theme_main.c * modules/engines/pixbuf/pixbuf-main.c * modules/engines/pixbuf/pixbuf-rc-style.c * modules/input/gtkimcontextime.c * modules/input/gtkimcontextxim.c * modules/input/imam-et.c * modules/input/imcedilla.c * modules/input/imcyrillic-translit.c * modules/input/iminuktitut.c * modules/input/imipa.c * modules/input/imthai-broken.c * modules/input/imti-er.c * modules/input/imti-et.c * modules/input/imviqr.c * tests/prop-editor.c * tests/testentrycompletion.c * tests/testfilechooser.c * tests/testmerge.c * tests/testtoolbar.c * tests/testtreecolumns.c * tests/testtreeview.c: get rid of unnecessary casts. * tests/testgtk.c (create_labels): add GTK_LABEL() casts for gtk_label_set_ellipsize() calls. * tests/testicontheme.c (main): remove unused pixbuf variable.
143 lines
2.9 KiB
C
143 lines
2.9 KiB
C
#include <gtk/gtk.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <locale.h>
|
|
|
|
static void
|
|
usage (void)
|
|
{
|
|
g_print ("usage: test-icon-theme lookup <theme name> <icon name> [size]]\n"
|
|
" or\n"
|
|
"usage: test-icon-theme list <theme name> [context]\n"
|
|
" or\n"
|
|
"usage: test-icon-theme display <theme name> <icon name> [size]\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;
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
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], "display") == 0)
|
|
{
|
|
GtkWidget *window, *image;
|
|
GtkIconSize size;
|
|
|
|
if (argc < 4)
|
|
{
|
|
g_object_unref (icon_theme);
|
|
usage ();
|
|
return 1;
|
|
}
|
|
|
|
if (argc >= 5)
|
|
size = atoi (argv[4]);
|
|
else
|
|
size = GTK_ICON_SIZE_BUTTON;
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
image = gtk_image_new_from_icon_name (argv[3], size);
|
|
gtk_container_add (GTK_CONTAINER (window), image);
|
|
gtk_widget_show_all (window);
|
|
|
|
gtk_main ();
|
|
}
|
|
else 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) : "<none>");
|
|
|
|
if (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);
|
|
g_print ("\n");
|
|
}
|
|
|
|
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;
|
|
}
|