summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2002-08-30 17:19:09 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2002-08-30 17:19:09 +0000
commitba6d314059e468f51a5cfee0d3dc1e969866c304 (patch)
tree5812a10f562adc8131d94ebc3dcfaffbe8b4b22d
parent0948f23974c8835cc42454defadb171e4b89974b (diff)
downloadcontrol-center-ba6d314059e468f51a5cfee0d3dc1e969866c304.tar
control-center-ba6d314059e468f51a5cfee0d3dc1e969866c304.tar.gz
control-center-ba6d314059e468f51a5cfee0d3dc1e969866c304.tar.bz2
control-center-ba6d314059e468f51a5cfee0d3dc1e969866c304.tar.xz
control-center-ba6d314059e468f51a5cfee0d3dc1e969866c304.zip
- mcc :
o kill gtkpng_() and gtk_createpng_() wrappers: if icon is missing, better die while testing rather than make perl display "uncaught code ..." o kill unused timer o use new ln's icons o disable stupid icon highlighting (was made with duplicating manually all icons in gimp and blue-y them there); restore this effect'll need little play with gamma o use ugtk o kill dead code o cleanups o icons: * switch to new icons set * replace pixmap table by a pixbuf one * use pixbufs for backgrouns and icons, * composite background and icons with transparency trough ugtk::compose_pixbufs() * render icons with full alpha blender in left column * comment the different states * simplify callbacks - ugtk : o readd gdkpixbuf support o ensure imlib is used by default to load files, not gdk-pixbuf o compose_with_back(): load a png icon into a pixbuf and call compose_pixbufs with background pixbuf o compose_pixbufs(): render transparent icon onto background into a new pixbuf o merge gtkcreate_png_pixbuf() from gdk-pixbuf-0-branch : load an icon into a pixbuf gdk-pixbuf-0-branch also uses it to simplify a lot of code o gtkicons_labels_widget() : * add a new background pixbuf parameter that'll be composited with icons * render icons with alpha blender in right area * kill imlib_counter * kill imlib usage for * kill dead code (was dead since i fixed mcc memory leaks) - TODO: icon flashing on application launch - POSTPONED: merge big cleanup, global replacement of imlib usage by gdk-pixbuf from gdk-pixbuf-0-branch since it would impacted drakx which is not so good
-rwxr-xr-xcontrol-center83
1 files changed, 38 insertions, 45 deletions
diff --git a/control-center b/control-center
index b3687661..d05ff13b 100755
--- a/control-center
+++ b/control-center
@@ -34,6 +34,7 @@ use common;
use interactive;
use detect_devices;
use my_gtk qw(:helpers :wrappers);
+use ugtk qw(:helpers :wrappers);
#use strict;
# set the locale, needed for proper fontset and charset selection
@@ -57,9 +58,7 @@ my ($embedded, $logs) = (text2bool($h{EMBEDDED}), text2bool($h{LOGS}));
my $theme = $h{THEME};
if ("@ARGV" =~ /--theme (\w+)/) { $theme = $1 }
-d "$themes_dir/$theme" or $theme = 'default';
-#"@ARGV" =~ /--safe/ and $theme = 'default';
ugtk::add_icon_path("$themes_dir/$theme");
-($theme ne 'default') and ugtk::add_icon_path("$themes_dir/default");
my $window_splash = new Gtk::Window -popup;
$window_splash->signal_connect (delete_event => \&quit_global);
$window_splash->set_title(_("Mandrake Control Center"));
@@ -170,7 +169,7 @@ my @tree =
[
[_("Hardware List"),'harddrake-mdk'],
[_("Monitor"),'XFdrake-mdk'],
- [_("Resolution"),'XFdrake-mdk'],
+ [_("Resolution"),'resolution-mdk'],
[_("Display"),'XFdrake-mdk'],
[_("TV Cards"),'XFdrake-mdk'],
[_("Keyboard"), 'keyboard-mdk'],
@@ -264,33 +263,39 @@ $window_global->set_title(_("Mandrake Control Center %s", $_version));
$window_global->set_policy(0, 1, 1);
my $notebook_global;
-my ($pixmap_back_left, undef) = gtkcreate_png_('mcc-left-back');
+my $left_back_pixbuf_unaltered = gtkcreate_png_pixbuf('mcc-left-back');
+my $left_back_pixbuf_unaltered_h = gtkcreate_png_pixbuf('mcc-left-back2');
+
my @darea_left_list;
my $cursor_hand = new Gtk::Gdk::Cursor 60;
my $cursor_normal = new Gtk::Gdk::Cursor 68;
my @back;
-($back[0], undef) = gtkcreate_png_('mcc-left-back');
+($back[0], undef) = gtkcreate_png('mcc-left-back');
$back[1] = $back[0];
-($back[2], undef) = gtkcreate_png_('mcc-left-back2');
+($back[2], undef) = gtkcreate_png('mcc-left-back2');
my ($index, $left_locked, $pending_app) = (0, 0, 0);
my $darea_left_sav;
foreach (@tree) {
$index++;
my $index = $index;
my $text = $_->[0];
- my @icon;
- ($icon[0], undef) = gtkcreate_png_($_->[1]);
- ($icon[1], undef) = gtkcreate_png_("$_->[1]_highlight");
- ($icon[2], undef) = gtkcreate_png_("$_->[1]2");
+
my $darea_left = gtkset_usize(new Gtk::DrawingArea, 160, 45);
$darea_left->{state} = 0;
my $dbl_area_left;
$darea_left->set_events(['exposure_mask', 'enter_notify_mask', 'leave_notify_mask', 'button_press_mask', 'button_release_mask' ]);
$darea_left->signal_connect(size_allocate => sub { $dbl_area_left = undef });
+
+ my @left_back_pixbuf;
+ # 0 => unselected, 1 => highlited, 2 => selected
+ $left_back_pixbuf[0] = compose_with_back($_->[1], $left_back_pixbuf_unaltered);
+ $left_back_pixbuf[2] = compose_with_back($_->[1], $left_back_pixbuf_unaltered_h);
+ $left_back_pixbuf[1] = $left_back_pixbuf[0];
+ my ($width, $height) = ($left_back_pixbuf[0]->get_width, $left_back_pixbuf[0]->get_height);
$darea_left->signal_connect(expose_event => sub {
my ($dx, $dy) = ($darea_left->allocation->[2], $darea_left->allocation->[3]);
+ my $state = $darea_left->{state};
if (!defined($dbl_area_left) || $darea_left->{state} != $dbl_area_left->{state}) {
- my $state = $darea_left->{state};
my ($pix, $width, $height) = create_pix_text($darea_left, $text, "#0#0#0",
$darea_left->style->font,
max($dx-40, 0), $dy, 0, 0, $back[$state], 160, 45, 0, 1, $state);
@@ -299,25 +304,26 @@ foreach (@tree) {
$darea_left->{dbl} = $dbl_area_left;
fill_tiled($darea_left, $dbl_area_left, $back[$state], 40, $dy, 40, 45);
$dbl_area_left->draw_pixmap($darea_left->style->bg_gc('normal'),
- $icon[$state], 0, 0, 4, int(($dy-35)/2/5)*5, 35, 35);
- $dbl_area_left->draw_pixmap($darea_left->style->bg_gc('normal'),
$pix, 0, 0, 40, 0, $width, $height);
}
$darea_left->window->draw_pixmap($darea_left->style->bg_gc('normal'),
$dbl_area_left, 0, 0, 0, 0, ($dx, $dy));
+
+ $left_back_pixbuf[$state]->render_to_drawable($darea_left->window, $darea_left->style->fg_gc('normal'), 0, 0, 8, 8,
+ $width, $height, 'normal', 0, 0);
});
$darea_left->signal_connect(realize => sub { $darea_left->window->set_cursor($cursor_hand) });
$darea_left->signal_connect(enter_notify_event => sub {
- if ($darea_left->{state} == 0) {
- $darea_left->{state} = 1;
- $darea_left->draw(undef);
- }
+ return if ($darea_left->{state} != 0);
+ $darea_left->{state} = 1;
+ $left_back_pixbuf[$darea_left->{state}]->render_to_drawable($darea_left->window, $darea_left->style->fg_gc('normal'), 0, 0, 8, 8,
+ $width, $height, 'normal', 0, 0);
});
$darea_left->signal_connect(leave_notify_event => sub {
- if ($darea_left->{state} == 1) {
- $darea_left->{state} = 0;
- $darea_left->draw(undef);
- }
+ return if ($darea_left->{state} != 1);
+ $darea_left->{state} = 0;
+ $left_back_pixbuf[$darea_left->{state}]->render_to_drawable($darea_left->window, $darea_left->style->fg_gc('normal'), 0, 0, 8, 8,
+ $width, $height, 'normal', 0, 0);
});
$darea_left->signal_connect(button_release_event => sub {
$left_locked and return;
@@ -369,7 +375,7 @@ $window_global->add(
0, gtkpack_(new Gtk::HBox(0, 0),
1, new Gtk::VBox(0, 0),
0, gtkadd(gtkset_shadow_type(new Gtk::Frame, 'etched_out'),
- gtkpng_('hourglass'),
+ gtkpng('hourglass'),
),
1, new Gtk::VBox(0, 0),
),
@@ -405,8 +411,8 @@ sub update_exp {
}
#540, 420
-$notebook_global->set_usize(40, $index * 45);
-$emb_box->set_usize(40, $index * 45);
+$notebook_global->set_usize(40, $index * 50);
+$emb_box->set_usize(40, $index * 50);
$log_check_box->set_active($logs);
$embedded_check_box->set_active($embedded);
@@ -415,11 +421,11 @@ res_socket();
foreach (@darea_left_list) { $fixed_left->put($_->[1], 0, $_->[0]) }
-$fixed_left->signal_connect(realize => sub { $fixed_left->window->set_back_pixmap($pixmap_back_left, 0) });
+$fixed_left->signal_connect(realize => sub { $fixed_left->window->set_back_pixmap($back[0], 0) });
my $dbl_area;
-my ($pixmap_back, undef) = gtkcreate_png_('mcc-title-back');
-my ($pixmap_icon, undef) = gtkcreate_png_('mcc-title-icon');
+my ($pixmap_back, undef) = gtkcreate_png('mcc-title-back');
+my ($pixmap_icon, undef) = gtkcreate_png('mcc-title-icon');
$fixed_title->put(my $darea_title = gtkset_usize(new Gtk::DrawingArea, 335, 55), 0, 0); # 335 -> 450
@@ -451,7 +457,8 @@ $darea_title->signal_connect(expose_event => sub {
$dbl_area, $dim[0], $dim[1], $dim[0], $dim[1], $dim[2], $dim[3]);
});
-my ($pixmap_back_right, undef) = gtkcreate_png_('mcc-core-back');
+my ($pixmap_back_right, undef) = gtkcreate_png('mcc-core-back');
+my $right_back_pixbuf = gtkcreate_png_pixbuf('mcc-core-back');
my $pix_dbl;
$notebook_global->append_page(my $darea1 = new Gtk::DrawingArea);#my $fixed_about = new Gtk::Fixed);
@@ -486,9 +493,10 @@ $darea1->signal_connect(expose_event => sub {
});
+my $left_back_pixbuf_unaltered_50 = gtkcreate_png_pixbuf('mcc-left-back2');
foreach (@tree) {
$notebook_global->append_page(gtkicons_labels_widget($_->[2], $window_global, "#0#0#0", $darea1,
- $pixmap_back_right, 540, 460, 55, 50, 50, 50, 50, 50, \&compute_exec_string, $exec_hash));
+ $pixmap_back_right, $left_back_pixbuf_unaltered_50, 540, 460, 55, 50, 50, 50, 50, 50, \&compute_exec_string, $exec_hash));
}
Gtk->main_iteration while Gtk->events_pending;
$notebook_global->signal_connect(switch_page => sub {
@@ -518,20 +526,6 @@ $SIG{TERM} = \&quit_global;
#$SIG{CHLD} = sub { wait() };
Gtk->main;
-sub gtkpng_ {
- my $gtkpix;
- eval { $gtkpix = gtkpng(@_) };
-# $@ and $theme ne 'default' ? exec "$0 --safe" : die "$@";
- $gtkpix
-}
-
-sub gtkcreate_png_ {
- my ($gdkpix, $gdkmap);
- eval { ($gdkpix, $gdkmap) = gtkcreate_png(@_) };
-# $@ and $theme ne 'default' ? exec "$0 --safe" : die "$@";
- ($gdkpix, $gdkmap);
-}
-
sub sig_usr1 {
$left_locked = 0;
clean_socket();
@@ -539,7 +533,6 @@ sub sig_usr1 {
$notebook_global->show;
}
-my $timer;
sub sig_usr2 {
$left_locked = 0;
$emb_wait->hide;
@@ -689,7 +682,7 @@ sub splash_warning {
)
);
gtkpack($win_about->vbox,
- gtkpng_("warning"),
+ gtkpng("warning"),
new Gtk::Label($label),
);
$win_about->show_all();