line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2007, 2008, 2009, 2010, 2011, 2012 Kevin Ryde |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Gtk2-Ex-WidgetBits. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# Gtk2-Ex-WidgetBits is free software; you can redistribute it and/or modify |
6
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the |
7
|
|
|
|
|
|
|
# Free Software Foundation; either version 3, or (at your option) any later |
8
|
|
|
|
|
|
|
# version. |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Gtk2-Ex-WidgetBits 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-WidgetBits. If not, see . |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Gtk2::Ex::MenuItem::Subclass; |
19
|
1
|
|
|
1
|
|
28929
|
use 5.008; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
35
|
|
20
|
1
|
|
|
1
|
|
1554
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use strict; |
22
|
|
|
|
|
|
|
use warnings; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Not sure about exporting. Would be a way to take just new_with_label() |
25
|
|
|
|
|
|
|
# and new_with_mnemonic() and leave key/value new(). Maybe a tag |
26
|
|
|
|
|
|
|
# ":all_except_new". |
27
|
|
|
|
|
|
|
# |
28
|
|
|
|
|
|
|
# use base 'Exporter'; |
29
|
|
|
|
|
|
|
# our @EXPORT_OK = qw(new new_with_label new_with_mnemonic); |
30
|
|
|
|
|
|
|
# our %EXPORT_TAGS = (all => \@EXPORT_OK); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
33
|
|
|
|
|
|
|
#use Smart::Comments; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = 48; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
BEGIN { |
38
|
|
|
|
|
|
|
if (Gtk2::MenuItem->find_property('label')) { |
39
|
|
|
|
|
|
|
eval "\n#line ".(__LINE__+1)." \"".__FILE__."\"\n" . <<'HERE' or die; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# GtkMenuItem in 2.16 up has "label" and "use-underline" properties which do |
42
|
|
|
|
|
|
|
# the AccelLabel creation stuff. |
43
|
|
|
|
|
|
|
# |
44
|
|
|
|
|
|
|
sub new_with_label { |
45
|
|
|
|
|
|
|
my ($class, $str) = @_; |
46
|
|
|
|
|
|
|
### MenuItem-Subclass new_with_label() |
47
|
|
|
|
|
|
|
return $class->Glib::Object::new (@_ > 1 |
48
|
|
|
|
|
|
|
? (label => $str) |
49
|
|
|
|
|
|
|
: ()); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
sub new_with_mnemonic { |
52
|
|
|
|
|
|
|
my ($class, $str) = @_; |
53
|
|
|
|
|
|
|
return $class->Glib::Object::new (@_ > 1 |
54
|
|
|
|
|
|
|
? (label => $str, |
55
|
|
|
|
|
|
|
use_underline => 1) |
56
|
|
|
|
|
|
|
: ()); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
1 |
59
|
|
|
|
|
|
|
HERE |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
} else { |
63
|
|
|
|
|
|
|
eval "\n#line ".(__LINE__+1)." \"".__FILE__."\"\n" . <<'HERE' or die; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new_with_label { |
66
|
|
|
|
|
|
|
my ($class, $str) = @_; |
67
|
|
|
|
|
|
|
my $self = $class->Glib::Object::new; |
68
|
|
|
|
|
|
|
if (@_ > 1) { |
69
|
|
|
|
|
|
|
# Replicate C code from |
70
|
|
|
|
|
|
|
# gtk_menu_item_new_with_label() |
71
|
|
|
|
|
|
|
# gtk_check_menu_item_new_with_label() |
72
|
|
|
|
|
|
|
# |
73
|
|
|
|
|
|
|
my $label = Gtk2::AccelLabel->new ($str); |
74
|
|
|
|
|
|
|
$label->set_alignment (0, 0.5); |
75
|
|
|
|
|
|
|
$self->add ($label); |
76
|
|
|
|
|
|
|
$label->set_accel_widget ($self); |
77
|
|
|
|
|
|
|
$label->show; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub new_with_mnemonic { |
83
|
|
|
|
|
|
|
my ($class, $str) = @_; |
84
|
|
|
|
|
|
|
my $self = $class->Glib::Object::new; |
85
|
|
|
|
|
|
|
if (@_ > 1) { |
86
|
|
|
|
|
|
|
# Replicate C code from |
87
|
|
|
|
|
|
|
# gtk_menu_item_new_with_mnemonic() |
88
|
|
|
|
|
|
|
# gtk_check_menu_item_new_with_mnemonic() |
89
|
|
|
|
|
|
|
# |
90
|
|
|
|
|
|
|
my $label = Gtk2::AccelLabel->Glib::Object::new; # no initial label string |
91
|
|
|
|
|
|
|
$label->set_text_with_mnemonic ($str); |
92
|
|
|
|
|
|
|
$label->set_alignment (0, 0.5); |
93
|
|
|
|
|
|
|
$self->add ($label); |
94
|
|
|
|
|
|
|
$label->set_accel_widget ($self); |
95
|
|
|
|
|
|
|
$label->show; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
return $self; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
1 |
100
|
|
|
|
|
|
|
HERE |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
*new = \&new_with_mnemonic; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |
107
|
|
|
|
|
|
|
__END__ |