Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/MenuActions.py
diff options
context:
space:
mode:
Diffstat (limited to 'com/gmail/bernabe/laurent/sugar_olpc/learning_writing/MenuActions.py')
-rwxr-xr-xcom/gmail/bernabe/laurent/sugar_olpc/learning_writing/MenuActions.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/MenuActions.py b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/MenuActions.py
new file mode 100755
index 0000000..e2d6b44
--- /dev/null
+++ b/com/gmail/bernabe/laurent/sugar_olpc/learning_writing/MenuActions.py
@@ -0,0 +1,83 @@
+# MenuActions.py Stores the actions for the MenuItems
+#
+#This file is part of LearningWriting.
+#
+#LearningWriting 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 3 of the License, or
+#(at your option) any later version.
+#
+#LearningWriting 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 LearningWriting. If not, see <http://www.gnu.org/licenses/>.
+from gettext import gettext as _
+from 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 ?"),text="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) ?"),text="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