[nautilus-python] Update examples and documentation to recommend always implementing get_backround-items, to avoid war
- From: Adam Plumb <adamplumb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-python] Update examples and documentation to recommend always implementing get_backround-items, to avoid war
- Date: Thu, 7 Dec 2017 00:14:43 +0000 (UTC)
commit 0759bbe7595e4ce2966a3d47734626b2a42044a5
Author: Adam Plumb <adamplumb gmail com>
Date: Wed Dec 6 19:14:31 2017 -0500
Update examples and documentation to recommend always implementing get_backround-items, to avoid warnings
docs/reference/entities.docbook | 1 +
.../reference/nautilus-python-overview-example.xml | 7 ++++++-
examples/background-image.py | 5 +++++
examples/open-terminal.py | 10 ++++++----
4 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/docs/reference/entities.docbook b/docs/reference/entities.docbook
new file mode 100644
index 0000000..d5bd714
--- /dev/null
+++ b/docs/reference/entities.docbook
@@ -0,0 +1 @@
+<!ENTITY version "1.1">
diff --git a/docs/reference/nautilus-python-overview-example.xml
b/docs/reference/nautilus-python-overview-example.xml
index c2908eb..2efa71f 100644
--- a/docs/reference/nautilus-python-overview-example.xml
+++ b/docs/reference/nautilus-python-overview-example.xml
@@ -33,7 +33,12 @@ class ColumnExtension(GObject.GObject, Nautilus.MenuProvider):
)
item.connect('activate', self.menu_activate_cb, file)
- return [item]</programlisting>
+ return [item]
+
+ # Even though we're not using background items, Nautilus will generate
+ # a warning if the method isn't present
+ def get_background_items(self, window, file):
+ return None</programlisting>
</example>
<para>Save this file as TestExtension.py in the ~/.local/share/nautilus-python/extensions folder.
diff --git a/examples/background-image.py b/examples/background-image.py
index 535ec8d..f5fca3c 100644
--- a/examples/background-image.py
+++ b/examples/background-image.py
@@ -34,3 +34,8 @@ class BackgroundImageExtension(GObject.GObject, Nautilus.MenuProvider):
tip='Set the current image as a background image')
item.connect('activate', self.menu_activate_cb, file)
return item,
+
+ # Current versions of Nautilus will throw a warning if get_background_items
+ # isn't present
+ def get_background_items(self, window, file):
+ return None
diff --git a/examples/open-terminal.py b/examples/open-terminal.py
index 7c70844..448bc94 100644
--- a/examples/open-terminal.py
+++ b/examples/open-terminal.py
@@ -2,6 +2,8 @@
import os
import urllib
+import gi
+gi.require_version('GConf', '2.0')
from gi.repository import Nautilus, GObject, GConf
TERMINAL_KEY = '/desktop/gnome/applications/terminal/exec'
@@ -32,14 +34,14 @@ class OpenTerminalExtension(Nautilus.MenuProvider, GObject.GObject):
return
item = Nautilus.MenuItem(name='NautilusPython::openterminal_file_item',
- label='Open Terminal' ,
+ label='Open Terminal 2' ,
tip='Open Terminal In %s' % file.get_name())
item.connect('activate', self.menu_activate_cb, file)
return item,
def get_background_items(self, window, file):
- item = Nautilus.MenuItem(name='NautilusPython::openterminal_item',
- label='Open Terminal Here',
- tip='Open Terminal In This Directory')
+ item = Nautilus.MenuItem(name='NautilusPython::openterminal_file_item2',
+ label='Open Terminal BG' ,
+ tip='Open Terminal In %s' % file.get_name())
item.connect('activate', self.menu_background_activate_cb, file)
return item,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]