How to use the safeeyes.Utility.format_time function in safeeyes

To help you get started, we’ve selected a few safeeyes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slgobinath / SafeEyes / safeeyes / plugins / trayicon / plugin.py View on Github external
# print(self.context['locale'].ngettext('For %d Hour', 'For %d Hours', 1) % 1)
            entry[0].set_label(self.context['locale'].ngettext(entry[1][0], entry[1][1], entry[2]) % entry[2])

        self.sub_menu_item_until_restart.set_label(_('Until restart'))
        self.item_enable.set_label(_('Enable Safe Eyes'))
        self.item_disable.set_label(_('Disable Safe Eyes'))

        breaks_found = self.has_breaks()
        if breaks_found:
            if self.active:
                if self.date_time:
                    self.__set_next_break_info()
                self.indicator.set_icon("safeeyes_enabled")
            else:
                if self.wakeup_time:
                    self.item_info.set_label(_('Disabled until %s') % Utility.format_time(self.wakeup_time))
                else:
                    self.item_info.set_label(_('Disabled until restart'))
                self.indicator.set_label('', '')
                self.indicator.set_icon("safeeyes_disabled")
        else:
            self.item_info.set_label(_('No Breaks Available'))
            self.indicator.set_label('', '')
            self.indicator.set_icon("safeeyes_disabled")
        self.item_info.set_sensitive(breaks_found and self.active)
        self.item_enable.set_sensitive(breaks_found and not self.active)
        self.item_disable.set_sensitive(breaks_found and self.active)
        self.item_manual_break.set_sensitive(breaks_found and self.active)

        self.item_manual_break.set_label(_('Take a break now'))
        self.item_settings.set_label(_('Settings'))
        self.item_about.set_label(_('About'))
github slgobinath / SafeEyes / safeeyes / plugins / trayicon / plugin.py View on Github external
def __set_next_break_info(self):
        """
        A private method to be called within this class to update the next break information using self.dateTime.
        """
        formatted_time = Utility.format_time(self.date_time)
        message = _('Next break at %s') % (formatted_time)
        # Update the menu item label
        Utility.execute_main_thread(self.item_info.set_label, message)
        # Update the tray icon label
        if self.plugin_config.get('show_time_in_tray', False):
            self.indicator.set_label(formatted_time, '')
        else:
            self.indicator.set_label('', '')
github slgobinath / SafeEyes / safeeyes / plugins / trayicon / plugin.py View on Github external
Handle the menu actions of all the sub menus of 'Disable Safe Eyes'.
        This action disables the application if it is currently active.
        """
        # active = self.item_enable.get_active()
        if self.active and len(args) > 1:
            self.disable_ui()

            time_to_wait = args[1]
            if time_to_wait <= 0:
                info = _('Disabled until restart')
                self.on_disable(info)
                self.wakeup_time = None
                self.item_info.set_label(info)
            else:
                self.wakeup_time = datetime.datetime.now() + datetime.timedelta(minutes=time_to_wait)
                info = _('Disabled until %s') % Utility.format_time(self.wakeup_time)
                self.on_disable(info)
                self.item_info.set_label(info)
                Utility.start_thread(self.__schedule_resume, time_minutes=time_to_wait)
github slgobinath / SafeEyes / safeeyes / SafeEyes.py View on Github external
def update_next_break(self, break_obj, break_time):
        """
        Update the next break to plugins and save the session.
        """
        self.plugins_manager.update_next_break(break_obj, break_time)
        self._status = _('Next break at %s') % (
            Utility.format_time(break_time))
        if self.config.get('persist_state'):
            Utility.write_json(Utility.SESSION_FILE_PATH,
                               self.context['session'])