Exemplo n.º 1
0
    def del_task(self, task):
        """ Suppression de tâches """
        rep = askyesno(
            _("Confirmation"),
            _("Are you sure you want to delete the task {task}? This action cannot be undone."
              ).format(task=task.capitalize()))
        if rep:
            CONFIG.remove_option("PomodoroTasks", task)
            # remove stats
            db = sqlite3.connect(PATH_STATS)
            cursor = db.cursor()
            try:
                cursor.execute('DROP TABLE {}'.format(
                    scrub(task.lower().replace(' ', '_'))))
                db.commit()
            except sqlite3.OperationalError:
                pass  # no stats yet
            db.close()
            self.tasks[task].destroy()
            self._tasks_btns[task].destroy()
            del self.tasks[task]
            del self._tasks_btns[task]

            if len(CONFIG.options("PomodoroTasks")) == 1:
                CONFIG.set("PomodoroTasks", _("Work"), CMAP[0])
                self._tasks_btns[CONFIG.options("PomodoroTasks")[0]].state(
                    ['disabled'])
            save_config()
Exemplo n.º 2
0
 def del_cat(self, cat):
     rep = askyesno(
         _("Confirmation"),
         _("Are you sure you want to delete the category {category}? This action cannot be undone."
           ).format(category=cat))
     if rep:
         CONFIG.remove_option("Categories", cat)
         for w in self.cats[cat]:
             w.destroy()
         del self.cats[cat]
         save_config()
Exemplo n.º 3
0
 def show(self):
     ''' make widget sticky '''
     self.deiconify()
     self.update_idletasks()
     splash_supp = CONFIG.getboolean('General',
                                     'splash_supported',
                                     fallback=True)
     try:
         pos = self._position.get()
         for w in self.ewmh.getClientList():
             if w.get_wm_name() == self.title():
                 if pos == 'above':
                     self.attributes('-type', 'dock')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_ABOVE')
                     self.ewmh.setWmState(w, 0, '_NET_WM_STATE_BELOW')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_STICKY')
                     self.ewmh.setWmState(w, 1,
                                          '_NET_WM_STATE_SKIP_TASKBAR')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_SKIP_PAGER')
                 elif pos == 'below':
                     self.attributes('-type', 'desktop')
                     self.ewmh.setWmState(w, 0, '_NET_WM_STATE_ABOVE')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_BELOW')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_STICKY')
                     self.ewmh.setWmState(w, 1,
                                          '_NET_WM_STATE_SKIP_TASKBAR')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_SKIP_PAGER')
                 else:
                     if splash_supp:
                         self.attributes('-type', 'splash')
                     else:
                         self.attributes('-type', 'toolbar')
                     self.ewmh.setWmState(w, 0, '_NET_WM_STATE_BELOW')
                     self.ewmh.setWmState(w, 0, '_NET_WM_STATE_ABOVE')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_STICKY')
                     self.ewmh.setWmState(w, 1,
                                          '_NET_WM_STATE_SKIP_TASKBAR')
                     self.ewmh.setWmState(w, 1, '_NET_WM_STATE_SKIP_PAGER')
         self.ewmh.display.flush()
         if not splash_supp:
             self.withdraw()
             self.deiconify()
         CONFIG.set(self.name, 'visible', 'True')
         self.variable.set(True)
         save_config()
     except TypeError:
         pass
