1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2025-12-17 19:40:21 +01:00

* Upgraded pygtkmvc to version 1.0.1.

This commit is contained in:
2007-06-23 17:07:59 +00:00
parent 1e70c4f69f
commit 653f51da15
4 changed files with 26 additions and 8 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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)

View File

@@ -1,6 +1,8 @@
# Author: Roberto Cavada <cavada@irst.itc.it>
# Modified by: Guillaume Libersat <glibersat AT linux62.org>
#
# 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