[Xfce4-commits] <thunarx-python:master> Added documentation for the renamer, renamer provider, and preferences provider interfaces. Minor tweaks and updates to other documentation.

Adam Plumb noreply at xfce.org
Tue Dec 14 20:06:01 CET 2010


Updating branch refs/heads/master
         to 50767d2c162e7b38a51d46ce88781ab9a8610e28 (commit)
       from 861b17ad95b82c73278e08182c0c48b1bdce81fb (commit)

commit 50767d2c162e7b38a51d46ce88781ab9a8610e28
Author: Adam Plumb <adamplumb at gmail.com>
Date:   Tue Dec 14 13:46:41 2010 -0500

    Added documentation for the renamer, renamer provider, and preferences provider interfaces.  Minor tweaks and updates to other documentation.

 INSTALL                                            |   97 ++++-
 docs/Makefile.am                                   |    6 +
 docs/reference/thunarx-python-class-reference.xml  |    1 +
 docs/reference/thunarx-python-file-info.xml        |   64 ++++-
 docs/reference/thunarx-python-menu-provider.xml    |   89 +++++
 .../thunarx-python-preferences-provider.xml        |  105 ++++++
 .../thunarx-python-property-page-provider.xml      |   50 +++-
 .../thunarx-python-provider-reference.xml          |    2 +
 docs/reference/thunarx-python-renamer-provider.xml |  142 ++++++++
 docs/reference/thunarx-python-renamer.xml          |  382 ++++++++++++++++++++
 10 files changed, 918 insertions(+), 20 deletions(-)

diff --git a/INSTALL b/INSTALL
index 2550dab..7d1c323 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,8 +4,10 @@ Installation Instructions
 Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
-   This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
+   Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.  This file is offered as-is,
+without warranty of any kind.
 
 Basic Installation
 ==================
@@ -13,7 +15,11 @@ Basic Installation
    Briefly, the shell commands `./configure; make; make install' should
 configure, build, and install this package.  The following
 more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
+instructions specific to this package.  Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below.  The lack of an optional feature in a given package is not
+necessarily a bug.  More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
 
    The `configure' shell script attempts to guess correct values for
 various system-dependent variables used during compilation.  It uses
@@ -42,7 +48,7 @@ may remove or edit it.
 you want to change it or regenerate `configure' using a newer version
 of `autoconf'.
 
-The simplest way to compile this package is:
+   The simplest way to compile this package is:
 
   1. `cd' to the directory containing the package's source code and type
      `./configure' to configure the package for your system.
@@ -53,12 +59,22 @@ The simplest way to compile this package is:
   2. Type `make' to compile the package.
 
   3. Optionally, type `make check' to run any self-tests that come with
-     the package.
+     the package, generally using the just-built uninstalled binaries.
 
   4. Type `make install' to install the programs and any data files and
-     documentation.
-
-  5. You can remove the program binaries and object files from the
+     documentation.  When installing into a prefix owned by root, it is
+     recommended that the package be configured and built as a regular
+     user, and only the `make install' phase executed with root
+     privileges.
+
+  5. Optionally, type `make installcheck' to repeat any self-tests, but
+     this time using the binaries in their final installed location.
+     This target does not install anything.  Running this target as a
+     regular user, particularly if the prior `make install' required
+     root privileges, verifies that the installation completed
+     correctly.
+
+  6. You can remove the program binaries and object files from the
      source code directory by typing `make clean'.  To also remove the
      files that `configure' created (so you can compile the package for
      a different kind of computer), type `make distclean'.  There is
@@ -67,8 +83,15 @@ The simplest way to compile this package is:
      all sorts of other programs in order to regenerate files that came
      with the distribution.
 
-  6. Often, you can also type `make uninstall' to remove the installed
-     files again.
+  7. Often, you can also type `make uninstall' to remove the installed
+     files again.  In practice, not all packages have tested that
+     uninstallation works correctly, even though it is required by the
+     GNU Coding Standards.
+
+  8. Some packages, particularly those that use Automake, provide `make
+     distcheck', which can by used by developers to test that all other
+     targets like `make install' and `make uninstall' work correctly.
+     This target is generally not run by end users.
 
 Compilers and Options
 =====================
@@ -93,7 +116,8 @@ same time, by placing the object files for each architecture in their
 own directory.  To do this, you can use GNU `make'.  `cd' to the
 directory where you want the object files and executables to go and run
 the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
+source code in the directory that `configure' is in and in `..'.  This
+is known as a "VPATH" build.
 
    With a non-GNU `make', it is safer to compile the package for one
 architecture at a time in the source code directory.  After you have
@@ -120,7 +144,8 @@ Installation Names
    By default, `make install' installs the package's commands under
 `/usr/local/bin', include files under `/usr/local/include', etc.  You
 can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
 
    You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files.  If you
