!C99Shell v. 1.0 pre-release build #16!

Software: Apache/2.0.54 (Fedora). PHP/5.0.4 

uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 

uid=48(apache) gid=48(apache) groups=48(apache)
context=system_u:system_r:httpd_sys_script_t
 

Safe-mode: OFF (not secure)

/usr/share/system-config-mouse/   drwxr-xr-x
Free 3.9 GB of 27.03 GB (14.43%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     mouse_gui.py (15.17 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# mouse_gui.py - GUI front end code for 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 General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

import string
import gtk
import gobject
import sys
import os
import rhpl.mouse as mouse
import kudzu

from rhpl.firstboot_gui_window import FirstbootGuiWindow
sys.path.append('/usr/share/system-config-mouse')
import mouse_backend

##
## I18N
##
from rhpl.translate import _, N_
import rhpl.translate as translate
translate.textdomain ("system-config-mouse")

##
## Icon for windows
##

iconPixbuf = None      
try:
    iconPixbuf = gtk.gdk.pixbuf_new_from_file("/usr/share/system-config-mouse/pixmaps/gnome-mouse.png")
except:
    pass

mouseBackend = mouse_backend.MouseBackend()

class MouseWindow(FirstbootGuiWindow):
    #You must specify a runPriority for the order in which you wish your module to run
    runPriority = 30
    moduleName = N_("Mouse")
    moduleClass = "reconfig"
    windowTitle = N_("Mouse Configuration")
    htmlTag = "mouse"
    commentTag = N_("Configure the mouse")
    shortMessage = N_("Select the appropriate mouse for the system.")
    instDataMouse = None

    def getNext(self):
        pass
    
    def destroy(self, args):
        gtk.main_quit()
    
    def setupScreen(self, instDataMouse=None):
        self.mouse = mouse.Mouse(skipProbe = 1)
        self.mouse.read()
        mouseDict = self.mouse.mouseToMouse()
        self.currentDev = self.mouse.getDevice()

        if instDataMouse == None:
            currentMouse, emulate3 = self.mouse.get()
        else:
            self.mouse = instDataMouse
            currentMouse = self.mouse.info["FULLNAME"]
            if "XEMU3" in self.mouse.info:
                emulate3 = self.mouse.info["XEMU3"]
            else:
                emulate3 = None

            self.currentDev = self.mouse.getDevice()

        self.Xemu3CheckButton = gtk.CheckButton(_("Emulate 3 button click"))

        self.mouseStore = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                                        gobject.TYPE_STRING, gobject.TYPE_INT)
        self.deviceStore = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)

        #Add icon to the top frame
        p = None
        try:
            p = gtk.gdk.pixbuf_new_from_file("../pixmaps/gnome-mouse.png")
        except:
            try:
                p = gtk.gdk.pixbuf_new_from_file("/usr/share/system-config-mouse/pixmaps/gnome-mouse.png")
            except:
                pass

        if p:
            self.icon = gtk.Image()
            self.icon.set_from_pixbuf(p)


        #XXX - due to a bug in rhpl, mouse.get() doesn't return the correct value for emulate3,
        if "XEMU3" in self.mouse.info:
            #so let's look in the data structure directly
            emulate3 = self.mouse.info["XEMU3"]

        self.mouseView = gtk.TreeView(self.mouseStore)
        self.col = gtk.TreeViewColumn(None, gtk.CellRendererText(), text=0)
        self.mouseView.append_column(self.col)
        self.mouseView.set_property("headers-visible", False)
        selection = self.mouseView.get_selection()
        selection.connect("changed", self.selectMouse)

        self.deviceView = gtk.TreeView(self.deviceStore)
        col = gtk.TreeViewColumn(_("_Device"), gtk.CellRendererText(), text=0)
        self.deviceView.append_column(col)
        self.deviceViewSW = gtk.ScrolledWindow()
        self.deviceViewSW.set_policy(gtk.POLICY_NEVER, gtk.POLICY_NEVER)
        self.deviceViewSW.set_shadow_type(gtk.SHADOW_IN)
        self.deviceViewSW.add(self.deviceView)

        self.mouseViewSW = gtk.ScrolledWindow()
        self.mouseViewSW.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        self.mouseViewSW.set_shadow_type(gtk.SHADOW_IN)
        self.mouseViewSW.add(self.mouseView)

        self.serialButton = gtk.Button(_("_Serial devices..."))
        self.serialButton.connect("clicked", self.on_serialButton_clicked)
        self.serialButton.set_sensitive(False)

        hbox = gtk.HBox()
        hbox.pack_start(self.Xemu3CheckButton, True)
        hbox.pack_start(self.serialButton, False)

        self.myVbox = gtk.VBox()
        self.myVbox.set_spacing(5)
        self.myVbox.pack_start(self.mouseViewSW, True)
        self.myVbox.pack_start(hbox, False, 3)

        self.serialDlg = gtk.Dialog(_("Serial Devices"))
        self.serialDlg.set_border_width(10)
        label = gtk.Label(_("Select the correct serial device for the mouse."))
        label.set_alignment(0.0, 0.5)
        self.serialDlg.vbox.set_spacing(5)
        self.serialDlg.vbox.pack_start(label, False)
        self.serialDlg.vbox.pack_start(self.deviceViewSW, True)
        self.serialDlg.add_button(gtk.STOCK_OK, 0)

        self.setupMice()
        self.setupDeviceList()
        self.setCurrentDevice()
        self.setCurrent(self.currentDev, currentMouse, emulate3)

    def setupMice(self):
        # go though and find all the makes that have more than 1 mouse
        toplevels = {}

        for key, value in self.mouse.available().items():
            make = string.split(_(key), ' - ')[0]
            if toplevels.has_key(make):
                toplevels[make] = toplevels[make] + 1
            else:
                toplevels[make] = 1

        # for each toplevel that has more than one mouse, make a parent
        # node for it.
        for make, count in toplevels.items():
            if count > 1:
                parent = self.mouseStore.append(None)
                self.mouseStore.set_value(parent, 0, make)
                toplevels[make] = parent
            else:
                del toplevels[make]
                
        # now go and add each child node
        for key, value in self.mouse.available().items():
            fields = string.split(_(key), ' - ')
            make = fields[0]
            model = fields[1]
            parent = toplevels.get(make)
            iter = self.mouseStore.append(parent)
            # if there is a parent, put only the model in the tree
            if parent:
                self.mouseStore.set_value(iter, 0, model)
            else:
                # otherwise, put the full device there.
                self.mouseStore.set_value(iter, 0, "%s %s" % tuple(fields))
            self.mouseStore.set_value(iter, 1, key)
            self.mouseStore.set_value(iter, 2, value[3])
            self.mouseStore.set_value(iter, 3, value[4])

    def on_serialButton_clicked(self, *args):
        self.serialDlg.show_all()
        #select the current serial device
        self.setCurrentDevice()
        rc = self.serialDlg.run()

        #figure out what was chosen and make that the new device
        data, iter = self.deviceView.get_selection().get_selected()
        dev = self.deviceStore.get_value(iter, 1)
        self.mouse.info["DEVICE"] = "/dev/%s" % dev

        self.serialDlg.hide()

    def selectMouse(self, selection, *args):
        model, iter = selection.get_selected()
        if not iter:
            return

        if model.iter_has_child(iter) == 1:
            selection.unselect_all()
            return

        type = self.mouseStore.get_value(iter, 2)
        emu3 = self.mouseStore.get_value(iter, 3)

        if type == "ttyS":
            self.serialButton.set_sensitive(True)
        else:
           self.serialButton.set_sensitive(False)

        if emu3 == 0:
            self.Xemu3CheckButton.set_active(False)
        else:
            self.Xemu3CheckButton.set_active(True)
            
    def setupDeviceList(self):
    deviceList = ((_("/dev/ttyS0 (COM1 under DOS)"), "ttyS0" ),
                      (_("/dev/ttyS1 (COM2 under DOS)"), "ttyS1" ),
                      (_("/dev/ttyS2 (COM3 under DOS)"), "ttyS2" ),
                      (_("/dev/ttyS3 (COM4 under DOS)"), "ttyS3" ))

    for descrip, dev in deviceList:
            iter = self.deviceStore.append()
            self.deviceStore.set_value(iter, 0, descrip)
            self.deviceStore.set_value(iter, 1, dev)

    def setCurrentDevice(self):
        iter = self.deviceStore.get_iter_root()

        while iter:
            dev = self.deviceStore.get_value(iter, 1)
            if self.mouse.info.has_key("DEVICE"):
                #Only try to set the serial device if the mouse has a DEVICE key
                infoDev = string.split(self.mouse.info["DEVICE"], "/dev/")[1]

                if infoDev == string.strip(dev):
                    self.deviceView.get_selection().select_iter(iter)
            iter = self.deviceStore.iter_next(iter)

    def setCurrent(self, currentDev, currentMouse, emulate3, recenter=1):
        self.ignoreEvents = 1

        foundMatch = 0
        parent = None
        iter = self.mouseStore.get_iter_first()
        # iterate over the list, looking for the current mouse selection
        while iter:
            # if this is a parent node, get the first child and iter over them
            if self.mouseStore.iter_has_child(iter):
                parent = iter
                iter = self.mouseStore.iter_children(parent)

            # if it's not a parent node and the mouse matches, select it.
            if self.mouseStore.get_value(iter, 1) == currentMouse:
        if parent:
            path = self.mouseStore.get_path(parent)
            self.mouseView.expand_row(path, True)
                foundMatch = 1
                selection = self.mouseView.get_selection()
                selection.unselect_all()
                selection.select_iter(iter)
                path = self.mouseStore.get_path(iter)
                col = self.mouseView.get_column(0)
                self.mouseView.set_cursor(path, col, False)
                if recenter:
                    self.mouseView.scroll_to_cell(path, col, True,
                                                  0.5, 0.5)

            # get the next row.
            iter = self.mouseStore.iter_next(iter)
            # if there isn't a next row and we had a parent, go to the node
            # after the parent we've just gotten the children of.
            if not iter and parent:
                parent = self.mouseStore.iter_next(parent)
                iter = parent

        if not foundMatch:
            # If the entry in /etc/sysconfig/mouse doesn't have a match in rhpl's list,
            # select a generic 2 button ps/2 mouse by default.  
            parent = self.mouseStore.get_iter_first()
            generic_iter = self.mouseStore.iter_children(parent)
            while generic_iter:
                if self.mouseStore.get_value(generic_iter, 1) == "Generic - 2 Button Mouse (PS/2)":
            path = self.mouseStore.get_path(parent)
            self.mouseView.expand_row(path, True)
                    selection = self.mouseView.get_selection()
                    selection.unselect_all()
                    selection.select_iter(generic_iter)
                    path = self.mouseStore.get_path(generic_iter)
                    col = self.mouseView.get_column(0)
                    self.mouseView.set_cursor(path, col, False)
                    
                generic_iter = self.mouseStore.iter_next(generic_iter)
            
        if emulate3 == "yes":
            self.Xemu3CheckButton.set_active(True)
        else:
            self.Xemu3CheckButton.set_active(False)
        self.ignoreEvents = 0
    
    def launch(self, doDebug=None):
        self.doDebug = doDebug
        if doDebug:
            print "in mouse launch"
        self.setupScreen()

        label = gtk.Label(_(self.shortMessage))
        label.set_alignment(0.0, 0.5)
        label.set_size_request(500, -1)
        self.myVbox.pack_start(label, False)
        self.myVbox.reorder_child(label, 0)
        self.myVbox.set_spacing(10)
        self.myVbox.set_border_width(10)

        outerVBox = gtk.VBox()
        outerVBox.pack_start(self.myVbox)

        return outerVBox, self.icon, self.windowTitle

    def apply(self, *args):
        model, iter = self.mouseView.get_selection().get_selected()
        if not iter:
            dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                    (_("Please select a mouse.")))
            dlg.set_position(gtk.WIN_POS_CENTER)
            dlg.set_icon(iconPixbuf)
            dlg.set_modal(True)
            dlg.run()
            dlg.destroy()
            return

        selectedMouse = model.get_value(iter,1)
        (gpm, xprotocol, iprotocol, device, emulate, shortname) = self.mouse.available()[selectedMouse]

        if emulate:
            Xemu3 = "yes"
        else:
            Xemu3 = "no"

        if self.Xemu3CheckButton.get_active() == True:
            Xemu3 = "yes"


        if device == "ttyS":
            data, iter = self.deviceView.get_selection().get_selected()
            if iter == None:
                port = "ttyS0"
            else:
                port = self.deviceStore.get_value(iter, 1)
            device = port

        mouseBackend.writeMouseFile(selectedMouse, gpm, Xemu3, xprotocol, iprotocol, device, self.doDebug)
        mouseBackend.restartGpm()

        try:
            #If we're in reconfig mode, this will fail because there is no self.mainWindow
            self.mainWindow.destroy()
        except:
            pass            
        return 0

    def stand_alone(self, doDebug = None):
        self.doDebug = doDebug
        self.setupScreen()
        return FirstbootGuiWindow.stand_alone(self, MouseWindow.windowTitle, iconPixbuf)

    def anacondaScreen(self, mouse, label):
        self.doDebug = None
        self.instDataMouse = mouse
        self.mouseLabel = label
        self.setupScreen(self.instDataMouse)
        return FirstbootGuiWindow.anacondaScreen(self, MouseWindow.windowTitle, iconPixbuf, 400, 350)

    def okAnacondaClicked(self, *args):
        model, iter = self.mouseView.get_selection().get_selected()
        if not iter:
            dlg = gtk.MessageDialog(None, 0, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                    (_("Please select a mouse.")))
            dlg.set_position(gtk.WIN_POS_CENTER)
            dlg.set_icon(iconPixbuf)
            dlg.set_modal(True)
            dlg.run()
            dlg.destroy()
            return

        selectedMouse = model.get_value(iter,1)
        (gpm, xprotocol, device, emulate, shortname) = self.mouse.available()[selectedMouse]

        if device == "ttyS":
            data, iter = self.deviceView.get_selection().get_selected()
            if iter == None:
                port = "ttyS0"
            else:
                port = self.deviceStore.get_value(iter, 1)
            device = port


        self.instDataMouse.set(selectedMouse, self.Xemu3CheckButton.get_active())
        self.instDataMouse.setDevice(device)

        self.mouseLabel.set_text(selectedMouse)
        self.mainWindow.destroy()

childWindow = MouseWindow

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0045 ]--