1 |
package Gtk2::Mdv::TextView; |
2 |
#***************************************************************************** |
3 |
# |
4 |
# Copyright (c) 2002 Guillaume Cottenceau |
5 |
# Copyright (c) 2002-2007 Thierry Vignaud <tvignaud@mandriva.com> |
6 |
# Copyright (c) 2003, 2004, 2005 MandrakeSoft SA |
7 |
# Copyright (c) 2005-2007 Mandriva SA |
8 |
# |
9 |
# This program is free software; you can redistribute it and/or modify |
10 |
# it under the terms of the GNU General Public License version 2, as |
11 |
# published by the Free Software Foundation. |
12 |
# |
13 |
# This program is distributed in the hope that it will be useful, |
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
# GNU General Public License for more details. |
17 |
# |
18 |
# You should have received a copy of the GNU General Public License |
19 |
# along with this program; if not, write to the Free Software |
20 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 |
# |
22 |
#***************************************************************************** |
23 |
# |
24 |
# $Id: widgets.pm 233986 2008-02-06 14:14:06Z tv $ |
25 |
|
26 |
use strict; |
27 |
use MDK::Common::Func 'any'; |
28 |
use lib qw(/usr/lib/libDrakX); |
29 |
|
30 |
use mygtk2 qw(gtknew); #- do not import anything else, especially gtkadd() which conflicts with ugtk2 one |
31 |
use ugtk2 qw(:all); |
32 |
use Time::HiRes; |
33 |
use feature 'state'; |
34 |
|
35 |
|
36 |
sub new { |
37 |
my ($_class) = @_; |
38 |
my $w = gtknew('TextView', editable => 0); |
39 |
state $time; |
40 |
$w->signal_connect(size_allocate => sub { |
41 |
my ($w, $requisition) = @_; |
42 |
return if !ref($w->{anchors}); |
43 |
return if Time::HiRes::clock_gettime() - $time < 0.200; |
44 |
$time = Time::HiRes::clock_gettime(); |
45 |
foreach my $anchor (@{$w->{anchors}}) { |
46 |
$_->set_size_request($requisition->width-30, -1) foreach $anchor->get_widgets; |
47 |
} |
48 |
1; |
49 |
}); |
50 |
$w; |
51 |
} |
52 |
|
53 |
1; |