mousetrap r30 - in branches/ng/src/mousetrap: . lib ui



Author: flaper
Date: Fri Apr  3 16:00:06 2009
New Revision: 30
URL: http://svn.gnome.org/viewvc/mousetrap?rev=30&view=rev

Log:
Settings Dialog Update

Modified:
   branches/ng/src/mousetrap/lib/settings.py
   branches/ng/src/mousetrap/mousetrap.py
   branches/ng/src/mousetrap/ui/main.py
   branches/ng/src/mousetrap/ui/settings_gui.py

Modified: branches/ng/src/mousetrap/lib/settings.py
==============================================================================
--- branches/ng/src/mousetrap/lib/settings.py	(original)
+++ branches/ng/src/mousetrap/lib/settings.py	Fri Apr  3 16:00:06 2009
@@ -1,3 +1,33 @@
+# -*- coding: utf-8 -*-
+
+# mouseTrap
+#
+# Copyright 2009 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/>.
+
+
+"""MouseTrap's settings handler."""
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2008 Flavio Percoco Premoli"
+__license__   = "GPLv2"
+
 import ConfigParser
 import environment as env
 

Modified: branches/ng/src/mousetrap/mousetrap.py
==============================================================================
--- branches/ng/src/mousetrap/mousetrap.py	(original)
+++ branches/ng/src/mousetrap/mousetrap.py	Fri Apr  3 16:00:06 2009
@@ -68,10 +68,14 @@
         if not self.dbusd.start():
             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()
+        if self.cfg.getboolean("main", "startCam"):
+            # Lets start the module
+            idm = pocv.get_idm(self.cfg.get("main", "algorithm"))
+            self.idm = idm.Module(self)
+            self.idm.set_capture()
+
+            gobject.timeout_add(150, a.update_frame)
+            gobject.timeout_add(50, a.update_pointers)
 
         # Lets build the interface
         self.itf = MainGui(self)
@@ -99,7 +103,5 @@
 loop = gobject.MainLoop()
 a = Controller()
 a.start()
-#gobject.timeout_add(150, a.update_frame)
-#gobject.timeout_add(50, a.update_pointers)
 gobject.threads_init()
 loop.run()

Modified: branches/ng/src/mousetrap/ui/main.py
==============================================================================
--- branches/ng/src/mousetrap/ui/main.py	(original)
+++ branches/ng/src/mousetrap/ui/main.py	Fri Apr  3 16:00:06 2009
@@ -94,20 +94,17 @@
         self.buttonsBox = gtk.HButtonBox()
         #self.buttonsBox = gtk.HBox(False,0)
 
-        self.prefButton = gtk.Button()
-        self.prefButton.add(self._newStockImageButton("_Preferences", gtk.STOCK_PREFERENCES))
+        self.prefButton = gtk.Button(stock=gtk.STOCK_PREFERENCES)
         self.prefButton.connect("clicked", self._show_settings_gui)
-        self.buttonsBox.pack_start( self.prefButton )
+        self.buttonsBox.pack_start( self.prefButton, True, True )
 
-        self.closeButton = gtk.Button()
-        self.closeButton.add(self._newStockImageButton("_Exit", gtk.STOCK_QUIT))
+        self.closeButton = gtk.Button(stock=gtk.STOCK_QUIT)
         self.closeButton.connect("clicked", self.close)
-        self.buttonsBox.pack_start( self.closeButton )
+        self.buttonsBox.pack_start( self.closeButton, True, True )
 
-        self.helpButton = gtk.Button()
-        self.helpButton.add(self._newStockImageButton("_Help", gtk.STOCK_HELP))
+        self.helpButton = gtk.Button(stock=gtk.STOCK_HELP)
         #self.helpButton.connect("clicked", self._loadHelp)
-        self.buttonsBox.pack_start( self.helpButton )
+        self.buttonsBox.pack_start( self.helpButton, True, True )
 
         self.vBox.pack_start( self.buttonsBox, False, False )
 

Modified: branches/ng/src/mousetrap/ui/settings_gui.py
==============================================================================
--- branches/ng/src/mousetrap/ui/settings_gui.py	(original)
+++ branches/ng/src/mousetrap/ui/settings_gui.py	Fri Apr  3 16:00:06 2009
@@ -2,7 +2,7 @@
 
 # mouseTrap
 #
-# Copyright 2008 Flavio Percoco Premoli
+# Copyright 2009 Flavio Percoco Premoli
 #
 # This file is part of mouseTrap.
 #
@@ -19,19 +19,20 @@
 # 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."""
+
+"""Settings Handler Interface."""
 
 __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
