[Pkg-privacy-commits] [onionshare] 18/55: Added a simple nautilus extension, written by the Subgraph developers (fixes #293)

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Sep 8 10:26:45 UTC 2016


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to branch debian
in repository onionshare.

commit 57dd6db1664c6f7c8cd4cfb45bd6cc9e67114a0c
Author: Micah Lee <micah at micahflee.com>
Date:   Fri Jun 10 17:56:34 2016 -0700

    Added a simple nautilus extension, written by the Subgraph developers (fixes #293)
---
 MANIFEST.in                            |  1 +
 install/scripts/onionshare-nautilus.py | 46 ++++++++++++++++++++++++++++++++++
 setup.py                               |  3 ++-
 3 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index f3b104e..64eca8f 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -8,3 +8,4 @@ include resources/html/*
 include install/onionshare.desktop
 include install/onionshare.appdata.xml
 include install/onionshare80.xpm
+include install/scripts/onionshare-nautilus.py
diff --git a/install/scripts/onionshare-nautilus.py b/install/scripts/onionshare-nautilus.py
new file mode 100644
index 0000000..db701c4
--- /dev/null
+++ b/install/scripts/onionshare-nautilus.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+import os
+import subprocess
+import urllib
+import gi
+gi.require_version('Nautilus', '3.0')
+
+from gi.repository import Nautilus
+from gi.repository import GObject
+
+# Put me in /usr/share/nautilus-python/extensions/
+class OnionShareExtension(GObject.GObject, Nautilus.MenuProvider):
+    def __init__(self):
+        pass
+
+    def url2path(self,url):
+	file_uri = url.get_activation_uri()
+        arg_uri = file_uri[7:]
+        path = urllib.url2pathname(arg_uri)
+        return path
+
+    def exec_onionshare(self, filenames):
+# Would prefer this method but there is a conflict between GTK 2.0 vs GTK 3.0 components being loaded at once
+# (nautilus:3090): Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported
+#        sys.argv = ["", "--filenames"] + filenames
+#        sys.exit(onionshare_gui.main())
+        path = os.path.join(os.sep, 'usr', 'bin', 'onionshare-gui')
+        cmd = [path, "--filenames"] + filenames
+        subprocess.Popen(cmd)
+
+    def get_file_items(self, window, files):
+        menuitem = Nautilus.MenuItem(name='OnionShare::Nautilus',
+                                         label='Share via OnionShare',
+                                         tip='',
+                                         icon='')
+        menu = Nautilus.Menu()
+        menu.append_item(menuitem)
+        menuitem.connect("activate", self.menu_activate_cb, files)
+        return menuitem,
+
+    def menu_activate_cb(self, menu, files):
+        file_list = []
+        for file in files:
+            file_list.append(self.url2path(file))
+        self.exec_onionshare(file_list)
diff --git a/setup.py b/setup.py
index 8ae56fe..95273dd 100644
--- a/setup.py
+++ b/setup.py
@@ -100,6 +100,7 @@ setup(
         ]),
         (os.path.join(sys.prefix, 'share/onionshare/images'), images),
         (os.path.join(sys.prefix, 'share/onionshare/locale'), locale),
-        (os.path.join(sys.prefix, 'share/onionshare/html'), html)
+        (os.path.join(sys.prefix, 'share/onionshare/html'), html),
+        ('/usr/share/nautilus-python/extensions/', ['install/scripts/onionshare-nautilus.py']),
     ]
 )

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list