1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2026-03-27 22:43:34 +01:00

* Upgrade pygtkmvc to ne version 1.2.1.

This commit is contained in:
2007-10-24 17:29:31 +00:00
parent 15cbe23161
commit 4dcfaa51e7
18 changed files with 1180 additions and 118 deletions

View File

@@ -0,0 +1,55 @@
__all__ = ("search_adapter_info",
"SIGNAL", "GETTER", "SETTER", "WIDTYPE")
import types
import gtk
# ----------------------------------------------------------------------
# This list defines a default behavior for widgets.
# If no particular behaviour has been specified, adapters will
# use information contained into this list to create themself.
# This list is ordered: the earlier a widget occurs, the better it
# will be matched by the search function.
# ----------------------------------------------------------------------
__def_adapter = [ # class, default signal, getter, setter, value type
(gtk.Entry, "changed", gtk.Entry.get_text, gtk.Entry.set_text, types.StringType),
(gtk.Label, None, gtk.Label.get_text, gtk.Label.set_text, types.StringType),
(gtk.Arrow, None, lambda a: a.get_property("arrow-type"),
lambda a,v: a.set(v,a.get_property("shadow-type")), gtk.ArrowType),
(gtk.ToggleButton, "toggled", gtk.ToggleButton.get_active, gtk.ToggleButton.set_active, types.BooleanType),
(gtk.CheckMenuItem, "toggled", gtk.CheckMenuItem.get_active, gtk.CheckMenuItem.set_active, types.BooleanType),
(gtk.Expander, "activate", lambda w: not w.get_expanded(), gtk.Expander.set_expanded, types.BooleanType),
(gtk.ColorButton, "color-set", gtk.ColorButton.get_color, gtk.ColorButton.set_color, gtk.gdk.Color),
(gtk.ColorSelection, "color-changed", gtk.ColorSelection.get_current_color, gtk.ColorSelection.set_current_color, gtk.gdk.Color),
]
if gtk.pygtk_version >= (2,10,0):
# conditionally added support
__def_adapter.append(
(gtk.LinkButton, "clicked", gtk.LinkButton.get_uri, gtk.LinkButton.set_uri, types.StringType))
pass
# constants to access values:
SIGNAL =1
GETTER =2
SETTER =3
WIDTYPE =4
# ----------------------------------------------------------------------
# To optimize the search
__memoize__ = {}
def search_adapter_info(wid):
"""Given a widget returns the default tuple found in __def_adapter"""
t = type(wid)
if __memoize__.has_key(t): return __memoize__[t]
for w in __def_adapter:
if isinstance(wid, w[0]):
__memoize__[t] = w
return w
pass
raise TypeError("Adapter type " + str(t) + " not found among supported adapters")