Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/MenuActions.py
diff options
context:
space:
mode:
Diffstat (limited to 'MenuActions.py')
-rwxr-xr-xMenuActions.py89
1 files changed, 89 insertions, 0 deletions
diff --git a/MenuActions.py b/MenuActions.py
new file mode 100755
index 0000000..1b81f48
--- /dev/null
+++ b/MenuActions.py
@@ -0,0 +1,89 @@
+# MenuActions.py Stores the actions for the MenuItems
+#
+# Copyright (C) 2011 Laurent BERNABE
+#
+# 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., 51 Franklin
+# St, Fifth Floor, Boston, MA 02110-1301 USA
+
+from gettext import gettext as _
+from com.gmail.bernabe.laurent.sugar_olpc.learning_writing.gui.InputDialog import \
+ InputDialog
+
+import pygtk
+pygtk.require('2.0')
+import gtk
+
+class MenuActions(object):
+ '''
+ Wraps codes for the menu actions in both
+ pure pygtk mode and in sugar mode
+ '''
+
+ def __init__(self, wrappedDrawingArea):
+ '''
+ Constructor
+ => wrappedDrawingArea argument : the instance of
+ TheDrawingAreaEventBox to act upon
+ => MenuActions(wrappedDrawingArea)
+ '''
+ self.__wrappedDrawingArea = wrappedDrawingArea
+
+ def manageDrawingWrite(self):
+ '''
+ manageDrawingWrite()
+ Wraps code for menu Drawing->Write
+ '''
+ dialog = InputDialog(_("Line thickness value ?\n(I advice you 5)"))
+ user_value = dialog.run()
+ if user_value != None :
+ try:
+ line_thickness = int(user_value)
+ assert line_thickness > 0
+ except (ValueError, AssertionError) :
+ message = _("As you did not give an correct integer value,\n5 will be taken")
+ message_dialog = gtk.MessageDialog(None,
+ gtk.DIALOG_MODAL,
+ gtk.MESSAGE_ERROR,
+ gtk.BUTTONS_OK,
+ message)
+ message_dialog.run()
+ message_dialog.destroy()
+ line_thickness = 5
+ self.__wrappedDrawingArea.setRecordingMode(line_thickness)
+
+ def manageDrawingRead(self):
+ '''
+ manageDrawingRead()
+ Wraps code for menu Drawing->Read
+ '''
+ dialog = InputDialog(_("Steps drawing delays (milliseconds) ?\n(I advice you 10)"))
+ user_value = dialog.run()
+ if user_value != None :
+ try:
+ delay_milliseconds = int(user_value)
+ assert delay_milliseconds > 0
+ except (ValueError, AssertionError) :
+ message = _("As you did not give an correct integer value,\n10 will be taken")
+ message_dialog = gtk.MessageDialog(None,
+ gtk.DIALOG_MODAL,
+ gtk.MESSAGE_ERROR,
+ gtk.BUTTONS_OK,
+ message)
+ message_dialog.run()
+ message_dialog.destroy()
+ delay_milliseconds = 10
+ self.__wrappedDrawingArea.setReadingMode(delay_milliseconds) \ No newline at end of file