@@ -131,15 +156,46 @@ Documentation and other data files still use the regular prefix.
    In addition, if you use an unusual directory layout you can give
 options like `--bindir=DIR' to specify different values for particular
 kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
+you can set and what kinds of files go in them.  In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+   The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+   The first method involves providing an override variable for each
+affected directory.  For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'.  Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated.  The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+   The second method involves providing the `DESTDIR' variable.  For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names.  The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters.  On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
 
    If the package supports it, you can cause programs to be installed
 with an extra prefix or suffix on their names by giving `configure' the
 option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
 
-Optional Features
-=================
-
    Some packages pay attention to `--enable-FEATURE' options to
 `configure', where FEATURE indicates an optional part of the package.
 They may also pay attention to `--with-PACKAGE' options, where PACKAGE
@@ -152,6 +208,13 @@ find the X include and library files automatically, but if it doesn't,
 you can use the `configure' options `--x-includes=DIR' and
 `--x-libraries=DIR' to specify their locations.
 
+   Some packages offer the ability to configure how verbose the
+execution of `make' will be.  For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
 Particular systems
 ==================
 
@@ -288,7 +351,7 @@ operates.
      `configure' can determine that directory automatically.
 
 `--prefix=DIR'
-     Use DIR as the installation prefix.  *Note Installation Names::
+     Use DIR as the installation prefix.  *note Installation Names::
      for more details, including other options available for fine-tuning
      the installation locations.
 
diff --git a/docs/Makefile.am b/docs/Makefile.am
index ebe7c86..4f33773 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -18,6 +18,9 @@ XMLFILES = 							\
 	reference/thunarx-python-menu-provider.xml \
 	reference/thunarx-python-property-page.xml \
 	reference/thunarx-python-property-page-provider.xml \
+	reference/thunarx-python-renamer.xml \
+	reference/thunarx-python-renamer-provider.xml \
+	reference/thunarx-python-preferences-provider.xml \
 	reference/thunarx-python-file-info.xml
 
 HTMLdir = $(datadir)/gtk-doc/html/thunarx-python
@@ -31,6 +34,9 @@ HTML_DATA =						\
 	html/class-thunarx-python-menu-provider.html  \
 	html/class-thunarx-python-property-page.html  \
 	html/class-thunarx-python-property-page-provider.html  \
+	html/class-thunarx-python-renamer.html  \
+	html/class-thunarx-python-renamer-provider.html  \
+	html/class-thunarx-python-preferences-provider.html  \
 	html/class-thunarx-python-file-info.html  \
 	html/thunarx-python.devhelp
 
diff --git a/docs/reference/thunarx-python-class-reference.xml b/docs/reference/thunarx-python-class-reference.xml
index 9e52f6f..eeb8e22 100644
--- a/docs/reference/thunarx-python-class-reference.xml
+++ b/docs/reference/thunarx-python-class-reference.xml
@@ -7,5 +7,6 @@
     <title>Available Classes</title>
     <xi:include href="thunarx-python-file-info.xml"/>
     <xi:include href="thunarx-python-property-page.xml"/>
+    <xi:include href="thunarx-python-renamer.xml"/>
 </chapter>
 
diff --git a/docs/reference/thunarx-python-file-info.xml b/docs/reference/thunarx-python-file-info.xml
index 2caaee5..609b21c 100644
--- a/docs/reference/thunarx-python-file-info.xml
+++ b/docs/reference/thunarx-python-file-info.xml
@@ -109,6 +109,31 @@
   </refsect1>
 
 
+<!-- ****************************************** -->
+<!-- BEGIN OF SIGNAL PROTOTYPES -->
+<!-- ****************************************** -->
+
+<refsect1>
+    <title>Signals</title>
+    <variablelist>
+      <varlistentry>
+        <term><link linkend="signal-thunarx-python-file-info--changed">"changed"</link></term>
+        <listitem>
+          <methodsynopsis language="python"><methodname>callback</methodname>
+          </methodsynopsis>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><link linkend="signal-thunarx-python-file-info--renamed">"renamed"</link></term>
+        <listitem>
+          <methodsynopsis language="python"><methodname>callback</methodname>
+          </methodsynopsis>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+</refsect1>
+
+
 <!-- ******************************** -->
 <!-- BEGIN OF METHODS -->
 <!-- ******************************** -->
@@ -182,12 +207,16 @@
     </refsect2>
 
     <refsect2 id="method-thunarx-python-file-info--has-mime-type">
-        <title>thunarx.FileInfo.get_mime_type</title>
+        <title>thunarx.FileInfo.has_mime_type</title>
         <programlisting><methodsynopsis language="python">
-            <methodname>get_mime_type</methodname>
+            <methodname>has_mime_type</methodname>
         </methodsynopsis></programlisting>
         <variablelist>
             <varlistentry>
+	            <term><parameter role="keyword">mime_type</parameter> :</term>
+	            <listitem><simpara>the mime_type to check for</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
                 <term><emphasis>Returns</emphasis> :</term>
                 <listitem><simpara>
 Checks whether file_info is of the given mime_type or whether the MIME-type of file_info is a subclass of mime_type.
@@ -285,5 +314,36 @@ The plugins should instead connect to the ::renamed signal and update it's inter
 </refsect1>
 
 
