Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion usr/lib/sticky/sticky.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import os
import signal
import sys

import gi
Expand Down Expand Up @@ -374,7 +375,7 @@ def restore(self, time=0):
self.move(self.x, self.y)

def queue_update(self, b=None, invalidate_cache=False):
self.invalid_cache = invalidate_cache
self.invalid_cache = self.invalid_cache or invalidate_cache

if self.changed_timer_id:
GLib.source_remove(self.changed_timer_id)
Expand Down Expand Up @@ -801,6 +802,10 @@ def do_activate(self):

self.hold()

GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM, self.quit_app)
GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGHUP, self.quit_app)
GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, self.quit_app)

if self.autostart_mode:
self.autostart_mode = False
if not self.settings.get_boolean("autostart-notes-visible"):
Expand Down Expand Up @@ -1259,7 +1264,19 @@ def on_removed(self, note):
self.notes.remove(note)
self.on_update()

def flush_pending_updates(self):
pending = False
for note in self.notes:
if note.changed_timer_id:
GLib.source_remove(note.changed_timer_id)
note.changed_timer_id = 0
pending = True

if pending:
self.on_update()

def quit_app(self, *args):
self.flush_pending_updates()
self.file_handler.flush()

for note in self.notes:
Expand Down