summaryrefslogtreecommitdiffstats
path: root/lib/mouse.pm
Commit message (Expand)AuthorAgeFilesLines
* adapt to new /etc/sysctl.dThierry Vignaud2013-12-271-1/+1
* fix my emailThierry Vignaud2013-12-161-1/+1
* workaround a gtk+3 regression (bgo#711873)Thierry Vignaud2013-11-241-1/+1
* get_width() => get_allocated_width()Thierry Vignaud2013-11-241-2/+2
* perlish ->style() => ->get_style()Thierry Vignaud2013-11-241-3/+3
* draw replaces expose_eventThierry Vignaud2013-11-241-1/+1
* get_height() => get_allocated_height()Thierry Vignaud2013-11-241-3/+3
* perlish ->allocation => ->get_allocationThierry Vignaud2013-11-241-2/+2
* perlish ->window => ->get_windowThierry Vignaud2013-11-241-1/+1
* perlish ->allocation => ->get_allocationThierry Vignaud2013-11-241-4/+4
* perlish ->window => ->get_windowThierry Vignaud2013-11-241-4/+4
* switch from gtk2 to gtk3Thierry Vignaud2013-11-241-10/+10
* help perl_checkerThierry Vignaud2012-03-241-1/+1
* cleanupsThierry Vignaud2011-12-191-2/+2
* help perl_checkerThierry Vignaud2011-12-191-0/+3
* evdev needs to be loaded before calling getInputDevices_and_usb else it will ...Colin Guthrie2011-12-181-0/+4
* Convert mouse helper to use udevadm in order to work with udev 175+Colin Guthrie2011-12-181-2/+8
* Revert commit 759, we will keep as a patch in the rpm as long as there is no...Dexter Morgan2011-04-171-4/+0
* evdev needs to be loaded before calling getInputDevices_and_usbAnne Nicolas2011-03-301-0/+4
* Synthesized commit during git-svn import combining previous Mandriva history ...Mageia SVN-Git Migration2011-02-031-1/+1
* Remove imwheel supportPaulo Ricardo Zanoni2010-04-131-17/+1
* - wacom driver is now in x11-driver-input-wacomFrederic Crozat2010-02-251-1/+1
* don't inconditionnally load Xconfig::cardChristophe Fergeau2009-10-221-1/+1
* bail out earlier if X isn't installedChristophe Fergeau2009-10-221-3/+2
* - fix input module path on 64 bit machinesChristophe Fergeau2009-10-221-2/+6
* don't add sections for synaptics devices to xorg.confChristophe Fergeau2009-09-221-2/+0
* move functions closer to their place of useChristophe Fergeau2009-09-221-50/+50
* move serial_ports to detect_devices.pmChristophe Fergeau2009-07-011-6/+1
* Prefix functions with _ when they are internalChristophe Fergeau2009-07-011-27/+27
* (set_xfree_conf) fix vmmouse configuration for vmware (#49654)Thierry Vignaud2009-04-221-1/+1
* (various_xfree_conf) install 'x11-driver-input-vmmouse' if neededThierry Vignaud2009-03-201-0/+1
* (detect) configure input driver as 'vmmouse' if running in vmware (#29106)Thierry Vignaud2009-03-201-0/+3
* small fix noticed by pixel's eagle eyePascal Terjan2009-02-111-2/+2
* mousedrake: test if the file is there before trying to install the packagesPascal Terjan2009-02-111-9/+10
* - mousedrake:Pascal Rigaux2009-01-081-1/+1
* - mousedrake:Pascal Rigaux2008-10-241-13/+1
* - mousedrake:Pascal Rigaux2008-04-281-1/+2
* - mousedrake:Pascal Rigaux2008-01-221-1/+1
* drop unused Primary option in set_synapticsOlivier Blin2007-12-141-4/+1
* - use /dev/input/by-id/xxx device instead of vendor+product for evdev micePascal Rigaux2007-11-191-14/+17
* - fix device /dev/input/by-id/usb-$ID_SERIAL-event-mouse for wacomsPascal Rigaux2007-11-121-0/+1
* add support for x11-driver-input-vboxmouse when inside a VirtualBox guestOlivier Blin2007-09-281-2/+6
* make mice list dynamic, since it probes pci busOlivier Blin2007-09-281-2/+4
* - when using evdev for mice, ensure it doesn't match a keyboardPascal Rigaux2007-09-201-1/+2
* - for evdev configured mice, specify bustypePascal Rigaux2007-09-191-1/+1
* - minimal support for allowing to choose evdev on all micePascal Rigaux2007-09-071-8/+20
* - fix detection of touchpad on some kernels (#31584)Pascal Rigaux2007-08-021-1/+1
* - wacom configuration: Pascal Rigaux2007-07-091-9/+14
* re-sync after the big svn lossPascal Rigaux2007-04-251-167/+204
* re-sync after the big svn lossPascal Rigaux2007-04-251-0/+641
hl opt">($printer, $queue, $configfilecontent); } } # Default printer if ($printer->{DEFAULT}) { if ($configfilecontent !~ /^\s*Current\-Printer\s*:/m) { $configfilecontent =~ s/\n/\nCurrent-Printer: $printer->{DEFAULT}\n/s; } else { if ($configfilecontent =~ /^\s*Current\-Printer\s*:\s*(\S+)\s*$/m && !isprinterconfigured($1, $configfilecontent)) { $configfilecontent =~ s/(Current\-Printer\s*:\s*)\S+/$1$printer->{DEFAULT}/; } } } # Write back GIMP's printer configuration file writeconfigfile($configfilename, $configfilecontent); } return 1; } sub addcupsremoteto { my ($printer, $queue) = @_; # Do we have files to treat? my @configfilenames = findconfigfiles(); return 1 if $#configfilenames < 0; my @printerlist = printer::cups::get_remote_queues(); my $ppdfile = ""; if ($printer->{SPOOLER} eq "cups" && (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { foreach my $listentry (@printerlist) { next if $listentry !~ /^([^\|]+)\|([^\|]+)$/; my $q = $1; next if $q ne $queue; my $server = $2; # Remove server name from queue name $q =~ s/^([^@]*)@.*$/$1/; if (-x "$::prefix/usr/bin/wget") { eval(run_program::rooted( $::prefix, "/usr/bin/wget", "-O", "/etc/foomatic/$queue.ppd", "http://$server:631/printers/$q.ppd")); } else { eval(run_program::rooted( $::prefix, "/usr/bin/curl", "-o", "/etc/foomatic/$queue.ppd", "http://$server:631/printers/$q.ppd")); } # Does the file exist and is it not an error message? if (-r "$::prefix/etc/foomatic/$queue.ppd" && cat_("$::prefix/etc/foomatic/$queue.ppd") =~ /^\*PPD-Adobe/) { $ppdfile = "/etc/foomatic/$queue.ppd"; } else { unlink "$::prefix/etc/foomatic/$queue.ppd"; return 0; } } } else { return 1 } # There is no system-wide config file, treat every user's config file foreach my $configfilename (@configfilenames) { # Load GIMP's printer config file my $configfilecontent = readconfigfile($configfilename); # Add the printer entry if (!isprinterconfigured($queue, $configfilecontent)) { # Remove the old printer entry $configfilecontent = removeprinter($queue, $configfilecontent); # Add the new printer entry $configfilecontent = makeprinterentry($printer, $queue, $configfilecontent); } # Write back GIMP's printer configuration file writeconfigfile($configfilename, $configfilecontent); } return 1; } sub removeprinterfrom { my ($_printer, $queue) = @_; # Do we have files to treat? my @configfilenames = findconfigfiles(); return 1 if $#configfilenames < 0; # There is no system-wide config file, treat every user's config file foreach my $configfilename (@configfilenames) { # Load GIMP's printer config file my $configfilecontent = readconfigfile($configfilename); # Remove the printer entry $configfilecontent = removeprinter($queue, $configfilecontent); # Write back GIMP's printer configuration file writeconfigfile($configfilename, $configfilecontent); } return 1; } sub removelocalprintersfrom { my ($printer) = @_; # Do we have files to treat? my @configfilenames = findconfigfiles(); return 1 if $#configfilenames < 0; # There is no system-wide config file, treat every user's config file foreach my $configfilename (@configfilenames) { # Load GIMP's printer config file my $configfilecontent = readconfigfile($configfilename); # Remove the printer entries foreach my $queue (keys(%{$printer->{configured}})) { $configfilecontent = removeprinter($queue, $configfilecontent); } # Write back GIMP's printer configuration file writeconfigfile($configfilename, $configfilecontent); } return 1; } sub makeprinterentry { my ($printer, $queue, $configfile) = @_; # Make printer's section $configfile = addprinter($queue, $configfile); # Load PPD file my $ppd = cat_("$::prefix/etc/foomatic/$queue.ppd"); # Is the printer configured with GIMP-Print? my $gimpprintqueue = 0; my $gimpprintdriver = "ps2"; if ($ppd =~ /CUPS\s*\+\s*GIMP\s*\-\s*Print/im) { # Native CUPS driver $gimpprintqueue = 1; $gimpprintdriver = $1 if $ppd =~ /\s*\*ModelName:\s*\"(\S+)\"\s*$/im; } elsif ($ppd =~ /Foomatic\s*\+\s*gimp\s*\-\s*print/im) { # GhostScript + Foomatic driver $gimpprintqueue = 1; $ppd =~ /\-sModel=((escp2|pcl|bjc|lexmark)\-[^\s\"\']*)/im and $gimpprintdriver = $1; } if ($gimpprintqueue) { # Get the paper size from the PPD file if ($ppd =~ /^\s*\*DefaultPageSize:\s*(\S+)\s*$/m) { my $papersize = $1; $configfile = removeentry($queue, "Media-Size", $configfile); $configfile = addentry($queue, "Media-Size: $papersize", $configfile); } $configfile = removeentry($queue, "PPD-File:", $configfile); $configfile = addentry($queue, "PPD-File:", $configfile); $configfile = removeentry($queue, "Driver:", $configfile); $configfile = addentry($queue, "Driver: $gimpprintdriver", $configfile); $configfile = removeentry($queue, "Destination:", $configfile); $configfile = addentry($queue, sprintf("Destination: /usr/bin/%s -P %s -o raw", $spoolers{$printer->{SPOOLER}}{print_command}, $queue), $configfile); } else { $configfile = removeentry($queue, "PPD-File:", $configfile); $configfile = addentry($queue, "PPD-File: /etc/foomatic/$queue.ppd", $configfile); $configfile = removeentry($queue, "Driver:", $configfile); $configfile = addentry($queue, "Driver: ps2", $configfile); $configfile = removeentry($queue, "Destination:", $configfile); $configfile = addentry($queue, sprintf("Destination: /usr/bin/%s -P %s", $spoolers{$printer->{SPOOLER}}{print_command}, $queue), $configfile); } return $configfile; } sub findconfigfiles() { my @configfilenames = (if_(-d "$::prefix/usr/lib/gimp/1.2", ".gimp-1.2/printrc"), if_(-d "$::prefix/usr/lib/gimp/1.3", ".gimp-1.3/printrc"), if_(-d "$::prefix/usr/lib/gimp/2.0", ".gimp-2.0/printrc")); return () unless @configfilenames; my @filestotreat; foreach (&list_passwd()) { last if ($#filestotreat > 50); my ($username, undef, $uid, $gid, undef, undef, undef, $homedir) = @$_; next if 0 < $uid && $uid < 500 || $username eq "nobody"; foreach my $file (@configfilenames) { my $dir = "$homedir/$file"; $dir =~ s,/[^/]*$,,; next if -f $dir; if (! -d "$::prefix$dir") { eval { mkdir_p("$::prefix$dir") } or next; run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", $dir) or next; } if (! -f "$::prefix$homedir/$file") { eval { output("$::prefix$homedir/$file", "#PRINTRCv1 written by GIMP-PRINT 4.2.2 - 13 Sep 2002\n") } or next; run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", "$homedir/$file") or next; } push @filestotreat, "$homedir/$file"; } } @filestotreat; } sub readconfigfile { my ($file) = @_; local *F; open F, "< $::prefix$file" or return ""; my $filecontent = join("", <F>); close F; return $filecontent; } sub writeconfigfile { my ($file, $filecontent) = @_; local *F; open F, "> $::prefix$file" or return 0; print F $filecontent; close F; return 1; } sub addentry { my ($section, $entry, $filecontent) = @_; my $sectionfound = 0; my $entryinserted = 0; my @lines = pop_spaces(split("\n", $filecontent)); foreach (@lines) { if (!$sectionfound) { $sectionfound = 1 if /^\s*Printer\s*:\s*($section)\s*$/; } else { if (!/^\s*$/ && !/^\s*;/) { $_ = "$entry\n$_"; $entryinserted = 1; last; } } } push(@lines, $entry) if $sectionfound && !$entryinserted; return join("\n", @lines) . "\n"; } sub addprinter { my ($section, $filecontent) = @_; foreach (pop_spaces(split("\n", $filecontent))) { # section already there, nothing to be done return $filecontent if /^\s*Printer\s*:\s*($section)\s*$/; } return $filecontent . "\nPrinter: $section\n"; } sub pop_spaces { my @lines = @_; pop @lines while @lines && $lines[-1] !~ /\S/; } sub removeentry { my ($section, $entry, $filecontent) = @_; my $sectionfound; my @lines = pop_spaces(split(/^/, $filecontent)); foreach (@lines) { if (!$sectionfound) { $sectionfound = /^\s*Printer\s*:\s*($section)\s*$/; } else { last if /^\s*Printer\s*:\s*.*\s*$/; # Next section if (/^\s*$entry/) { $_ = ""; last; } } } return join "", @lines; } sub removeprinter { my ($section, $filecontent) = @_; my $sectionfound; my @lines = pop_spaces(split(/^/, $filecontent)); foreach (@lines) { if (!$sectionfound) { if (/^\s*Printer\s*:\s*($section)\s*$/) { $_ = ""; $sectionfound = 1; } } else { last if /^\s*Printer\s*:\s*.*\s*$/; # Next section $_ = ""; } } return join "", @lines; } sub isprinterconfigured { my ($queue, $filecontent) = @_; my $sectionfound = 0; my $done = 0; my $drivernotps2 = 0; my $ppdfileset = 0; my $nonrawprinting = 0; foreach (split("\n", $filecontent)) { if (!$sectionfound) { if (/^\s*Printer\s*:\s*($queue)\s*$/) { $sectionfound = 1; } } else { if (/^\s*Printer\s*:\s*.*\s*$/) { # Next section $done = 1; last; } elsif (/^\s*Driver:\s*(\S+)\s*$/) { $drivernotps2 = $1 ne "ps2"; } elsif (/^\s*PPD\-File:\s*(\S+)\s*$/) { $ppdfileset = 1; } elsif (my ($dest) = /^\s*Destination:\s*(\S+.*)$/) { $nonrawprinting = $dest !~ /\-o\s*raw/; } } } return 0 if $done && !$sectionfound; # FIXME: IMPOSSIBLE; should be just $done return 1 if $ppdfileset || $drivernotps2 || $nonrawprinting; return 0; } # ------------------------------------------------------------------ 1;