summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcontrol-center211
-rwxr-xr-xprint_launcher.pl5
2 files changed, 96 insertions, 120 deletions
diff --git a/control-center b/control-center
index 0f72be1a..c8713819 100755
--- a/control-center
+++ b/control-center
@@ -26,7 +26,7 @@ my $mcc_dir = "/usr/share/mcc";
my $themes_dir = "$mcc_dir/themes/";
my $_wizdir = "/usr/share/wizards";
-BEGIN { !$ENV{DISPLAY} and exec ("/usr/sbin/drakxconf; reset") }
+BEGIN { !$ENV{DISPLAY} || system('/usr/X11R6/bin/xtest 2>/dev/null') and exec ("/usr/sbin/drakxconf; reset") }
use Gtk;
use lib qw(/usr/lib/libDrakX);
@@ -59,29 +59,23 @@ my $still_in_splash_screen = 1;
my %h = getVarsFromSh($conffile);
my %class = getVarsFromSh($class_install);
-defined $h{THEME} or $h{THEME} = 'default';
-defined $h{EMBEDDED} or $h{EMBEDDED} = bool2text(1);
-defined $h{LOGS} or do { if ($class{CLASS} eq 'expert') { $h{LOGS} = bool2text(0)} else { $h{LOGS} = bool2text(1) } };
+$h{THEME} ||= 'default';
+$h{EMBEDDED} ||= bool2text(1);
+$h{LOGS} ||= bool2text($class{CLASS} eq 'expert' ? 1 : 0);
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';
add_icon_path("$themes_dir/$theme");
my $window_splash = new Gtk::Window -popup;
-$window_splash->signal_connect (delete_event => \&quit_global);
+$window_splash->signal_connect(delete_event => \&quit_global);
$window_splash->set_title(N("Mandrake Control Center"));
$window_splash->set_policy(0, 0, 1);
$window_splash->set_position(1);
-$window_splash->add(
- gtkadd(gtkset_shadow_type(new Gtk::Frame(), 'etched_out'),
- new Gtk::Label(N("Loading... Please wait")))
- );
+$window_splash->add(gtkadd(gtkset_shadow_type(new Gtk::Frame(), 'etched_out'), new Gtk::Label(N("Loading... Please wait"))));
$window_splash->show_all;
-Gtk->main_iteration while Gtk->events_pending;
-my $timer_splash = Gtk->timeout_add(200, sub { Gtk->main_iteration while Gtk->events_pending });
-
-# timeout to avoid refresh problem
-Gtk->timeout_add(100, sub{ 1 });
+gtkflush;
+my $timer_splash = Gtk->timeout_add(200, \&gtkflush);
my $rc = "$mcc_dir/$theme/gtkrc";
-r $rc and Gtk::Rc->parse($rc);
@@ -266,12 +260,12 @@ my @tree =
my $window_global = new Gtk::Window -toplevel;
my ($pixmap_back_right, undef) = gtkcreate_png('mcc-core-back');
-$window_global->signal_connect (delete_event => \&quit_global);
+$window_global->signal_connect(delete_event => \&quit_global);
$window_global->set_title(N("Mandrake Control Center %s", $_version));
$window_global->set_policy(0, 1, 1);
my $notebook_global;
-my $left_back_pixbuf_unaltered = gtkcreate_png_pixbuf('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;
@@ -303,7 +297,7 @@ foreach (@tree) {
my $draw = sub {
my ($dx, $dy) = ($darea_left->allocation->[2], $darea_left->allocation->[3]);
my $state = $darea_left->{state};
- if (!defined($dbl_area_left)) {
+ unless (defined($dbl_area_left)) {
($pix, $width, $height) = create_pix_text($darea_left, $text, $darea_left->style->font,
max($dx-40, 0), $dy, 0, 0, $back, 160, 45, 0, 1);
$dbl_area_left = new Gtk::Gdk::Pixmap($darea_left->window, $dx, $dy);
@@ -313,13 +307,11 @@ foreach (@tree) {
$dbl_area_left->{state} = $state;
$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'),
- $pix->[$state], 0, 0, 40, 0, $width, $height);
+ $dbl_area_left->draw_pixmap($darea_left->style->bg_gc('normal'), $pix->[$state], 0, 0, 40, 0, $width, $height);
$left_back_pixbuf[$state]->render_to_drawable($dbl_area_left, $darea_left->style->fg_gc('normal'), 0, 0, 8, 10,
- $pixbuf_width, $pixbuf_height, 'normal', 0, 0);
+ $pixbuf_width, $pixbuf_height, 'normal', 0, 0);
}
- $darea_left->window->draw_pixmap($darea_left->style->bg_gc('normal'),
- $dbl_area_left, 0, 0, 0, 0, ($dx, $dy));
+ $darea_left->window->draw_pixmap($darea_left->style->bg_gc('normal'), $dbl_area_left, 0, 0, 0, 0, ($dx, $dy));
};
$darea_left->signal_connect(expose_event => $draw);
$darea_left->signal_connect(realize => sub { $darea_left->window->set_cursor($cursor_hand) });
@@ -341,7 +333,7 @@ foreach (@tree) {
$darea_left->{state} == 2 and set_page($index), return;
foreach (@darea_left_list) {
$_->[1]->window->set_cursor($cursor_hand);
- if($_->[1]{state} != 0) {
+ if ($_->[1]{state} != 0) {
$_->[1]{state} = 0;
$_->[1]->draw(undef);
}
@@ -395,9 +387,9 @@ $window_global->add(
)
)
),
- 1, $notebook_global = new Gtk::Widget ('Gtk::Notebook',
- show_border => 0,
- show_tabs => 0),
+ 1, $notebook_global = new Gtk::Widget('Gtk::Notebook',
+ show_border => 0,
+ show_tabs => 0),
)
)
)
@@ -405,19 +397,14 @@ $window_global->add(
sub update_exp {
return if $still_in_splash_screen || $pending_app;
- if($logs && !$exp_frame) {
- gtkpack__($right_box,
- gtkadd($exp_frame = gtkset_shadow_type(gtkset_usize(gtkset_border_width(new Gtk::Frame(N("Logs")), 5), 0, 120), 'etched_out'),
- )
- );
- }
- if($logs) {
- $exp_frame->show_all;
- }
- if (!$logs && $exp_frame) {
- $exp_frame->destroy();
- undef $exp_frame;
- }
+ if ($logs) {
+ if ($exp_frame) {
+ $exp_frame->show_all;
+ } else {
+ gtkpack__($right_box,
+ gtkadd($exp_frame = gtkset_shadow_type(gtkset_usize(gtkset_border_width(new Gtk::Frame(N("Logs")), 5), 0, 120), 'etched_out')));
+ }
+ } elsif ($logs) { $exp_frame->hide }
}
#540, 420
@@ -448,7 +435,7 @@ $fixed_title->signal_connect(realize => sub { $fixed_title->window->set_back_pix
$darea_title->signal_connect(expose_event => sub {
my @dim = @{$_[1]{area}};
my ($dx, $dy) = ($darea_title->allocation->[2], $darea_title->allocation->[3]);
- if (!defined($dbl_area)) {
+ unless (defined($dbl_area)) {
$dbl_area = new Gtk::Gdk::Pixmap($darea_title->window, $dx, $dy);
fill_tiled($darea_title, $dbl_area, $pixmap_back, 110, 55, $dx, $dy);
$dbl_area->draw_pixmap($darea_title->style->bg_gc('normal'),
@@ -464,22 +451,21 @@ $notebook_global->append_page(my $summary_darea = new Gtk::DrawingArea);
$summary_darea->signal_connect(size_allocate => sub { $pix_dbl = undef }); # needed when hiding emb_box
$summary_darea->signal_connect(expose_event => sub {
my ($dx, $dy) = ($summary_darea->allocation->[2], $summary_darea->allocation->[3]);
- if (!defined($pix_dbl)) {
+ unless (defined($pix_dbl)) {
$pix_dbl = new Gtk::Gdk::Pixmap($summary_darea->window, $dx, $dy);
my ($splash_pix, undef) = gtkcreate_png("mcc-splash");
fill_tiled($summary_darea, $pix_dbl, $splash_pix, $notebook_width, $notebook_height, $dx, $dy);
my $style = $summary_darea->style->copy();
$style->font(Gtk::Gdk::Font->fontset_load(N("-*-helvetica-medium-r-normal-*-20-*-100-100-p-*-iso8859-1,*-r-*")));
$pix_dbl->draw_string($style->font, $summary_darea->style->black_gc, 80, 115, N("Welcome to the Mandrake Control Center"));
- local *VERS;
+ local *VERS;
open VERS, "/etc/mandrake-release" or die N("cannot open this file for read: %s", $!);
my ($sysname, $nodename, $release, undef, $machine) = uname();
my $i = 0;
- foreach(
- [N("System:"), substr(<VERS>, 0, -1)],
- [N("Hostname:"), $nodename],
- [N("Kernel Version:"), $release],
- [N("Machine:"), $machine]) {
+ foreach ([N("System:"), substr(<VERS>, 0, -1)],
+ [N("Hostname:"), $nodename],
+ [N("Kernel Version:"), $release],
+ [N("Machine:"), $machine]) {
$pix_dbl->draw_string($summary_darea->style->font, $summary_darea->style->black_gc, 80, 150+$i, $_->[0]);
$pix_dbl->draw_string($summary_darea->style->font, $summary_darea->style->black_gc, 81, 150+$i, $_->[0]);
$pix_dbl->draw_string($summary_darea->style->font, $summary_darea->style->black_gc, 200, 150+$i, $_->[1]);
@@ -506,13 +492,12 @@ $run_darea->signal_connect(expose_event => sub {
$window_global->set_usize($global_width, $global_height);
-my $left_back_pixbuf_unaltered_50 = gtkcreate_png_pixbuf('mcc-left-back2');
# Create right notebook pages
foreach (@tree) {
$notebook_global->append_page(gtkicons_labels_widget($_->[2], $window_global, $summary_darea,
- $pixmap_back_right, $left_back_pixbuf_unaltered_50, $notebook_width, $notebook_height, 55, 50, 50, 50, 50, 50, \&compute_exec_string, $exec_hash));
+ $pixmap_back_right, $left_back_pixbuf_unaltered_h, $notebook_width, $notebook_height, 55, 50, 50, 50, 50, 50, \&compute_exec_string, $exec_hash));
}
-Gtk->main_iteration while Gtk->events_pending;
+gtkflush;
$notebook_global->signal_connect(switch_page => sub {
my (undef, $tab_widget, $tab_number) = @_;
$tab_number > 0 or return;
@@ -521,7 +506,7 @@ $notebook_global->signal_connect(switch_page => sub {
$window_global->set_usize($global_width, $global_height);
#$window_global->set_default_size($global_width, $global_height);
$window_global->set_position('center');
-Gtk->main_iteration while Gtk->events_pending;
+gtkflush;
$window_global->show_all;
$emb_box->hide;
my $p = $#tree + ($::isWiz ? 1 : 0);
@@ -534,9 +519,18 @@ $window_global->set_position(1);
$SIG{USR1} = \&sig_usr1;
$SIG{USR2} = \&sig_usr2;
$SIG{TERM} = \&quit_global;
-$SIG{CHLD} = sub { wait };
+$SIG{CHLD} = \&sig_child;
+$SIG{CONT} = sub { Gtk->main };
Gtk->main;
+sub sig_child {
+ wait;
+ return unless $left_locked;
+ kill('USR1', $$);
+ splash_warning(N("This program was abnomarly exited"));
+}
+
+# got when finished
sub sig_usr1 {
$left_locked = 0;
clean_socket();
@@ -545,6 +539,7 @@ sub sig_usr1 {
$notebook_global->show;
}
+# got when apps begin to draw
sub sig_usr2 {
$left_locked = 0;
$emb_wait->hide;
@@ -576,9 +571,7 @@ sub compute_exec_string {
}
if ($gtkplug > 0) {
$emb_wait->show;
- if ($run_pixbuf) {
- undef $run_pixbuf;#->unref;
- }
+ undef $run_pixbuf if $run_pixbuf; #->unref;
$run_pixbuf = gtkcreate_png_pixbuf($icon . "_128");
$run_counter = 255;
$run_counter_add = -10;
@@ -593,7 +586,7 @@ sub compute_exec_string {
$emb_socket->show;
$SIG{CHLD} = undef;
$emb_socket->steal(launch_xapp($alternate));
- $SIG{CHLD} = sub { wait };
+ $SIG{CHLD} = \&sig_child;
}
} else { # not embedded
fork_($gtkplug == 0 ? $alternate->[0] : $alternate || $exec);
@@ -607,6 +600,7 @@ sub compute_exec_string {
}
}
}
+ # start logdrake if needed
if ($logs && $show_log) {
my $pid;
gtkadd($exp_frame, my $exp_socket = new Gtk::Socket);
@@ -665,7 +659,7 @@ sub res_socket {
}
sub quit_global {
- foreach((@pid_launched,@pid_exp)) { kill 'TERM', $_ if (defined $_) }
+ foreach (@pid_launched,@pid_exp) { kill 'TERM', $_ if defined $_ }
setVarsInSh($conffile, {
EMBEDDED => bool2text($embedded),
LOGS => bool2text($logs),
@@ -684,8 +678,8 @@ sub splash_warning {
gtkpack__($win_about->action_area,
gtkadd(new Gtk::HButtonBox,
- gtksignal_connect(new Gtk::Button($cancel_button ? N("OK") : N("Close")), "clicked" => sub { $ret = 1; Gtk->main_quit }),
- if_($cancel_button, gtksignal_connect(new Gtk::Button(N("Cancel")), "clicked" => sub { Gtk->main_quit })),
+ gtksignal_connect(new Gtk::Button($cancel_button ? N("OK") : N("Close")), clicked => sub { $ret = 1; Gtk->main_quit }),
+ if_($cancel_button, gtksignal_connect(new Gtk::Button(N("Cancel")), clicked => sub { Gtk->main_quit })),
)
);
gtkpack($win_about->vbox,
@@ -741,7 +735,7 @@ sub about_mdk_cc {
[ '', ''],
[ N("Old authors: "), '', ''],
[ '', 'Chmouel Boudjnah', 'original C version'],
- [ '', 'Damien "dams" Krotkine', 'perl version'],
+ [ '', 'Damien "dam\'s" Krotkine', 'perl version'],
[ '', 'Yves Duret', 'logdrake integration'],
[ '', ''],
[ N("Artwork: "),
@@ -758,11 +752,10 @@ sub about_mdk_cc {
#-PO Add your E-Mail address here if you want to show it in the about doialog.
my $translator_email = N("~ @ ~");
if ($translator_name ne "~ * ~ " && 0) {
- $i++, $clist->append(@$_) foreach (
- [ '', ''],
- [ N("Translator: "),
- $translator_name, $translator_email],
- );
+ $i++, $clist->append(@$_) foreach ([ '', ''],
+ [ N("Translator: "),
+ $translator_name, $translator_email],
+ );
}
$clist->set_selectable($_, 0) foreach 0..$i;
$clist->columns_autosize();
@@ -785,7 +778,10 @@ sub connect_to_site {
my $browser = $ENV{BROWSER};
my $initial_user = $ENV{INITIAL_USER};
- if (!$browser) { splash_warning(" ". N("Warning: No browser specified") ." "); return }
+ unless ($browser) {
+ splash_warning(" ". N("Warning: No browser specified") ." ");
+ return;
+ }
if ($help) {
fork_("$browser $link &");
@@ -800,60 +796,43 @@ sub connect_to_site {
sub get_main_menu {
my ($window) = @_;
- my $accel_group = new Gtk::AccelGroup();
- my $item_factory = new Gtk::ItemFactory('Gtk::MenuBar', '<main>', $accel_group);
- my @theme_list = grep { -d "$themes_dir/$_" } all($themes_dir);
- $item_factory->create_items(
- (
- { path => N("/_File"),
- type => '<Branch>' },
- { path => N("/_File").N("/_Quit"),
- accelerator => N("<control>Q"),
- callback => \&quit_global },
- { path => N("/_Options"),
- type => '<Branch>' },
- { path => N("/_Options").N("/Display _Logs"),
- callback => sub {
- $logs = $log_check_box->active;
- update_exp();
- $show_log = 1 if $logs },
- type => '<CheckItem>' },
- { path => N("/_Options").N("/_Embedded Mode"),
- callback => sub { $embedded = $embedded_check_box->active },
- type => '<ToggleItem>'},
- if_(all($themes_dir) > 1,
- { path => N("/_Themes"),
- type => '<Branch>' },
- (map { my $l = $_;
- my %h = (
- path => N("/_Themes"). "/" . ($l eq $theme ? " O " : " ") . "_$l",
- callback => sub {
- $theme eq $l and return;
- !$pending_app || splash_warning(
- N("This action will restart the control center.\nAny change not applied will be lost."), 1) and sig_usr1(), exec "$0 --theme $l";
- },
- );
- \%h;
- } @theme_list),
- { path => N("/_Themes").N("/_More themes"),
- callback => \&more_themes },
- ),
- { path => N("/_Help"),
- type => '<Branch>' },
- { path => N("/_Help").N("/_Report Bug"),
- callback => sub { fork_("drakbug --report drakconf &") } },
- { path => N("/_Help").N("/_About..."),
- callback => \&about_mdk_cc }
- )
- );
- $window->add_accel_group($accel_group);
- $log_check_box = $item_factory->get_widget("<main>".N("/Options").N("/Display Logs"));
- $embedded_check_box = $item_factory->get_widget("<main>".N("/Options").N("/Embedded Mode"));
- return ($item_factory->get_widget('<main>'));
+ my $menu = ugtk::create_factory_menu($window,
+ ({ path => N("/_File"), type => '<Branch>' },
+ { path => N("/_File") . N("/_Quit"), accelerator => N("<control>Q"), callback => \&quit_global },
+#-PO Don't remember to translate "_Options" the same way "Options" is (but for the underscore of course)
+ { path => N("/_Options"), type => '<Branch>' },
+ { path => N("/_Options") . N("/Display _Logs"), type => '<CheckItem>',
+ callback => sub {
+ $logs = $log_check_box->active;
+ update_exp();
+ }
+ },
+ { path => N("/_Options") . N("/_Embedded Mode"), type => '<ToggleItem>',
+ callback => sub { $embedded = $embedded_check_box->active }
+ },
+ if_(all($themes_dir) > 1,
+ { path => N("/_Themes"), type => '<Branch>' },
+ (map { {path => N("/_Themes") . "/" . ($_ eq $theme ? " O " : " ") . "_$_",
+ callback => sub {
+ $theme eq $_ and return;
+ !$pending_app || splash_warning(N("This action will restart the control center.\nAny change not applied will be lost."), 1) and sig_usr1(), exec "$0 --theme $_";
+ }};
+ } grep { -d "$themes_dir/$_" } all($themes_dir)),
+ { path => N("/_Themes").N("/_More themes"), callback => \&more_themes }),
+ { path => N("/_Help"), type => '<Branch>' },
+ { path => N("/_Help").N("/_Report Bug"), callback => sub { fork_("drakbug --report drakconf &") } },
+ { path => N("/_Help").N("/_About..."), callback => \&about_mdk_cc }
+ ));
+ my $factory = $menu->{factory};
+#-PO Don't remember to translate "Options" the same way "_Options" is (but without the underscore of course)
+ $log_check_box = $factory->get_widget("<main>".N("/Options").N("/Display Logs"));
+ $embedded_check_box = $factory->get_widget("<main>".N("/Options").N("/Embedded Mode"));
+ return $menu;
}
sub set_page {
my ($index) = @_;
update_exp;
+# if $still_in_splash_screen;
$notebook_global->set_page($index);
}
diff --git a/print_launcher.pl b/print_launcher.pl
index 28a1e9e0..f5742e39 100755
--- a/print_launcher.pl
+++ b/print_launcher.pl
@@ -3,12 +3,9 @@
use strict;
use lib qw(/usr/lib/libDrakX);
use common;
-use ugtk;
-use my_gtk;
+use my_gtk qw(:helpers :wrappers :various);;
use interactive;
use standalone;
-init Gtk;
-Gtk->set_locale;
#-------------------------------------------------------------
# i18n