commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9356 - in trunk/gnue-forms: defaults src/GFObjects src/uidrivers


From: reinhard
Subject: [gnue] r9356 - in trunk/gnue-forms: defaults src/GFObjects src/uidrivers/gtk2/widgets src/uidrivers/gtk2/widgets/form src/uidrivers/qt3/widgets src/uidrivers/wx26/widgets
Date: Tue, 6 Feb 2007 16:25:46 -0600 (CST)

Author: reinhard
Date: 2007-02-06 16:25:44 -0600 (Tue, 06 Feb 2007)
New Revision: 9356

Added:
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/menu.py
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/menuitem.py
Modified:
   trunk/gnue-forms/defaults/default.gfd
   trunk/gnue-forms/src/GFObjects/commanders.py
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/menu.py
   trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
Log:
More work on gfd defined menus.

issue79 in-progress


Modified: trunk/gnue-forms/defaults/default.gfd
===================================================================
--- trunk/gnue-forms/defaults/default.gfd       2007-02-06 14:37:52 UTC (rev 
9355)
+++ trunk/gnue-forms/defaults/default.gfd       2007-02-06 22:25:44 UTC (rev 
9356)
@@ -150,7 +150,7 @@
         hotkey="F12"/>
       <menuitem name="__sep1__"/>
       <menuitem name="__delete_record__" action="act__delete_record__"
-        action_off="act__undelete_record__" hotkey="F5"/>
+        action_off="act__undelete_record__" icon="" hotkey="F5"/>
     </menu>
     <menu name="__navigation__" label="Navigation">
       <menuitem name="__previous_block__" action="act__previous_block__"

