Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=gi,
pyinotify,
setproctitle

# Add files or directories to the blacklist. They should be base names, not
Expand Down
1 change: 0 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ Depends:
python3-pam | python3-pampy,
python3-pexpect,
python3-pil,
python3-pyinotify,
python3-requests,
python3-setproctitle,
python3-tinycss2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import os
import signal
import sys
import pyinotify
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gio, Gtk, GObject, Gdk, GLib
Expand Down Expand Up @@ -224,22 +223,6 @@ def select_file(self):

return result

class FileWatchHandler(pyinotify.ProcessEvent):
def my_init(self, view):
self.view = view

def process_IN_CLOSE_WRITE(self, event):
self.view.get_updates()

def process_IN_CREATE(self, event):
self.view.get_updates()

def process_IN_DELETE(self, event):
self.view.get_updates()

def process_IN_MODIFY(self, event):
self.view.get_updates()

class FileWatcherView(Gtk.ScrolledWindow):
def __init__(self, filename):
Gtk.ScrolledWindow.__init__(self)
Expand All @@ -259,21 +242,18 @@ def __init__(self, filename):
self.show_all()
self.get_updates()

handler = FileWatchHandler(view=self)
watch_manager = pyinotify.WatchManager()
self.notifier = pyinotify.ThreadedNotifier(watch_manager, handler)
watch_manager.add_watch(filename, (pyinotify.IN_CLOSE_WRITE |
pyinotify.IN_CREATE |
pyinotify.IN_DELETE |
pyinotify.IN_MODIFY))
self.notifier.start()
self.monitor = Gio.File.new_for_path(filename).monitor_file(Gio.FileMonitorFlags.NONE, None)
self.monitor.connect("changed", self.on_file_changed)
self.connect("destroy", self.on_destroy)
self.connect("size-allocate", self.on_size_changed)

def on_file_changed(self, monitor, gfile, other_file, event_type):
self.get_updates()

def on_destroy(self, widget):
if self.notifier:
self.notifier.stop()
self.notifier = None
if self.monitor:
self.monitor.cancel()
self.monitor = None

def on_size_changed(self, widget, bla):
if self.changed > 0:
Expand Down
Loading