aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AdminPanel/Module/AdminMouse.pm
diff options
context:
space:
mode:
authorAngelo Naselli <anaselli@linux.it>2015-03-16 18:16:50 +0100
committerAngelo Naselli <anaselli@linux.it>2015-03-16 18:16:50 +0100
commitfc9772f1f03684e8dab50ff77d2c46c5e0309c7b (patch)
tree375b76cf80e5d816eb48a4badf3bb949199ef220 /lib/AdminPanel/Module/AdminMouse.pm
parent825922057a21a9b09c60edf4b44535d7fd49926d (diff)
downloadcolin-keep-fc9772f1f03684e8dab50ff77d2c46c5e0309c7b.tar
colin-keep-fc9772f1f03684e8dab50ff77d2c46c5e0309c7b.tar.gz
colin-keep-fc9772f1f03684e8dab50ff77d2c46c5e0309c7b.tar.bz2
colin-keep-fc9772f1f03684e8dab50ff77d2c46c5e0309c7b.tar.xz
colin-keep-fc9772f1f03684e8dab50ff77d2c46c5e0309c7b.zip
Moved to namespace to ManaTools
Diffstat (limited to 'lib/AdminPanel/Module/AdminMouse.pm')
-rw-r--r--lib/AdminPanel/Module/AdminMouse.pm100
1 files changed, 50 insertions, 50 deletions
diff --git a/lib/AdminPanel/Module/AdminMouse.pm b/lib/AdminPanel/Module/AdminMouse.pm
index 071a8f3..279fb76 100644
--- a/lib/AdminPanel/Module/AdminMouse.pm
+++ b/lib/AdminPanel/Module/AdminMouse.pm
@@ -1,27 +1,27 @@
# vim: set et ts=4 sw=4:
#*****************************************************************************
-#
+#
# Copyright (c) 2013 - 2015 Angelo Naselli <anaselli@linux.it>
# from drakx services
-#
+#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2, as
# published by the Free Software Foundation.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
+#
#*****************************************************************************
# NOTE this module has not been ported and does not work
# TODO porting it if it is really needed nowadays
-package AdminPanel::Module::AdminMouse;
+package ManaTools::Module::AdminMouse;
#leaving them atm
use lib qw(/usr/lib/libDrakX);
@@ -34,19 +34,19 @@ use modules;
use mouse;
use c;
-use AdminPanel::Shared;
+use ManaTools::Shared;
use yui;
use Moose;
-extends qw( AdminPanel::Module );
+extends qw( ManaTools::Module );
has '+icon' => (
default => "/usr/share/mcc/themes/default/mousedrake-mdk.png",
);
has '+name' => (
- default => N("AdminMouse"),
+ default => N("AdminMouse"),
);
sub start {
@@ -57,7 +57,7 @@ sub start {
sub _getUntranslatedName {
my ($self, $name, $list) = @_;
-
+
foreach my $n (@{$list}) {
my @names = split(/\|/, $n);
for (my $lev=0; $lev < scalar(@names); $lev++) {
@@ -73,23 +73,23 @@ sub _getUntranslatedName {
sub _adminMouseDialog {
my $self = shift;
-
+
my $datavalue = "TEST";
-
+
my $appTitle = yui::YUI::app()->applicationTitle();
-
+
## set new title to get it in dialog
yui::YUI::app()->setApplicationTitle($self->name);
## set icon if not already set by external launcher
yui::YUI::app()->setApplicationIcon($self->icon);
my $factory = yui::YUI::widgetFactory;
-
+
my $dialog = $factory->createMainDialog;
my $vbox = $factory->createVBox( $dialog );
my $frame = $factory->createFrame ($vbox, N("Please choose your type of mouse."));
my $treeWidget = $factory->createTree($frame, "");
-
+
my $modules_conf = modules::any_conf->read;
my $mouse = mouse::read();
@@ -98,17 +98,17 @@ sub _adminMouseDialog {
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');
-
+
my $prev = my $fullname = $mouse->{type} . '|' . $mouse->{name};
my $selected = $mouse->{name};
-
- my $fullList = { list => [ mouse::_fullnames() ], items => [], separator => '|', val => \$fullname,
+
+ my $fullList = { list => [ mouse::_fullnames() ], items => [], separator => '|', val => \$fullname,
format => sub { join('|', map { translate($_) } split('\|', $_[0])) } } ;
- my $i;
-
+ my $i;
+
my $itemColl = new yui::YItemCollection;
my @items;
for ($i=0; $i<scalar(@{$fullList->{list}}); $i++) {
@@ -118,37 +118,37 @@ sub _adminMouseDialog {
}
if ($i == 0 || $names[0] ne $items[0]->{label}) {
if ($i != 0) {
- $itemColl->push($items[0]->{item});
+ $itemColl->push($items[0]->{item});
push @{$fullList->{items}}, $items[-1]->{item};;
}
- @items = undef;
+ @items = undef;
my $item = new yui::YTreeItem ($names[0]);
-
+
if ($selected eq $self->_getUntranslatedName($item->label(), $fullList->{list})) {
$item->setSelected(1) ;
$item->setOpen(1);
- my $parent = $item;
+ my $parent = $item;
while($parent = $parent->parent()) {
- $parent->setOpen(1);
+ $parent->setOpen(1);
}
}
$item->DISOWN();
@items = ({item => $item, label => $names[0], level => 0});
for (my $lev=1; $lev < scalar(@names); $lev++) {
$item = new yui::YTreeItem ($items[$lev-1]->{item}, $names[$lev]);
-
+
if ($selected eq $self->_getUntranslatedName($item->label(), $fullList->{list})) {
$item->setSelected(1) ;
$item->setOpen(1);
- my $parent = $item;
+ my $parent = $item;
while($parent = $parent->parent()) {
- $parent->setOpen(1);
+ $parent->setOpen(1);
}
}
$item->DISOWN();
if ($lev < scalar(@names)-1) {
push @items, {item => $item, label => $names[$lev], level => $lev};
- }
+ }
}
}
else {
@@ -159,7 +159,7 @@ sub _adminMouseDialog {
if ($items[$it]->{label} eq $names[$lev] && $items[$it]->{level} == $lev) {
$prevItem = $it;
last;
- }
+ }
}
if ($it == scalar(@items)) {
my $item = new yui::YTreeItem ($items[$prevItem]->{item}, $names[$lev]);
@@ -167,13 +167,13 @@ sub _adminMouseDialog {
if ($selected eq $self->_getUntranslatedName($item->label(), $fullList->{list})) {
$item->setSelected(1) ;
$item->setOpen(1);
- my $parent = $item;
+ my $parent = $item;
while($parent = $parent->parent()) {
- $parent->setOpen(1);
+ $parent->setOpen(1);
}
}
$item->DISOWN();
- push @items, {item => $item, label => $names[$lev], level => $lev};
+ push @items, {item => $item, label => $names[$lev], level => $lev};
}
}
}
@@ -193,7 +193,7 @@ sub _adminMouseDialog {
while(1) {
my $event = $dialog->waitForEvent();
my $eventType = $event->eventType();
-
+
#event type checking
if ($eventType == $yui::YEvent::CancelEvent) {
last;
@@ -206,12 +206,12 @@ sub _adminMouseDialog {
last;
}
elsif ($widget == $aboutButton) {
- my $license = translate($AdminPanel::Shared::License);
- AdminPanel::Shared::AboutDialog(
+ my $license = translate($ManaTools::Shared::License);
+ ManaTools::Shared::AboutDialog(
{ name => N("AdminMouse"),
- version => $self->VERSION,
+ version => $self->VERSION,
copyright => N("Copyright (C) %s Mageia community", '2014'),
- license => $license,
+ license => $license,
comments => N("AdminMouse is the Mageia mouse management tool \n(from the original idea of Mandriva mousedrake)."),
website => 'http://www.mageia.org',
website_label => N("Mageia"),
@@ -224,13 +224,13 @@ sub _adminMouseDialog {
elsif ($widget == $okButton) {
my $continue = 1;
my $selectedItem = $treeWidget->selectedItem();
-
+
my $it=$selectedItem;
my $fullname = $self->_getUntranslatedName($it->label(), $fullList->{list});
while($it = yui::toYTreeItem($it)->parent()) {
$fullname = join("|", $self->_getUntranslatedName($it->label(), $fullList->{list}), $fullname);
}
-
+
if ($fullname ne $prev) {
my $mouse_ = mouse::fullname2mouse($fullname, device => $mouse->{device});
if ($fullname =~ /evdev/) {
@@ -238,16 +238,16 @@ sub _adminMouseDialog {
}
%$mouse = %$mouse_;
}
-
+
if ($mouse->{nbuttons} < 3 ) {
- $mouse->{Emulate3Buttons} = AdminPanel::Shared::ask_YesOrNo('', N("Emulate third button?"));
+ $mouse->{Emulate3Buttons} = ManaTools::Shared::ask_YesOrNo('', N("Emulate third button?"));
}
if ($mouse->{type} eq 'serial') {
my @list = ();
foreach (detect_devices::serialPorts()) {
push @list, detect_devices::serialPort2text($_);
}
- my $choice = AdminPanel::Shared::ask_fromList(N("Mouse Port"),
+ my $choice = ManaTools::Shared::ask_fromList(N("Mouse Port"),
N("Please choose which serial port your mouse is connected to."),
\@list);
if ( !$choice ) {
@@ -257,24 +257,24 @@ sub _adminMouseDialog {
$mouse->{device} = $choice;
}
}
-
+
if ($continue) {
last;
}
}
}
}
-
+
}
# TODO manage write conf without interactive things
# mouse::write_conf($in->do_pkgs, $modules_conf, $mouse, 1);
system('systemctl', 'try-restart', 'gpm.service') if -e '/usr/lib/systemd/system/gpm.service';
-
- AdminPanel::Shared::infoMsgBox(N("Not implemented yet: configuration is not changed"));
-
+
+ ManaTools::Shared::infoMsgBox(N("Not implemented yet: configuration is not changed"));
+
$dialog->destroy();
-
+
#restore old application title
yui::YUI::app()->setApplicationTitle($appTitle);
}