Skip to content

Commit

Permalink
rename methods/variables for gfile monitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
maoschanz committed Oct 17, 2023
1 parent c53c39d commit 910e65f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(self, window, **kwargs):

self.gfile = None
self.filename = None
self._waiting_for_monitor = False
self._monitoring_disabled = False
self._gfile_monitor = None
self._can_reload()

Expand Down Expand Up @@ -254,15 +254,15 @@ def _connect_gfile_monitoring(self):
self._gfile_monitor = self.gfile.monitor(flags)
self._gfile_monitor.connect('changed', self.reveal_reload_message)

def set_monitoring(self, value):
self._waiting_for_monitor = value
def lock_monitoring(self, value):
self._monitoring_disabled = value

def reveal_reload_message(self, *args):
if self._waiting_for_monitor:
if self._monitoring_disabled:
# I'm not sure this lock is 100% correct because i'm monitoring the
# portal proxy file when testing with flatpak. Better than nothing.
if args[3] != Gio.FileMonitorEvent.CHANGED:
self._waiting_for_monitor = False
self._monitoring_disabled = False
return
self._can_reload()
self.reload_label.set_visible(self.window.get_allocated_width() > 500)
Expand Down
6 changes: 3 additions & 3 deletions src/saving_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ def save_current_image(self, is_export, to_new, selection_only, allow_alpha):
self._window.reveal_message(_("Failed to replace transparency"))

# The "reload?" message shouldn't be shown, i force the reload later
image.set_monitoring(False)
image.lock_monitoring(False)

try:
# Actually save the pixbuf to the given file path
pixbuf.savev(file_path, file_format, [None], [])
except Exception as e:
image.set_monitoring(False)
image.lock_monitoring(False)
print(e)
# Context: an error message
self._window.reveal_message(_("Failed to save %s") % file_path)
return False

# Reset the file monitoring flag
image.set_monitoring(True)
image.lock_monitoring(True)

if not is_export:
# Update the image and the window objects
Expand Down

0 comments on commit 910e65f

Please sign in to comment.