#!/usr/bin/python # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Library General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Copyright 2007 Red Hat Inc, # Written by Seth Vidal - skvidal @ fedoraproject.org gtdomain = "pybackpack" localedir = "/usr/share/locale" import gettext gettext.install(gtdomain, localedir, unicode=True) # display list of backup sets to send selected files to # iterate over selected files, add them to filelist import nautilus import urllib import pybackpack import pybackpack.rdiff_interface as rdiff_interface class PyBackPackAdd(nautilus.MenuProvider): def __init__(self): pass def get_file_items(self, window, files): rdiff_interface.FindSets() self._backup_sets = rdiff_interface.backupsets items = [] for bset in self._backup_sets: if bset['name'] == 'home': continue name = 'Nautilus::add_to_backup_%s' % bset['name'] label = 'Add to backup %s' % bset['name'] tip = "Add current file(s) to backup set %s" % bset['name'] item = nautilus.MenuItem(name, label, tip) item.connect('activate', self.menu_activate_cb, files, bset) items.append(item) return items def menu_activate_cb(self, menu, files, backup): real_files = [] for file in files: if file.is_gone(): continue if file.get_uri_scheme() != 'file': continue filename = urllib.unquote(file.get_uri()[7:]) if filename in backup['filelist_inc']: continue real_files.append(filename) total_files = backup['filelist_inc'] + real_files total_files.sort() flist = [] for file in total_files: flist.append((file, True)) extrakeys = {'default_dest':backup['default_dest'], 'removable':backup['removable']} rdiff_interface.WriteSet(backup['name'], backup['desc'], flist, True, extrakeys)