+from ocvfw import pocv
 
 class preffGui( gtk.Window ):
     """
@@ -96,10 +97,11 @@
         self.Table.attach( self.NoteBook, 0, 6, 0, 1 )
         self.NoteBook.show()
 
-        self.mainGuiTab()
-        self.camTab()
+        self.main_gui_tab()
+        self.cam_tab()
+        self.algorithm_tab()
         #self.mouseTab()
-        self.debugTab()
+        self.debug_tab()
 
         ####################
         # Bottom's buttons #
@@ -125,7 +127,7 @@
         self.add( self.Table )
         self.show()
 
-    def mainGuiTab( self ):
+    def main_gui_tab( self ):
         """
         The mainGui Preff Tab.
 
@@ -150,7 +152,7 @@
 
         self.NoteBook.insert_page(Frame, gtk.Label( _("General") ) )
 
-    def camTab( self ):
+    def cam_tab( self ):
         """
         The cam module Preff Tab.
 
@@ -196,6 +198,63 @@
 
         self.NoteBook.insert_page(Frame, gtk.Label( _("Camera") ) )
 
+    def algorithm_tab( self ):
+        """
+        The cam module Preff Tab.
+
+        Arguments:
+        - self: The main object pointer.
+        """
+
+        Frame = gtk.Frame()
+
+        algo_box = gtk.VBox( spacing = 6 )
+
+        liststore = gtk.ListStore(bool, str, bool)
+
+        conf_button = gtk.Button(stock=gtk.STOCK_PREFERENCES)
+        conf_button.set_sensitive(False)
+
+        tree_view = gtk.TreeView(liststore)
+        tree_view.connect("cursor-changed", self._tree_view_click, conf_button)
+
+        toggle_cell = gtk.CellRendererToggle()
+        toggle_cell.set_radio(True)
+        toggle_cell.connect( 'toggled', self._toggle_cell_changed, liststore)
+        toggle_cell.set_property('activatable', True)
+        #toggle_cell.set_property('background-set' , True)
+
+        text_cell = gtk.CellRendererText()
+
+        toggle_column = gtk.TreeViewColumn(_('Active Algorithms'), toggle_cell)
+        text_column = gtk.TreeViewColumn(_('Installed Algorithms'))
+
+        for alg in pocv.get_idms_list():
+            alg_inf = pocv.get_idm_inf(alg)
+            liststore.append([False, "%s: %s" % (alg_inf["name"], alg_inf["dsc"]), alg_inf["stgs"]])
+
+        tree_view.append_column(toggle_column)
+        tree_view.append_column(text_column)
+
+        text_column.pack_start(text_cell, True)
+
+        toggle_column.add_attribute( toggle_cell, "active", 0 )
+        toggle_column.set_max_width(30)
+        #toggle_column.set_attributes( toggle_cell, background=2 )
+        text_column.set_attributes(text_cell, text=1)
+
+        algo_box.pack_start(tree_view)
+        algo_box.pack_start(conf_button, False, False)
+
+
+
+        algo_box.show_all()
+
+        Frame.add( algo_box )
+        Frame.show()
+
+        self.NoteBook.insert_page(Frame, gtk.Label( _("Algorithm") ) )
+
     def mouseTab( self ):
         """
         The cam module Preff Tab.
@@ -267,7 +326,7 @@
 
         self.NoteBook.insert_page(Frame, gtk.Label( _("Mouse") ) )
 
-    def debugTab( self ):
+    def debug_tab( self ):
         """
         The debuging Preff Tab.
 
@@ -317,9 +376,42 @@
         self.destroy()
 
 
+    def _tree_view_click(self, widget, conf_button):
+        """
+        Row Selection Event.
+
+        Enables/Disables the conf_button whether the
+        selected algorithm can be configured or not.
+
+        Arguments:
+        - widget: The gtk Widget
+        - conf_button: The configuration button object.
+        """
+
+        ts = widget.get_selection()
+        model, it = ts.get_selected()
+        path = model.get_path(it)[0]
+        conf_button.set_sensitive(model[path][2])
+
+    def _toggle_cell_changed(self, cell, path, model ):
+        """
+        ListStore RadioButton Value Changer.
+        """
+
+        if model[path][0]:
+            return False
+
+        for pth in range(len(model)):
+            pth = str(pth)
+            if pth == path:
+                model[pth][0] = True
+            else:
+                model[pth][0] = False
+
+
     def _checkToggled( self, widget, section, option ):
         """
-0        Sets the new value in the settings object for the toggled checkbox
+        Sets the new value in the settings object for the toggled checkbox
 
         Arguments:
         - self: The main object pointer.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]