commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r8506 - in trunk: gnue-common/src/logic gnue-forms/src gnue-forms


From: reinhard
Subject: [gnue] r8506 - in trunk: gnue-common/src/logic gnue-forms/src gnue-forms/src/GFObjects
Date: Thu, 22 Jun 2006 04:42:49 -0500 (CDT)

Author: reinhard
Date: 2006-06-22 04:42:48 -0500 (Thu, 22 Jun 2006)
New Revision: 8506

Added:
   trunk/gnue-forms/src/GFObjects/commanders.py
Modified:
   trunk/gnue-common/src/logic/usercode.py
   trunk/gnue-forms/src/GFParser.py
Log:
Moved Menu and Toolbar objects from common to forms. There's just too much
forms specific issues for them to be in common.


Modified: trunk/gnue-common/src/logic/usercode.py
===================================================================
--- trunk/gnue-common/src/logic/usercode.py     2006-06-21 12:49:18 UTC (rev 
8505)
+++ trunk/gnue-common/src/logic/usercode.py     2006-06-22 09:42:48 UTC (rev 
8506)
@@ -1,4 +1,4 @@
-# GNU Enterprise Common Library - Triggers, Actions, Menus, And Toolbars
+# GNU Enterprise Common Library - Actions and Triggers
 #
 # Copyright 2000-2006 Free Software Foundation
 #
@@ -22,8 +22,9 @@
 # $Id$
 
 """
-Classes for all the object trees that handle user code: Triggers, Actions,
-Menus, and Toolbars
+Classes for all the object trees that handle user code: Actions and Triggers.
+
+Triggers are still in the GTrigger module.
 """
 
 from gnue.common.definitions import GObjects, GRootObj
@@ -31,7 +32,7 @@
 
 from gnue.common.logic import language
 
-__all__ = ['GAction', 'GMenu', 'GMenuItem', 'GToolbar', 'GToolButton']
+__all__ = ['GAction']
 
 
 # =============================================================================
@@ -70,7 +71,7 @@
         self._xml_content_as_cdata_ = gConfig('StoreTriggersAsCDATA')
 
         # Find the next GRootObj. This can be, for example, either a <form> or
-        # a <dialog> within a <form>. This most be done because every dialog
+        # a <dialog> within a <form>. This must be done because every dialog
         # has its own global trigger namespace and its own trigger dictionary.
         parent = self.getParent()
         while not isinstance(parent, GRootObj.GRootObj) \
@@ -233,300 +234,6 @@
 
 
 # =============================================================================
