line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 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
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Gtk2::Ex::TableBits; |
20
|
1
|
|
|
1
|
|
943
|
use 5.008; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
51
|
|
21
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
53
|
|
22
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
23
|
1
|
|
|
1
|
|
12
|
use Scalar::Util 'refaddr'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
442
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
26
|
|
|
|
|
|
|
#use Smart::Comments; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = 48; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my @attach_pnames = ('left-attach', |
31
|
|
|
|
|
|
|
'right-attach', |
32
|
|
|
|
|
|
|
'top-attach', |
33
|
|
|
|
|
|
|
'bottom-attach', |
34
|
|
|
|
|
|
|
'x-options', |
35
|
|
|
|
|
|
|
'y-options', |
36
|
|
|
|
|
|
|
'x-padding', |
37
|
|
|
|
|
|
|
'y-padding'); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub update_attach { |
40
|
0
|
|
|
0
|
1
|
|
my ($table, $child, @args) = @_; |
41
|
|
|
|
|
|
|
### TableBits update_attach: "$child", @args |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if (! _child_is_attached_at($table, $child, @args)) { |
44
|
|
|
|
|
|
|
### must re-attach ... |
45
|
0
|
0
|
|
|
|
|
if (my $parent = $child->get_parent) { |
46
|
0
|
|
|
|
|
|
$parent->remove ($child); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
$table->attach ($child, @args); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# or maybe a func which just checked the attach positions, not the table too |
53
|
|
|
|
|
|
|
sub _child_is_attached_at { |
54
|
0
|
|
|
0
|
|
|
my ($table, $child, @args) = @_; |
55
|
|
|
|
|
|
|
{ |
56
|
0
|
|
|
|
|
|
my $parent = $child->get_parent; |
|
0
|
|
|
|
|
|
|
57
|
0
|
0
|
0
|
|
|
|
if (! $parent || refaddr($parent) != refaddr($table)) { |
58
|
|
|
|
|
|
|
# parent is not the desired $table |
59
|
0
|
|
|
|
|
|
return 0; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
# Note: compare with "==" operator here, not with "!=". Glib::Flags |
63
|
|
|
|
|
|
|
# "!=" is only in Perl-Gtk2 1.200 and higher. "x-options" and |
64
|
|
|
|
|
|
|
# "y-options" are Gtk2::AttachOptions flags. |
65
|
0
|
|
|
|
|
|
foreach my $pname (@attach_pnames) { |
66
|
0
|
0
|
|
|
|
|
unless ($table->child_get_property($child,$pname) |
67
|
|
|
|
|
|
|
== shift @args) { |
68
|
0
|
|
|
|
|
|
return 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
return 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
__END__ |