mousetrap r29 - in branches/ng/src/mousetrap: . lib ui
- From: flaper svn gnome org
- To: svn-commits-list gnome org
- Subject: mousetrap r29 - in branches/ng/src/mousetrap: . lib ui
- Date: Tue, 31 Mar 2009 12:06:45 +0000 (UTC)
Author: flaper
Date: Tue Mar 31 12:06:44 2009
New Revision: 29
URL: http://svn.gnome.org/viewvc/mousetrap?rev=29&view=rev
Log:
Missing files
Added:
branches/ng/src/mousetrap/__init__.py (contents, props changed)
branches/ng/src/mousetrap/environment.py.in
branches/ng/src/mousetrap/lib/__init__.py (contents, props changed)
branches/ng/src/mousetrap/lib/dbusd.py (contents, props changed)
branches/ng/src/mousetrap/lib/httpd.py (contents, props changed)
branches/ng/src/mousetrap/lib/settings.py (contents, props changed)
branches/ng/src/mousetrap/ui/i18n.py (contents, props changed)
branches/ng/src/mousetrap/ui/settings_gui.py (contents, props changed)
Modified:
branches/ng/src/mousetrap/mousetrap.py
Added: branches/ng/src/mousetrap/__init__.py
==============================================================================
--- (empty file)
+++ branches/ng/src/mousetrap/__init__.py Tue Mar 31 12:06:44 2009
@@ -0,0 +1 @@
+
Added: branches/ng/src/mousetrap/environment.py.in
==============================================================================
--- (empty file)
+++ branches/ng/src/mousetrap/environment.py.in Tue Mar 31 12:06:44 2009
@@ -0,0 +1,112 @@
+
+# -*- coding: utf-8 -*-
+
+# mouseTrap
+#
+# Copyright 2008 Flavio Percoco Premoli
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library 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
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA 02110-1301 USA.
+
+""" Holds mouseTrap internal information. """
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli."
+__license__ = "GPLv2"
+
+import sys
+import os
+import gtk
+
+## mouseTrap Version
+version = "@MOUSETRAP_VERSION@"
+
+## "--prefix" parameter used when configuring the build.
+prefix = "@prefix@"
+
+## The package name (should be "mouseTrap").
+package = "@PACKAGE@"
+
+## The name of the data directory (usually "share").
+datadirname = "%s/@DATADIRNAME@" % prefix
+
+## Directly mouseTrap data dir
+mTDataDir = "%s/mouseTrap" % datadirname
+
+## The actuall running desktop manager.
+desktop = os.getenv("DESKTOP_MANAGER")
+
+## The name of the O.S
+osName = os.name
+
+## The application's path
+appPath = os.path.dirname(__file__)
+
+## The user's home directory
+home = os.path.expanduser("~")
+
+## Configurations dir
+configPath = home + "/.mouseTrap/"
+
+## Configurations dir
+configPath = "%s/.mouseTrap/" % home
+
+## Scripts Path
+scriptsPath = "%s/scripts/" % configPath
+
+## Profiles Path
+profilesPath = "%s/profiles/" % scriptsPath
+
+## The config file
+configFile = configPath + "userSettings.cfg"
+
+## The debug file
+debugFile = configPath + "mouseTrap_DEBUG.log"
+
+## The language path
+langPath = "%s/locale/" % datadirname
+
+## The haarcascade folder
+haarcascades = appPath + "/haarcascade"
+
+## The debugging parts
+DEBUG = ['widget']
+
+## mouseTrap Modules
+mTModules = { 'lTr' : '_startListener',
+ 'cAm' : '_startCam',
+ 'wTp' : '_startWidgetsTrap'}
+
+
+## Screen Resolution
+screen = { 'width' : gtk.gdk.screen_width(),
+ 'height' : gtk.gdk.screen_height()}
+
+## Mose Movement Modes
+mouseModes = { }
+
+###################################################
+# #
+# MOUSETRAP'S STATES DEFINITION #
+# #
+###################################################
+
+## Mousetrap is active and the mouse pointer can be moved
+ACTIVE = "active"
+
+## Mousetrap is active and the click dialog is not hidden.
+CLKDLG = "clk-dialog"
Added: branches/ng/src/mousetrap/lib/__init__.py
==============================================================================
Added: branches/ng/src/mousetrap/lib/dbusd.py
==============================================================================
--- (empty file)
+++ branches/ng/src/mousetrap/lib/dbusd.py Tue Mar 31 12:06:44 2009
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+
+# mouseTrap
+#
+# Copyright 2008 Flavio Percoco Premoli
+#
+# This file is part of mouseTrap.
+#
+# mouseTrap 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.
+#
+# mouseTrap 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 mouseTrap. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+""" Exposes mouseTrap as a DBus service for comunication purposes. """
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
+__license__ = "GPLv2"
+
+import dbus
+import dbus.service
+from dbus.mainloop.glib import DBusGMainLoop
+
+dbusserver = None
+main_loop = DBusGMainLoop()
+bus = dbus.SessionBus(mainloop=main_loop)
+
+DBUS_NAME = "org.gnome.mousetrap"
+DBUS_PATH = "/org/gnome/mousetrap"
+
+class DbusServer(dbus.service.Object):
+ """DBus service"""
+
+ def start( self ):
+ """
+ Initialize the dbus server module.
+
+ Arguments:
+ - lself: The main object pointer
+ - mouseTrap: The mouseTrap onject pointer
+ """
+
+ global bus
+ bus_name = dbus.service.BusName(DBUS_NAME, bus=bus)
+ dbus.service.Object.__init__(self, bus_name, DBUS_PATH)
+
+ @dbus.service.method(DBUS_NAME)
+ def move(self, action):
+ """
+ Just Move the mouse to de required position.
+ """
+ print(action)
+ #X, Y = action.split(",")
+ #mouseTrap.move( "click", X, Y )
+
+def start():
+ """
+ Start's the dbus server and store it in the global variable
+ dbusserver, so it won't be started twice.
+ """
+ global dbusserver
+
+ if dbusserver:
+ return
+
+ try:
+ dbusserver = DbusServer()
+ return True
+ except:
+ debug.exception( "mouseTrap.mTDbus", "The dbus server load failed" )
+
+
+def shutdown():
+ """
+ Fake shutdown
+ """
+ pass
Added: branches/ng/src/mousetrap/lib/httpd.py
==============================================================================
--- (empty file)
+++ branches/ng/src/mousetrap/lib/httpd.py Tue Mar 31 12:06:44 2009
@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+
+# mouseTrap
+#
+# Copyright 2008 Flavio Percoco Premoli
+#
+# This file is part of mouseTrap.
+#
+# mouseTrap 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.
+#
+# mouseTrap 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 mouseTrap. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+"""The Server module of mouseTrap."""
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
+__license__ = "GPLv2"
+
+import threading
+import thread
+import gobject
+import BaseHTTPServer
+
+
+class _HTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ """
+ Provides support for communicating with mouseTrap via HTTP.
+
+ To test this, run:
+
+ wget --post-data='move:X,Y' localhost:20433
+
+ """
+
+ def log_request(self, code=None, size=None):
+ """
+ Override to avoid getting a log message on stdout for
+ each GET, POST, etc. request
+ """
+ pass
+
+ def do_GET(self):
+ self.send_response(200)
+ self.send_header("Content-type", "text/html")
+ self.end_headers()
+ self.wfile.write("<html><body><p>mouseTrap 0.1</p></body></html>")
+
+ def do_POST(self):
+ contentLength = self.headers.getheader('content-length')
+ if contentLength:
+ contentLength = int(contentLength)
+ inputBody = self.rfile.read(contentLength)
+
+ if inputBody.startswith("move:"):
+ X, Y = inputBody[5:].split(",")
+ print X + " " + Y
+ self.send_response(200, 'OK')
+ else:
+ print( "mal" )
+
+#class _HTTPRequestThread(threading.Thread):
+class HttpdServer:
+ """Runs a _HTTPRequestHandler in a separate thread."""
+
+ def __init__( self, port ):
+ self.httpd = None
+ self.run = True
+ self.port = port
+ self.connected = False
+
+ def start(self):
+ """
+ Try to start an HTTP server on self.settings.httpPort
+ """
+
+ while not self.connected:
+ self.httpd = BaseHTTPServer.HTTPServer(('', self.port),
+ _HTTPRequestHandler)
+ self.connected = True
+ #debug.log( debug.MODULES, "Highest")
+
+ if not self.connected:
+ print( "problems" )
+ return False
+
+ thread.start_new_thread(self.__handler, ())
+
+ def is_running(self):
+ return self.connected
+
+ def __handler( self ):
+ while self.run:
+ self.httpd.handle_request()
+
Added: branches/ng/src/mousetrap/lib/settings.py
==============================================================================
--- (empty file)
+++ branches/ng/src/mousetrap/lib/settings.py Tue Mar 31 12:06:44 2009
@@ -0,0 +1,12 @@
+import ConfigParser
+import environment as env
+
+class settings( ConfigParser.ConfigParser ):
+
+ def optionxform( self, optionstr ):
+ return optionstr
+
+def load():
+ cfg = settings()
+ cfg.readfp(open( env.configFile ))
+ return cfg
Modified: branches/ng/src/mousetrap/mousetrap.py
==============================================================================
--- branches/ng/src/mousetrap/mousetrap.py (original)
+++ branches/ng/src/mousetrap/mousetrap.py Tue Mar 31 12:06:44 2009
@@ -69,9 +69,9 @@
self.httpd.start()
# Lets start the module
- idm = pocv.get_idm(self.cfg.get("main", "algorithm"))
- self.idm = idm.Module(self)
- self.idm.set_capture()
+ #idm = pocv.get_idm(self.cfg.get("main", "algorithm"))
+ #self.idm = idm.Module(self)
+ #self.idm.set_capture()
# Lets build the interface
self.itf = MainGui(self)
@@ -99,7 +99,7 @@
loop = gobject.MainLoop()
a = Controller()
a.start()
-gobject.timeout_add(150, a.update_frame)
-gobject.timeout_add(50, a.update_pointers)
+#gobject.timeout_add(150, a.update_frame)
+#gobject.timeout_add(50, a.update_pointers)
gobject.threads_init()
loop.run()
Added: branches/ng/src/mousetrap/ui/i18n.py
==============================================================================
--- (empty file)
+++ branches/ng/src/mousetrap/ui/i18n.py Tue Mar 31 12:06:44 2009
@@ -0,0 +1,2 @@
+def _(txt):
+ return txt
Added: branches/ng/src/mousetrap/ui/settings_gui.py
==============================================================================
--- (empty file)
+++ branches/ng/src/mousetrap/ui/settings_gui.py Tue Mar 31 12:06:44 2009
@@ -0,0 +1,424 @@
+# -*- coding: utf-8 -*-
+
+# mouseTrap
+#
+# Copyright 2008 Flavio Percoco Premoli
+#
+# This file is part of mouseTrap.
+#
+# mouseTrap 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.
+#
+# mouseTrap 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 mouseTrap. If not, see <http://www.gnu.org/licenses/>.
+
+"""The prefferences GUI."""
+
+__id__ = "$Id$"
+__version__ = "$Revision$"
+__date__ = "$Date$"
+__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
+__license__ = "GPLv2"
+#
+
+import gtk
+import sys
+from i18n import _
+import environment as env
+
+class preffGui( gtk.Window ):
+ """
+ The Class for the preferences GUI.
+
+ Arguments:
+ - gtk.Window: The gtk.Window Object.
+ """
+
+ def __init__(self, controller):
+ """
+ The Class Constructor.
+
+ Arguments:
+ - self: The main object pointer.
+ - mouseTrap: The mouseTrap object pointer.
+ """
+
+ gtk.Window.__init__( self )
+
+ self.ctr = controller
+ self.cfg = self.ctr.cfg
+ self.preffWidgets = dict()
+
+ def _SetWindowsIcon( self ):
+ """
+ Sets the icon for the preffGUI.
+
+ Arguments:
+ - self: The main object pointer.
+ """
+
+ icon_theme = gtk.icon_theme_get_default()
+ try:
+ icon = icon_theme.load_icon("mouseTrap", 48, 0)
+ except:
+ return
+
+ gtk.window_set_default_icon(icon)
+
+ def _buildInterface( self ):
+ """
+ Builds the preffGUI.
+
+ Arguments:
+ - self: The main object pointer.
+ """
+
+ accelGroup = gtk.AccelGroup()
+ self.add_accel_group( accelGroup )
+
+ accelGroup = accelGroup
+
+ self.set_title( _("mouseTrap Preferences") )
+ self.set_size_request( 600 , 400)
+ self.connect( "destroy", self.close)
+
+ self.Table = gtk.Table( 3, 6, False )
+
+ self.NoteBook = gtk.Notebook()
+ self.NoteBook.set_tab_pos( gtk.POS_TOP )
+ self.Table.attach( self.NoteBook, 0, 6, 0, 1 )
+ self.NoteBook.show()
+
+ self.mainGuiTab()
+ self.camTab()
+ #self.mouseTab()
+ self.debugTab()
+
+ ####################
+ # Bottom's buttons #
+ ####################
+ self.ButtonsBox = gtk.HBox( False, spacing=6 )
+
+ self.AcceptButton = gtk.Button( _("Accept"), stock=gtk.STOCK_OK)
+ self.AcceptButton.connect("clicked", self.acceptButtonClick )
+ self.ButtonsBox.pack_end( self.AcceptButton )
+
+ CancelButton = gtk.Button( _("Accept"), stock=gtk.STOCK_CANCEL )
+ CancelButton.connect("clicked", self.close )
+ self.ButtonsBox.pack_end( CancelButton)
+
+ self.ApplyButton = gtk.Button( _("Accept"), stock=gtk.STOCK_APPLY )
+ self.ApplyButton.connect( "clicked", self.applyButtonClick )
+ self.ButtonsBox.pack_end( self.ApplyButton )
+
+ self.ButtonsBox.show_all()
+
+ self.Table.attach(self.ButtonsBox, 1, 2, 2, 3, 'fill', False)
+ self.Table.show()
+ self.add( self.Table )
+ self.show()
+
+ def mainGuiTab( self ):
+ """
+ The mainGui Preff Tab.
+
+ Arguments:
+ - self: The main object pointer.
+ """
+
+ Frame = gtk.Frame()
+
+ mainGuiBox = gtk.VBox( spacing = 6 )
+
+ mWindowActive = gtk.CheckButton( _("Show main window") )
+ mWindowActive.set_active( self.cfg.getboolean( "gui", "showMainGui" ) )
+ mWindowActive.connect( "toggled", self._checkToggled, "gui", "showMainGui" )
+
+ mainGuiBox.pack_start( mWindowActive, False, False )
+
+ mainGuiBox.show_all()
+
+ Frame.add( mainGuiBox )
+ Frame.show()
+
+ self.NoteBook.insert_page(Frame, gtk.Label( _("General") ) )
+
+ def camTab( self ):
+ """
+ The cam module Preff Tab.
+
+ Arguments:
+ - self: The main object pointer.
+ """
+
+ Frame = gtk.Frame()
+
+ camBox = gtk.VBox( spacing = 6 )
+
+ cAmActive = gtk.CheckButton( _("Activate Camera module") )
+ cAmActive.set_active( self.cfg.getboolean( "main", "startCam" ) )
+ cAmActive.connect( "toggled", self._checkToggled, "main", "startCam" )
+
+ camBox.pack_start( cAmActive, False, False )
+
+ flipImage = gtk.CheckButton( _("Flip Image") )
+ flipImage.set_active( self.cfg.getboolean( "cam", "flipImage" ) )
+ flipImage.connect( "toggled", self._checkToggled, "cam", "flipImage" )
+
+ camBox.pack_start( flipImage, False, False )
+
+ mapperActive = gtk.CheckButton( _("Show Point Mapper") )
+ mapperActive.set_active( self.cfg.getboolean( "gui", "showPointMapper" ) )
+ mapperActive.connect( "toggled", self._checkToggled, "gui", "showPointMapper" )
+
+ camBox.pack_start( mapperActive, False, False )
+
+ showCapture = gtk.CheckButton( _("Show Capture") )
+ showCapture.set_active( self.cfg.getboolean( "gui", "showCapture" ) )
+ showCapture.connect( "toggled", self._checkToggled, "gui", "showCapture" )
+
+ camBox.pack_start( showCapture, False, False )
+
+ inputDevIndex = self.addSpin( _("Input Video Device Index: "), "inputDevIndex", self.cfg.getint( "cam", "inputDevIndex" ), "cam", "inputDevIndex", 0)
+ camBox.pack_start( inputDevIndex, False, False )
+
+ camBox.show_all()
+
+ Frame.add( camBox )
+ Frame.show()
+
+ self.NoteBook.insert_page(Frame, gtk.Label( _("Camera") ) )
+
+ def mouseTab( self ):
+ """
+ The cam module Preff Tab.
+
+ Arguments:
+ - self: The main object pointer.
+ """
+
+ Frame = gtk.Frame()
+
+ camBox = gtk.VBox( spacing = 6 )
+
+ reqMov = self.addSpin( _("Step Speed: "), "stepSpeed", self.cfg.getint( "mouse", "stepSpeed" ), "mouse", "stepSpeed" )
+ camBox.pack_start( reqMov, False, False )
+
+ defClickF = gtk.Frame( _( "Default Click:" ) )
+
+ defClicks = { "b1c" : _("Left Click"),
+ "b1d" : _("Double Click"),
+ "b1p" : _("Drag/Drop Click"),
+ "b3c" : _("Right Click")}
+
+ defClicksInv = dict((v,k) for k,v in defClicks.iteritems())
+
+ defClick = gtk.combo_box_new_text()
+ defClick.append_text(defClicks[self.cfg.get( "mouse", "defClick" )])
+
+ defClicklBl = gtk.Label(self.cfg.get( "mouse", "defClick" ))
+ self.preffWidgets['defClick'] = defClicklBl
+
+ for mode in defClicks:
+ if mode == self.cfg.get( "mouse", "defClick" ):
+ continue
+ defClick.append_text( defClicks[mode] )
+
+ defClick.connect('changed', self._comboChanged, "mouse", "defClick", defClicksInv)
+ defClick.set_active(0)
+
+ defClickF.add( defClick)
+ camBox.pack_start( defClickF, False, False )
+
+
+ mouseModF = gtk.Frame( _( "Select Mouse Mode:" ) )
+
+ mouseModes = env.mouseModes
+
+ mouseModesInv = dict((v,k) for k,v in mouseModes.iteritems())
+
+ mouseMod = gtk.combo_box_new_text()
+ mouseMod.append_text(mouseModes[self.cfg.get( "cam", "mouseMode" )])
+ mouseModlBl = gtk.Label(self.cfg.get( "cam", "mouseMode" ))
+ self.preffWidgets['mouseMode'] = mouseModlBl
+
+ for mode in mouseModes:
+ if mode == self.cfg.get( "cam", "mouseMode" ):
+ continue
+ mouseMod.append_text( mouseModes[mode] )
+
+ mouseMod.connect('changed', self._comboChanged, "cam", "mouseMode", mouseModesInv)
+ mouseMod.set_active(0)
+
+ mouseModF.add( mouseMod)
+ camBox.pack_start( mouseModF, False, False )
+
+ camBox.show_all()
+
+ Frame.add( camBox )
+ Frame.show()
+
+ self.NoteBook.insert_page(Frame, gtk.Label( _("Mouse") ) )
+
+ def debugTab( self ):
+ """
+ The debuging Preff Tab.
+
+ Arguments:
+ - self: The main object pointer.
+ """
+
+
+ Frame = gtk.Frame()
+
+ debugBox = gtk.VBox( spacing = 6 )
+
+ levelHbox = gtk.HBox( spacing = 4 )
+
+ levellabel = gtk.Label( _("Debugging Level:") )
+ levellabel.set_alignment( 0.0, 0.5 )
+ levellabel.show()
+ levelHbox.pack_start( levellabel, False, False )
+
+ adj = gtk.Adjustment( self.cfg.getint( "main", "debugLevel" ), 10, 50, 10, 1, 0)
+ levelSpin = gtk.SpinButton( adj, 0.0, 0 )
+ levelSpin.set_wrap( True )
+ levelHbox.pack_start( levelSpin, False, False )
+ levelSpin.connect( "value-changed", self._spinChanged, "main", "debugLevel" )
+
+ debugBox.pack_start( levelHbox, False, False )
+
+ debugBox.show_all()
+
+ Frame.add( debugBox )
+ Frame.show()
+
+ self.NoteBook.insert_page(Frame, gtk.Label( _("Debug") ) )
+
+
+ def acceptButtonClick( self, *args ):
+ """
+ Acept button callback. This will apply the settings and close the
+ preferences GUI.
+
+ Arguments:
+ - self: The main object pointer.
+ - *args: The button event arguments
+ """
+
+ self.cfg.write( open( env.configPath + "userSettings.cfg", "w" ) )
+ self.destroy()
+
+
+ def _checkToggled( self, widget, section, option ):
+ """
+0 Sets the new value in the settings object for the toggled checkbox
+
+ Arguments:
+ - self: The main object pointer.
+ - widget: The checkbox.
+ - section: The section of the settings object.
+ - option: The option in the section.
+ """
+ self.cfg.set( section, option, str(widget.get_active()))
+
+ def _spinChanged( self, widget, section, option ):
+ """
+ Sets the new value in the settings object for the toggled checkbox
+
+ Arguments:
+ - self: The main object pointer.
+ - widget: The checkbox.
+ - section: The section of the settings object.
+ - option: The option in the section.
+ """
+ self.cfg.set( section, option, str(widget.get_value_as_int()))
+
+
+ def applyButtonClick( self, *args):
+ """
+ Apply button callback. This will apply the settings.
+
+ Arguments:
+ - self: The main object pointer.
+ - *args: The button event arguments
+ """
+ self.cfg.write( open( env.configPath + 'userSettings.cfg', "w" ) )
+
+ def _comboChanged( self, widget, section, option, modes ):
+ """
+ On combo change. This function is the callback for the on_change
+ event.
+
+ This helps to keep the combobox settings variable updated with the
+ selected option.
+
+ Arguments:
+ - self: The main object pointer.
+ - widget: The widget pointer.
+ - section: The section of the settings object.
+ - option: The option in the section.
+ - modes: The new value.
+ """
+
+ model = widget.get_model()
+ index = widget.get_active()
+ self.cfg.set( section, option, modes[model[index][0]] )
+
+ def addSpin( self, label, var, startValue, section, option, min = 1, max = 15):
+ """
+ Creates a new spin button inside a HBox and return it.
+
+ Arguments:
+ - self: The main object pointer.
+ - label: The spin button label.
+ - var: The prefferences dict variable.
+ - startValue: The start value.
+ """
+
+ spinHbox = gtk.HBox( spacing = 4 )
+
+ spinLbl = gtk.Label( label )
+ spinLbl.set_alignment( 0.0, 0.5 )
+ spinLbl.show()
+ spinHbox.pack_start( spinLbl, False, False )
+
+ adj = gtk.Adjustment( startValue, min, max, 1, 1, 0)
+ spinButton = gtk.SpinButton( adj, 0.0, 0 )
+ spinButton.set_wrap( True )
+ spinButton.connect( "value-changed", self._spinChanged, section, option )
+ spinHbox.pack_start( spinButton, False, False )
+
+ spinLbl.set_mnemonic_widget( spinButton )
+
+ return spinHbox
+
+ def close( self, *args ):
+ """
+ Closes the prefferences GUI without saving the changes.
+
+ Arguments:
+ - self: The main object pointer.
+ - *args: The button event arguments
+ """
+ self.destroy()
+
+
+def showPreffGui(controller):
+ """
+ Starts the preffGui.
+
+ Arguments:
+ - mouseTrap: The mouseTrap object pointer.
+ """
+
+ GUI = preffGui(controller)
+ GUI._SetWindowsIcon()
+ GUI._buildInterface()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]