summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xcontrol-center138
1 files changed, 88 insertions, 50 deletions
diff --git a/control-center b/control-center
index e0e0e219..06f25594 100755
--- a/control-center
+++ b/control-center
@@ -2,9 +2,7 @@
# $Id$
# Copyright (C) 1999-2001 MandrakeSoft
-# Yves Duret <yduret at mandrakesoft.com>
# Damien Krotkine (damien@mandrakesoft.com)
-# Daouda Lo (daouda@mandrakesoft.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -57,9 +55,9 @@ defined $h{LOGS} or $h{LOGS} = bool2text(0);
$theme = $h{THEME};
if ("@ARGV" =~ /--theme (\w+)/) { $theme = $1 }
-d "$mcc_dir/$theme" or $theme = 'default';
+"@ARGV" =~ /--safe/ and $theme = 'default';
my_gtk::add_icon_path("$mcc_dir/$theme");
my $rc = "$mcc_dir/$theme/gtkrc";
-print "rc : $rc\n";
-r $rc and Gtk::Rc->parse($rc);
my ($log_check_box, $embedded_check_box);
@@ -68,17 +66,18 @@ $::isWiz = -e "/usr/sbin/wizdrake"; #- $in->do_pkgs->is_installed(q(wizard));
my $exec_hash =
{
-#- ("label") => [ "exec", gtk_plug? if not, then xplug, "exec_alternative" for when not embedded, or [ args for xplug ] ],
+#- ("label") => [ "search exp", "exec", gtk_plug? if not, then xplug, "exec_alternative" for when not embedded, or [ args for xplug ] ],
_("Boot Disk") => [ "drakfloppy", "$_xbindir/drakfloppy.real", 1],
_("Boot Config") => [ "drakboot", "$_sbindir/drakboot", 1 ],
_("Auto Install") => [ "drakautoinst", "$_sbindir/drakautoinst", 1 ],
_("Display") => [ "XFdrake", "$_sbindir/XFdrake", 1 ],
- _("Hardware") => [ "harddrake", "$_sbindir/harddrake", 1 ],
+ _("Hardware List") => [ "harddrake", "$_sbindir/harddrake", 1 ],
_("Mouse") => [ "mousedrake", "$_sbindir/mousedrake", 1 ],
_("Printer") => [ "printerdrake", "$_sbindir/printerdrake", 1, "$_sbindir/printerdrake" ],
+ _("Scanner") => [ "scannerdrake", "$_sbindir/scannerdrake", 1 ],
_("Keyboard") => [ "keyboarddrake", "$_sbindir/keyboarddrake", 1 ],
_("Hard Drives") => [ "diskdrake", "$_sbindir/diskdrake --hd", 1 ],
- _("Removable disks") => [ "diskdrake", "$_sbindir/diskdrake --removable", 1 ],
+# _("Removable disks") => [ "diskdrake", "$_sbindir/diskdrake --removable", 1 ],
_("NFS mount points") => [ "diskdrake", "$_sbindir/diskdrake --nfs", 1 ],
_("Samba mount points") => [ "diskdrake", "$_sbindir/diskdrake --smb", 1 ],
_("Partition Sharing") => [ "diskdrake", "$_sbindir/diskdrake --fileshare", 1 ],
@@ -90,10 +89,11 @@ my $exec_hash =
_("Services") => [ "drakxservices", "$_sbindir/drakxservices", 1 ],
_("Fonts") => [ "drakfont", "$_sbindir/drakfont", 1 ],
_("Date & Time") => [ "clock", "$_sbindir/clock.pl", 1 ],
- _("Software Manager") => [ "rpmdrake", "$_bindir/rpmdrake", 1 ],
+ _("Software Manager") => [ "rpmdrake", "$_bindir/rpmdrake", -1 ],
_("Logs") => [ "logdrake", "$_sbindir/logdrake", 1 ],
_("Console") => [ "rxvt", "$_xbindir/rxvt", 0, ["rxvt", "rxvt", 1] ],
_("Servers") => [ "wizdrake", "$_sbindir/wizdrake", 1 ],
+ _("Users") => [ "userdrake", "$_bindir/userdrake", 1 ],
};
my @tree =
@@ -106,10 +106,11 @@ my @tree =
],
[_("Hardware"), 'drakhard-mdk',
[
+ [_("Hardware List"),'harddrake-mdk'],
[_("Display"),'XFdrake-mdk'],
- [_("Hardware"),'harddrake-mdk'],
[_("Mouse"), 'mousedrake-mdk'],
[_("Printer"),'printer-mdk'],
+ [_("Scanner"),'scanner-mdk'],
[_("Keyboard"), 'keyboard-mdk'],
]
],
@@ -137,7 +138,6 @@ my @tree =
[ 'zip', _("Zip"), \&detect_devices::zips ],
),
}),
- [_("Removable disks"), 'diskdrake_other'],
[_("NFS mount points"), 'diskdrake_nfs'],
[_("Samba mount points"), 'diskdrake_samba'],
[_("Partition Sharing"), 'diskdrake_fileshare'],
@@ -147,7 +147,6 @@ my @tree =
[
[_("Connection"), 'draknet-mdk'],
[_("Connection Sharing"),'drakgw-mdk'],
- #[_("Proxy"), 'drakgw-mdk', "$_sbindir/drakproxy"],
],
],
[_("Security"),'security-mdk',
@@ -162,9 +161,10 @@ my @tree =
[_("Services") , 'service-mdk'],
[_("Fonts"), 'drakfont-mdk'],
[_("Date & Time") , 'time-mdk'],
- [_("Software Manager"), 'harddrake-mdk'],
+ [_("Software Manager"), 'rpmdrake-mdk'],
[_("Logs"), 'logdrake-mdk'],
[_("Console"), 'console-mdk'],
+ [_("Users"), 'console-mdk'],
]
],
if_($::isWiz,
@@ -184,14 +184,14 @@ $window_global->set_title( _("Mandrake Control Center %s", 'beta' )); #$_version
$window_global->set_policy(0, 1, 1);
my $notebook_global;
-my ($pixmap_back_left, undef) = gtkcreate_png('mcc-left-back');
+my ($pixmap_back_left, undef) = gtkcreate_png_('mcc-left-back');
my @darea_left_list;
my $cursor_hand = new Gtk::Gdk::Cursor 60;
my $cursor_normal = new Gtk::Gdk::Cursor 68;
my $cursor_busy = new Gtk::Gdk::Cursor 150;
my @back;
-($back[0], undef) = gtkcreate_png('mcc-left-back');
-($back[2], undef) = gtkcreate_png('mcc-left-back2');
+($back[0], undef) = gtkcreate_png_('mcc-left-back');
+($back[2], undef) = gtkcreate_png_('mcc-left-back2');
$back[1] = $back[0];
my $style_dflt = new Gtk::Style;
# fontsets *must* be used in order to allow proper font selection for non
@@ -199,14 +199,16 @@ my $style_dflt = new Gtk::Style;
# $style_dflt->font(Gtk::Gdk::Font->fontset_load(_("-*-times-bold-r-normal-*-14-*-*-*-p-*-iso8859-1,*-r-*")));
my $index = 0;
my $darea_left_sav;
+my $left_locked = 0;
+my $pending_app = 0;
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");
+ ($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;
@@ -246,6 +248,8 @@ foreach (@tree) {
}
});
$darea_left->signal_connect( button_release_event => sub {
+ $left_locked and return;
+ $pending_app && !splash_warning("The modifications done in the current module won't be saved.", 1) and return;
clean_socket();
$notebook_global->show;
$darea_left->{state} == 2 and $notebook_global->set_page($index), return;
@@ -290,7 +294,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),
),
@@ -340,8 +344,8 @@ foreach (@darea_left_list) {
$fixed_left->signal_connect( realize => sub { $fixed_left->window->set_back_pixmap($pixmap_back_left, 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
@@ -373,9 +377,9 @@ $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 ($pix_splash_map, undef) = gtkcreate_png('mcc-splash');
+#my ($pix_splash_map, undef) = gtkcreate_png_('mcc-splash');
my $pix_dbl;
$notebook_global->append_page(my $darea1 = new Gtk::DrawingArea);#my $fixed_about = new Gtk::Fixed);
$darea1->signal_connect( size_allocate => sub { $pix_dbl = undef });
@@ -456,28 +460,44 @@ Gtk->main;
#---
+# icon handling
+#---
+
+# my @icon_cache;
+
+sub gtkpng_ {
+ my $gtkpix;
+ eval { $gtkpix = gtkpng(@_) };
+ $@ and $theme ne 'default' ? exec "$0 --safe" : die "$@";
+# push @icon_cache, { type => 'gtkpng', name => $_[0], data => $gtkpix };
+ $gtkpix;
+}
+
+sub gtkcreate_png_ {
+ my ($gdkpix, $gdkmap);
+ eval { ($gdkpix, $gdkmap) = gtkcreate_png(@_) };
+ $@ and $theme ne 'default' ? exec "$0 --safe" : die "$@";
+# push @icon_cache, { type => 'gdkpng', name => $_[0], data => [$gdkpix, $gdkmap] };
+ ($gdkpix, $gdkmap);
+}
+
+#---
# signal handlers
#---
sub sig_usr1 { # embedded applications will send me that signal in order to "kill/hide" them}
- print "USR1\n";
+ $left_locked = 0;
clean_socket();
- $darea_left_sav->{state} = 2, $darea_left_sav->draw(undef);
+ $darea_left_sav and $darea_left_sav->{state} = 2, $darea_left_sav->draw(undef);
$notebook_global->show;
}
my $timer;
sub sig_usr2 {
- print "USR2\n";
+ $left_locked = 0;
Gtk->timeout_remove($timer);
$emb_wait->hide;
$emb_socket->show;
-# Gtk->timeout_remove($lock_time_tag);
-# $$global_vbox->hide; Gtk->timeout_remove($global_time_tag); $$global_socket->show;
-# ${$tree_launched{$_}->[1]} and ${$tree_launched{$_}->[1]}->set_sensitive(1) foreach (keys %tree_launched);
-# my $a = $notebook_global->get_current_page;
-# $notebook_global->set_page(0);
-# $notebook_global->set_page($a);
}
#---
@@ -510,13 +530,17 @@ sub compute_exec_string {
my ($arg) = @_;
my ($log_exp, $exec, $gtkplug, $alternate) = @$arg;
if ($embedded) {
- $notebook_global->hide;
- res_socket();
- $emb_box->show;
- $emb_socket->realize;
- my $exec = $exec . " --embedded " . $emb_socket->window->XWINDOW . " " . $$;
+ if ($gtkplug != -1) {
+ $notebook_global->hide;
+ res_socket();
+ $emb_box->show;
+ $emb_socket->realize;
+ $exec = $exec . " --embedded " . $emb_socket->window->XWINDOW . " " . $$;
+ }
if ($gtkplug) {
$emb_wait->show;
+ $left_locked = 1;
+ $pending_app = 1;
$timer = Gtk->timeout_add(15000, sub { splash_warning(_("This tool seems to be broken, as it didn't show up.\n Try to reinstall it")); sig_usr1(); });
my $pid;
unless ($pid = fork) {
@@ -524,6 +548,8 @@ sub compute_exec_string {
exec("$exec");
}
push @pid_launched, $pid;
+ } elsif ($gtkplug == -1) {
+ system($exec . " &");
} else {
$emb_socket->show;
$emb_socket->steal(launch_xapp($alternate));
@@ -540,7 +566,7 @@ sub compute_exec_string {
}
push @pid_launched, $pid;
}
- if ($embedded) {
+ if ($embedded && $gtkplug != -1) {
foreach (@darea_left_list) {
$_->[1]->window->set_cursor($cursor_hand);
if($_->[1]->{state} != 0) {
@@ -593,6 +619,7 @@ sub clean_socket {
$emb_socket and $emb_socket->destroy();
$exp_socket and $exp_socket->destroy();
$logs and $exp_frame->show;
+ $pending_app = 0;
}
sub res_socket {
@@ -624,21 +651,27 @@ sub quit_global {
#---
sub splash_warning {
- my ($label) = @_;
+ my ($label, $cancel_button) = @_;
+ my $ret;
my $win_about = new Gtk::Dialog();
$win_about->set_position(1);
+ $win_about->set_border_width(10);
gtkpack__($win_about->action_area,
- gtkadd(new Gtk::HButtonBox,
- gtksignal_connect(new Gtk::Button(_("Close")), "clicked" => sub {$win_about->destroy()}),
- )
+ gtkadd(new Gtk::HButtonBox,
+ gtksignal_connect(new Gtk::Button($cancel_button ? _("OK") : _("Close")), "clicked" => sub { $ret = 1; Gtk->main_quit}),
+ if_($cancel_button, gtksignal_connect(new Gtk::Button(_("Cancel")), "clicked" => sub { Gtk->main_quit})),
+ )
);
gtkpack($win_about->vbox,
- gtkpng("warning"),
+ gtkpng_("warning"),
new Gtk::Label($label),
);
$win_about->show_all();
$win_about->set_modal(1);
+ Gtk->main;
+ $win_about->destroy();
+ $ret;
}
sub about_mdk_cc {
@@ -662,8 +695,7 @@ sub about_mdk_cc {
$window_about->vbox->pack_start( new Gtk::Label( _("Copyright (C) 2001 Mandrakesoft SA")), 1, 1, 0);
$window_about->vbox->pack_start( new Gtk::Label( ''), 1, 1, 0 );
$window_about->vbox->pack_start( new Gtk::Label( _("Author: ") . "Damien Krotkine <damien\@mandrakesoft.com>\n"), 1, 1, 0 );
- $window_about->vbox->pack_start( new Gtk::Label( _("Contributors: ") . "- Yves Duret <yduret\@mandrakesoft.com>\n - Daouda Lo <daouda\@mandrakesoft.com>"), 1, 1, 0 );
-
+ $window_about->vbox->pack_start( new Gtk::Label( _("Technology Contributor : ") . "Yves Duret <yduret\@mandrakesoft.com>"), 1, 1, 0 );
$window_about->show_all();
$window_about->set_modal(1);
}
@@ -704,6 +736,8 @@ 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 "$mcc_dir/$_" } all($mcc_dir);
+ my $ignore_active;
$item_factory->create_items(
(
{ path => _("/_File"),
@@ -721,13 +755,17 @@ sub get_main_menu {
type => '<ToggleItem>'},
{ path => _("/_Themes"),
type => '<Branch>' },
- map { my $l = $_;
- my %h = (
- path => _("/Themes"). "/_" . $l,
- callback => \&embedded_mode, #sub { print " pp :$l\n"; },
- );
+ (map { my $l = $_;
+ my %h = (
+ path => _("/Themes"). "/" . ($l eq $theme ? " O " : " ") . "_$l",
+ callback => sub {
+ $theme eq $l and return;
+ !$pending_app || splash_warning(
+ _("This action will restart the control center.\nAny change not applied will be lost."), 1) and sig_usr1(), exec "$0 --theme $l";
+ },
+ );
\%h;
- } ("plop", "plap", "plip"),
+ } @theme_list ),
{ path => _("/_Help"),
type => '<Branch>' },
# { path => _("/Help")._("/_Help on line"), callback => sub { Gtk->exit(0) } },