Exemplo n.º 4
0
    def ok(self):
        # --- General
        CONFIG.set("General", "language", REV_LANGUAGES[self.lang.get()])
        CONFIG.set("General", "trayicon", self.gui.get().lower())
        # CONFIG.set("General", "check_update", str('selected' in self.confirm_update.state()))
        CONFIG.set('General', 'splash_supported',
                   str(not self.splash_support.instate(('selected', ))))

        eyes = self.eyes_interval.get()
        if eyes == '':
            eyes = '20'
        CONFIG.set("General", "eyes_interval", eyes)
        # --- Reminders
        CONFIG.set("Reminders", 'window',
                   str("selected" in self.reminders_window.state()))
        CONFIG.set("Reminders", 'window_bg',
                   self.reminders_window_bg.get_color())
        CONFIG.set("Reminders", 'window_fg',
                   self.reminders_window_fg.get_color())
        CONFIG.set("Reminders", "window_alpha",
                   "%.2f" % (self.reminders_opacity.get_opacity()))
        CONFIG.set("Reminders", 'window_bg_alternate',
                   self.reminders_window_bg_alt.get_color())
        CONFIG.set("Reminders", 'window_fg_alternate',
                   self.reminders_window_fg_alt.get_color())
        CONFIG.set("Reminders", 'blink',
                   str("selected" in self.reminders_blink.state()))
        CONFIG.set("Reminders", 'notification',
                   str("selected" in self.reminders_notif.state()))
        alarm, mute = self.reminders_sound.get()
        CONFIG.set("Reminders", 'alarm', alarm)
        timeout = self.reminders_timeout.get()
        if timeout == '':
            timeout = '5'
        CONFIG.set("Reminders", 'timeout', timeout)
        CONFIG.set("Reminders", 'mute', str(mute))
        # --- Calendar
        CONFIG.set("Calendar", "alpha",
                   "%.2f" % (self.cal_opacity.get_opacity()))

        font = self.cal_font.get_font()
        CONFIG.set(
            "Calendar", "font",
            "{} {}".format(font['family'].replace(' ', '\ '), font['size']))
        CONFIG.set("Calendar", "bordercolor", self.cal_bd.get_color())
        CONFIG.set("Calendar", "background", self.cal_bg.get_color())
        CONFIG.set("Calendar", "foreground", self.cal_fg.get_color())
        for name, widget in self.cal_colors.items():
            CONFIG.set("Calendar", name, widget.get_color())

        for cat, (l, bg, fg, b) in self.cats.items():
            CONFIG.set("Categories", cat,
                       "{}, {}".format(fg.get_color(), bg.get_color()))

        # --- Events
        CONFIG.set("Events", "alpha",
                   "%.2f" % (self.events_opacity.get_opacity()))

        font = self.events_font.get_font()
        CONFIG.set(
            "Events", "font", "{} {}".format(font['family'].replace(' ', '\ '),
                                             font['size']))
        font_title = self.events_font_title.get_font()
        title = [
            font_title['family'].replace(' ', '\ '),
            str(font_title['size']), font_title['weight'], font_title['slant']
        ]
        if font_title['underline']:
            title.append('underline')
        CONFIG.set("Events", "font_title", " ".join(title))

        font_day = self.events_font_day.get_font()
        day = [
            font_day['family'].replace(' ', '\ '),
            str(font_day['size']), font_day['weight'], font_day['slant']
        ]
        if font_day['underline']:
            day.append('underline')
        CONFIG.set("Events", "font_day", " ".join(day))

        CONFIG.set("Events", "background", self.events_bg.get_color())
        CONFIG.set("Events", "foreground", self.events_fg.get_color())

        # --- Tasks
        CONFIG.set("Tasks", "alpha",
                   "%.2f" % (self.tasks_opacity.get_opacity()))

        font = self.tasks_font.get_font()
        CONFIG.set(
            "Tasks", "font", "{} {}".format(font['family'].replace(' ', '\ '),
                                            font['size']))
        font_title = self.tasks_font_title.get_font()
        title = [
            font_title['family'].replace(' ', '\ '),
            str(font_title['size']), font_title['weight'], font_title['slant']
        ]
        if font_title['underline']:
            title.append('underline')
        CONFIG.set("Tasks", "font_title", " ".join(title))

        CONFIG.set("Tasks", "background", self.tasks_bg.get_color())
        CONFIG.set("Tasks", "foreground", self.tasks_fg.get_color())
        CONFIG.set('Tasks', 'hide_completed', str(self.tasks_hide_comp.get()))

        # --- Timer
        CONFIG.set("Timer", "alpha",
                   "%.2f" % (self.timer_opacity.get_opacity()))

        font_time = self.timer_font_time.get_font()
        CONFIG.set(
            "Timer", "font_time",
            "{} {}".format(font_time['family'].replace(' ', '\ '),
                           font_time['size']))
        font_intervals = self.timer_font_intervals.get_font()
        CONFIG.set(
            "Timer", "font_intervals",
            "{} {}".format(font_intervals['family'].replace(' ', '\ '),
                           font_intervals['size']))

        CONFIG.set("Timer", "background", self.timer_bg.get_color())
        CONFIG.set("Timer", "foreground", self.timer_fg.get_color())

        # --- Pomodoro
        stop_pomodoro = self.frames[_('Pomodoro')].valide()
        if stop_pomodoro:
            self.master.widgets['Pomodoro'].stop(False)
        save_config()
        self.destroy()
Exemplo n.º 5
0
 def hide(self):
     CONFIG.set(self.name, 'visible', 'False')
     self.variable.set(False)
     save_config()
     self.withdraw()
Exemplo n.º 6
0
 def _on_configure(self, event):
     CONFIG.set(self.name, 'geometry', self.geometry())
     save_config()
Exemplo n.º 7
0
                      ).format(pidfile=PIDFILE))
                sys.exit()
    # it is an old pid file (certainly due to session logout then login)
    os.remove(PIDFILE)

if args.update_date:
    # scheduler was not running, does nothing
    sys.exit()

open(PIDFILE, 'w').write(pid)

try:
    from schedulerlib.scheduler import EventScheduler

    app = EventScheduler()
    if not args.withdraw:
        app.show()
    app.mainloop()
finally:
    try:
        app.save()
    except NameError:
        pass
    save_config()
    try:
        os.unlink(PIDFILE)
    except FileNotFoundError:
        # PIDFILE might have been deleted
        pass
    logging.info('Quit')
Exemplo n.º 8
0
 def _on_configure(self, event):
     geo = self.geometry().split('+')[1:]
     CONFIG.set(self.name, 'geometry', '+%s+%s' % tuple(geo))
     save_config()