-# Abstract parent class for all objects that can fire an action
-# =============================================================================
-
-class GCommander(GObjects.GObj):
-    """
-    Any object that is bound to an action.
-
-    A commander can either be linked to a single action, in which case the
-    action is executed whenever the commander is fired, or it can be linked to
-    an L{action} and an L{action_off}, in which case the commander is a toggle
-    and the action is executed when the toggle is switched on and the
-    action_off is fired when the toggle is switched off.
-
-    For toggles, the action determines icon, label, and description, rather
-    than the action_off.
-    """
-
-    # -------------------------------------------------------------------------
-    # Attributes
-    # -------------------------------------------------------------------------
-
-    name        = None
-    icon        = None
-    label       = None
-    description = None
-    action      = None
-    action_off  = None
-    state       = False
-    enabled     = True
-
-
-    # -------------------------------------------------------------------------
-    # Constructor
-    # -------------------------------------------------------------------------
-
-    def __init__(self, parent, object_type):
-        """
-        Create a GCommander instance.
-        """
-        GObjects.GObj.__init__(self, parent, object_type)
-
-        #: L{GAction} object linked to this commander.
-        self.__action = None
-
-        #: L{GAction} object linked to the "off" operation of the commander.
-        self.__action_off = None
-
-        #: Whether the UI widget is enabled or not. The UIxxx implementations
-        #: read this variable on initialisation; if at some point the UI
-        #: widgets are initialized with parameters, this variable can be made
-        #: private.
-        self._ui_enabled = False
-
-        # Trigger support
-        _triggerProperties = {
-                'state': {
-                    'get': self.__trigger_get_state,
-                    'set': self.__trigger_set_state},
-                'enabled': {
-                    'get': self.__trigger_get_enabled,
-                    'set': self.__trigger_set_enabled}}
-
-        self._inits = [self.__initialize]
-
-
-    # -------------------------------------------------------------------------
-    # Phase 1 initialization
-    # -------------------------------------------------------------------------
-
-    def __initialize(self):
-
-        # Find the next GRootObj
-        parent = self.getParent()
-        while not isinstance(parent, GRootObj.GRootObj) \
-                and parent.getParent() is not None:
-            parent = parent.getParent()
-
-        # Link to action object
-        if self.action is not None:
-            self.__action = parent._actions[self.action]
-
-            # Register ourselves to the action so we get notified of action
-            # enables/disables
-            self.__action.register_commander(self)
-
-            # Copy icon, label and description from action object if not set
-            # here. We can safely do this here because designer doesn't run
-            # this code.
-            if self.icon is None:
-                self.icon = self.__action.icon
-            if self.label is None:
-                self.label = self.__action.label
-            if self.description is None:
-                self.description = self.__action.description
-
-            # Set a variable to determine whether the UI widget should be
-            # enabled or not.
-            if self.action_off is None or not self.state:
-                self._ui_enabled = self.enabled and self.__action.enabled
-
-        # Link to action_off object
-        if self.action_off is not None:
-            self.__action_off = parent._actions[self.action_off]
-
-            # Register ourselves to the action so we get notified of action
-            # enables/disables
-            self.__action_off.register_commander(self)
-
-            # Set a variable to determine whether the UI widget should be
-            # enabled or not.
-            if self.state:
-                self._ui_enabled = self.enabled and self.__action_off.enabled
-
-
-    # -------------------------------------------------------------------------
-    # Trigger functions
-    # -------------------------------------------------------------------------
-
-    def __trigger_get_state(self):
-        return self.state
-
-    # -------------------------------------------------------------------------
-
-    def __trigger_set_state(self, value):
-        if value != self.state:
-            self.fire()
-
-    # -------------------------------------------------------------------------
-
-    def __trigger_get_enabled(self):
-        return self.enabled
-
-    # -------------------------------------------------------------------------
-
-    def __trigger_set_enabled(self, value):
-        self.enabled = value
-        self.update_status()
-
-
-    # -------------------------------------------------------------------------
-    # Update enabled/disabled status
-    # -------------------------------------------------------------------------
-
-    def update_status(self):
-        """
-        Update the enabled/disabled status of the commander.
-
-        The attached action calls this function whenever its enabled/disabled
-        status changes, so the commander can adjust the status of the user
-        interface element.
-        """
-
-        if self.state and self.__action_off is not None:
-            new_ui_enabled = self.enabled and self.__action_off.enabled
-        elif self.__action is not None:
-            new_ui_enabled = self.enabled and self.__action.enabled
-        else:
-            new_ui_enabled = False
-
-        if new_ui_enabled != self._ui_enabled:
-            # FIXME: This relies on the object having an uiWidget assigned.
-            # Either GCommander should be a descendant of GFObj (and thus be
-            # moved to gnue-forms), or the UI buildup should be moved to
-            # common.
-            if new_ui_enabled:
-                self.uiWidget.do_enable()
-            else:
-                self.uiWidget.do_disable()
-            self._ui_enabled = new_ui_enabled
-
-
-    # -------------------------------------------------------------------------
-    # Fire the commander
-    # -------------------------------------------------------------------------
-
-    def fire(self):
-        """
-        Fire the commander.
-
-        If the commander is bound to a single action, this action is executed.
-        
-        If the commander is bound to two actions (i.e. it is a toggle), the
-        state of the toggle is changed, and the corresponding action is
-        executed.
-        """
-
-        if self.state and self.__action_off is not None:
-            self.__action_off.run()
-            self.state = False
-            self.uiWidget.do_switch_off()
-        elif self.__action is not None:
-            self.__action.run()
-            if self.__action_off is not None:
-                self.state = True
-                self.uiWidget.do_switch_on()
-        self.update_status()
-
-
-# =============================================================================
-# <menu>
-# =============================================================================
-
-class GMenu(GObjects.GObj):
-    """
-    A Menu that can either be the menu bar, a context menu, or a submenu.
-    """
-
-    # -------------------------------------------------------------------------
-    # Attributes
-    # -------------------------------------------------------------------------
-
-    name  = None
-    label = None
-
-
-    # -------------------------------------------------------------------------
-    # Constructor
-    # -------------------------------------------------------------------------
-
-    def __init__(self, parent = None, object_type = "GCMenu"):
-        """
-        Create a GMenu instance.
-        """
-        GObjects.GObj.__init__(self, parent, object_type)
-
-
-# =============================================================================
-# <menuitem>
-# =============================================================================
-
-class GMenuItem(GCommander):
-    """
-    An item in a menu that fires an action when selected.
-    """
-
-    # -------------------------------------------------------------------------
-    # Constructor
-    # -------------------------------------------------------------------------
-
-    def __init__(self, parent = None, object_type = "GCMenuItem"):
-        """
-        Create a GMenuItem instance.
-        """
-        GCommander.__init__(self, parent, object_type)
-
-
-# =============================================================================
-# <toolbar>
-# =============================================================================
-
-class GToolbar(GObjects.GObj):
-    """
-    A Toolbar containing L{GToolButton} buttons.
-    """
-
-    # -------------------------------------------------------------------------
-    # Attributes
-    # -------------------------------------------------------------------------
-
-    name  = None
-
-
-    # -------------------------------------------------------------------------
-    # Constructor
-    # -------------------------------------------------------------------------
-
-    def __init__(self, parent = None, object_type = "GCToolbar"):
-        """
-        Create a GToolbar instance.
-        """
-        GObjects.GObj.__init__(self, parent, object_type)
-
-
-# =============================================================================
-# <toolbutton>
-# =============================================================================
-
-class GToolButton(GCommander):
-    """
-    A button in a toolbar that fires an action when selected.
-    """
-
-    # -------------------------------------------------------------------------
-    # Constructor
-    # -------------------------------------------------------------------------
-
-    def __init__(self, parent = None, object_type = "GCToolButton"):
-        """
-        Create a GToolButton instance.
-        """
-        GCommander.__init__(self, parent, object_type)
-
-
-# =============================================================================
 # XML Element dictionary
 # =============================================================================
 
