1#!/usr/bin/perl -w
2use strict;
3use Gtk2::TestHelper tests => 24;
4
5# $Id$
6
7my $pixbuf = Gtk2::Gdk::Pixbuf -> new("rgb", 0, 8, 10, 10);
8my $style = Gtk2::Style -> new();
9my $button = Gtk2::Button -> new("Bla");
10# my $settings = Gtk2::Settings -> get_default();
11
12###############################################################################
13
14my ($width, $height) = Gtk2::IconSize -> lookup("button");
15
16like($width, qr/^\d+$/);
17like($height, qr/^\d+$/);
18
19SKIP: {
20  skip "lookup_for_settings is new in 2.2.0", 2
21    unless Gtk2->CHECK_VERSION (2, 2, 0);
22  my $settings = $button -> get_settings();
23  ($width, $height) = Gtk2::IconSize -> lookup_for_settings($settings, "button");
24
25  like($width, qr/^\d+$/);
26  like($height, qr/^\d+$/);
27}
28
29is(Gtk2::IconSize -> register("answer", 23, 42), "answer");
30
31Gtk2::IconSize -> register_alias("everything", "answer");
32is(Gtk2::IconSize -> from_name("everything"), "answer");
33
34###############################################################################
35
36my $source = Gtk2::IconSource -> new();
37isa_ok($source, "Gtk2::IconSource");
38
39SKIP: {
40  skip("[sg]et_icon_name are new in 2.4", 1)
41    unless Gtk2->CHECK_VERSION (2, 4, 0);
42
43  $source -> set_icon_name("gtk-save");
44  is($source -> get_icon_name(), "gtk-save");
45}
46
47$source = Gtk2::IconSource -> new();
48isa_ok($source, "Gtk2::IconSource");
49
50$source -> set_direction("ltr");
51is($source -> get_direction(), "ltr");
52
53$source -> set_direction_wildcarded(1);
54is($source -> get_direction_wildcarded(), 1);
55
56$source -> set_filename("/tmp/bla");
57is($source -> get_filename(), "/tmp/bla");
58
59$source -> set_pixbuf($pixbuf);
60is($source -> get_pixbuf(), $pixbuf);
61
62$source -> set_size("button");
63is($source -> get_size(), "button");
64
65$source -> set_size_wildcarded(1);
66is($source -> get_size_wildcarded(), 1);
67
68$source -> set_state("prelight");
69is($source -> get_state(), "prelight");
70
71$source -> set_state_wildcarded(1);
72is($source -> get_state_wildcarded(), 1);
73
74###############################################################################
75
76my $set = Gtk2::IconSet -> new();
77isa_ok($set, "Gtk2::IconSet");
78
79$set = Gtk2::IconSet -> new_from_pixbuf($pixbuf);
80isa_ok($set, "Gtk2::IconSet");
81
82$set -> add_source($source);
83
84isa_ok($set -> render_icon($style, "rtl", "prelight", "button", $button),
85       "Gtk2::Gdk::Pixbuf");
86
87my %sizes = map { $_ => 1 } $set -> get_sizes();
88is($sizes{ answer }, 1);
89
90###############################################################################
91
92my $factory = Gtk2::IconFactory -> new();
93isa_ok($factory, "Gtk2::IconFactory");
94
95$factory -> add("kaffee-splatter", $set);
96
97isa_ok($factory -> lookup("kaffee-splatter"), "Gtk2::IconSet");
98isa_ok($factory -> lookup_default("gtk-find-and-replace"), "Gtk2::IconSet");
99
100$factory -> add_default();
101$factory -> remove_default();
102
103__END__
104
105Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the
106full list).  See LICENSE for more information.
107