Viewing file: mouse_cli.py (3.63 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# mouse_cli.py: command line mouse configuration # # Copyright (C) 2002, 2003 Red Hat, Inc. # Copyright (C) 2002, 2003 Brent Fox <bfox@redhat.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 # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 Library Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import sys from rhpl.mouse import Mouse from rhpl.translate import _ import mouse_backend
mouseBackend = mouse_backend.MouseBackend()
class childWindow: def usage(self): print _("""Usage: system-config-mouse [--help] [--noui] [--text] [--emulthree] [--device <dev>] [<mousetype>] --help Print out this message. --noui Run in command line mode. --text Run in text interface mode. --emulthree Emulate three button mouse --device <dev> Specify port mouse is on. <dev> is typically ttyS[0-3], or psaux for PS/2 mice on a PS/2 port <mousetype> is one of: """) for item in self.typelist: print " ", item sys.exit(1)
def __init__(self, mousetype, device, emulthree, help): self.mouse = Mouse(skipProbe = 1) self.mouse.read()
self.miceDict = self.mouse.available () mice = self.miceDict.keys () mice.sort() self.micenames = mice self.typelist = []
for item in mice: (a, b, c, d, e, type) = self.miceDict[item] self.typelist.append(type)
if help: self.usage()
if mousetype == []: print _("You must specify a valid mouse type.") print _("Run 'system-config-mouse --help' to see a list of mice")
elif mousetype != None and device != "": if mousetype in self.mouse.mouseToMouse(): fullName = self.mouse.mouseToMouse()[mousetype] (gpm, xprotocol, iprotocol, listdevice, listemulate, shortname) = self.mouse.available()[fullName]
if device == None: #If they didn't specify a device, try to make some assumptions if listdevice == "ttyS": #This is a serial mouse, let's assume ttyS0 print _("A serial device was not specified. Assuming ttyS0") device = "ttyS0" else: #Well, what the heck. Let's assume that the listdevice from mouse.py is right device = listdevice
if emulthree == None: #If they didn't specify emulthree, let's go with what is in mouse.py emulthree = listemulate
if emulthree: emulthree = "yes" else: emulthree = "no"
mouseBackend.writeMouseFile(fullName, gpm, emulthree, xprotocol, iprotocol, device) mouseBackend.restartGpm() else: print _("\"%s\" is not a valid mouse type." % mousetype) print _("Run 'system-config-mouse --help' to see a list of mice")
|