Add file managers integration for qvm-open-in-dvm --view-only

Rename existing entry from 'Open In DisposableVM' to 'Edit in
DisposableVM', then add new 'View In DisposableVM'.

Fixes QubesOS/qubes-issues#1118
This commit is contained in:
Marek Marczykowski-Górecki 2018-05-26 02:50:55 +02:00
parent 42b1355957
commit e8a2d9c32a
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
4 changed files with 47 additions and 9 deletions

View File

@ -59,7 +59,7 @@
</action>
<action>
<icon>document-open</icon>
<name>Open in DisposableVM</name>
<name>Edit in DisposableVM</name>
<unique-id>1507455559234996-8</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh opendvm %F</command>
<description></description>
@ -70,3 +70,16 @@
<text-files/>
<video-files/>
</action>
<action>
<icon>document-open</icon>
<name>View in DisposableVM</name>
<unique-id>1507455559234997-9</unique-id>
<command>/usr/lib/qubes/qvm-actions.sh viewdvm %F</command>
<description></description>
<patterns>*</patterns>
<audio-files/>
<image-files/>
<other-files/>
<text-files/>
<video-files/>
</action>

View File

@ -45,6 +45,12 @@ case "$action" in
qvm-open-in-dvm "$file" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 &
done
;;
viewdvm)
for file in "$@"
do
qvm-open-in-dvm --view-only "$file" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 &
done
;;
*)
echo "Unknown action. Aborting..."
exit 1

View File

@ -1,10 +1,15 @@
[Desktop Entry]
Actions=QvmDvm;
Actions=QvmDvm;QvmViewDvm
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,all/allfiles
[Desktop Action QvmDvm]
Exec=/usr/bin/qvm-open-in-dvm %U
Icon=kget
Name=Open In DisposableVM
Name=Edit In DisposableVM
[Desktop Action QvmViewDvm]
Exec=/usr/bin/qvm-open-in-dvm --view-only %U
Icon=kget
Name=View In DisposableVM

View File

@ -17,15 +17,24 @@ class OpenInDvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
if not files:
return
menu_item = Nautilus.MenuItem(name='QubesMenuProvider::OpenInDvm',
label='Open In DisposableVM',
menu_item1 = Nautilus.MenuItem(name='QubesMenuProvider::OpenInDvm',
label='Edit In DisposableVM',
tip='',
icon='')
menu_item.connect('activate', self.on_menu_item_clicked, files)
return menu_item,
menu_item1.connect('activate', self.on_menu_item_clicked, files)
def on_menu_item_clicked(self, menu, files):
menu_item2 = Nautilus.MenuItem(name='QubesMenuProvider::ViewInDvm',
label='View In DisposableVM',
tip='',
icon='')
menu_item2.connect('activate',
self.on_menu_item_clicked,
files, True)
return menu_item1, menu_item2,
def on_menu_item_clicked(self, menu, files, view_only=False):
'''Called when user chooses files though Nautilus context menu.
'''
for file_obj in files:
@ -38,6 +47,11 @@ class OpenInDvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
# Use subprocess.DEVNULL in python >= 3.3
devnull = open(os.devnull, 'wb')
command = ['nohup', '/usr/bin/qvm-open-in-dvm']
if view_only:
command.append('--view-only')
command.append(gio_file.get_path())
# Use Popen instead of subprocess.call to spawn the process
Popen(['nohup', '/usr/bin/qvm-open-in-dvm', gio_file.get_path()], stdout=devnull, stderr=devnull)
Popen(command, stdout=devnull, stderr=devnull)
devnull.close()