コード例 #1
0
ファイル: GtkGUI.py プロジェクト: Subsentient/lamentcalendar
    def SilenceToggled(self, MenuItem):
        OldState = Audio.GetSilenced()
        Audio.SetSilenced(not OldState)

        Methods = (Audio.AudioEvent.Unpause, Audio.AudioEvent.Pause)

        for Key in self.Notifications:
            Methods[not OldState](self.Notifications[Key].Noisemaker)
コード例 #2
0
ファイル: GtkGUI.py プロジェクト: Subsentient/lamentcalendar
 def SilenceSignalHandler(self, *Discarded):
     self.SilenceItem.set_active(not Audio.GetSilenced())
コード例 #3
0
ファイル: GtkGUI.py プロジェクト: Subsentient/lamentcalendar
    def __init__(
            self
    ):  #Yes, the same static-initialized list is indeed what we want.

        Gtk.Window.__init__(self, title='Lament Calendar')

        self.Notifications = {}
        self.Stopwatches = []

        self.set_default_size(640, 480)
        self.connect('destroy', self.TerminateApp)

        SetWindowIcon(self)

        self.VBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
        self.add(self.VBox)

        # Create the menu bar
        self.MenuBarAlign = Gtk.Alignment(xalign=0.0,
                                          yalign=0.5,
                                          xscale=1.0,
                                          yscale=0.0)
        self.MenuBar = Gtk.MenuBar()
        self.MenuBarAlign.add(self.MenuBar)

        # Create file menu
        self.FileMenu = Gtk.Menu.new()
        self.FileTag = Gtk.MenuItem.new_with_mnemonic('_File')
        self.FileTag.set_submenu(self.FileMenu)
        self.MenuBar.append(self.FileTag)

        self.TimerMenu = Gtk.Menu.new()
        self.TimerTag = Gtk.MenuItem.new_with_mnemonic('_Timer')
        self.TimerTag.set_submenu(self.TimerMenu)
        self.MenuBar.append(self.TimerTag)

        #Populate file menu
        self.QuitItem = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT)
        self.QuitItem.connect('activate', self.TerminateApp)

        self.NewEventItem = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_NEW)
        self.NewEventItem.set_label("_New Event")
        self.NewEventItem.connect('activate', self.OnNewItemClick)

        self.ReloadDBItem = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_REFRESH)
        self.ReloadDBItem.set_label("_Reload database")
        self.ReloadDBItem.connect('activate', self.OnReloadDBClick)

        self.AllEventsItem = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_INDEX)
        self.AllEventsItem.set_label('List _all events')
        self.AllEventsItem.connect('activate', self.OnListAllClick)

        self.MinimizeToTrayItem = Gtk.ImageMenuItem.new_from_stock(
            Gtk.STOCK_CLOSE)
        self.MinimizeToTrayItem.set_label("_Minimize to tray")
        self.MinimizeToTrayItem.connect('activate', self.OnSendToTrayClick)

        self.SilenceItem = Gtk.CheckMenuItem.new_with_mnemonic(
            "_Silence alarms")
        self.SilenceItem.set_active(Audio.GetSilenced())
        self.SilenceItem.connect('activate', self.SilenceToggled)

        self.FileMenu.append(self.MinimizeToTrayItem)
        self.FileMenu.append(self.SilenceItem)
        self.FileMenu.append(self.NewEventItem)
        self.FileMenu.append(self.AllEventsItem)
        self.FileMenu.append(self.ReloadDBItem)
        self.FileMenu.append(self.QuitItem)

        #Populate timer menu
        self.StopwatchItem = Gtk.MenuItem.new_with_mnemonic('New s_topwatch')
        self.StopwatchItem.connect('activate',
                                   lambda *Discarded: self.SpawnStopwatch())
        self.TimerMenu.append(self.StopwatchItem)

        #Configure calendar display.
        self.Calendar = Gtk.Calendar()
        self.Calendar.connect('day-selected-double-click', self.DayClicked)
        self.Calendar.connect('month-changed', self.MonthChanged)

        #Add it all in
        self.VBox.pack_start(self.MenuBarAlign, False, True, 0)
        self.VBox.pack_start(self.Calendar, True, True, 0)

        #First callbacks we must manually invoke
        Dates = [*self.Calendar.get_date()]
        Dates[1] += 1

        self.DB = DB.DBObject()

        self.OnMonthChange(*Dates)