Skip to content

Commit

Permalink
qubes-rpc/nautilus: Add support for Nautilus API 4.0
Browse files Browse the repository at this point in the history
The get_file_items method of Nautilus.MenuProvider no longer take the window argument.

https://gnome.pages.gitlab.gnome.org/nautilus-python/nautilus-python-migrating-to-4.html

Fixes: QubesOS/qubes-issues#7916
  • Loading branch information
noskb committed Nov 27, 2022
1 parent 45a7af9 commit 78c0968
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 6 additions & 2 deletions qubes-rpc/nautilus/qvm_copy_nautilus.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ class CopyToAppvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
Uses the nautilus-python api to provide a context menu with Nautilus which
will enable the user to select file(s) to to copy to another AppVM
'''
def get_file_items(self, window, files):
def get_file_items(self, *args):
'''Attaches context menu in Nautilus
`args` will be `[files: List[Nautilus.FileInfo]]` in Nautilus 4.0 API,
and `[window: Gtk.Widget, files: List[Nautilus.FileInfo]]` in Nautilus 3.0 API.
'''
files = args[-1]
if not files:
return

Expand All @@ -31,4 +35,4 @@ def on_menu_item_clicked(self, menu, files):
# Check if file is not gone
if not file_obj.is_gone()]
cmd.insert(0, '/usr/lib/qubes/qvm-copy-to-vm.gnome')
subprocess.call(cmd)
subprocess.Popen(cmd, shell=False)
6 changes: 5 additions & 1 deletion qubes-rpc/nautilus/qvm_dvm_nautilus.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ class OpenInDvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
will enable the user to select file(s) to to open in a disposableVM
'''

def get_file_items(self, window, files):
def get_file_items(self, *args):
'''Attaches context menu in Nautilus
`args` will be `[files: List[Nautilus.FileInfo]]` in Nautilus 4.0 API,
and `[window: Gtk.Widget, files: List[Nautilus.FileInfo]]` in Nautilus 3.0 API.
'''
files = args[-1]
if not files:
return

Expand Down
8 changes: 6 additions & 2 deletions qubes-rpc/nautilus/qvm_move_nautilus.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ class MoveToAppvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
Uses the nautilus-python api to provide a context menu within Nautilus which
will enable the user to select file(s) to to move to another AppVM
'''
def get_file_items(self, window, files):
def get_file_items(self, *args):
'''Attaches context menu in Nautilus
`args` will be `[files: List[Nautilus.FileInfo]]` in Nautilus 4.0 API,
and `[window: Gtk.Widget, files: List[Nautilus.FileInfo]]` in Nautilus 3.0 API.
'''
files = args[-1]
if not files:
return

Expand All @@ -31,4 +35,4 @@ def on_menu_item_clicked(self, menu, files):
# Check if file is not gone
if not file_obj.is_gone()]
cmd.insert(0, '/usr/lib/qubes/qvm-move-to-vm.gnome')
subprocess.call(cmd)
subprocess.Popen(cmd)

0 comments on commit 78c0968

Please sign in to comment.