diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2002-07-28 22:02:39 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2002-07-28 22:02:39 +0000 |
commit | ee295df5670f73b285e3de0cea0fdae7d92941bd (patch) | |
tree | 1dbff785561e08dd894473b3c3b223fb1b68e081 /perl-install/Xconfig/xfree.pm | |
parent | 70fd8ae05409bb33818da725015daf181c6e6a83 (diff) | |
download | drakx-ee295df5670f73b285e3de0cea0fdae7d92941bd.tar drakx-ee295df5670f73b285e3de0cea0fdae7d92941bd.tar.gz drakx-ee295df5670f73b285e3de0cea0fdae7d92941bd.tar.bz2 drakx-ee295df5670f73b285e3de0cea0fdae7d92941bd.tar.xz drakx-ee295df5670f73b285e3de0cea0fdae7d92941bd.zip |
14 new modules, will it be enough?? :)
Diffstat (limited to 'perl-install/Xconfig/xfree.pm')
-rw-r--r-- | perl-install/Xconfig/xfree.pm | 77 |
1 files changed, 52 insertions, 25 deletions
diff --git a/perl-install/Xconfig/xfree.pm b/perl-install/Xconfig/xfree.pm index 43c4fe885..69c1b307e 100644 --- a/perl-install/Xconfig/xfree.pm +++ b/perl-install/Xconfig/xfree.pm @@ -3,22 +3,24 @@ package Xconfig::xfree; # $Id$ use diagnostics; use strict; -use MDK::Common; +use common; use Xconfig::parse; use Xconfig::xfree3; use Xconfig::xfree4; use log; +#- files are optional sub read { - my ($class) = @_; - bless { xfree3 => Xconfig::xfree3->read, - xfree4 => Xconfig::xfree4->read }, $class; + my ($class, $xfree3_file, $xfree4_file) = @_; + bless { xfree3 => Xconfig::xfree3->read($xfree3_file), + xfree4 => Xconfig::xfree4->read($xfree4_file) }, $class; } +#- files are optional sub write { - my ($both) = @_; - $both->{xfree3}->write; - $both->{xfree4}->write; + my ($both, $xfree3_file, $xfree4_file) = @_; + $both->{xfree3}->write($xfree3_file); + $both->{xfree4}->write($xfree4_file); } sub empty_config { @@ -32,8 +34,18 @@ sub set_keyboard { set_both('set_keyboard', @_) } sub get_mice { get_both('get_mice', @_) } sub set_mice { set_both('set_mice', @_) } +sub get_resolution { get_both('get_resolution', @_) } +sub set_resolution { set_both('set_resolution', @_) } + +sub get_device { get_both('get_device', @_) } +sub get_devices { get_both('get_devices', @_) } +sub set_devices { set_both('set_devices', @_) } +sub set_wacoms { set_both('set_wacoms', @_) } +sub get_monitor { get_both('get_monitor', @_) } +sub get_monitors { get_both('get_monitors', @_) } +sub set_monitors { set_both('set_monitors', @_) } #-############################################################################## #- helpers @@ -43,36 +55,51 @@ sub get_both { my @l3 = $both->{xfree3}->$getter; my @l4 = $both->{xfree4}->$getter; - my @r = mapn { + merge_values(\@l3, \@l4); +} +sub set_both { + my ($setter, $both, @l) = @_; + + $both->{xfree3}->$setter(@l); + $both->{xfree4}->$setter(@l); +} + +sub merge_values { + my ($l3, $l4) = @_; + + sub merge_values__hashes { my ($h3, $h4) = @_; + $h3 || $h4 or return; + $h3 or return $h4; + $h4 or return $h3; + my %h = %$h4; foreach (keys %$h3) { - if (exists $h{$_}) { - my $s4 = join(", ", deref_array($h{$_})); - my $s3 = join(", ", deref_array($h3->{$_})); - my $s3_ = join(", ", map { qq("$_") } deref_array($h3->{$_})); - if ($s4 eq $s3_) { - #- keeping the non-double-quoted value - $h{$_} = $h3->{$_}; + if (exists $h{$_}) { + if (ref($h{$_}) eq 'HASH' && ref($h3->{$_}) eq 'HASH') { + #- needed for "Options" of Devices + $h{$_} = +{ %{$h3->{$_}}, %{$h{$_}} }; } else { - $s4 eq $s3 or log::l(qq(XFree: conflicting value for $_, "$s4" and "$s3" are different)); + my $s4 = join(", ", deref_array($h{$_})); + my $s3 = join(", ", deref_array($h3->{$_})); + my $s3_ = join(", ", map { qq("$_") } deref_array($h3->{$_})); + if ($s4 eq $s3_) { + #- keeping the non-double-quoted value + $h{$_} = $h3->{$_}; + } else { + $s4 eq $s3 or log::l(qq(XFree: conflicting value for $_, "$s4" and "$s3" are different)); + } } } else { $h{$_} = $h3->{$_}; } } \%h; - } \@l3, \@l4; + } - @r == 1 ? $r[0] : @r; -} -sub set_both { - my ($setter, $both, @l) = @_; + my @r = mapn(\&merge_values__hashes, $l3, $l4); - $both->{xfree3}->$setter(@l); - $both->{xfree4}->$setter(@l); + @r == 1 ? $r[0] : @r; } - - 1; |