line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2010, 2011 Kevin Ryde |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Gtk2-Ex-History. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Gtk2-Ex-History is free software; you can redistribute it and/or modify it |
6
|
|
|
|
|
|
|
# under the terms of the GNU General Public License as published by the Free |
7
|
|
|
|
|
|
|
# Software Foundation; either version 3, or (at your option) any later |
8
|
|
|
|
|
|
|
# version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Gtk2-Ex-History is distributed in the hope that it will be useful, but |
11
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
12
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13
|
|
|
|
|
|
|
# for more details. |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
16
|
|
|
|
|
|
|
# with Gtk2-Ex-History. If not, see . |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Gtk2::Ex::History::MenuToolButton; |
19
|
1
|
|
|
1
|
|
29367
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
20
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
21
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
22
|
1
|
|
|
1
|
|
1577
|
use Gtk2 1.220; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Glib::Ex::ConnectProperties 13; # v.13 for model-rows |
24
|
|
|
|
|
|
|
use Gtk2::Ex::History; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
27
|
|
|
|
|
|
|
#use Smart::Comments; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = 8; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
use Glib::Object::Subclass |
34
|
|
|
|
|
|
|
'Gtk2::MenuToolButton', |
35
|
|
|
|
|
|
|
signals => { clicked => \&_do_clicked, |
36
|
|
|
|
|
|
|
show_menu => \&_do_show_menu }, |
37
|
|
|
|
|
|
|
properties => [ Glib::ParamSpec->object |
38
|
|
|
|
|
|
|
('history', |
39
|
|
|
|
|
|
|
'History object', |
40
|
|
|
|
|
|
|
'The history object to act on.', |
41
|
|
|
|
|
|
|
'Gtk2::Ex::History', |
42
|
|
|
|
|
|
|
Glib::G_PARAM_READWRITE), |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Glib::ParamSpec->enum |
45
|
|
|
|
|
|
|
('way', |
46
|
|
|
|
|
|
|
'Which way', |
47
|
|
|
|
|
|
|
'Which way to go in the history when clicked, either back or forward.', |
48
|
|
|
|
|
|
|
'Gtk2::Ex::History::Way', |
49
|
|
|
|
|
|
|
'back', |
50
|
|
|
|
|
|
|
Glib::G_PARAM_READWRITE), |
51
|
|
|
|
|
|
|
]; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub INIT_INSTANCE { |
54
|
|
|
|
|
|
|
my ($self) = @_; |
55
|
|
|
|
|
|
|
$self->set_stock_id ('gtk-go-back'); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub SET_PROPERTY { |
59
|
|
|
|
|
|
|
my ($self, $pspec, $newval) = @_; |
60
|
|
|
|
|
|
|
my $pname = $pspec->get_name; |
61
|
|
|
|
|
|
|
$self->{$pname} = $newval; # per default GET_PROPERTY |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if ($pname eq 'history') { |
64
|
|
|
|
|
|
|
unless ($self->get_menu) { |
65
|
|
|
|
|
|
|
$self->set_menu (Gtk2::Menu->new); # dummy to make arrow sensitive |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
if ($pname eq 'way') { |
70
|
|
|
|
|
|
|
$self->set_stock_id ("gtk-go-$newval"); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $history = $self->{'history'}; |
74
|
|
|
|
|
|
|
my $way = $self->get('way'); |
75
|
|
|
|
|
|
|
if (my $menu = $self->get_menu) { |
76
|
|
|
|
|
|
|
if ($menu->isa('Gtk2::Ex::History::Menu')) { |
77
|
|
|
|
|
|
|
$menu->set (history => $history, |
78
|
|
|
|
|
|
|
way => $way); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
$self->{'connp'} = $history && Glib::Ex::ConnectProperties->dynamic |
82
|
|
|
|
|
|
|
([$history->model($way), 'model-rows#not-empty'], |
83
|
|
|
|
|
|
|
[$self, 'sensitive']); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _do_show_menu { |
87
|
|
|
|
|
|
|
my ($self) = @_; |
88
|
|
|
|
|
|
|
### _do_show_menu() |
89
|
|
|
|
|
|
|
if (my $history = $self->{'history'}) { |
90
|
|
|
|
|
|
|
my $menu; |
91
|
|
|
|
|
|
|
unless (($menu = $self->get_menu) |
92
|
|
|
|
|
|
|
&& ($menu->isa('Gtk2::Ex::History::Menu'))) { |
93
|
|
|
|
|
|
|
require Gtk2::Ex::History::Menu; |
94
|
|
|
|
|
|
|
$self->set_menu (Gtk2::Ex::History::Menu->new (history => $history, |
95
|
|
|
|
|
|
|
way => $self->get('way'))); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
shift->signal_chain_from_overridden(@_); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# 'clicked' class closure |
102
|
|
|
|
|
|
|
sub _do_clicked { |
103
|
|
|
|
|
|
|
my ($self) = @_; |
104
|
|
|
|
|
|
|
### History-MenuToolButton clicked: $self->get('way') |
105
|
|
|
|
|
|
|
my $history = $self->{'history'} || return; |
106
|
|
|
|
|
|
|
my $way = $self->get('way'); |
107
|
|
|
|
|
|
|
$history->$way; |
108
|
|
|
|
|
|
|
return shift->signal_chain_from_overridden(@_); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
__END__ |