+
+<!-- ******************************** -->
+<!-- BEGIN OF SIGNAL DETAILS -->
+<!-- ******************************** --> 
+ 
+<refsect1>
+    <title>Signal Details</title>
+
+  <refsect2 id="signal-thunarx-python-file-info--changed">
+    <title>The "changed" thunarx.FileInfo Signal</title>
+
+    <para>
+Emitted whenever the system notices a change to file_info.
+</para><para>
+Thunar plugins should use this signal to stay informed about changes to a file_info for which they currently display information (i.e. in a thunarx.PropertyPage), and update it's user interface whenever a change is noticed on file_info.
+    </para>
+
+  </refsect2>
+  
+  <refsect2 id="signal-thunarx-python-file-info--renamed">
+    <title>The "renamed" thunarx.FileInfo Signal</title>
+
+    <para>
+Emitted when the file_info is renamed to another name.
+</para><para>
+For example, within Thunar, ThunarFolder uses this signal to reregister it's VFS directory monitor, after the corresponding file was renamed.
+    </para>
+
+  </refsect2>
+</refsect1>
+
 </refentry>
 
diff --git a/docs/reference/thunarx-python-menu-provider.xml b/docs/reference/thunarx-python-menu-provider.xml
index e031c1f..6562226 100644
--- a/docs/reference/thunarx-python-menu-provider.xml
+++ b/docs/reference/thunarx-python-menu-provider.xml
@@ -51,6 +51,95 @@
       </para>        
   </refsect1>
 
+
+<example>
+    <title>A thunarx.MenuProvider plugin (without submenus)</title>
+    <programlisting>
+import thunarx
+import gtk
+
+class ThunarxMenuProviderPlugin(thunarx.MenuProvider):
+    def __init__(self):
+        pass
+    
+    def get_file_actions(self, window, files):
+        return [gtk.Action("TMP:TestFileAction", "PyFileAction", "Python File Action", gtk.STOCK_FILE)]
+    
+    def get_folder_actions(self, window, folder):
+        return [gtk.Action("TMP:TestFolderAction", "PyFolderAction", "Python Folder Action", gtk.STOCK_DIRECTORY)]
+    </programlisting>
+</example>
+
+<example>
+    <title>A thunarx.MenuProvider plugin (with submenus)</title>
+    <programlisting>
+import thunarx
+import gtk
+
+"""
+Thunarx Submenu Plugin
+    This plugin shows an example of a MenuProvider plugin that implements
+    sub-menus.    The example used here requires the developer to sub-class 
+    gtk.Action and override the create_menu_item virtual method.
+    
+"""
+
+class MyAction(gtk.Action):
+    __gtype_name__ = "MyAction"
+    
+    def __init__(self, name, label, tooltip=None, stock_id=None, menu_handler=None):
+        gtk.Action.__init__(self, name, label, tooltip, stock_id)
+        self.menu_handler = menu_handler
+
+    def create_menu_item(self):
+        menuitem = gtk.MenuItem(self.get_label())
+        
+        if self.menu_handler is not None:
+            menu = gtk.Menu()
+            menuitem.set_submenu(menu)
+            self.menu_handler(menu)
+        
+        return menuitem
+
+    do_create_menu_item = create_menu_item
+
+def PyFileActionMenu(menu):
+    action = gtk.Action("TMP:Submenuitem1", "Submenuitem 1", None, None)
+    subitem = action.create_menu_item()
+    menu.append(subitem)
+    subitem.show()
+
+    action = MyAction("TMP:Submenuitem2", "Submenuitem 2", None, None, menu_handler=PyFileActionSubmenu)
+    subitem = action.create_menu_item()
+    menu.append(subitem)
+    subitem.show()
+
+def PyFileActionSubmenu(menu):
+    action = gtk.Action("TMP:SubSubmenuitem1", "Subsubmenuitem 1", None, None)
+    subitem = action.create_menu_item()
+    menu.append(subitem)
+    subitem.show()
+
+    action = gtk.Action("TMP:SubSubmenuitem2", "Subsubmenuitem 2", None, None)
+    subitem = action.create_menu_item()
+    menu.append(subitem)
+    subitem.show()
+
+class ThunarxSubMenuProviderPlugin(thunarx.MenuProvider):
+    def __init__(self):
+        pass
+    
+    def get_file_actions(self, window, files):
+        return [MyAction("TMP:TestFileAction", "PyFileAction", "Python File Action", 
+            gtk.STOCK_FILE, menu_handler=PyFileActionMenu)]
+    
+    def get_folder_actions(self, window, folder):
+        return [MyAction("TMP:TestFolderAction", "PyFolderAction", 
+            "Python Folder Action", gtk.STOCK_DIRECTORY)]
+    </programlisting>
+</example>
+
+
 <!-- ****************************** -->
 <!-- BEGIN OF METHODS -->
 <!-- ****************************** -->
