Debian Codegraph @

sendto/blueman_sendto.py.in

raw
1 from gi.repository import @FILEMANAGER@, GObject, Gio
2
3
4 # noinspection PyMissingConstructor
5 class BluemanSendtoExtension(GObject.GObject, @[email protected]):
6 def __init__(self):
7 pass
8
9 def on_menu_activate(self, menu, files):
10 send_files = []
11
12 for f in files:
13 if f.is_directory():
14 print("Skipping directory")
15 continue
16 elif f.is_gone():
17 print("Skipping none existing file")
18 continue
19
20 gfile = f.get_location()
21 send_files.append("\"%s\"" % gfile.get_path())
22
23 if len(send_files) == 0:
24 return
25 else:
26 cmd = "blueman-sendto %s" % " ".join(send_files)
27 flags = Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION
28 appinfo = Gio.AppInfo.create_from_commandline(cmd, "blueman-sendto", flags)
29 print("Running: %s" % cmd)
30
31 launched = appinfo.launch()
32 if not launched:
33 print("*** Failed to launch program ***")
34
35 def get_file_items(self, *args):
36 files = args[-1]
37
38 if len(files) == 0:
39 return
40
41 # We do not support sending whole directories
42 for f in files:
43 if f.is_directory():
44 return
45
46 item = @[email protected](
47 name='BluemanSendto::blueman_send_files',
48 label='Send files over bluetooth',
49 tip='Sends files over bluetooth with blueman',
50 icon='blueman'
51 )
52
53 item.connect('activate', self.on_menu_activate, files)
54
55 return [item]
56
57 # stub to avoid potential warning (nautilus throws fit)
58 def get_background_items(self, *args):
59 return []