@@ -584,140 +291,6 @@
                         'Description': u_(
                             "Determines whether this action can be run"),
                         'Typecast'   : GTypecast.boolean,
-                        'Default'    : True}}},
-            'menu': {
-                'Description': u_(
-                    "A menu or submenu containing menu items and/or submenus"),
-                'BaseClass'  : GMenu,
-                'ParentTags' : None,
-                'Attributes' : {
-                    'name': {
-                        'Label'      : u_("Name"),
-                        'Description': u_("Name of this element"),
-                        'Typecast'   : GTypecast.name,
-                        'Required'   : True,
-                        'Unique'     : True},
-                    'label': {
-                        'Label'      : u_("Label"),
-                        'Description': u_("Text to use if this is a submenu"),
-                        'Typecast'   : GTypecast.text}}},
-            'menuitem': {
-                'Description': u_(
-                    "A menu item that fires a trigger when selected"),
-                'BaseClass'  : GMenuItem,
-                'ParentTags' : ['menu'],
-                'Attributes' : {
-                    'name': {
-                        'Label'      : u_("Name"),
-                        'Description': u_("Name of this element"),
-                        'Typecast'   : GTypecast.name,
-                        'Required'   : True,
-                        'Unique'     : True},
-                    'icon': {
-                        'Label'      : u_("Icon"),
-                        'Description': u_(
-                            "Icon to display besides this menu item"),
-                        'Typecast'   : GTypecast.name},
-                    'label': {
-                        'Label'      : u_("Label"),
-                        'Description': u_("Text to use for this menu item"),
-                        'Typecast'   : GTypecast.text},
-                    'description': {
-                        'Label'      : u_("Description"),
-                        'Description': u_(
-                            "Text to display in the status bar for this menu "
-                            "item"),
-                        'Typecast'   : GTypecast.text},
-                    'action': {
-                        'Label'      : u_("Action"),
-                        'Description': u_(
-                            "Name of the trigger to run whenever this menu "
-                            "item is selected"),
-                        'Typecast'   : GTypecast.name,
-                        'References' : 'trigger.name'},
-                    'action_off': {
-                        'Label'      : u_("Action Off"),
-                        'Description': u_(
-                            "Name of the trigger to run whenever this menu "
-                            "item is switched to off"),
-                        'Typecast'   : GTypecast.name,
-                        'References' : 'trigger.name'},
-                    'state': {
-                        'Label'      : u_("State"),
-                        'Description': u_(
-                            "Determines whether this menu item will be "
-                            "switched on by default"),
-                        'Typecast'   : GTypecast.boolean,
-                        'Default'    : False},
-                    'enabled': {
-                        'Label'      : u_("Enabled"),
-                        'Description': u_(
-                            "Determines whether this menu item will be "
-                            "enabled by default"),
-                        'Typecast'   : GTypecast.boolean,
-                        'Default'    : True}}},
-            'toolbar': {
-                'Description': u_("A toolbar containing tool buttons"),
-                'BaseClass'  : GToolbar,
-                'ParentTags' : None,
-                'Attributes' : {
-                    'name': {
-                        'Label'      : u_("Name"),
-                        'Description': u_("Name of this element"),
-                        'Typecast'   : GTypecast.name,
-                        'Required'   : True,
-                        'Unique'     : True}}},
-            'toolbutton': {
-                'Description': u_("A button on a toolbar"),
-                'BaseClass'  : GToolButton,
-                'ParentTags' : ['toolbar'],
-                'Attributes' : {
-                    'name': {
-                        'Label'      : u_("Name"),
-                        'Description': u_("Name of this element"),
-                        'Typecast'   : GTypecast.name,
-                        'Required'   : True,
-                        'Unique'     : True},
-                    'icon': {
-                        'Label'      : u_("Icon"),
-                        'Description': u_("Icon to display on the button"),
-                        'Typecast'   : GTypecast.name},
-                    'label': {
-                        'Label'      : u_("Label"),
-                        'Description': u_("Text to display on the button"),
-                        'Typecast'   : GTypecast.text},
-                    'description': {
-                        'Label'      : u_("Description"),
-                        'Description': u_(
-                            "Text to display in a tooltip window"),
-                        'Typecast'   : GTypecast.text},
-                    'action': {
-                        'Label'      : u_("Action"),
-                        'Description': u_(
-                            "Name of the trigger to run whenever this button "
-                            "is clicked"),
-                        'Typecast'   : GTypecast.name,
-                        'References' : 'trigger.name'},
-                    'action_off': {
-                        'Label'      : u_("Action Off"),
-                        'Description': u_(
-                            "Name of the trigger to run whenever this button "
-                            "is switched to off"),
-                        'Typecast'   : GTypecast.name,
-                        'References' : 'trigger.name'},
-                    'state': {
-                        'Label'      : u_("State"),
-                        'Description': u_(
-                            "Determines whether this button will be switched "
-                            "on by default"),
-                        'Typecast'   : GTypecast.boolean,
-                        'Default'    : False},
-                    'enabled': {
-                        'Label'      : u_("Enabled"),
-                        'Description': u_(
-                            "Determines whether this button will be enabled "
-                            "by default"),
-                        'Typecast'   : GTypecast.boolean,
                         'Default'    : True}}}}
 
     for alteration in updates.keys():

