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:
parent
42b1355957
commit
e8a2d9c32a
@ -59,7 +59,7 @@
|
|||||||
</action>
|
</action>
|
||||||
<action>
|
<action>
|
||||||
<icon>document-open</icon>
|
<icon>document-open</icon>
|
||||||
<name>Open in DisposableVM</name>
|
<name>Edit in DisposableVM</name>
|
||||||
<unique-id>1507455559234996-8</unique-id>
|
<unique-id>1507455559234996-8</unique-id>
|
||||||
<command>/usr/lib/qubes/qvm-actions.sh opendvm %F</command>
|
<command>/usr/lib/qubes/qvm-actions.sh opendvm %F</command>
|
||||||
<description></description>
|
<description></description>
|
||||||
@ -70,3 +70,16 @@
|
|||||||
<text-files/>
|
<text-files/>
|
||||||
<video-files/>
|
<video-files/>
|
||||||
</action>
|
</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>
|
||||||
|
@ -45,6 +45,12 @@ case "$action" in
|
|||||||
qvm-open-in-dvm "$file" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 &
|
qvm-open-in-dvm "$file" | zenity --notification --text "Opening $file in DisposableVM..." --timeout 3 &
|
||||||
done
|
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..."
|
echo "Unknown action. Aborting..."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Actions=QvmDvm;
|
Actions=QvmDvm;QvmViewDvm
|
||||||
Type=Service
|
Type=Service
|
||||||
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,all/allfiles
|
X-KDE-ServiceTypes=KonqPopupMenu/Plugin,all/allfiles
|
||||||
|
|
||||||
[Desktop Action QvmDvm]
|
[Desktop Action QvmDvm]
|
||||||
Exec=/usr/bin/qvm-open-in-dvm %U
|
Exec=/usr/bin/qvm-open-in-dvm %U
|
||||||
Icon=kget
|
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
|
||||||
|
|
||||||
|
@ -17,15 +17,24 @@ class OpenInDvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
|
|||||||
if not files:
|
if not files:
|
||||||
return
|
return
|
||||||
|
|
||||||
menu_item = Nautilus.MenuItem(name='QubesMenuProvider::OpenInDvm',
|
menu_item1 = Nautilus.MenuItem(name='QubesMenuProvider::OpenInDvm',
|
||||||
label='Open In DisposableVM',
|
label='Edit In DisposableVM',
|
||||||
tip='',
|
tip='',
|
||||||
icon='')
|
icon='')
|
||||||
|
|
||||||
menu_item.connect('activate', self.on_menu_item_clicked, files)
|
menu_item1.connect('activate', self.on_menu_item_clicked, files)
|
||||||
return menu_item,
|
|
||||||
|
|
||||||
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.
|
'''Called when user chooses files though Nautilus context menu.
|
||||||
'''
|
'''
|
||||||
for file_obj in files:
|
for file_obj in files:
|
||||||
@ -38,6 +47,11 @@ class OpenInDvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
|
|||||||
|
|
||||||
# Use subprocess.DEVNULL in python >= 3.3
|
# Use subprocess.DEVNULL in python >= 3.3
|
||||||
devnull = open(os.devnull, 'wb')
|
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
|
# 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()
|
||||||
|
Loading…
Reference in New Issue
Block a user