diff options
Diffstat (limited to 'reviewselection.py')
-rw-r--r-- | reviewselection.py | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/reviewselection.py b/reviewselection.py new file mode 100644 index 0000000..b3c2307 --- /dev/null +++ b/reviewselection.py @@ -0,0 +1,161 @@ +# -*- coding: utf-8 -*- +#Copyright (c) 2010, Kirk Winans + +# 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 3 of the License, or +# (at your option) any later version. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +import gtk +from os import environ +from os.path import join, basename +import hippo + +import shutil +import tempfile +from gettext import gettext as _ +import logging +from gobject import SIGNAL_RUN_FIRST, TYPE_PYOBJECT +from sugar.graphics import style +from sugar.graphics.toolbutton import ToolButton +from sugar.graphics.icon import Icon +from sugar.graphics.palette import Palette +from port.widgets import ToggleToolButton +from port.widgets import CanvasRoundBox, ToolComboBox +#from port import chooser + +from sugar.datastore import datastore +import xml.etree.ElementTree +from datetime import date +import time +_logger = logging.getLogger("test-activity") + +from gettext import gettext as _ + + + +# +# Review Selection Panel for Flashcard Activity +# +class ReviewSelection(gtk.VBox): + + def __init__(self, activity_root): + gtk.VBox.__init__(self) + + self.activity_root = activity_root + + self.box_selection_box = gtk.HBox() + + self.catagory_selection_box = gtk.HBox() + + self.box_label = gtk.Label(_('Select Box:')) + + self.box_selection = gtk.ComboBoxEntry() + + self.box_selection = gtk.combo_box_new_text() + + self.catagory_label = gtk.Label(_('Select Category:')) + + self.catagory_selection = gtk.ComboBoxEntry() + + self.catagory_selection = gtk.combo_box_new_text() + + self.expired = gtk.CheckButton(_("Review Only Expired Cards")) + + self.expired.set_active(True) + + self.cardfile = "testfile.xml" + + self.tree = xml.etree.ElementTree.parse(self.cardfile) + + boxes = self.get_boxes() + + catagories = self.get_catagories() + + # Sets text for dropdown menus + for text in boxes: + self.box_selection.append_text(text) + + for text in catagories: + self.catagory_selection.append_text(text) + + self.box_selection.set_active(0) + + self.catagory_selection.set_active(0) + + self.box_selection_box.pack_start(self.box_label) + + self.box_selection_box.pack_start(self.box_selection) + + self.catagory_selection_box.pack_start(self.catagory_label) + + self.catagory_selection_box.pack_start(self.catagory_selection) + + self.add(self.box_selection_box) + + self.add(self.catagory_selection_box) + + self.add(self.expired) + + self.box_selection.show() + + self.catagory_selection.show() + + self.box_selection_box.show() + + self.box_label.show() + + self.catagory_selection_box.show() + + self.catagory_label.show() + + self.expired.show() + + # Returns name of selected box + def get_selected_box(self): + return self.box_selection.get_active_text() + + # Returns name of selected category + def get_selected_catagory(self): + return self.catagory_selection.get_active_text() + + # Returns the time boxes + def get_boxes(self): + boxes = ["All", "Every Day", "Every 2 Days", "Every 4 Days", + "Every Week", "Every 2 Weeks", "Every Month"] + return boxes + + # Returns the categories available + def get_catagories(self): + deck = self.tree.getroot() + card_catagories = [] + card_catagories = card_catagories + ["All"] + for card in deck: + card_catagories = card_catagories + [card.find("catagory").text] + + card_catagories = set(card_catagories) + card_catagories = list(card_catagories) + + card_catagories = self.move_all(sorted(card_catagories)) + + return card_catagories + + # Returns True if only the expired cards are seleceted + def get_expired_only(self): + return self.expired.get_active() + + # Moves the All option to top of the list and default selected + def move_all(self, catagories): + + for idx in range(len(catagories)): + if catagories[idx] == "All": + catagories[idx] = catagories[0] + catagories[0] = "All" + + return catagories + + |