Added: trunk/gnue-forms/src/GFObjects/commanders.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/commanders.py        2006-06-21 12:49:18 UTC 
(rev 8505)
+++ trunk/gnue-forms/src/GFObjects/commanders.py        2006-06-22 09:42:48 UTC 
(rev 8506)
@@ -0,0 +1,315 @@
+# GNU Enterprise Forms - Menus and Toolbars
+#
+# Copyright 2000-2006 Free Software Foundation
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise 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, or (at your option) any later version.
+#
+# GNU Enterprise 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 program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+"""
+Classes for all the visible objects that call actions: Menus and Toolbars
+"""
+
+from gnue.forms.GFObjects.GFObj import GFObj
+
+__all__ = ['GFMenu', 'GFMenuItem', 'GFToolbar', 'GFToolButton']
+
+
+# =============================================================================
+# Abstract parent class for all objects that can fire an action
+# =============================================================================
+
+class GFCommander(GFObj):
+    """
+    Any object that is bound to an action.
+
+    A commander can either be linked to a single action, in which case the
+    action is executed whenever the commander is fired, or it can be linked to
+    an L{action} and an L{action_off}, in which case the commander is a toggle
+    and the action is executed when the toggle is switched on and the
+    action_off is fired when the toggle is switched off.
+
+    For toggles, the action determines icon, label, and description, rather
+    than the action_off.
+    """
+
+    # -------------------------------------------------------------------------
+    # Attributes
+    # -------------------------------------------------------------------------
+
+    name        = None
+    icon        = None
+    label       = None
+    description = None
+    action      = None
+    action_off  = None
+    state       = False
+    enabled     = True
+
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent, object_type):
+        """
+        Create a GFCommander instance.
+        """
+        GFObj.__init__(self, parent, object_type)
+
+        #: L{common.logic.usercode.GAction} object linked to this commander.
+        self.__action = None
+
+        #: L{common.logic.usercode.GAction} object linked to the "off"
+        #: operation of the commander.
+        self.__action_off = None
+
+        #: Whether the UI widget is enabled or not. The UIxxx implementations
+        #: read this variable on initialisation; if at some point the UI
+        #: widgets are initialized with parameters, this variable can be made
+        #: private.
+        self._ui_enabled = False
+
+        # Trigger support
+        _triggerProperties = {
+                'state': {
+                    'get': self.__trigger_get_state,
+                    'set': self.__trigger_set_state},
+                'enabled': {
+                    'get': self.__trigger_get_enabled,
+                    'set': self.__trigger_set_enabled}}
+
+
+    # -------------------------------------------------------------------------
+    # Phase 1 initialization
+    # -------------------------------------------------------------------------
+
+    def _phase_1_init_(self):
+
+        GFObj._phase_1_init_(self)
+
+        # Link to action object
+        if self.action is not None:
+            self.__action = self._form._actions[self.action]
+
+            # Register ourselves to the action so we get notified of action
+            # enables/disables
+            self.__action.register_commander(self)
+
+            # Copy icon, label and description from action object if not set
+            # here. We can safely do this here because designer doesn't run
+            # this code.
+            if self.icon is None:
+                self.icon = self.__action.icon
+            if self.label is None:
+                self.label = self.__action.label
+            if self.description is None:
+                self.description = self.__action.description
+
+            # Set a variable to determine whether the UI widget should be
+            # enabled or not.
+            if self.action_off is None or not self.state:
+                self._ui_enabled = self.enabled and self.__action.enabled
+
+        # Link to action_off object
+        if self.action_off is not None:
+            self.__action_off = self._form._actions[self.action_off]
+
+            # Register ourselves to the action so we get notified of action
+            # enables/disables
+            self.__action_off.register_commander(self)
+
+            # Set a variable to determine whether the UI widget should be
+            # enabled or not.
+            if self.state:
+                self._ui_enabled = self.enabled and self.__action_off.enabled
+
+
+    # -------------------------------------------------------------------------
+    # Trigger functions
+    # -------------------------------------------------------------------------
+
+    def __trigger_get_state(self):
+        return self.state
+
+    # -------------------------------------------------------------------------
+
+    def __trigger_set_state(self, value):
+        if value != self.state:
+            self.fire()
+
+    # -------------------------------------------------------------------------
+
+    def __trigger_get_enabled(self):
+        return self.enabled
+
+    # -------------------------------------------------------------------------
+
+    def __trigger_set_enabled(self, value):
+        self.enabled = value
+        self.update_status()
+
+
+    # -------------------------------------------------------------------------
+    # Update enabled/disabled status
+    # -------------------------------------------------------------------------
+
+    def update_status(self):
+        """
+        Update the enabled/disabled status of the commander.
+
+        The attached action calls this function whenever its enabled/disabled
+        status changes, so the commander can adjust the status of the user
+        interface element.
+        """
+
+        if self.state and self.__action_off is not None:
+            new_ui_enabled = self.enabled and self.__action_off.enabled
+        elif self.__action is not None:
+            new_ui_enabled = self.enabled and self.__action.enabled
+        else:
+            new_ui_enabled = False
+
+        if new_ui_enabled != self._ui_enabled:
+            if new_ui_enabled:
+                self.uiWidget.do_enable()
+            else:
+                self.uiWidget.do_disable()
+            self._ui_enabled = new_ui_enabled
+
+
+    # -------------------------------------------------------------------------
+    # Fire the commander
+    # -------------------------------------------------------------------------
+
+    def fire(self):
+        """
+        Fire the commander.
+
+        If the commander is bound to a single action, this action is executed.
+        
+        If the commander is bound to two actions (i.e. it is a toggle), the
+        state of the toggle is changed, and the corresponding action is
+        executed.
+        """
+
+        if self.state and self.__action_off is not None:
+            self.__action_off.run()
+            self.state = False
+            self.uiWidget.do_switch_off()
+        elif self.__action is not None:
+            self.__action.run()
+            if self.__action_off is not None:
+                self.state = True
+                self.uiWidget.do_switch_on()
+        self.update_status()
+
+
+# =============================================================================
+# <menu>
+# =============================================================================
+
+class GFMenu(GFObj):
+    """
+    A Menu that can either be the menu bar, a context menu, or a submenu.
+    """
+
+    # -------------------------------------------------------------------------
+    # Attributes
+    # -------------------------------------------------------------------------
+
+    name  = None
+    label = None
+
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent = None, object_type = "GCMenu"):
+        """
+        Create a GFMenu instance.
+        """
+        GFObj.__init__(self, parent, object_type)
+
+
+# =============================================================================
+# <menuitem>
+# =============================================================================
+
+class GFMenuItem(GFCommander):
+    """
+    An item in a menu that fires an action when selected.
+    """
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent = None, object_type = "GCMenuItem"):
+        """
+        Create a GFMenuItem instance.
+        """
+        GFCommander.__init__(self, parent, object_type)
+
+
+# =============================================================================
+# <toolbar>
+# =============================================================================
+
+class GFToolbar(GFObj):
+    """
+    A Toolbar containing L{GFToolButton} buttons.
+    """
+
+    # -------------------------------------------------------------------------
+    # Attributes
+    # -------------------------------------------------------------------------
+
+    name  = None
+
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent = None, object_type = "GCToolbar"):
+        """
+        Create a GFToolbar instance.
+        """
+        GFObj.__init__(self, parent, object_type)
+
+
+# =============================================================================
+# <toolbutton>
+# =============================================================================
+
+class GFToolButton(GFCommander):
+    """
+    A button in a toolbar that fires an action when selected.
+    """
+
+    # -------------------------------------------------------------------------
+    # Constructor
+    # -------------------------------------------------------------------------
+
+    def __init__(self, parent = None, object_type = "GCToolButton"):
+        """
+        Create a GFToolButton instance.
+        """
+        GFCommander.__init__(self, parent, object_type)


Property changes on: trunk/gnue-forms/src/GFObjects/commanders.py
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/gnue-forms/src/GFParser.py
===================================================================
--- trunk/gnue-forms/src/GFParser.py    2006-06-21 12:49:18 UTC (rev 8505)
+++ trunk/gnue-forms/src/GFParser.py    2006-06-22 09:42:48 UTC (rev 8506)
@@ -76,6 +76,7 @@
 
   if xmlElements == None:
     from gnue.forms import GFObjects, GFLibrary, GFForm
+    from gnue.forms.GFObjects import commanders
 
     xmlElements = {
       'form': {
@@ -113,6 +114,141 @@
                         'and visuals that the user interface will show '
                         'to the user.' },
 
+      'menu': {
+                'Description': u_(
+                    "A menu or submenu containing menu items and/or submenus"),
+                'BaseClass'  : commanders.GFMenu,
+                'ParentTags' : ['form', 'menu'],
+                'Attributes' : {
+                    'name': {
+                        'Label'      : u_("Name"),
+                        'Description': u_("Name of this element"),
+                        'Typecast'   : GTypecast.name,
+                        'Required'   : True,
+                        'Unique'     : True},
+                    'label': {
+                        'Label'      : u_("Label"),
+                        'Description': u_("Text to use if this is a submenu"),
+                        'Typecast'   : GTypecast.text}}},
+      'menuitem': {
+                'Description': u_(
+                    "A menu item that fires a trigger when selected"),
+                'BaseClass'  : commanders.GFMenuItem,
+                'ParentTags' : ['menu'],
+                'Attributes' : {
+                    'name': {
+                        'Label'      : u_("Name"),
+                        'Description': u_("Name of this element"),
+                        'Typecast'   : GTypecast.name,
+                        'Required'   : True,
+                        'Unique'     : True},
+                    'icon': {
+                        'Label'      : u_("Icon"),
+                        'Description': u_(
+                            "Icon to display besides this menu item"),
+                        'Typecast'   : GTypecast.name},
+                    'label': {
+                        'Label'      : u_("Label"),
+                        'Description': u_("Text to use for this menu item"),
+                        'Typecast'   : GTypecast.text},
+                    'description': {
+                        'Label'      : u_("Description"),
+                        'Description': u_(
+                            "Text to display in the status bar for this menu "
+                            "item"),
+                        'Typecast'   : GTypecast.text},
+                    'action': {
+                        'Label'      : u_("Action"),
+                        'Description': u_(
+                            "Name of the trigger to run whenever this menu "
+                            "item is selected"),
+                        'Typecast'   : GTypecast.name,
+                        'References' : 'trigger.name'},
+                    'action_off': {
+                        'Label'      : u_("Action Off"),
+                        'Description': u_(
+                            "Name of the trigger to run whenever this menu "
+                            "item is switched to off"),
+                        'Typecast'   : GTypecast.name,
+                        'References' : 'trigger.name'},
+                    'state': {
+                        'Label'      : u_("State"),
+                        'Description': u_(
+                            "Determines whether this menu item will be "
+                            "switched on by default"),
+                        'Typecast'   : GTypecast.boolean,
+                        'Default'    : False},
+                    'enabled': {
+                        'Label'      : u_("Enabled"),
+                        'Description': u_(
+                            "Determines whether this menu item will be "
+                            "enabled by default"),
+                        'Typecast'   : GTypecast.boolean,
+                        'Default'    : True}}},
+      'toolbar': {
+                'Description': u_("A toolbar containing tool buttons"),
+                'BaseClass'  : commanders.GFToolbar,
+                'ParentTags' : ['form'],
+                'Attributes' : {
+                    'name': {
+                        'Label'      : u_("Name"),
+                        'Description': u_("Name of this element"),
+                        'Typecast'   : GTypecast.name,
+                        'Required'   : True,
+                        'Unique'     : True}}},
+      'toolbutton': {
+                'Description': u_("A button on a toolbar"),
+                'BaseClass'  : commanders.GFToolButton,
+                'ParentTags' : ['toolbar'],
+                'Attributes' : {
+                    'name': {
+                        'Label'      : u_("Name"),
+                        'Description': u_("Name of this element"),
+                        'Typecast'   : GTypecast.name,
+                        'Required'   : True,
+                        'Unique'     : True},
+                    'icon': {
+                        'Label'      : u_("Icon"),
+                        'Description': u_("Icon to display on the button"),
+                        'Typecast'   : GTypecast.name},
+                    'label': {
+                        'Label'      : u_("Label"),
+                        'Description': u_("Text to display on the button"),
+                        'Typecast'   : GTypecast.text},
+                    'description': {
+                        'Label'      : u_("Description"),
+                        'Description': u_(
+                            "Text to display in a tooltip window"),
+                        'Typecast'   : GTypecast.text},
+                    'action': {
+                        'Label'      : u_("Action"),
+                        'Description': u_(
+                            "Name of the trigger to run whenever this button "
+                            "is clicked"),
+                        'Typecast'   : GTypecast.name,
+                        'References' : 'trigger.name'},
+                    'action_off': {
+                        'Label'      : u_("Action Off"),
+                        'Description': u_(
+                            "Name of the trigger to run whenever this button "
+                            "is switched to off"),
+                        'Typecast'   : GTypecast.name,
+                        'References' : 'trigger.name'},
+                    'state': {
+                        'Label'      : u_("State"),
+                        'Description': u_(
+                            "Determines whether this button will be switched "
+                            "on by default"),
+                        'Typecast'   : GTypecast.boolean,
+                        'Default'    : False},
+                    'enabled': {
+                        'Label'      : u_("Enabled"),
+                        'Description': u_(
+                            "Determines whether this button will be enabled "
+                            "by default"),
+                        'Typecast'   : GTypecast.boolean,
+                        'Default'    : True}}},
+
       'logic': {
          'BaseClass': GFObjects.GFLogic,
          'Required': True,
@@ -1046,9 +1182,8 @@
     # Add usercode elements
     xmlElements.update(usercode.get_xml_elements(
         updates = {
-            'action': {'ParentTags': ('form')},
-            'menu': {'ParentTags': ('form', 'menu')},
-            'toolbar': {'ParentTags': ('form')}}))
+            'action': {'ParentTags': ('form')}
+                }))
     
     #
     # Add trigger elements
@@ -1056,7 +1191,7 @@
     xmlElements.update(
       GTrigger.getXMLelements(
         updates={'trigger':{
-                   'ParentTags': ('form')},
+                   'ParentTags': ('form')}
                 }))
 
     xmlElements = GParser.buildImportableTags ('form', xmlElements)
@@ -1092,5 +1227,3 @@
     self.xmlNamespaceAttributesAsPrefixes = True
 
     self.xmlElements = getXMLelements()
-
-





reply via email to

[Prev in Thread] Current Thread [Next in Thread]