/usr/share/gtk-doc/html/caja-python/caja-python-overview-example.html is in python-caja-common 1.12.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>A Simple Extension</title><link rel="stylesheet" type="text/css" href="style.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="caja-python Reference Manual"><link rel="up" href="caja-python-overview.html" title="Overview"><link rel="prev" href="caja-python-overview.html" title="Overview"><link rel="next" href="caja-python-overview-methods.html" title="Explanation of Passive/Active Methods"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">A Simple Extension</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="caja-python-overview.html">Prev</a> </td><th width="60%" align="center">Overview</th><td width="20%" align="right"> <a accesskey="n" href="caja-python-overview-methods.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="caja-python-overview-example"></a>A Simple Extension</h2></div></div></div><p>Create an empty file with the following code:</p><div class="example"><a name="idp44740592"></a><p class="title"><b>Example 1. A Simple Extension</b></p><div class="example-contents"><pre class="programlisting">
from gi.repository import Caja, GObject
class ColumnExtension(GObject.GObject, Caja.MenuProvider):
def __init__(self):
pass
def menu_activate_cb(self, menu, file):
print "menu_activate_cb",file
def get_file_items(self, window, files):
if len(files) != 1:
return
file = files[0]
item = Caja.MenuItem(
name="SimpleMenuExtension::Show_File_Name",
label="Showing %s" % file.get_name(),
tip="Showing %s" % file.get_name()
)
item.connect('activate', self.menu_activate_cb, file)
return [item]</pre></div></div><br class="example-break"><p>Save this file as TestExtension.py in the ~/.local/share/caja-python/extensions folder.
You may need to create this folder. To run, simply restart Caja.</p><p>Once Caja restarts, right-click on a file and you should see a new menu item,
"Showing #filename#". It is as simple as that!</p><p>As mentioned above, in order to
get loaded by Caja, a python extension must import the Caja module from gi.repository,
create a class derived from a caja *Provider and a gobject.GObject, and create the methods that
will be called by Caja when it requests information from its providers.
In this case, when someone right-clicks on a file, Caja will ask all of its
MenuProviders for additional menu items to show the user. When folders or files are clicked,
the get_file_items method is called and a list of Caja.MenuItems is expected.</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="caja-python-overview.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="caja-python-overview.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="caja-python-overview-methods.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Overview </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Explanation of Passive/Active Methods</td></tr></table></div></body></html>
|