File: GtkUIManager.t

package info (click to toggle)
libgtk2-perl 1%3A1.190-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,132 kB
  • ctags: 516
  • sloc: perl: 16,575; sh: 149; ansic: 148; makefile: 76
file content (81 lines) | stat: -rw-r--r-- 2,348 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Gtk2/t/GtkUIManager.t,v 1.3 2004/03/17 03:52:24 muppetman Exp $
#

use Gtk2::TestHelper
	at_least_version => [2, 4, 0, "GtkUIManager is new in 2.4"],
	tests => 14;


my $ui_manager = Gtk2::UIManager->new;
isa_ok ($ui_manager, 'Gtk2::UIManager');

$ui_manager->set_add_tearoffs (TRUE);
ok ($ui_manager->get_add_tearoffs);

$ui_manager->set_add_tearoffs (FALSE);
ok (!$ui_manager->get_add_tearoffs);

my $group_one = Gtk2::ActionGroup->new ("Barney");
my $group_two = Gtk2::ActionGroup->new ("Fred");

my @entries = (
  [ "HelpMenu", undef, "_Help" ],
  [ "About", undef, "_About", "<control>A", "About" ],
  [ "Help", undef, "_Help", "<control>H", "Help" ],
  [ "License", undef, "_License", "<control>L", "License" ],
);

$group_one->add_actions (\@entries, undef);

$ui_manager->insert_action_group ($group_one, 0);
$ui_manager->insert_action_group ($group_two, 1);

is_deeply ([$ui_manager->get_action_groups], [$group_one, $group_two]);

$ui_manager->remove_action_group ($group_two);

isa_ok ($ui_manager->get_accel_group, "Gtk2::AccelGroup");

my $ui_info = <<__EOD__;
<ui>
  <menubar name='MenuBar'>
    <menu action='HelpMenu'>
      <menuitem action='About'/>
    </menu>
  </menubar>
  <menubar name='MenuBla'>
    <menu action='HelpMenu'>
      <menuitem action='License'/>
    </menu>
  </menubar>
</ui>
__EOD__

ok (my $id = $ui_manager->add_ui_from_string ($ui_info) != 0);

ok (my $new_id = $ui_manager->new_merge_id != 0);
$ui_manager->add_ui ($new_id, "/MenuBar/HelpMenu", "Help", "Help", qw(menuitem), 0);

ok (my $new_new_id = $ui_manager->new_merge_id != 0);
$ui_manager->add_ui ($new_new_id, "/MenuBar/HelpMenu/License", "License", "License", qw(menuitem), 1);
$ui_manager->remove_ui ($new_new_id);

$ui_manager->ensure_update;
ok (defined ($ui_manager->get_ui));

isa_ok ($ui_manager->get_widget ("/MenuBar/HelpMenu/About"), "Gtk2::ImageMenuItem");

my @menubars = $ui_manager->get_toplevels ("menubar");
is (@menubars, 2);
isa_ok ($menubars[0], "Gtk2::MenuBar");
isa_ok ($menubars[1], "Gtk2::MenuBar");

isa_ok ($ui_manager->get_action ("/MenuBar/HelpMenu/About"), "Gtk2::Action");

# FIXME: guint $ui_manager->add_ui_from_file (const gchar *filename);

__END__

Copyright (C) 2003 by the gtk2-perl team (see the file AUTHORS for the
full list).  See LICENSE for more information.