gramps/src/widgets/valuetoolitem.py
Zsolt Foldvari 12369d04a8 Few changes in the 'widgets' package.
* introducing __all__ in modules, so __init__ imports only public objects;
  * MultiTypeComboEntry renamed to ValidatedComboEntry and different data
    type support implemented;
  * ShortlistComboEntry introduced;
  * ValueAction and ValueToolItem introduced;
  * ComboToolAction and ComboToolItem are removed, ValueAction and
    ToolComboEntry are implemented instead;


svn: r10763
2008-05-27 19:53:25 +00:00

95 lines
2.7 KiB
Python

#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2008 Zsolt Foldvari
#
# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
"ValueToolItem class."
__all__ = ["ValueToolItem"]
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
import logging
_LOG = logging.getLogger(".widgets.valuetoolitem")
#-------------------------------------------------------------------------
#
# GTK modules
#
#-------------------------------------------------------------------------
import gobject
import gtk
#-------------------------------------------------------------------------
#
# ValueToolItem class
#
#-------------------------------------------------------------------------
class ValueToolItem(gtk.ToolItem):
"""ValueToolItem is an abstract toolbar proxy for ValueAction.
For each kind of widget a separete tool item proxy has to be
subclassed from this ValueToolItem.
"""
__gtype_name__ = "ValueToolItem"
__gsignals__ = {
'changed': (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, #return value
()), # arguments
}
def __init__(self, data_type, args):
gtk.ToolItem.__init__(self)
self._data_type = data_type
self._create_widget(*args)
def _on_widget_changed(self, widget):
self.emit('changed')
def _create_widget(self, args):
"""Create the apropriate widget for the actual proxy."""
raise NotImplementedError
def set_value(self, value):
"""Set new value for the proxied widget.
The method is responsible converting the data type between action and
widget.
"""
raise NotImplementedError
def get_value(self):
"""Get value from the proxied widget.
The method is responsible converting the data type between action and
widget.
"""
raise NotImplementedError