From 653f51da152f93c198f1a8744beded8a64d72d5b Mon Sep 17 00:00:00 2001 From: gryf Date: Sat, 23 Jun 2007 17:07:59 +0000 Subject: [PATCH] * Upgraded pygtkmvc to version 1.0.1. --- mvc/gtkmvc/__init__.py | 2 +- mvc/gtkmvc/model.py | 6 ++++-- mvc/gtkmvc/model_mt.py | 14 +++++++++----- mvc/gtkmvc/view.py | 12 ++++++++++++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/mvc/gtkmvc/__init__.py b/mvc/gtkmvc/__init__.py index 3e4e252..f7a16fd 100644 --- a/mvc/gtkmvc/__init__.py +++ b/mvc/gtkmvc/__init__.py @@ -23,7 +23,7 @@ __all__ = ["model", "view", "controller", "observable", "observer"] -__version = (1,0,0) +__version = (1,0,1) from model import Model, TreeStoreModel, ListStoreModel, TextBufferModel from model_mt import ModelMT diff --git a/mvc/gtkmvc/model.py b/mvc/gtkmvc/model.py index 54434bd..c2981c2 100644 --- a/mvc/gtkmvc/model.py +++ b/mvc/gtkmvc/model.py @@ -117,8 +117,10 @@ class Model (object): def _reset_property_notification(self, prop_name): - """Called when it has done an assignment that changes the type - of a property, so it must be unregistered and registered again""" + """Called when it has be done an assignment that changes the + type of a property or the instance of the property has been + changed to a different instance. In this case it must be + unregistered and registered again""" self.register_property(prop_name) diff --git a/mvc/gtkmvc/model_mt.py b/mvc/gtkmvc/model_mt.py index 07ac6ca..1ce8421 100644 --- a/mvc/gtkmvc/model_mt.py +++ b/mvc/gtkmvc/model_mt.py @@ -37,11 +37,15 @@ class ModelMT (Model): changed by threads different than gtk main thread. Notification is performed by exploiting the gtk idle loop only if needed, otherwise the standard notification system (direct method call) is - used.""" + used. In this model, the observer is expected to run in the gtk + main loop thread.""" + __metaclass__ = support.metaclasses.ObservablePropertyMetaMT + def __init__(self): Model.__init__(self) self.__observer_threads = {} + self._prop_lock = _threading.Lock() return def register_observer(self, observer): @@ -65,7 +69,7 @@ class ModelMT (Model): if _threading.currentThread() == self.__observer_threads[observer]: # standard call return Model.__notify_observer__(self, observer, method, - args, kwargs) + *args, **kwargs) # multi-threading call gobject.idle_add(self.__idle_callback, observer, method, args, kwargs) @@ -84,7 +88,7 @@ import gtk class TreeStoreModelMT (ModelMT, gtk.TreeStore): """Use this class as base class for your model derived by gtk.TreeStore""" - __metaclass__ = support.metaclasses.ObservablePropertyGObjectMeta + __metaclass__ = support.metaclasses.ObservablePropertyGObjectMetaMT def __init__(self, column_type, *args): ModelMT.__init__(self) @@ -97,7 +101,7 @@ class TreeStoreModelMT (ModelMT, gtk.TreeStore): class ListStoreModelMT (ModelMT, gtk.ListStore): """Use this class as base class for your model derived by gtk.ListStore""" - __metaclass__ = support.metaclasses.ObservablePropertyGObjectMeta + __metaclass__ = support.metaclasses.ObservablePropertyGObjectMetaMT def __init__(self, column_type, *args): ModelMT.__init__(self) @@ -110,7 +114,7 @@ class ListStoreModelMT (ModelMT, gtk.ListStore): class TextBufferModelMT (ModelMT, gtk.TextBuffer): """Use this class as base class for your model derived by gtk.TextBuffer""" - __metaclass__ = support.metaclasses.ObservablePropertyGObjectMeta + __metaclass__ = support.metaclasses.ObservablePropertyGObjectMetaMT def __init__(self, table=None): ModelMT.__init__(self) diff --git a/mvc/gtkmvc/view.py b/mvc/gtkmvc/view.py index 94147b1..7dbd0ce 100644 --- a/mvc/gtkmvc/view.py +++ b/mvc/gtkmvc/view.py @@ -1,6 +1,8 @@ # Author: Roberto Cavada +# Modified by: Guillaume Libersat # # Copyright (c) 2005 by Roberto Cavada +# Copyright (c) 2007 by Guillaume Libersat # # pygtkmvc is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -37,6 +39,9 @@ class View (object): self.manualWidgets = {} self.xmlWidgets = [] + # Sets a callback for custom widgets + gtk.glade.set_custom_handler(self._custom_widget_create) + if (( type(glade_top_widget_name) == types.StringType) or (glade_top_widget_name is None) ): wids = (glade_top_widget_name,) @@ -155,4 +160,11 @@ class View (object): pass return + # Finds the right callback for custom widget creation and call it + def _custom_widget_create(self, glade, function_name, widget_name, + str1, str2, int1, int2): + handler = getattr(self, function_name) + return handler(str1, str2, int1, int2) + + pass # end of class View