summaryrefslogtreecommitdiffstats
path: root/tools/mousedrake
blob: 0531372a48c51e2eae3f987e20e2241b69a43b2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/perl

use lib qw(/usr/lib/libDrakX);

# i18n: IMPORTANT: to get correct namespace (drakx-kbd-mouse-x11 instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakx-kbd-mouse-x11' }

use standalone;     #- warning, standalone must be loaded very first, for 'explanations'

use common;
use interactive;
use modules;
use mouse;
use c;


$ugtk2::wm_icon = "/usr/share/mcc/themes/default/mousedrake-mdk.png";
my $in = 'interactive'->vnew('su');

my $modules_conf = modules::any_conf->read;

begin:
my $mouse = mouse::read();
my %old = %$mouse;

if (!$::noauto) {
    my $probed_mouse = mouse::detect($modules_conf);
    $mouse = $probed_mouse if !$mouse->{Protocol} || !$probed_mouse->{unsafe};
}

if (!$mouse || !$::auto) {
    $mouse ||= mouse::fullname2mouse('Universal|Any PS/2 & USB mice');
    mouse::select($in, $mouse) or $in->exit(0);
}

mouse::write_conf($in->do_pkgs, $modules_conf, $mouse, 1);

if ($in->isa('interactive::gtk') && mouse::change_mouse_live($mouse, \%old)) {

    require ugtk2;
    ugtk2->import(qw(:wrappers :create));
    require mygtk2;
    mygtk2->import(qw(gtknew));
    my $w = ugtk2->new(N("Mouse test"));
    gtkadd($w->{window},
           gtknew('VBox', spacing => 5, children_loose => [
                   gtknew('Label', text => N("Please test your mouse:")),
                   my $test_hbox = gtknew('HBox', spacing => 5),
		   $w->create_okcancel]));
    mouse::test_mouse_standalone($mouse, $test_hbox);
    $w->main or goto begin;
}

system('service', 'gpm', 'restart') if -e '/var/lock/subsys/gpm';

$in->exit(0);