diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2003-12-17 15:42:47 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2003-12-17 15:42:47 +0000 |
commit | 81ed481418975d127b9138b18136d50f0422ffb5 (patch) | |
tree | b885f07dc3e54e00337c1c0bbd481ad0160e55aa | |
parent | d34211f0039c88fc737067c8adebfb2a3b910ac6 (diff) | |
download | control-center-81ed481418975d127b9138b18136d50f0422ffb5.tar control-center-81ed481418975d127b9138b18136d50f0422ffb5.tar.gz control-center-81ed481418975d127b9138b18136d50f0422ffb5.tar.bz2 control-center-81ed481418975d127b9138b18136d50f0422ffb5.tar.xz control-center-81ed481418975d127b9138b18136d50f0422ffb5.zip |
(Gtk2::SizeableImage package) factorize code that create a DrawingArea
with a background that survive theme changes
-rwxr-xr-x | control-center | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/control-center b/control-center index e1f6512c..9b15cdce 100755 --- a/control-center +++ b/control-center @@ -469,13 +469,11 @@ gtkadd($window_global, 0, gtkpack_(Gtk2::VBox->new(0, 0), 0, my $fixed_left = gtkset_name(Gtk2::Fixed->new, 'mcc'), # default left background - 1, gtksignal_connect(gtkset_size_request(Gtk2::DrawingArea->new, -1, -1), - realize => sub { set_back_pixbuf($_[0], rtl_gtkcreate_pixbuf('mcc-left-back-middle')) }), + 1, Gtk2::SizeableImage->new('mcc-left-back-middle'), 0, rtl_gtkcreate_img('mcc-left-back-bottom') ), 1, gtkpack_(Gtk2::VBox->new(0, 0), - 0, gtksignal_connect(gtkset_size_request(Gtk2::DrawingArea->new, -1, 1), - realize => sub { set_back_pixbuf($_[0], gtkcreate_pixbuf('mcc-right-bottom')) }), + 0, Gtk2::SizeableImage->new('mcc-right-bottom'), 1, gtkset_name( gtkadd(my $emb_frame = Gtk2::EventBox->new, gtkadd(gtkset_border_width(Gtk2::Frame->new, 5), @@ -501,9 +499,7 @@ gtkadd($window_global, 'mcc'), 1, my $notebook_global = gtkset_name(Gtk2::Notebook->new, 'mcc'), 0, gtkset_name(my $w_exp = create_scrolled_window(gtkset_shadow_type(gtkset_size_request(gtkset_border_width($exp_frame = Gtk2::Frame->new(N("Logs")), 5), -1, 120), 'etched_in'), [ 'never', 'never' ], 'none'), 'mcc'), - 0, gtksignal_connect(gtkset_size_request(Gtk2::DrawingArea->new, -1, 1), - realize => sub { set_back_pixbuf($_[0], gtkcreate_pixbuf('mcc-right-bottom')) }), - + 0, Gtk2::SizeableImage->new('mcc-right-bottom') ) ), 0, gtkset_size_request(Gtk2::VBox->new(10, 10), -1, 2) @@ -1124,3 +1120,29 @@ sub scale { my ($width, $height) = ($pixbuf->get_height, $pixbuf->get_width); $pixbuf->scale_simple($height+$gain, $width+$gain, 'hyper'); } + + +package Gtk2::SizeableImage; + +use ugtk2; + +sub set_bg_img { + my ($w) = @_; + $w->{pixbuf} ||= ugtk2::gtkcreate_pixbuf($w->{image}); + ugtk2::set_back_pixbuf($w, $w->{pixbuf}); +} + +sub new { + my ($_class, $image) = @_; + my $w = ugtk2::gtksignal_connect( + ugtk2::gtksignal_connect( + ugtk2::gtkset_size_request(Gtk2::DrawingArea->new, -1, 1), + "configure-event" => \&set_bg_img + ), + realize => \&set_bg_img + ); + $w->{image} = $image; + $w; +} + +1; |