diff --git a/docs/reference/thunarx-python-preferences-provider.xml b/docs/reference/thunarx-python-preferences-provider.xml
new file mode 100644
index 0000000..416b4f3
--- /dev/null
+++ b/docs/reference/thunarx-python-preferences-provider.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+
+<refentry id="class-thunarx-python-preferences-provider">
+  <refnamediv>
+    <refname>thunarx.PreferencesProvider</refname>
+    <refpurpose>thunarx.PreferencesProvider Reference</refpurpose>
+  </refnamediv>
+
+<!-- ******************************* -->
+<!-- BEGIN OF SYNOPSIS -->
+<!-- ******************************* -->
+
+  <refsect1>
+    <title>Synopsis</title>
+
+    <classsynopsis language="python">
+      <ooclass><classname>thunarx.PreferencesProvider</classname></ooclass>
+
+      <methodsynopsis language="python">
+        <methodname><link linkend="method-thunarx-preferences-provider--get-actions">get_actions</link></methodname>
+        <methodparam><parameter role="keyword">window</parameter></methodparam>
+      </methodsynopsis>
+    </classsynopsis>
+  </refsect1>
+
+<!-- ********************************** -->
+<!-- BEGIN OF DESCRIPTION -->
+<!-- ********************************** -->
+
+  <refsect1 id="description-preferences-provider">
+    <title>Description</title>
+
+      <para>
+The thunarx.PreferencesProvider interface is implemented by extensions that want to register additional actions in the preferences menu of the file manager. In general this should only be done by extensions that are closely tied to the file manager (for example, the thunar-uca is such an extension, while an extension that just adds Compress file and Uncompress file to the context menu of compressed files should not add their own preferences to the file manager menu, because it should use desktop-wide settings for archive managers instead).
+</para><para>
+The gtk.Action objects returned from the thunarx.PreferencesProvider.get_actions() method must be namespaced with the model to avoid collision with internal file manager actions and actions provided by other extensions. For example, the preferences action provided by the thunar-uca extension is called ThunarUca::manage-actions.
+      </para>
+  </refsect1>
+
+<example>
+    <title>A thunarx.PreferencesProvider plugin</title>
+    <programlisting>
+import thunarx
+import gtk
+
+class ThunarxPreferencesPlugin(thunarx.PreferencesProvider):
+    def __init__(self):
+        pass
+    
+    def get_preferences_actions(self, window):
+        action = gtk.Action("TPP:PrefItem", "My Example Preferences", None, None)
+        action.connect("activate", self.__open_preferences, window)
+        return action,
+    
+    def __open_preferences(self, action, window):
+        dialog = gtk.Dialog("My dialog",
+            window,
+            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
+            gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+
+        dialog.show()
+        dialog.run()
+        dialog.destroy()
+    </programlisting>
+</example>
+
+<!-- ****************************** -->
+<!-- BEGIN OF METHODS -->
+<!-- ****************************** -->
+
+  <refsect1>
+        <title>Passive Methods</title>
+
+        <refsect2 id="method-thunarx-preferences-provider--get-actions">
+          <title>thunarx.PreferencesProvider.get_actions</title>
+
+          <programlisting><methodsynopsis language="python">
+            <methodname>get_actions</methodname>
+              <methodparam></methodparam>
+          </methodsynopsis></programlisting>
+
+          <variablelist>
+            <varlistentry>
+	            <term><parameter role="keyword">window</parameter> :</term>
+	            <listitem><simpara>a gtk.Window</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
+              <term><emphasis>Returns</emphasis> :</term>
+              <listitem><simpara>the list of gtk.Action objects that provider has to offer as preferences within window.</simpara></listitem>
+            </varlistentry>
+          </variablelist>
+
+          <para>
+Returns the list of GtkActions that provider has to offer as preferences within window. These actions will usually be added to the builtin list of preferences in the "Edit" menu of the file manager's window.
+</para><para>
+Plugin writers that implement this interface should make sure to choose descriptive action names and tooltips, and not to crowd the "Edit" menu too much. That said, think twice before implementing this interface, as too many preference actions will render the file manager useless over time!
+          </para>
+        </refsect2>
+    </refsect1>
+
+</refentry>
+
diff --git a/docs/reference/thunarx-python-property-page-provider.xml b/docs/reference/thunarx-python-property-page-provider.xml
index 79732d9..29f3bbc 100644
--- a/docs/reference/thunarx-python-property-page-provider.xml
+++ b/docs/reference/thunarx-python-property-page-provider.xml
@@ -37,6 +37,54 @@
       </para>
   </refsect1>
 
+<example>
+    <title>A thunarx.PropertyPageProvider plugin</title>
+    <programlisting>
+import hashlib
+import urllib
+
+import thunarx
+import gtk
+
+class ThunarxPropertyPagePlugin(thunarx.PropertyPageProvider):
+    def __init__(self):
+        pass
+
+    def get_property_pages(self, files):
+        if len(files) != 1:
+            return
+        
+        file = files[0]
+        if file.get_uri_scheme() != 'file':
+            return
+
+        if file.is_directory():
+            return
+
+        filename = urllib.unquote(file.get_uri()[7:])
+
+        self.hbox = gtk.HBox(0, False)
+        self.hbox.show()
+
+        label = gtk.Label('MD5Sum:')
+        label.show()
+        self.hbox.pack_start(label)
+
+        self.value_label = gtk.Label()
+        self.hbox.pack_start(self.value_label)
+
+        md5sum = hashlib.md5(filename).hexdigest()
+        self.value_label.set_text(md5sum)
+        self.value_label.show()
+
+        page = thunarx.PropertyPage("MD5")
+
+        page.add(self.hbox)
+
+        return [page]
+    </programlisting>
+</example>
+
 <!-- ****************************** -->
 <!-- BEGIN OF METHODS -->
 <!-- ****************************** -->
@@ -49,7 +97,7 @@
 
           <programlisting><methodsynopsis language="python">
             <methodname>get_pages</methodname>
-              <methodparam></methodparam>
+        <methodparam><parameter role="keyword">files</parameter></methodparam>
           </methodsynopsis></programlisting>
 
           <variablelist>
diff --git a/docs/reference/thunarx-python-provider-reference.xml b/docs/reference/thunarx-python-provider-reference.xml
index ac829eb..6c0a69d 100644
--- a/docs/reference/thunarx-python-provider-reference.xml
+++ b/docs/reference/thunarx-python-provider-reference.xml
@@ -7,5 +7,7 @@
     <title>Provider Interfaces</title>
     <xi:include href="thunarx-python-menu-provider.xml"/>
     <xi:include href="thunarx-python-property-page-provider.xml"/>
+    <xi:include href="thunarx-python-renamer-provider.xml"/>
+    <xi:include href="thunarx-python-preferences-provider.xml"/>
 </chapter>
 
diff --git a/docs/reference/thunarx-python-renamer-provider.xml b/docs/reference/thunarx-python-renamer-provider.xml
new file mode 100644
index 0000000..18cda15
--- /dev/null
+++ b/docs/reference/thunarx-python-renamer-provider.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+
+<refentry id="class-thunarx-python-renamer-provider">
+  <refnamediv>
+    <refname>thunarx.RenamerProvider</refname>
+    <refpurpose>thunarx.RenamerProvider Reference</refpurpose>
+  </refnamediv>
+
+<!-- ******************************* -->
+<!-- BEGIN OF SYNOPSIS -->
+<!-- ******************************* -->
+
+  <refsect1>
+    <title>Synopsis</title>
+
+    <classsynopsis language="python">
+      <ooclass><classname>thunarx.RenamerProvider</classname></ooclass>
+
+      <methodsynopsis language="python">
+        <methodname><link linkend="method-thunarx-renamer-provider--get-pages">get_pages</link></methodname>
+        <methodparam><parameter role="keyword">files</parameter></methodparam>
+      </methodsynopsis>
+    </classsynopsis>
+  </refsect1>
+
+<!-- ********************************** -->
+<!-- BEGIN OF DESCRIPTION -->
+<!-- ********************************** -->
+
+  <refsect1 id="description-renamer-provider">
+    <title>Description</title>
+
+      <para>
+The thunarx.RenamerProvider interface is implemented by extensions which provide additional bulk renamers that should be used by the bulk rename dialog in Thunar.
+      </para>
+      
+      <example>
+        <title>A thunarx.RenamerProvider Extension</title>
+        <programlisting>
+import thunarx
+import gtk
+import gobject
+
+class ThunarxPythonRenamer(thunarx.Renamer):
+    __gtype_name__ = "ThunarxPythonRenamer"
+    prefix = gobject.property(type=str)
+    
+    def __init__(self):
+        thunarx.Renamer.__init__(self)
+
+        # Set properties to be saved in the settings files
+        self.set_property("prefix", "__")
+        
+        self.set_name("Example Python Renamer")
+        self.set_help_url("http://www.google.com")
+     
+        hbox = gtk.HBox(0, False)
+        
+        label = gtk.Label("Prefix:")
+        hbox.pack_start(label, False, False, 0)
+        
+        self.entry = gtk.Entry()
+        self.entry.set_text(self.get_property("prefix"))
+        self.entry.connect("changed", self.entry_changed)
+        hbox.pack_start(self.entry, False, False, 0)
+        
+        label.show()
+        self.entry.show()
+        self.add(hbox)
+        hbox.show()
+    
+    def do_process(self, file, text, index):
+        prefix = self.entry.get_text()
+        return prefix + text
+
+    def entry_changed(self, widget):
+        self.set_property("prefix", widget.get_text())
+        
+        # Emitting this will cause the do_process method to be called
+        self.emit("changed")
+
+    def do_get_actions(self, window, files):
+        return [gtk.Action("TPR:SomeAction", "Some Action", None, gtk.STOCK_OPEN)]
+
+    def do_load(self, settings):
+        """
+        Loads settings saved in ~/.config/Thunar/renamerrc
+        """
+        if settings.haskey("Prefix"):
+            self.set_property("prefix", settings["Prefix"])
+            self.entry.set_text(self.get_property("prefix"))
+
+    def do_save(self, settings):
+        """
+        If do_save is overriden, you must rebuild the settings dictionary and then
+        return it.
+        """
+        settings["Prefix"] = self.get_property("prefix")
+        return settings
+
+class ThunarxRenamerPlugin(thunarx.RenamerProvider):
+    def __init__(self):
+        pass
+    
+    def get_renamers(self):
+        return [ThunarxPythonRenamer()]
+        </programlisting>
+      </example>
+  </refsect1>
+
+<!-- ****************************** -->
+<!-- BEGIN OF METHODS -->
+<!-- ****************************** -->
+
+  <refsect1>
+        <title>Passive Methods</title>
+
+        <refsect2 id="method-thunarx-renamer-provider--get-renamers">
+          <title>thunarx.RenamerProvider.get_renamers</title>
+
+          <programlisting><methodsynopsis language="python">
+            <methodname>get_renamers</methodname>
+            <methodparam><parameter role="keyword">files</parameter></methodparam>
+          </methodsynopsis></programlisting>
+
+          <variablelist>
+            <varlistentry>
+              <term><emphasis>Returns</emphasis> :</term>
+              <listitem><simpara>the list of thunarx.Renamer objects provided by the specified provider.</simpara></listitem>
+            </varlistentry>
+          </variablelist>
+
+          <para>
+Returns the list of ThunarxRenamers provided by the specified provider.
+          </para>
+        </refsect2>
+    </refsect1>
+
+</refentry>
+
diff --git a/docs/reference/thunarx-python-renamer.xml b/docs/reference/thunarx-python-renamer.xml
new file mode 100644
index 0000000..858fd3b
--- /dev/null
+++ b/docs/reference/thunarx-python-renamer.xml
@@ -0,0 +1,382 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
+    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
+
+<refentry id="class-thunarx-python-renamer">
+  <refnamediv>
+    <refname>thunarx.Renamer</refname>
+    <refpurpose>thunarx.Renamer Reference</refpurpose>
+  </refnamediv>
+
+<!-- ******************************* -->
+<!-- BEGIN OF NAUTILUS-PYTHON SYNOPSIS -->
+<!-- ******************************* -->
+
+  <refsect1>
+    <title>Synopsis</title>
+
+    <classsynopsis language="python">
+        <ooclass><classname>thunarx.Renamer</classname></ooclass>
+        <ooclass><classname><link linkend="class-ginterface">gobject.GObject</link></classname></ooclass>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--get-help-url">get_help_name</link></methodname>
+            <methodparam></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--set-help-url">set_help_url</link></methodname>
+            <methodparam><parameter role="keyword">help_url</parameter></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--get-name">get_name</link></methodname>
+            <methodparam></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--set-name">set_name</link></methodname>
+            <methodparam><parameter role="keyword">name</parameter></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--do-process">do_process</link></methodname>
+            <methodparam><parameter role="keyword">file</parameter></methodparam>
+            <methodparam><parameter role="keyword">text</parameter></methodparam>
+            <methodparam><parameter role="keyword">index</parameter></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--do-load">do_load</link></methodname>
+            <methodparam><parameter role="keyword">settings</parameter></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--do-save">do_save</link></methodname>
+            <methodparam><parameter role="keyword">settings</parameter></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--do-get-actions">do_get_actions</link></methodname>
+            <methodparam><parameter role="keyword">window</parameter></methodparam>
+            <methodparam><parameter role="keyword">files</parameter></methodparam>
+        </methodsynopsis>
+
+        <methodsynopsis language="python">
+            <methodname><link linkend="method-thunarx-python-renamer--do-changed">do_changed</link></methodname>
+            <methodparam></methodparam>
+        </methodsynopsis>
+    </classsynopsis>
+  </refsect1>
+
+<!-- ********************************* -->
+<!-- BEGIN OF ANCESTRY -->
+<!-- ********************************* -->
+
+<refsect1>
+    <title>Ancestry</title>
+
+<synopsis>+-- <link linkend="class-ginterface">gobject.GObject</link>
+    +-- <link linkend="class-thunarx-python-renamer">thunarx.Renamer</link>
+</synopsis>
+</refsect1>
+
+
+<!-- ********************************** -->
+<!-- BEGIN OF DESCRIPTION -->
+<!-- ********************************** -->
+
+  <refsect1 id="description-renamer">
+    <title>Description</title>
+
+      <para>
+        The abstract base class thunarx.Renamer is implemented by extensions which provide additional bulk renamers that should be used in the bulk rename dialog.
+      </para>
+      
+      <para>
+Derived classes must override the process() method, which is called by the bulk rename dialog for every file to generate a new name. For example, the ThunarSbrReplaceRenamer class included in the thunar-sbr plugin (which is part of the Thunar distribution) provides a bulk renamer, named Search & Replace, which allows the user to rename multiple files by searching for a pattern in each file name and, if the pattern is found, replacing it with the specified replacement text.
+      </para>
+
+  </refsect1>
+
+<!-- *********************************** -->
+<!-- BEGIN OF PROPERTIES -->
+<!-- *********************************** -->
+
+<refsect1>
+    <title>Properties</title>
+
+    <blockquote role="properties">
+      <informaltable pgwide="1" frame="none">
+      <tgroup cols="3">
+        <colspec column="1" colwidth="1in"/>
+        <colspec column="2" colwidth="1in"/>
+        <colspec column="3" colwidth="4in"/>
+          <tbody>
+      
+            <row valign="top">
+              <entry>"help-url"</entry>
+              <entry>
+The URL to the documentation of this ThunarxRenamer. Derived classes can set this property to point to the documentation for the specific renamer. The documentation of the specific renamer in turn should contain a link to the general Thunar renamer documentation.
+
+May also be unset, in which case the general Thunar renamer documentation will be shown when the user clicks the "Help" button.
+
+Default value: NULL
+              </entry>
+              <entry>Read-Write</entry>
+            </row>
+      
+            <row valign="top">
+              <entry>"name"</entry>
+              <entry>The user visible name of the renamer, that is displayed in the bulk rename dialog of the file manager. Derived classes should set a useful name.
+
+Default value: NULL
+</entry>
+              <entry>Read-Write</entry>
+            </row>
+            
+          </tbody>
+        </tgroup>
+      </informaltable>
+    </blockquote>
+</refsect1>
+
+
+<!-- ****************************************** -->
+<!-- BEGIN OF SIGNAL PROTOTYPES -->
+<!-- ****************************************** -->
+
+<refsect1>
+    <title>Signals</title>
+    <variablelist>
+      <varlistentry>
+        <term><link linkend="signal-thunarx-python-renamer--changed">"changed"</link></term>
+        <listitem>
+          <methodsynopsis language="python"><methodname>callback</methodname>
+          </methodsynopsis>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+</refsect1>
+
+
+<!-- ******************************** -->
+<!-- BEGIN OF METHODS -->
+<!-- ******************************** -->
+
+<refsect1>
+    <title>Passive Methods</title>
+
+    <refsect2 id="method-thunarx-python-renamer--do-process">
+        <title>thunarx.Renamer.do_process</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>do_process</methodname>
+            <methodparam><parameter role="keyword">file</parameter></methodparam>
+            <methodparam><parameter role="keyword">text</parameter></methodparam>
+            <methodparam><parameter role="keyword">index</parameter></methodparam>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+	            <term><parameter role="keyword">file</parameter> :</term>
+	            <listitem><simpara>the thunarx.FileInfo for the file whose new name - according to renamer - should be determined.</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
+	            <term><parameter role="keyword">text</parameter> :</term>
+	            <listitem><simpara>the part of the filename to which the renamer should be applied.</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
+	            <term><parameter role="keyword">index</parameter> :</term>
+	            <listitem><simpara>the index of the file in the list, used for renamers that work on numbering.</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><emphasis>Returns</emphasis> :</term>
+                <listitem><simpara>the string with which to replace text.</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+        
+        <para>Determines the replacement for text (which is the relevant part of the full file name, i.e. either the suffix, the name or the name and the suffix).</para>
+    </refsect2>
+
+    <refsect2 id="method-thunarx-python-renamer--do-load">
+        <title>thunarx.Renamer.do_load</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>do_load</methodname>
+            <methodparam><parameter role="keyword">settings</parameter></methodparam>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+	            <term><parameter role="keyword">settings</parameter> :</term>
+	            <listitem><simpara>a dictionary which contains the previously saved settings for renamer as key/value pairs of strings.</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+        
+        <para>Tells renamer to load its internal settings from the specified settings. The settings hash table contains previously saved settings, see thunarx.Renamer.do_save(), as key/value pairs of strings. That is, both the keys and the values are strings.
+</para><para>
+Implementations of thunarx.Renamer may decide to override this method to perform custom loading of settings. If you do not override this method, the default method of thunarx.Renamer will be used, which simply loads all GObject properties provided by renamers class (excluding the ones provided by the parent classes) from the settings. The GObject properties must be transformable to strings and from strings.
+</para><para>
+If you decide to override this method for your thunarx.Renamer implementation, you should also override thunarx.Renamer.do_save().
+</para>
+    </refsect2>
+
+    <refsect2 id="method-thunarx-python-renamer--do-save">
+        <title>thunarx.Renamer.do_save</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>do_save</methodname>
+            <methodparam><parameter role="keyword">settings</parameter></methodparam>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+	            <term><parameter role="keyword">settings</parameter> :</term>
+	            <listitem><simpara>a dictionary to which the current settings of renamer should be stored as key/value pairs of strings.</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+    </refsect2>
+
+    <refsect2 id="method-thunarx-python-renamer--do-get-actions">
+        <title>thunarx.Renamer.do_get_actions</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>do_get_actions</methodname>
+            <methodparam><parameter role="keyword">window</parameter></methodparam>
+            <methodparam><parameter role="keyword">files</parameter></methodparam>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+	            <term><parameter role="keyword">window</parameter> :</term>
+	            <listitem><simpara>a gtk.Window</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
+	            <term><parameter role="keyword">files</parameter> :</term>
+	            <listitem><simpara>a list of thunarx.FileInfo objects</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><emphasis>Returns</emphasis> :</term>
+                <listitem><simpara>the list of GtkActions provided by renamer for the given list of files</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+
+        <para>
+Returns the list of gtk.Action objects provided by renamer for the given list of files. By default, this method returns NULL (the empty list), but derived classes may override this method to provide additional actions for files in the bulk renamer dialog list.
+</para><para>
+The returned gtk.Action objects will be displayed in the file's context menu of the bulk renamer dialog, when this renamer is active. For example, an ID3-Tag based renamer may add an action "Edit Tags" to the context menus of supported media files and, when activated, display a dialog (which should be transient and modal for window, if not NULL), which allows the users to edit media file tags on-the-fly.
+</para><para>
+Derived classes that override this method should always check first if all the thunarx.FileInfo objects in the list of files are supported, and only return actions that can be performed on this specific list of files. For example, the ID3-Tag renamer mentioned above, should first check whether all items in files are actually audio files. The thunarx.FileInfo.has_mime_type() of the thunarx.FileInfo interface can be used to easily test whether a file in the files list is of a certain MIME type.
+</para><para>
+Some actions may only work properly if only a single file ist selected (for example, the ID3-Tag renamer will probably only supporting editing one file at a time). In this case you have basicly two options: Either you can return NULL here if files does not contain exactly one item, or you can return the actions as usual, but make them insensitive, using: action.set_sensitive(False)
+</para><para>
+The latter has the advantage that the user will still notice the existance of the action and probably realize that it can only be applied to a single item at once.
+</para><para>
+The gtk.Action objects returned from this method must be namespaced with the module to avoid collision with internal file manager actions and actions provided by other extensions. For example, the menu action provided by the ID3-Tag renamer mentioned above, should be named TagRenamer::edit-tags (if TagRenamer is the class name). For additional information about the way GtkActions should be returned from extensions and the way they are used, read the description of the thunarx.MenuProvider interface or read the introduction provided with this reference manual.
+        </para>
+    </refsect2>
+
+    <refsect2 id="method-thunarx-python-renamer--do-changed">
+        <title>thunarx.Renamer.do_changed</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>do_changed</methodname>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+                <term><emphasis>Returns</emphasis> :</term>
+                <listitem><simpara></simpara></listitem>
+            </varlistentry>
+        </variablelist>
+        
+        <para>This method should be used by derived classes to emit the "changed" signal for renamer. See the documentation of the "changed" signal for details.</para>
+    </refsect2>
+
+</refsect1>
+
+<refsect1>
+    <title>Active Methods</title>
+    
+    <refsect2 id="method-thunarx-python-renamer--get-help-url">
+        <title>thunarx.Renamer.get_help_url</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>get_help_url</methodname>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+                <term><emphasis>Returns</emphasis> :</term>
+                <listitem><simpara>the URL of the documentation for renamer.</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+        
+        <para>Returns the URL of the documentation for renamer or NULL if no specific documentation is available for renamer and the general documentation of the Thunar renamers should be displayed instead.</para>
+    </refsect2>
+    
+    <refsect2 id="method-thunarx-python-renamer--set-help-url">
+        <title>thunarx.Renamer.set_help_url</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>set_help_url</methodname>
+            <methodparam><parameter role="keyword">help_url</parameter></methodparam>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+                <term><emphasis>Returns</emphasis> :</term>
+                <listitem><simpara>the new URL for the documentation for renamer.</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+        
+        <para>
+The URL to the documentation of this thunarx.Renamer. Derived classes can set this property to point to the documentation for the specific renamer. The documentation of the specific renamer in turn should contain a link to the general Thunar renamer documentation.
+</para><para>
+May also be unset, in which case the general Thunar renamer documentation will be shown when the user clicks the "Help" button.
+        </para>
+    </refsect2>
+
+    <refsect2 id="method-thunarx-python-renamer--get-name">
+        <title>thunarx.Renamer.get_name</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>get_name</methodname>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+                <term><emphasis>Returns</emphasis> :</term>
+                <listitem><simpara>the user visible name for renamer.</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+        
+        <para>Returns the user visible name for renamer, previously set with thunarx.Renamer.set_name().</para>
+    </refsect2>
+    
+    <refsect2 id="method-thunarx-python-renamer--set-name">
+        <title>thunarx.Renamer.set_name</title>
+        <programlisting><methodsynopsis language="python">
+            <methodname>set_name</methodname>
+        </methodsynopsis></programlisting>
+        <variablelist>
+            <varlistentry>
+	            <term><parameter role="keyword">name</parameter> :</term>
+	            <listitem><simpara>the new user visible name for renamer.</simpara></listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><emphasis>Returns</emphasis> :</term>
+                <listitem><simpara>the new user visible name for renamer.</simpara></listitem>
+            </varlistentry>
+        </variablelist>
+        
+        <para>Sets the user visible name for renamer to name.</para>
+    </refsect2>
+</refsect1>
+
+<!-- ******************************** -->
+<!-- BEGIN OF SIGNAL DETAILS -->
+<!-- ******************************** --> 
+ 
+<refsect1>
+    <title>Signal Details</title>
+
+  <refsect2 id="signal-thunarx-python-renamer--changed">
+    <title>The "changed" thunarx.Renamer Signal</title>
+
+    <para>
+Derived classes should emit this signal using the thunarx.Renamer.do_changed() method whenever the user changed a setting in the renamer GUI.
+</para><para>
+The file manager will then invoke thunarx.Renamer.do_process() for all files that should be renamed and update the preview.
+    </para>
+
+  </refsect2>
+</refsect1>
+
+</refentry>
+



More information about the Xfce4-commits mailing list