File: widget.pl

package info (click to toggle)
libgtk-perl 0.1.17-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,352 kB
  • ctags: 1,100
  • sloc: ansic: 4,393; perl: 3,463; makefile: 36
file content (72 lines) | stat: -rw-r--r-- 1,050 bytes parent folder | download
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

# partially busted example of widget creation

package Foo;

use Data::Dumper;

init Gtk;

use Gtk;

@ISA = qw(Gtk::Button);

register_type Foo 0; # 0 means zero signals

#signal_new Foo "bloop", 'first';

add_arg_type Foo "blorp", "string";

add_arg_type Foo "Foo::bletch", "int";

#signals_add Foo;

sub new {
	return Gtk::Object::new(@_);
}

sub init {
	print "init: ";
	print Dumper([@_]);
}

sub set_arg {
	print "set_arg: ";
	print Dumper([@_]);
}

sub get_arg {
	print "get_arg: ";
	print Dumper([@_]);
	return "$_[1]-result";
}

sub class_init {
	print "class_init: ";
	print Dumper([@_]);
}

package main;

use Gtk;

$w = new Gtk::Window 'toplevel';

$b = new Foo GtkButton::label => "Foo button";

$b->{bibble} = 12;

$b->signal_connect("clicked", sub { destroy $w });
#$b->signal_connect("clicked", sub { $b->signal_emit("bloop")});
#$b->signal_connect("bloop", sub {print "Bloop!\n"});

$b->set("Foo::blorp", 'fibble');
$b->set("Foo::bletch", 'fabble');
print "|",$b->get("Foo::blorp"),"|\n";

$w->add($b);

show $w;
show $b;

main Gtk;