qvm_move_nautilus.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import subprocess
  2. from gi.repository import Nautilus, GObject
  3. class MoveToAppvmItemExtension(GObject.GObject, Nautilus.MenuProvider):
  4. '''Move file(s) to AppVM.
  5. Uses the nautilus-python api to provide a context menu within Nautilus which
  6. will enable the user to select file(s) to to move to another AppVM
  7. '''
  8. def get_file_items(self, window, files):
  9. '''Attaches context menu in Nautilus
  10. '''
  11. if not files:
  12. return
  13. menu_item = Nautilus.MenuItem(name='QubesMenuProvider::MoveToAppvm',
  14. label='Move To Other AppVM...',
  15. tip='',
  16. icon='')
  17. menu_item.connect('activate', self.on_menu_item_clicked, files)
  18. return menu_item,
  19. def on_menu_item_clicked(self, menu, files):
  20. '''Called when user chooses files though Nautilus context menu.
  21. '''
  22. cmd = [file_obj.get_location().get_path()
  23. for file_obj in files
  24. # Check if file is not gone
  25. if not file_obj.is_gone()]
  26. cmd.insert(0, '/usr/lib/qubes/qvm-move-to-vm.gnome')
  27. subprocess.call(cmd)