commit-gnue
[Top][All Lists]
Advanced

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

[gnue] r9372 - trunk/gnue-forms/src/uidrivers/gtk2/widgets


From: reinhard
Subject: [gnue] r9372 - trunk/gnue-forms/src/uidrivers/gtk2/widgets
Date: Mon, 12 Feb 2007 07:09:36 -0600 (CST)

Author: reinhard
Date: 2007-02-12 07:09:36 -0600 (Mon, 12 Feb 2007)
New Revision: 9372

Added:
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbar.py
   trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbutton.py
Log:
Added dynamic toolbar implementation for gtk2.

issue79 testing


Added: trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbar.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbar.py      2007-02-12 
13:03:48 UTC (rev 9371)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbar.py      2007-02-12 
13:09:36 UTC (rev 9372)
@@ -0,0 +1,81 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - Toolbar 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: toolbar.py 9364 2007-02-09 11:17:51Z reinhard $
+
+import gtk
+
+from gnue.forms.uidrivers.gtk2.widgets._base import UIHelper
+
+
+# =============================================================================
+# Wrap an UI layer around a wxMenu widget
+# =============================================================================
+
+class UIToolbar(UIHelper):
+    """
+    Implements a toolbar object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new toolbar widget.
+        """
+
+        widget = None
+
+        if self._gfObject.name == '__main__' \
+                and not self._form._features['GUI:TOOLBAR:SUPPRESS']:
+
+            handlebox = gtk.HandleBox()
+            widget = gtk.Toolbar()
+
+            widget.set_orientation(gtk.ORIENTATION_HORIZONTAL)
+            widget.set_style(gtk.TOOLBAR_ICONS)
+            widget.set_tooltips(True)
+            handlebox.add(widget)
+
+            self._uiForm.content_table.attach(handlebox,
+                  # X direction            Y direction
+                    0, 1,                  1, 2,
+                    gtk.EXPAND | gtk.FILL, 0,
+                    0,                     0)
+
+            self._uiForm._tooltips = gtk.Tooltips()
+
+        self._container = widget
+
+        return widget
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIToolbar,
+  'provides' : 'GFToolbar',
+  'container': 1,
+}

Added: trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbutton.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbutton.py   2007-02-12 
13:03:48 UTC (rev 9371)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/toolbutton.py   2007-02-12 
13:09:36 UTC (rev 9372)
@@ -0,0 +1,131 @@
+# GNU Enterprise Forms - wx 2.6 UI Driver - ToolButton 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: toolbutton.py 9364 2007-02-09 11:17:51Z reinhard $
+
+import gtk
+
+from gnue.forms.uidrivers.gtk2.widgets._base import UIHelper
+
+
+# =============================================================================
+# UIToolButton
+# =============================================================================
+
+class UIToolButton(UIHelper):
+    """
+    Implements a toolbar button object.
+    """
+
+    # -------------------------------------------------------------------------
+    # Create a menu item widget
+    # -------------------------------------------------------------------------
+
+    def _create_widget_(self, event, spacer):
+        """
+        Creates a new toolbar button widget.
+        """
+
+        # These are the relevant parameters
+        icon_file = self._gfObject._get_icon_file(size="24x24", format="png")
+        label = self._gfObject.label
+        description = self._gfObject.description
+        check = (self._gfObject.action_off is not None)
+
+        if label is not None:
+            if icon_file:
+                image = gtk.Image()
+                image.set_from_file(icon_file)
+            else:
+                image = None
+
+            if check:
+                widget = gtk.ToggleToolButton()
+                self.__h_toggled = widget.connect('toggled', self.__on_clicked)
+            else:
+                widget = gtk.ToolButton()
+                widget.connect('clicked', self.__on_clicked)
+
+            widget.set_icon_widget(image)
+            widget.set_label(label)
+            widget.set_tooltip(self._uiForm._tooltips, label, None)
+
+            event.container.insert(widget, -1)
+        else:
+            widget = None
+            event.container.insert(gtk.SeparatorToolItem(), -1)
+
+        self.__widget = widget
+
+        return widget
+
+
+    # -------------------------------------------------------------------------
+    # Events
+    # -------------------------------------------------------------------------
+
+    def __on_clicked(self, event):
+        self._gfObject._event_fire()
+
+
+    # -------------------------------------------------------------------------
+    # Check/uncheck menu item
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_on_(self):
+        if self.__widget is not None:
+            self.__widget.handler_block(self.__h_toggled)
+            self.__widget.set_active(True)
+            self.__widget.handler_unblock(self.__h_toggled)
+
+    # -------------------------------------------------------------------------
+
+    def _ui_switch_off_(self):
+        if self.__widget is not None:
+            self.__widget.handler_block(self.__h_toggled)
+            self.__widget.set_active(False)
+            self.__widget.handler_unblock(self.__h_toggled)
+
+
+    # -------------------------------------------------------------------------
+    # 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)
+
+
+# =============================================================================
+# Configuration data
+# =============================================================================
+
+configuration = {
+  'baseClass': UIToolButton,
+  'provides' : 'GFToolButton',
+  'container': False
+}





reply via email to

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