1
'''NitroShare - A simple network file sharing tool.
2
Copyright (C) 2012 Nathan Osman
4
This program is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program. If not, see <http://www.gnu.org/licenses/>.'''
17
from xmlrpclib import ServerProxy, Fault
18
from gi.repository import Nautilus, GObject
20
class NitroShare(GObject.GObject, Nautilus.MenuProvider):
23
# Initialize our RPC connection to NitroShare
24
self.rpc = ServerProxy('http://localhost:41722')
26
def send_files(self, menu, files):
27
# Get the URIs for each of the files and send them to NitroShare
28
filename_list = [x.get_uri() for x in files]
29
self.rpc.SendFiles(filename_list)
31
def get_file_items(self, window, files):
32
# If no files were provided, we don't show anything
36
# Determine the caption to display for the menu item
37
caption = "Send item%s with NitroShare" % ('' if len(files) == 1 else 's')
39
# Create the menu item
40
item = Nautilus.MenuItem(name="NitroShare::SendFiles",
44
# Connect the menu item to our handler and return the item
45
item.connect('activate', self.send_files, files)