Exemple #1
0
    def __init__(self):
        self.undo = UndoStack()
        self.history = UndoStack(
            gtk.Action("Back", None, None, gtk.STOCK_GO_BACK),
            gtk.Action("Forward", None, None, gtk.STOCK_GO_FORWARD))
        w = gtk.Window()
        w.connect("destroy", gtk.main_quit)
        vbox = gtk.VBox()
        self.model = Schedule("schedule.csv")
        self.info = CalendarInfo(self.model)
        self.weekview = WeekView(self.info, self.undo, self.history)
        self.monthview = MonthView(self.info, self.undo, self.history)

        uiman = gtk.UIManager ()
        actiongroup = MenuCommand.create_action_group(self)
        actiongroup.add_action(self.undo.undo_action)
        actiongroup.add_action(self.undo.redo_action)
        actiongroup.add_action(self.history.undo_action)
        actiongroup.add_action(self.history.redo_action)

        self.undo.undo_action.connect("activate", self.update_actions)
        self.undo.redo_action.connect("activate", self.update_actions)
        uiman.insert_action_group(actiongroup)
        uiman.add_ui_from_string(self.ui)
        toolbar = uiman.get_widget("/upperToolbar")
        vbox.pack_start (toolbar, False, False)

        vbox.pack_start(self.weekview, True, True)
        vbox.pack_start(self.monthview, True, True)

        toolbar = uiman.get_widget("/lowerToolbar")

        self.selection_buffer = gtk.TextBuffer()
        self.selection_buffer.create_tag("error",
                                         underline=pango.UNDERLINE_SINGLE)
        self.selection_entry = gtk.TextView(self.selection_buffer)
        
        self.pack_toolbar_widget(toolbar, self.selection_entry)
        vbox.pack_end (toolbar, False, False)

        w.add(vbox)
        w.show()
        vbox.show()
        self.monthview.hide()
        self.window = w
        self.weekview.connect("notify::selected", self.update_actions)
        self.info.connect("selection-recurrence-changed", self.update_actions)
        self.selection_entry.connect("key-press-event", self.selection_entry_key_press_cb)