Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
facelessuser committed Jun 18, 2014
1 parent 9fb2e84 commit ddafc5a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ThemeScheduler.py
Expand Up @@ -172,6 +172,8 @@ def init(cls, set_safe=False):
"""
Initialize theme changer object
"""

cls.busy = True
cls.ready = False
cls.set_safe = set_safe

Expand All @@ -189,6 +191,7 @@ def init(cls, set_safe=False):
seconds, now = get_current_time()
cls.update_theme(seconds, now)
cls.ready = True
cls.busy = False

@classmethod
def update_next(cls, seconds, now):
Expand All @@ -200,7 +203,7 @@ def update_next(cls, seconds, now):
closest = None
lowest = None
for t in cls.themes:
if seconds <= t.time and (closest is None or t.time < closest.time):
if seconds < t.time and (closest is None or t.time < closest.time):
closest = t
if lowest is None or t.time < lowest.time:
lowest = t
Expand Down Expand Up @@ -263,6 +266,7 @@ def on_post_dialog(cls, seconds, now):
Maybe this can be removed in the future.
"""

cls.busy = True
update = True
last_next = cls.next_change
cls.update_next(seconds, now)
Expand All @@ -278,13 +282,15 @@ def on_post_dialog(cls, seconds, now):
if update:
debug_log("After dialog - Update needed.")
cls.update_current()
cls.busy = False

@classmethod
def on_change(cls, seconds, now):
"""
Change the theme and get the next time point to change themes.
"""

cls.busy = True
# Change the theme
if (
cls.next_change is not None and
Expand All @@ -303,6 +309,7 @@ def on_change(cls, seconds, now):
update = False

cls.update_theme(seconds, now, update)
cls.busy = False

@classmethod
def set_theme(cls, theme, ui_theme):
Expand Down Expand Up @@ -352,8 +359,6 @@ def apply_changes(cls, theme, msg, filters, ui_theme, command):
Update theme. Set the theme, then get the next one in line.
"""

cls.busy = True

debug_log(
"apply_changes(\n theme=%s\n msg=%s,\n filters=%s,\n ui_theme=%s,\n command=%s\n)" % (
theme, msg, filters, ui_theme, command
Expand Down Expand Up @@ -391,8 +396,6 @@ def apply_changes(cls, theme, msg, filters, ui_theme, command):
if msg is not None and isinstance(msg, str):
sublime.set_timeout(lambda m=msg: display_message(m), 3000)

cls.busy = False


def theme_loop():
"""
Expand All @@ -404,7 +407,8 @@ def is_update_time(seconds, now):
if (
not ThemeScheduler.busy and
ThemeScheduler.next_change is not None and
not ThemeScheduler.update
not ThemeScheduler.update and
ThemeScheduler.day is not None
):
update = (
(
Expand Down

0 comments on commit ddafc5a

Please sign in to comment.