Modified: trunk/gnue-forms/src/GFObjects/commanders.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/commanders.py        2007-02-06 14:37:52 UTC 
(rev 9355)
+++ trunk/gnue-forms/src/GFObjects/commanders.py        2007-02-06 22:25:44 UTC 
(rev 9356)
@@ -254,6 +254,18 @@
         interface element.
         """
 
+        # For toggle commanders, the state can implicitly be changed by
+        # enabling one of the actions and disabling the other one.
+        if self.__action_off is not None and self.__action_off is not None:
+            if self.__action.enabled and not self.__action_off.enabled:
+                if self.state:
+                    self.state = False
+                    self.uiWidget._ui_switch_off_()
+            if self.__action_off.enabled and not self.__action.enabled:
+                if not self.state:
+                    self.state = True
+                    self.uiWidget._ui_switch_on_()
+
         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:

Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py  2007-02-06 
14:37:52 UTC (rev 9355)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py  2007-02-06 
22:25:44 UTC (rev 9356)
@@ -143,8 +143,9 @@
      
     # Add Statusbar, Toolbar and Menubar as requested and/or allowed
     if self._form.style != 'dialog':
-      if not self._form._features ['GUI:MENUBAR:SUPPRESS']:
-        MenuBar (self._uiDriver, self, self._form)
+      if not self._form.findChildNamed('__main__', 'GFMenu'):
+        if not self._form._features ['GUI:MENUBAR:SUPPRESS']:
+          MenuBar (self._uiDriver, self, self._form)
       
       if not self._form._features['GUI:TOOLBAR:SUPPRESS']:
         ToolBar (self._uiDriver, self, self._form)

Added: trunk/gnue-forms/src/uidrivers/gtk2/widgets/menu.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/menu.py 2007-02-06 14:37:52 UTC 
(rev 9355)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/menu.py 2007-02-06 22:25:44 UTC 
(rev 9356)
@@ -0,0 +1,83 @@
+# GNU Enterprise Forms - gtk2 UI Driver - Menu widget
+#
+# Copyright 2001-2007 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$
+
+import gtk
+
+from gnue.forms.uidrivers.wx26.widgets._base import UIHelper
+
+
+# =============================================================================
+# Wrap an UI layer around a wxMenu widget
+# =============================================================================
+
+class UIMenu(UIHelper):
+    """
+    Implements a menu object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new Menu widget.
+        """
+
+        label = self._gfObject.label or ""
+
+        if self._gfObject.name == '__main__' \
+                and not self._form._features['GUI:MENUBAR:SUPPRESS']:
+            # Menu bar of the form
+            handle_box = gtk.HandleBox()
+            widget = gtk.MenuBar()
+            handle_box.add(widget)
+            widget.show()
+            self._uiForm.content_table.attach(handle_box,
+                  # X direction             Y direction
+                    0, 1,                   0, 1,
+                    gtk.EXPAND | gtk.FILL,  0,
+                    0,                      0)
+        else:
+            # Submenu or popup menu
+            menuitem = gtk.MenuItem(label.replace("&", "_"))
+            widget = gtk.Menu()
+            menuitem.set_submenu(widget)
+            if isinstance(event.container, gtk.Menu) \
+                    or isinstance(event.container, gtk.MenuBar):
+                event.container.add(menuitem)
+
+        self._container = widget
+
+        return widget
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIMenu,
+  'provides' : 'GFMenu',
+  'container': 1,
+}


Property changes on: trunk/gnue-forms/src/uidrivers/gtk2/widgets/menu.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: trunk/gnue-forms/src/uidrivers/gtk2/widgets/menuitem.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/menuitem.py     2007-02-06 
14:37:52 UTC (rev 9355)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/menuitem.py     2007-02-06 
22:25:44 UTC (rev 9356)
@@ -0,0 +1,187 @@
+# GNU Enterprise Forms - gtk2 UI Driver - MenuItem widget
+#
+# Copyright 2001-2007 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$
+
+import gtk
+
+from gnue.forms.uidrivers.gtk2.widgets._base import UIHelper
+
+
+# =============================================================================
+# Wrap an UI layer around a Menu widget
+# =============================================================================
+
+class UIMenuItem(UIHelper):
+    """
+    Implements a menu item object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu item widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new MenuItem widget.
+        """
+
+        # These are the relevant parameters
+        icon_file = self._gfObject._get_icon_file(size="16x16", format="png")
+        label = self._gfObject.label
+        description = self._gfObject.description
+        hotkey = self._gfObject.hotkey
+        check = (self._gfObject.action_off is not None)
+
+        # TODO: Checkable menu items
+        #if check:
+        #    kind = wx.ITEM_CHECK
+        #else:
+        #    kind = wx.ITEM_NORMAL
+
+        if label is not None:
+            widget = gtk.ImageMenuItem(label.replace("&", "_"))
+            if hotkey is not None:
+                parts = hotkey.split("+")
+                if len(parts[-1]) == 1:
+                    base = ord(parts[-1])
+                else:
+                    base = self.__keymap[parts[-1]]
+                mod = 0
+                if "SHIFT" in parts: mod = mod | gtk.gdk.SHIFT_MASK
+                if "CTRL"  in parts: mod = mod | gtk.gdk.CONTROL_MASK
+                if "ALT"   in parts: mod = mod | gtk.gdk.MOD1_MASK
+                widget.add_accelerator('activate', self._uiForm.accelGroup,
+                            base, mod, gtk.ACCEL_VISIBLE)
+    
+            if icon_file:
+                image = gtk.Image()
+                image.set_from_file(icon_file)
+                widget.set_image(image)
+
+            event.container.append(widget)
+
+            self.__description = description
+            self.__container = event.container
+
+            widget.connect('activate', self.__on_activate)
+            widget.connect('select', self.__on_select)
+            widget.connect('deselect', self.__on_deselect)
+        else:
+            widget = None
+            event.container.add(gtk.SeparatorMenuItem())
+
+        self.__widget = widget
+
+        return widget
+
+
+    # -------------------------------------------------------------------------
+    # Events
+    # -------------------------------------------------------------------------
+
+    def __on_activate(self, event):
+        self._gfObject._event_fire()
+
+    # -------------------------------------------------------------------------
+
+    def __on_select(self, menu_item):
+        self._uiForm._show_tip(self.__description)
+
+    # -------------------------------------------------------------------------
+
+    def __on_deselect(self, menu_item):
+        self._uiForm._show_tip("")
+
+    # -------------------------------------------------------------------------
+    # Check/uncheck menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_on_(self):
+        if self.__widget is not None:
+            # FIXME
+            #self.__widget.Check(True)
+            pass
+
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_off_(self):
+        if self.__widget is not None:
+            # FIXME
+            #self.__widget.Check(False)
+            pass
+
+
+    # -------------------------------------------------------------------------
+    # Enable/disable menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_enable_(self):
+        if self.__widget is not None:
+            self.__widget.set_sensitive(True)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_disable_(self):
+        if self.__widget is not None:
+            self.__widget.set_sensitive(False)
+
+
+    # -------------------------------------------------------------------------
+    # Keymap translation
+    # -------------------------------------------------------------------------
+
+    __keymap = {
+        "F1"        : gtk.keysyms.F1,
+        "F2"        : gtk.keysyms.F2,
+        "F3"        : gtk.keysyms.F3,
+        "F4"        : gtk.keysyms.F4,
+        "F5"        : gtk.keysyms.F5,
+        "F6"        : gtk.keysyms.F6,
+        "F7"        : gtk.keysyms.F7,
+        "F8"        : gtk.keysyms.F8,
+        "F9"        : gtk.keysyms.F9,
+        "F10"       : gtk.keysyms.F10,
+        "F11"       : gtk.keysyms.F11,
+        "F12"       : gtk.keysyms.F12,
+        "INS"       : gtk.keysyms.Insert,
+        "DEL"       : gtk.keysyms.Delete,
+        "HOME"      : gtk.keysyms.Home,
+        "END"       : gtk.keysyms.End,
+        "PGUP"      : gtk.keysyms.Prior,
+        "PGDN"      : gtk.keysyms.Next,
+        "UP"        : gtk.keysyms.Up,
+        "DOWN"      : gtk.keysyms.Down,
+        "LEFT"      : gtk.keysyms.Left,
+        "RIGHT"     : gtk.keysyms.Right,
+        "TAB"       : gtk.keysyms.Tab,
+        "ENTER"     : gtk.keysyms.Return,
+        "BACK"      : gtk.keysyms.BackSpace}
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIMenuItem,
+  'provides' : 'GFMenuItem',
+  'container': False
+}


Property changes on: trunk/gnue-forms/src/uidrivers/gtk2/widgets/menuitem.py
___________________________________________________________________
Name: svn:keywords
   + Id

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py  2007-02-06 14:37:52 UTC 
(rev 9355)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/menu.py  2007-02-06 22:25:44 UTC 
(rev 9356)
@@ -43,7 +43,8 @@
         Create a menu widget
         """
 
-        if self._gfObject.name == '__main__':
+        if self._gfObject.name == '__main__' \
+                and not self._form._features['GUI:MENUBAR:SUPPRESS']:
             widget = self._uiForm.main_window.menuBar()
 
         else:


Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/hbox.py
___________________________________________________________________
Name: svn:executable
   - *

Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/menu.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/menu.py 2007-02-06 14:37:52 UTC 
(rev 9355)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/menu.py 2007-02-06 22:25:44 UTC 
(rev 9356)
@@ -44,7 +44,8 @@
         Creates a new Menu widget.
         """
 
-        if self._gfObject.name == '__main__':
+        if self._gfObject.name == '__main__' \
+                and not self._form._features['GUI:MENUBAR:SUPPRESS']:
             # Menu bar of the form
             widget = wx.MenuBar()
             if isinstance(self._uiForm.main_window, wx.Frame):


Property changes on: trunk/gnue-forms/src/uidrivers/wx26/widgets/vbox.py
___________________________________________________________________
Name: svn:executable
   - *





reply via email to

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