Git Repositories

2005-09-09 Benedikt Meurer <benny@xfce.org>
authorBenedikt Meurer <benny@xfce.org>
Sun, 11 Sep 2005 00:07:08 +0000 (00:07 +0000)
committerBenedikt Meurer <benny@xfce.org>
Sun, 11 Sep 2005 00:07:08 +0000 (00:07 +0000)
* configure.in.in: Substitute version information.
* thunar/thunar-window.c(thunar_window_action_about): Escape the
  copyright sign.
* thunar/thunar-gdk-pixbuf-extensions.{c,h},
  thunar/thunar-gtk-extensions.{c,h}, thunar/thunar-desktop-view.c,
  thunar/thunar-icon-factory.c, thunar/thunar-icon-renderer.c,
  thunar/thunar-standard-view.c, thunar/thunar-window.c,
  thunar/Makefile.am: Merge the GdkPixbuf and GTK+ extensions into
  the thunar namespace.
* configure.in.in, thunarx/: Import the initial extensions library.
* configure.in.in, docs/Makefile.am, Makefile.am, docs/reference/:
  Import the reference manual for the extensions library.
* thunar/thunar-file.c: Implement the ThunarxFileInfo interface.
* thunar/thunar-extension-manager.{c,h}, thunar/Makefile.am: Import the
  ThunarExtensionManager class.
* thunar/thunar-standard-view-ui.xml, thunar/thunar-standard-view.c: Add
  support for context menu providers to the standard views.
* po/POTFILES.in: Add thunarx/thunarx-property-page.c here.
* thunar/thunar-properties-dialog.c: Add support for property page
  providers here.
* Makefile.am, configure.in.in, examples/Makefile.am,
  examples/open-terminal-here/: Add "Open Terminal Here" menu provider
  example.

(Old svn revision: 17553)

54 files changed:
ChangeLog
Makefile.am
configure.in.in
docs/Makefile.am
docs/reference/Makefile.am [new file with mode: 0644]
docs/reference/thunarx/Makefile.am [new file with mode: 0644]
docs/reference/thunarx/images/abstraction.png [new file with mode: 0644]
docs/reference/thunarx/images/menu-provider.png [new file with mode: 0644]
docs/reference/thunarx/images/say-hello.png [new file with mode: 0644]
docs/reference/thunarx/thunarx-docs.sgml [new file with mode: 0644]
docs/reference/thunarx/thunarx-sections.txt [new file with mode: 0644]
docs/reference/thunarx/thunarx.types [new file with mode: 0644]
docs/reference/thunarx/tmpl/thunarx-file-info.sgml [new file with mode: 0644]
docs/reference/thunarx/tmpl/thunarx-menu-provider.sgml [new file with mode: 0644]
docs/reference/thunarx/tmpl/thunarx-property-page-provider.sgml [new file with mode: 0644]
docs/reference/thunarx/tmpl/thunarx-property-page.sgml [new file with mode: 0644]
docs/reference/thunarx/tmpl/thunarx-version-information.sgml [new file with mode: 0644]
docs/reference/thunarx/version.xml.in [new file with mode: 0644]
examples/Makefile.am [new file with mode: 0644]
examples/open-terminal-here/Makefile.am [new file with mode: 0644]
examples/open-terminal-here/README [new file with mode: 0644]
examples/open-terminal-here/open-terminal-here.c [new file with mode: 0644]
po/POTFILES.in
thunar/Makefile.am
thunar/thunar-desktop-view.c
thunar/thunar-extension-manager.c [new file with mode: 0644]
thunar/thunar-extension-manager.h [new file with mode: 0644]
thunar/thunar-file.c
thunar/thunar-gdk-pixbuf-extensions.c [moved from thunarx/thunarx-gdk-pixbuf-extensions.c with 95% similarity]
thunar/thunar-gdk-pixbuf-extensions.h [moved from thunarx/thunarx-gdk-pixbuf-extensions.h with 54% similarity]
thunar/thunar-gtk-extensions.c [moved from thunarx/thunarx-gtk-extensions.c with 83% similarity]
thunar/thunar-gtk-extensions.h [moved from thunarx/thunarx-gtk-extensions.h with 70% similarity]
thunar/thunar-icon-factory.c
thunar/thunar-icon-renderer.c
thunar/thunar-properties-dialog.c
thunar/thunar-standard-view-ui.xml
thunar/thunar-standard-view.c
thunar/thunar-window.c
thunarx/Makefile.am
thunarx/abicheck.sh [new file with mode: 0755]
thunarx/make-thunarx-alias.pl [new file with mode: 0755]
thunarx/thunarx-1.pc.in [new file with mode: 0644]
thunarx/thunarx-config.c [new file with mode: 0644]
thunarx/thunarx-config.h.in [new file with mode: 0644]
thunarx/thunarx-file-info.c [new file with mode: 0644]
thunarx/thunarx-file-info.h [new file with mode: 0644]
thunarx/thunarx-menu-provider.c [new file with mode: 0644]
thunarx/thunarx-menu-provider.h [new file with mode: 0644]
thunarx/thunarx-property-page-provider.c [new file with mode: 0644]
thunarx/thunarx-property-page-provider.h [new file with mode: 0644]
thunarx/thunarx-property-page.c [new file with mode: 0644]
thunarx/thunarx-property-page.h [new file with mode: 0644]
thunarx/thunarx.h [new file with mode: 0644]
thunarx/thunarx.symbols [new file with mode: 0644]

index 1ff0278..05a56ce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2005-09-09     Benedikt Meurer <benny@xfce.org>
+
+       * configure.in.in: Substitute version information.
+       * thunar/thunar-window.c(thunar_window_action_about): Escape the
+         copyright sign.
+       * thunar/thunar-gdk-pixbuf-extensions.{c,h},
+         thunar/thunar-gtk-extensions.{c,h}, thunar/thunar-desktop-view.c,
+         thunar/thunar-icon-factory.c, thunar/thunar-icon-renderer.c,
+         thunar/thunar-standard-view.c, thunar/thunar-window.c,
+         thunar/Makefile.am: Merge the GdkPixbuf and GTK+ extensions into
+         the thunar namespace.
+       * configure.in.in, thunarx/: Import the initial extensions library.
+       * configure.in.in, docs/Makefile.am, Makefile.am, docs/reference/:
+         Import the reference manual for the extensions library.
+       * thunar/thunar-file.c: Implement the ThunarxFileInfo interface.
+       * thunar/thunar-extension-manager.{c,h}, thunar/Makefile.am: Import the
+         ThunarExtensionManager class.
+       * thunar/thunar-standard-view-ui.xml, thunar/thunar-standard-view.c: Add
+         support for context menu providers to the standard views.
+       * po/POTFILES.in: Add thunarx/thunarx-property-page.c here.
+       * thunar/thunar-properties-dialog.c: Add support for property page
+         providers here.
+       * Makefile.am, configure.in.in, examples/Makefile.am,
+         examples/open-terminal-here/: Add "Open Terminal Here" menu provider
+         example.
+
 2005-09-06     Benedikt Meurer <benny@xfce.org>
 
        * thunar/thunar-list-model.c: Don't emit the "row-inserted" and
index 8f0b329..83af654 100644 (file)
@@ -1,14 +1,15 @@
 # $Id$
 
 SUBDIRS =                                                              \
-       docs                                                            \
        icons                                                           \
        pixmaps                                                         \
        po                                                              \
        thunar-vfs                                                      \
        thunarx                                                         \
        thunar                                                          \
-       tests
+       tests                                                           \
+       docs                                                            \
+       examples
 
 AUTOMAKE_OPTIONS =                                                     \
        1.8                                                             \
@@ -40,4 +41,6 @@ DISTCLEANFILES =                                                      \
        intltool-update                                                 \
        $(desktop_DATA)
 
+DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+
 # vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
index 809b17c..eb1ebfe 100644 (file)
@@ -64,8 +64,14 @@ dnl *** Substitute version information ***
 dnl **************************************
 THUNAR_VERINFO=thunar_verinfo()
 THUNAR_VERSION_API=thunar_version_api()
+THUNAR_VERSION_MAJOR=thunar_version_major()
+THUNAR_VERSION_MINOR=thunar_version_minor()
+THUNAR_VERSION_MICRO=thunar_version_micro()
 AC_SUBST([THUNAR_VERINFO])
 AC_SUBST([THUNAR_VERSION_API])
+AC_SUBST([THUNAR_VERSION_MAJOR])
+AC_SUBST([THUNAR_VERSION_MINOR])
+AC_SUBST([THUNAR_VERSION_MICRO])
 
 dnl **********************************
 dnl *** Check for standard headers ***
@@ -124,6 +130,7 @@ dnl *** Check for required packages ***
 dnl ***********************************
 XDT_CHECK_PACKAGE([EXO], [exo-0.3], [0.3.1])
 XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.6.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.6.0])
 XDT_CHECK_PACKAGE([LIBPNG], [libpng12], [1.2.0])
 
 dnl ***********************************
@@ -131,6 +138,11 @@ dnl *** Check for optional packages ***
 dnl ***********************************
 XDT_CHECK_OPTIONAL_PACKAGE([CAIRO], [cairo], [0.5], [cairo], [Cairo])
 
+dnl *************************
+dnl *** Check for gtk-doc ***
+dnl *************************
+GTK_DOC_CHECK([1.0])
+
 dnl ***************************
 dnl *** Check for Gamin/FAM ***
 dnl ***************************
@@ -251,6 +263,11 @@ Makefile
 docs/Makefile
 docs/design/Makefile
 docs/papers/Makefile
+docs/reference/Makefile
+docs/reference/thunarx/Makefile
+docs/reference/thunarx/version.xml
+examples/Makefile
+examples/open-terminal-here/Makefile
 icons/Makefile
 icons/24x24/Makefile
 icons/48x48/Makefile
@@ -262,4 +279,6 @@ thunar/Makefile
 thunar-vfs/Makefile
 thunar-vfs/thunar-vfs-1.pc
 thunarx/Makefile
+thunarx/thunarx-1.pc
+thunarx/thunarx-config.h
 ])
index 80ee678..5311c00 100644 (file)
@@ -2,6 +2,7 @@
 
 SUBDIRS =                                                              \
        design                                                          \
-       papers
+       papers                                                          \
+       reference
 
 # vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
new file mode 100644 (file)
index 0000000..d95c60c
--- /dev/null
@@ -0,0 +1,6 @@
+# $Id$
+
+SUBDIRS =                                                              \
+       thunarx
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/docs/reference/thunarx/Makefile.am b/docs/reference/thunarx/Makefile.am
new file mode 100644 (file)
index 0000000..43b4e7c
--- /dev/null
@@ -0,0 +1,62 @@
+# $Id$
+
+AUTOMAKE_OPTIONS = 1.8
+
+# The name of the module.
+DOC_MODULE=thunarx
+
+# The top-level SGML file.
+DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.sgml
+
+# Extra options to supply to gtkdoc-scan
+SCAN_OPTIONS=--deprecated-guards="EXO_DISABLE_DEPRECATED"
+
+# Extra options to pass to gtkdoc-scangobj
+SCANGOBJ_OPTIONS=--type-init-func="gtk_type_init(0);g_type_class_ref(G_TYPE_OBJECT)"
+
+# The directory containing the source code. Relative to $(srcdir)
+DOC_SOURCE_DIR=../../../thunarx
+
+# Extra options to supply to gtkdoc-mkdb
+MKDB_OPTIONS=--sgml-mode --output-format=xml
+
+# Extra options to supply to gtkdoc-fixref
+FIXXREF_OPTIONS=
+
+# Used for dependencies
+HFILE_GLOB=$(top_srcdir)/thunarx/*.h
+CFILE_GLOB=$(top_srcdir)/thunarx/*.c
+
+# Header files to ignore when scanning
+IGNORE_HFILES=thunarx-alias.h
+
+# Extra files to add when scanning (relative to $srcdir)
+EXTRA_HFILES=
+
+# Images to copy into HTML directory
+HTML_IMAGES =                                                          \
+       $(srcdir)/images/abstraction.png                                \
+       $(srcdir)/images/menu-provider.png                              \
+       $(srcdir)/images/say-hello.png
+
+# Extra SGML files that are included by DOC_MAIN_SGML_FILE
+content_files =                                                        \
+       version.xml
+
+# CFLAGS and LDFLAGS for compiling scan program. Only needed
+# if $(DOC_MODULE).types is non-empty.
+INCLUDES =                                                             \
+       -I$(top_srcdir)                                                 \
+       -I$(top_builddir)                                               \
+       $(GTK_CFLAGS)
+
+GTKDOC_LIBS =                                                                  \
+       $(top_builddir)/thunarx/libthunarx-$(THUNAR_VERSION_API).la
+
+include $(top_srcdir)/gtk-doc.make
+
+# Other files to distribute
+EXTRA_DIST +=                                                          \
+       version.xml.in
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/docs/reference/thunarx/images/abstraction.png b/docs/reference/thunarx/images/abstraction.png
new file mode 100644 (file)
index 0000000..33c5624
Binary files /dev/null and b/docs/reference/thunarx/images/abstraction.png differ
diff --git a/docs/reference/thunarx/images/menu-provider.png b/docs/reference/thunarx/images/menu-provider.png
new file mode 100644 (file)
index 0000000..6097495
Binary files /dev/null and b/docs/reference/thunarx/images/menu-provider.png differ
diff --git a/docs/reference/thunarx/images/say-hello.png b/docs/reference/thunarx/images/say-hello.png
new file mode 100644 (file)
index 0000000..0731ae9
Binary files /dev/null and b/docs/reference/thunarx/images/say-hello.png differ
diff --git a/docs/reference/thunarx/thunarx-docs.sgml b/docs/reference/thunarx/thunarx-docs.sgml
new file mode 100644 (file)
index 0000000..9170769
--- /dev/null
@@ -0,0 +1,454 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" 
+               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
+
+<!ENTITY ThunarxFileInfo SYSTEM "xml/thunarx-file-info.xml">
+<!ENTITY ThunarxMenuProvider SYSTEM "xml/thunarx-menu-provider.xml">
+<!ENTITY ThunarxPropertyPage SYSTEM "xml/thunarx-property-page.xml">
+<!ENTITY ThunarxPropertyPageProvider SYSTEM "xml/thunarx-property-page-provider.xml">
+<!ENTITY thunarx-version-information SYSTEM "xml/thunarx-version-information.xml">
+
+<!ENTITY version SYSTEM "version.xml">
+<!ENTITY date "September 2005">
+]>
+
+<book id="index">
+  <bookinfo>
+    <title>Thunar Extensions Reference Manual</title>
+    <releaseinfo>Version &version;</releaseinfo>
+    <pubdate>&date;</pubdate>
+
+    <copyright>
+      <year>2005</year>
+      <holder>Benedikt Meurer</holder>
+    </copyright>
+
+    <legalnotice id="legalnotice">
+      <para>
+        Permission is granted to copy, distribute and/or modify this document
+        under the terms of the GNU Free Documentation License, Version 1.1 or
+        any later version published by the Free Software Foundation; with no
+        Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
+        Texts. The complete license text is available from the <ulink
+        type="http" url="http://www.gnu.org/">Free Software Foundation</ulink>.
+      </para>
+    </legalnotice>
+
+    <authorgroup>
+      <author>
+        <firstname>Benedikt</firstname>
+        <surname>Meurer</surname>
+        <affiliation>
+          <address><email>benny@xfce.org</email></address>
+          <orgname>os-cillation</orgname>
+          <orgdiv>System development</orgdiv>
+          <jobtitle>Software developer</jobtitle>
+        </affiliation>
+      </author>
+    </authorgroup>
+  </bookinfo>
+
+  <part id="thunarx-overview">
+    <title>Overview</title>
+
+    <para>
+      The Thunar Extension Framework (<systemitem class="library">thunarx</systemitem>) provides
+      developers with an easy way to extend the basic functionality provided by
+      the <ulink type="http" url="http://thunar.xfce.org/">Thunar File Manager</ulink>.
+      The <systemitem class="library">thunarx</systemitem> library includes interfaces that can
+      be implemented by extensions for various purposes.
+    </para>
+
+    <para>
+      It is based on the <ulink type="http"
+      url="http://developer.gnome.org/doc/API/2.0/gobject/ch02.html">GLib Dynamic Type
+      System</ulink> and loads the extensions on demand to reduce the system resources
+      allocated for the file manager process.
+    </para>
+
+    <sect1 id="thunarx-overview-goals">
+      <title>Goals</title>
+
+      <para>
+        The Thunar Extension Framework was developed with the following goals in mind:
+      </para>
+
+      <orderedlist>
+        <listitem>
+          It should be easy to extend the functionality of the file manager in certain
+          ways.
+        </listitem>
+
+        <listitem>
+          The internals of the file manager should be hidden from the extensions to be
+          able to maintain API/ABI compatibility for extensions over various major
+          releases of the file manager.
+        </listitem>
+
+        <listitem>
+          Provide basic compatibility with the <ulink type="http"
+          url="http://www.gnome.org/projects/nautilus/">Nautilus</ulink> Extension Framework,
+          so vendors don't need to write several versions of their extensions for the various
+          file managers. With the current implementation it should be easy to write a small
+          wrapper library for generic extensions that can be loaded into both Thunar and
+          Nautilus.
+        </listitem>
+
+        <listitem>
+          Extensions should not be loaded into memory until they are actually required to
+          save system resources. This differs from the way Nautilus handles extensions and
+          therefore people that already know how to write Nautilus extensions must be
+          careful when writing extensions for Thunar, because Thunar actually unloads the
+          extension when it's no longer needed. The <ulink type="http"
+          url="http://developer.gnome.org/doc/API/2.0/gobject/GTypePlugin.html">GTypePlugin</ulink>
+          and <ulink type="http"
+          url="http://developer.gnome.org/doc/API/2.0/gobject/GTypeModule.html">GTypeModule</ulink>
+          sections in the <ulink type="http" url="http://developer.gnome.org/doc/API/2.0/gobject/">GObject
+          Reference Manual</ulink> provide details about the handling of dynamic type plugins.
+        </listitem>
+
+        <listitem>
+          Permit developers to write extensions in languages other than C.
+        </listitem>
+      </orderedlist>
+    </sect1>
+  </part>
+
+  <part id="thunarx-writing-extensions">
+    <title>Writing Extensions</title>
+
+    <para>
+      This section explains the basic steps required to write an extension for the <ulink type="http"
+      url="http://thunar.xfce.org">Thunar File Manager</ulink> using the C language interface. It is
+      just a short introduction and not meant to provide extensive details about the internal workings
+      of the file manager.
+    </para>
+
+    <sect1 id="thunarx-writing-extensions-basic-concepts">
+      <title>Basic Concepts</title>
+
+      <sect2 id="thunarx-writing-extensions-extensions-and-providers">
+        <title>Extensions and Providers</title>
+
+        <para>
+          <emphasis>Thunar Extensions</emphasis> are shared libraries that extend the basic functionality
+          provided by the Thunar File Manager. An extension exports one or more <link
+          linkend="GObject"><type>GObject</type></link>s, called <emphasis>providers</emphasis> to Thunar.
+        </para>
+
+        <para>
+          Providers implement one or more of the <link linkend="GInterface"><type>GInterface</type></link>s included with
+          the <systemitem class="library">thunarx</systemitem> library. The currently exported interfaces
+          include the <link linkend="ThunarxMenuProvider"><type>ThunarxMenuProvider</type></link> for adding context menu
+          items to the file views and the <link
+          linkend="ThunarxPropertyPageProvider"><type>ThunarxPropertyPageProvider</type></link> for adding pages to the
+          file properties dialog.
+        </para>
+      </sect2>
+
+      <sect2 id="thunarx-writing-extensions-thunarxfileinfo">
+        <title>ThunarxFileInfo</title>
+
+        <para>
+          Thunar passes file references to the provider using <link linkend="ThunarxFileInfo"><type>ThunarxFileInfo</type></link>
+          objects. The <link linkend="ThunarxFileInfo"><type>ThunarxFileInfo</type></link> interface provides access to the file
+          information that Thunar has already read - mime type, URI, name, etc. Extensions should use the data from
+          from the <link linkend="ThunarxFileInfo"><type>ThunarxFileInfo</type></link> rather than reading it themselves, to
+          prevent excessive I/O.
+        </para>
+
+        <para>
+          There is exactly one <link linkend="ThunarxFileInfo"><type>ThunarxFileInfo</type></link> per file, and it is kept around
+          for as long as Thunar is interested in the file. Extensions can use this information to manage lifecycles of
+          its own data - e.g. when the <link linkend="ThunarxFileInfo"><type>ThunarxFileInfo</type></link> goes away, it is safe
+          for the extension to forget any private data for that file.
+        </para>
+      </sect2>
+
+      <sect2 id="thunarx-writing-extensions-names">
+        <title>Names</title>
+
+        <para>
+          Most objects created by the extensions need names, e.g. the <link linkend="GtkAction"><type>GtkAction</type></link>s
+          returned from the <link linkend="ThunarxMenuProvider"><type>ThunarxMenuProvider</type></link>s. These names must be
+          namespaced with the name of the extension. For example the main action returned from the
+          <application>OpenTerminal</application> extension should be called <literal>OpenTerminal::open-terminal</literal>.
+          The namespace must be global among the providers exported by a certain extension.
+        </para>
+      </sect2>
+
+      <sect2 id="thunarx-writing-extensions-types">
+        <title>Types</title>
+
+        <para>
+          Thunar extensions are loaded as <link linkend="GTypeModule"><type>GTypeModule</type></link>s. This means that all GTypes
+          created by the extension must be registered with the <link linkend="GTypeModule"><type>GTypeModule</type></link>, using
+          <link linkend="g-type-module-register-type"><function>g_type_module_register_type()</function></link> function rather
+          than <link linked="g-type-register-static"><function>g_type_register_static()</function></link>. All types exported by
+          an extension must be registered in
+          <link linkend="thunar-extension-initialize"><function>thunar_extension_initialize()</function></link>.
+        </para>
+      </sect2>
+    </sect1>
+
+    <sect1 id="thunarx-writing-extensions-getting-started">
+      <title>Getting Started</title>
+
+      <para>
+        Providers are <link linkend="GTypeModule"><type>GTypeModule</type></link>s loaded from shared libraries installed in
+        <filename role="directory">$libdir/thunarx-1/</filename>. The shared libraries are linked against the
+        <systemitem class="library">thunarx-1</systemitem> library.
+      </para>
+
+      <para>
+        The extensions must provide three public functions, <function>thunar_extension_initialize()</function>,
+        <function>thunar_extension_shutdown()</function> and <function>thunar_extension_list_types()</function>.
+      </para>
+
+      <para>
+        <function>thunar_extension_initialize()</function> is passed a <link linkend="GTypeModule"><type>GTypeModule</type></link>
+        object, and must register all GTypes that the extension needs. <function>thunar_extension_shutdown()</function> should
+        perform any extension-specific shutdown required prior to unloading the extension. <function>thunar_extension_list_types()</function>
+        returns an array of GTypes that represent the types of the providers exported by the extension. Thunar will instantiate
+        objects of those types when needed.
+      </para>
+
+      <example>
+        <title>Basic Structure of an extension</title>
+
+        <programlisting>
+#include &lt;gmodule.h&gt;
+#include &lt;thunarx/thunarx.h&gt;
+
+static GType type_list[1];
+
+static void
+foo_extension_register_type (GTypeModule *module)
+{
+  static const GTypeInfo info =
+  {
+    sizeof (FooExtensionClass),
+    NULL,
+    NULL,
+    (GClassInitFunc) foo_extension_class_init,
+    NULL,
+    NULL,
+    sizeof (FooExtension),
+    0,
+    (GInstanceInitFunc) foo_extension_init,
+    NULL,
+  };
+
+  type_list[0] = g_type_module_register_type (module,
+                                              G_TYPE_OBJECT,
+                                              "FooExtension",
+                                              &amp;info, 0);
+
+  /* implement the desired provider interfaces */
+}
+
+static GType
+foo_extension_get_type (void)
+{
+  return type_list[0];
+}
+
+G_MODULE_EXPORT void
+thunar_extension_initialize (GTypeModule *module)
+{
+  const gchar *mismatch;
+
+  /* verify the versions */
+  mismatch = thunarx_check_version (THUNARX_MAJOR_VERSION,
+                                    THUNARX_MINOR_VERSION,
+                                    THUNARX_MICRO_VERSION);
+  if (G_UNLIKELY (mismatch != NULL))
+    {
+      g_warning ("Version mismatch: %s", mismatch);
+      return;
+    }
+
+  foo_extension_register_type (module);
+}
+
+G_MODULE_EXPORT void
+thunar_extension_shutdown (void)
+{
+  /* any extension-specific shutdown */
+}
+
+G_MODULE_EXPORT void
+thunar_extension_list_types (const GType **types,
+                             gint         *n_types)
+{
+  *types = type_list;
+  *n_types = G_N_ELEMENTS (type_list);
+}</programlisting>
+      </example>
+
+      <sect2 id="thunarx-writing-extensions-compiling-thunar-extensions">
+        <title>Compiling Thunar Extensions</title>
+
+        <para>
+          To compile a Thunar extension, you need to tell the compiler where to find the
+          <systemitem class="library">thunarx</systemitem> header files and library. This
+          is done with the <literal>pkg-config</literal> utility.
+        </para>
+
+        <para>
+          The following interactive shell session demonstrates how <literal>pkg-config</literal>
+          is used (the actual output on your system will be different):
+          <screen>
+$ pkg-config --cflags thunarx-1
+-DXTHREADS -DXUSE_MTSAFE_API -I/opt/local/include/thunarx-1 -I/usr/local/include/atk-1.0 \
+-I/usr/local/include/glib-2.0 -I/usr/local/lib/glib-2.0/include -I/usr/X11R6/include/gtk-2.0 \
+-I/usr/X11R6/lib/gtk-2.0/include -I/usr/X11R6/include -I/usr/X11R6/include/pango-1.0 \
+-I/usr/local/include/freetype2 -I/usr/local/include
+$ pkg-config --libs thunarx-1
+-Wl,--rpath -Wl,/usr/local/lib -L/usr/local/lib -L/usr/X11R6/lib -L/opt/local/lib -lthunarx-1</screen>
+        </para>
+
+        <para>
+          The easiest way to compile an extension is to use the <emphasis>backticks</emphasis>
+          feature of the shell. If you enclose a command in backticks (<emphasis>not single
+          quotes</emphasis>), then its output will be substituted into the command line before
+          execution. So to compile an extension, you would type the following:
+          <screen>
+$ gcc -shared -fPIC -DPIC `pkg-config --cflags --libs thunarx-1` foo.c -o foo.so</screen>
+        </para>
+      </sect2>
+
+      <sect2 id="thunarx-writing-extensions-installing-thunar-extensions">
+        <title>Installing Thunar Extensions</title>
+
+        <para>
+          To determine the directory where extensions must be installed on your local system,
+          you can use the following command (as mentioned above, the output will be different
+          on your system):
+          <screen>
+$ pkg-config --variable=extensionsdir thunarx-1
+/opt/local/lib/thunarx-1</screen>
+        </para>
+
+        <para>
+          For example, to install the extension <filename>foo.so</filename> on your system,
+          you would type the following:
+          <screen>
+$ install -d `pkg-config --variable=extensionsdir thunarx-1`
+$ install -c -m 0755 foo.so `pkg-config --variable=extensionsdir thunarx-1`/foo.so</screen>
+        </para>
+      </sect2>
+    </sect1>
+
+    <sect1 id="thunarx-writing-extensions-advanced-topics">
+      <title>Advanced topics</title>
+
+      <para>
+        This section provides a short introduction to some of the advanced topics in the
+        Thunar Extension Framework.
+      </para>
+
+      <sect2 id="thunarx-writing-extensions-memory-resident-extensions">
+        <title>Memory-Resident Extensions</title>
+
+        <para>
+          Some extensions may not play well with Thunar's on-demand loading and unloading
+          of extensions. For example, an extension that uses a desktop library, which in
+          turn registers additional static GTypes will not work after being loaded and
+          unloaded for the first time. For these kind of extensions, Thunar provides the
+          option to make extensions <emphasis>memory resident</emphasis>, which means the
+          extension will be loaded once and afterwards will never be unloaded again until
+          Thunar exits.
+        </para>
+
+        <para>
+          Such extensions must set the <literal>resident</literal> property of the type
+          module in its <function>thunar_extension_initialize()</function> function to
+          <literal>TRUE</literal>.
+        </para>
+
+        <example>
+          <title>Making an extension memory resident</title>
+          <programlisting>
+G_MODULE_EXPORT void
+thunar_extension_initialize (GTypeModule *module)
+{
+  /* setup the types for the extension */
+  ...
+
+  /* ensure that the extension will never be unloaded */
+  g_object_set (G_OBJECT (module),
+                "resident", TRUE,
+                NULL);
+}</programlisting>
+        </example>
+      </sect2>
+    </sect1>
+  </part>
+
+  <part id="thunarx-fundamentals">
+    <title>Fundamentals</title>
+
+    &thunarx-version-information;
+  </part>
+
+  <part id="thunarx-abstraction-layer">
+    <title>Abstraction Layer</title>
+
+    <para>
+      In order to hide the internals of the file manager from the extensions, the <systemitem
+      class="library">thunarx</systemitem> provides an abstraction layer, which includes interfaces
+      accessible to the extension, that are implemented by the file manager at runtime.
+    </para>
+
+    <para>
+      <inlinegraphic fileref="abstraction.png" format="PNG" />
+    </para>
+
+    <para>
+      Currently the abstraction layer consists of the interface <link
+      linkend="ThunarxFileInfo"><type>ThunarxFileInfo</type></link>, which provides
+      extensions with a way to access information about a file handled within
+      the file manager, and the class <link
+      linkend="ThunarxPropertyPage"><type>ThunarxPropertyPage</type></link>, which
+      is the base class for widgets that can be added to the properties dialog by
+      extensions.
+    </para>
+
+    &ThunarxFileInfo;
+    &ThunarxPropertyPage;
+  </part>
+
+  <part id="thunarx-providers">
+    <title>Providers</title>
+
+    <para>
+      The extensions interact with the file manager by implementing so called
+      <emphasis>providers</emphasis>. This is a concept adopted from the Nautilus
+      Extension Framework.
+    </para>
+
+    <para>
+      Providers are interfaces in the <systemitem class="library">thunarx</systemitem>
+      library that describe the functionality provided by a certain extension. For
+      example, when the file manager pops up the file context menu, it'll first lookup
+      all extensions that implement the interface <interface>ThunarxMenuProvider</interface>
+      ask those extensions for the list of additional actions.
+    </para>
+
+    <para>
+      <inlinegraphic fileref="menu-provider.png" format="PNG" />
+    </para>
+
+    &ThunarxMenuProvider;
+    &ThunarxPropertyPageProvider;
+  </part>
+
+  <index>
+    <title>Index</title>
+  </index>
+</book>
+
+<!--
+  vi:set ts=2 sw=2 et ai syntax=docbkxml:
+-->
diff --git a/docs/reference/thunarx/thunarx-sections.txt b/docs/reference/thunarx/thunarx-sections.txt
new file mode 100644 (file)
index 0000000..1511a2e
--- /dev/null
@@ -0,0 +1,92 @@
+<INCLUDE>thunarx/thunarx.h</INCLUDE>
+
+<SECTION>
+<FILE>thunarx-file-info</FILE>
+<TITLE>ThunarxFileInfo</TITLE>
+ThunarxFileInfoIface
+ThunarxFileInfo
+thunarx_file_info_get_name
+thunarx_file_info_get_uri
+thunarx_file_info_get_parent_uri
+thunarx_file_info_get_uri_scheme
+thunarx_file_info_get_mime_type
+thunarx_file_info_has_mime_type
+thunarx_file_info_is_directory
+thunarx_file_info_list_copy
+thunarx_file_info_list_free
+<SUBSECTION Standard>
+THUNARX_TYPE_FILE_INFO
+THUNARX_FILE_INFO
+THUNARX_IS_FILE_INFO
+THUNARX_FILE_INFO_GET_IFACE
+<SUBSECTION Private>
+thunarx_file_info_get_type
+</SECTION>
+
+<SECTION>
+<FILE>thunarx-menu-provider</FILE>
+<TITLE>ThunarxMenuProvider</TITLE>
+ThunarxMenuProviderIface
+ThunarxMenuProvider
+thunarx_menu_provider_get_file_actions
+thunarx_menu_provider_get_folder_actions
+<SUBSECTION Standard>
+THUNARX_TYPE_MENU_PROVIDER
+THUNARX_MENU_PROVIDER
+THUNARX_IS_MENU_PROVIDER
+THUNARX_MENU_PROVIDER_GET_IFACE
+<SUBSECTION Private>
+thunarx_menu_provider_get_type
+</SECTION>
+
+<SECTION>
+<FILE>thunarx-property-page</FILE>
+<TITLE>ThunarxPropertyPage</TITLE>
+ThunarxPropertyPage
+thunarx_property_page_new
+thunarx_property_page_new_with_label_widget
+thunarx_property_page_get_label
+thunarx_property_page_set_label
+thunarx_property_page_get_label_widget
+thunarx_property_page_set_label_widget
+<SUBSECTION Standard>
+ThunarxPropertyPageClass
+THUNARX_TYPE_PROPERTY_PAGE
+THUNARX_PROPERTY_PAGE
+THUNARX_PROPERTY_PAGE_CLASS
+THUNARX_IS_PROPERTY_PAGE
+THUNARX_IS_PROPERTY_PAGE_CLASS
+THUNARX_PROPERTY_PAGE_GET_CLASS
+<SUBSECTION Private>
+ThunarxPropertyPagePrivate
+thunarx_property_page_get_type
+</SECTION>
+
+<SECTION>
+<FILE>thunarx-property-page-provider</FILE>
+<TITLE>ThunarxPropertyPageProvider</TITLE>
+ThunarxPropertyPageProvider
+ThunarxPropertyPageProviderIface
+thunarx_property_page_provider_get_pages
+<SUBSECTION Standard>
+THUNARX_TYPE_PROPERTY_PAGE_PROVIDER
+THUNARX_PROPERTY_PAGE_PROVIDER
+THUNARX_IS_PROPERTY_PAGE_PROVIDER
+THUNARX_PROPERTY_PAGE_PROVIDER_GET_IFACE
+<SUBSECTION Private>
+thunarx_property_page_provider_get_type
+</SECTION>
+
+<SECTION>
+<FILE>thunarx-version-information</FILE>
+<TITLE>Variables and functions to check the library version</TITLE>
+thunarx_major_version
+thunarx_minor_version
+thunarx_micro_version
+thunarx_check_version
+THUNARX_MAJOR_VERSION
+THUNARX_MINOR_VERSION
+THUNARX_MICRO_VERSION
+THUNARX_CHECK_VERSION
+</SECTION>
+
diff --git a/docs/reference/thunarx/thunarx.types b/docs/reference/thunarx/thunarx.types
new file mode 100644 (file)
index 0000000..604cc03
--- /dev/null
@@ -0,0 +1,6 @@
+#include <thunarx/thunarx.h>
+
+thunarx_file_info_get_type
+thunarx_menu_provider_get_type
+thunarx_property_page_get_type
+thunarx_property_page_provider_get_type
diff --git a/docs/reference/thunarx/tmpl/thunarx-file-info.sgml b/docs/reference/thunarx/tmpl/thunarx-file-info.sgml
new file mode 100644 (file)
index 0000000..362ef9a
--- /dev/null
@@ -0,0 +1,122 @@
+<!-- ##### SECTION Title ##### -->
+ThunarxFileInfo
+
+<!-- ##### SECTION Short_Description ##### -->
+Abstraction of a file handled within the file manager
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+  The <interface>ThunarxFileInfo</interface> interface provides extensions with
+  a way to access information about a file handled within the file manager.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+Stable
+
+<!-- ##### STRUCT ThunarxFileInfoIface ##### -->
+<para>
+  Interface with virtual methods implemented by the file manager and accessible
+  from the extensions.
+</para>
+
+@get_name: See thunarx_file_info_get_name().
+@get_uri: See thunarx_file_info_get_uri().
+@get_parent_uri: See thunarx_file_info_get_parent_uri().
+@get_uri_scheme: See thunarx_file_info_get_uri_scheme().
+@get_mime_type: See thunarx_file_info_get_mime_type().
+@has_mime_type: See thunarx_file_info_has_mime_type().
+@is_directory: See thunarx_file_info_is_directory().
+
+<!-- ##### STRUCT ThunarxFileInfo ##### -->
+<para>
+       File info type, which is mapped to the real file info implementation
+       within the file manager.
+</para>
+
+
+<!-- ##### FUNCTION thunarx_file_info_get_name ##### -->
+<para>
+
+</para>
+
+@file_info: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_get_uri ##### -->
+<para>
+
+</para>
+
+@file_info: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_get_parent_uri ##### -->
+<para>
+
+</para>
+
+@file_info: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_get_uri_scheme ##### -->
+<para>
+
+</para>
+
+@file_info: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_get_mime_type ##### -->
+<para>
+
+</para>
+
+@file_info: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_has_mime_type ##### -->
+<para>
+
+</para>
+
+@file_info: 
+@mime_type: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_is_directory ##### -->
+<para>
+
+</para>
+
+@file_info: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_list_copy ##### -->
+<para>
+
+</para>
+
+@file_infos: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_file_info_list_free ##### -->
+<para>
+
+</para>
+
+@file_infos: 
+
+
diff --git a/docs/reference/thunarx/tmpl/thunarx-menu-provider.sgml b/docs/reference/thunarx/tmpl/thunarx-menu-provider.sgml
new file mode 100644 (file)
index 0000000..c50d9f8
--- /dev/null
@@ -0,0 +1,175 @@
+<!-- ##### SECTION Title ##### -->
+ThunarxMenuProvider
+
+<!-- ##### SECTION Short_Description ##### -->
+The interface to extensions that provide additional menu items
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+  The <interface>ThunarxMenuProvider</interface> interface is implemented by
+  extensions which provide additional menu items that should be displayed in
+  the file or folder context menus for certain types of files.
+</para>
+
+<para>
+  Extensions that implement this interface should do its best to respond as
+  fast as possible to method invokations by the file manager. That said, when
+  the file manager calls the thunarx_menu_provider_get_file_actions() or the
+  thunarx_menu_provider_get_folder_actions() method, the implementation in the
+  extension should use only the thunarx_file_info_has_mime_type() and
+  thunarx_file_info_is_directory() methods to determine the actions that should
+  be added to the file manager's context menu. Don't perform any complicated I/O
+  to determine the action list, as that would block the whole file manager process.
+</para>
+
+<para>
+  The <link linkend="GtkAction">GtkAction</link>s returned from the
+  thunarx_menu_provider_get_file_actions() and thunarx_menu_provider_get_folder_actions()
+  methods 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 <systemitem class="library">ThunarOpenTerminal</systemitem> extension should be
+  called <literal>ThunarOpenTerminal::open-terminal</literal>.
+</para>
+
+<example>
+  <title>Menu provider example</title>
+
+  <programlisting>
+static GType hello_type;
+
+static void   hello_menu_provider_init (ThunarxMenuProviderIface *iface);
+static GList *hello_get_file_actions   (ThunarxMenuProvider      *provider,
+                                        GtkWidget                *window,
+                                        GList                    *files);
+
+static void
+hello_register_type (GTypeModule *module)
+{
+  static const GTypeInfo info =
+  {
+    sizeof (HelloClass),
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    sizeof (Hello),
+    0,
+    NULL,
+    NULL,
+  };
+
+  static const GInterfaceInfo menu_provider_info =
+  {
+    (GInterfaceInitFunc) hello_menu_provider_init,
+    NULL,
+    NULL,
+  };
+
+  hello_type = g_type_module_register_type (module, G_TYPE_OBJECT,
+                                            "Hello", &amp;info, 0);
+  g_type_module_add_interface (module, hello_type,
+                               THUNARX_TYPE_MENU_PROVIDER,
+                               &amp;menu_provider_info);
+}
+
+static void
+hello_menu_provider_init (ThunarxMenuProviderIface *iface)
+{
+  iface->get_file_actions = hello_get_file_actions;
+}
+
+static void
+hello_activated (GtkAction *action,
+                 GtkWidget *window)
+{
+  GtkWidget *dialog;
+
+  dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                   GTK_DIALOG_MODAL
+                                   | GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_INFO,
+                                   GTK_BUTTONS_OK,
+                                   "Hello World!");
+  gtk_dialog_run (GTK_DIALOG (dialog));
+  gtk_widget_destroy (dialog);
+}
+
+static GList*
+hello_get_file_actions (ThunarxMenuProvider *provider,
+                        GtkWidget           *window,
+                        GList               *files)
+{
+  GtkAction *action;
+
+  action = gtk_action_new ("Hello::say-hello",
+                           "Say hello", "Say hello",
+                           NULL);
+  g_signal_connect (G_OBJECT (action), "activate",
+                    G_CALLBACK (hello_activated),
+                    window);
+
+  return g_list_append (NULL, action);
+}</programlisting>
+
+  <para>
+    The above example will add an item <guimenu><guimenuitem>Say hello</guimenuitem></guimenu>
+    to the file context menus as shown in the picture below:
+  </para>
+
+  <para>
+    <inlinegraphic fileref="say-hello.png" format="PNG" />
+  </para>
+</example>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+  The description of the <link linkend="ThunarxFileInfo">ThunarxFileInfo</link>
+  interface.
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+Stable
+
+<!-- ##### STRUCT ThunarxMenuProviderIface ##### -->
+<para>
+  Interface with virtual methods implemented by extensions that provide
+  additional menu items for the file manager's context menus.
+</para>
+
+<para>
+  Providers don't need to implement all of the virtual methods listed in
+  the interface.
+</para>
+
+@get_file_actions: See thunarx_menu_provider_get_file_actions().
+@get_folder_actions: See thunarx_menu_provider_get_folder_actions().
+
+<!-- ##### STRUCT ThunarxMenuProvider ##### -->
+<para>
+  Menu provider type.
+</para>
+
+
+<!-- ##### FUNCTION thunarx_menu_provider_get_file_actions ##### -->
+<para>
+
+</para>
+
+@provider: 
+@window: 
+@files: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_menu_provider_get_folder_actions ##### -->
+<para>
+
+</para>
+
+@provider: 
+@window: 
+@folder: 
+@Returns: 
+
+
diff --git a/docs/reference/thunarx/tmpl/thunarx-property-page-provider.sgml b/docs/reference/thunarx/tmpl/thunarx-property-page-provider.sgml
new file mode 100644 (file)
index 0000000..d744765
--- /dev/null
@@ -0,0 +1,47 @@
+<!-- ##### SECTION Title ##### -->
+ThunarxPropertyPageProvider
+
+<!-- ##### SECTION Short_Description ##### -->
+The interface to extensions that provide additional property pages
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+  To add a property page to the file properties dialog, extensions must implement the
+  <type>ThunarxPropertyPageProvider</type> interface. This interface has only one virtual
+  method, <function>get_pages</function>, that is passed a list of <link
+  linkend="ThunarxFileInfo"><type>ThunarxFileInfo</type></link> objects and returns a list
+  of <link linkend="ThunarxPropertyPage"><type>ThunarxPropertyPage</type></link> objects.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+  The description of the <link linkend="ThunarxPropertyPage"><type>ThunarxPropertyPage</type></link> class.
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+Stable
+
+<!-- ##### STRUCT ThunarxPropertyPageProvider ##### -->
+<para>
+  Property page provider type.
+</para>
+
+
+<!-- ##### STRUCT ThunarxPropertyPageProviderIface ##### -->
+<para>
+       Interface with virtual methods implemented by extensions that provide
+       additional pages for the file properties dialog.
+</para>
+
+@get_pages: See thunarx_property_page_provider_get_pages().
+
+<!-- ##### FUNCTION thunarx_property_page_provider_get_pages ##### -->
+<para>
+
+</para>
+
+@provider: 
+@files: 
+@Returns: 
+
+
diff --git a/docs/reference/thunarx/tmpl/thunarx-property-page.sgml b/docs/reference/thunarx/tmpl/thunarx-property-page.sgml
new file mode 100644 (file)
index 0000000..6e05255
--- /dev/null
@@ -0,0 +1,90 @@
+<!-- ##### SECTION Title ##### -->
+ThunarxPropertyPage
+
+<!-- ##### SECTION Short_Description ##### -->
+Base class for pages added to the properties dialog
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+  The class for pages that can be added to Thunar's file properties dialog
+  by extensions implementing the #ThunarxPropertyPageProvider interface.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+  The description of the <link linkend="ThunarxPropertyPageProvider"><type>ThunarxPropertyPageProvider</type></link> interface.
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+Stable
+
+<!-- ##### STRUCT ThunarxPropertyPage ##### -->
+<para>
+  Base instance type for property pages.
+</para>
+
+
+<!-- ##### ARG ThunarxPropertyPage:label ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG ThunarxPropertyPage:label-widget ##### -->
+<para>
+
+</para>
+
+<!-- ##### FUNCTION thunarx_property_page_new ##### -->
+<para>
+
+</para>
+
+@label: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_property_page_new_with_label_widget ##### -->
+<para>
+
+</para>
+
+@label_widget: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_property_page_get_label ##### -->
+<para>
+
+</para>
+
+@property_page: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_property_page_set_label ##### -->
+<para>
+
+</para>
+
+@property_page: 
+@label: 
+
+
+<!-- ##### FUNCTION thunarx_property_page_get_label_widget ##### -->
+<para>
+
+</para>
+
+@property_page: 
+@Returns: 
+
+
+<!-- ##### FUNCTION thunarx_property_page_set_label_widget ##### -->
+<para>
+
+</para>
+
+@property_page: 
+@label_widget: 
+
+
diff --git a/docs/reference/thunarx/tmpl/thunarx-version-information.sgml b/docs/reference/thunarx/tmpl/thunarx-version-information.sgml
new file mode 100644 (file)
index 0000000..5834bbe
--- /dev/null
@@ -0,0 +1,96 @@
+<!-- ##### SECTION Title ##### -->
+Version information
+
+<!-- ##### SECTION Short_Description ##### -->
+Variables and functions to check the library version
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+  The Thunar Extension library provides version information,
+  which should be used by extensions.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+Stable
+
+<!-- ##### VARIABLE thunarx_major_version ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### VARIABLE thunarx_minor_version ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### VARIABLE thunarx_micro_version ##### -->
+<para>
+
+</para>
+
+
+<!-- ##### FUNCTION thunarx_check_version ##### -->
+<para>
+
+</para>
+
+@required_major: 
+@required_minor: 
+@required_micro: 
+@Returns: 
+
+
+<!-- ##### MACRO THUNARX_MAJOR_VERSION ##### -->
+<para>
+  The major version number of the <systemitem class="library">thunarx</systemitem> library.
+  Like thunarx_major_version, but from the headers used at application compile time, rather
+  than from the library linked against at application run time.
+</para>
+
+
+
+<!-- ##### MACRO THUNARX_MINOR_VERSION ##### -->
+<para>
+  The minor version number of the <systemitem class="library">thunarx</systemitem> library.
+  Like thunarx_minor_version, but from the headers used at application compile time, rather
+  than from the library linked against at application run time.
+</para>
+
+
+
+<!-- ##### MACRO THUNARX_MICRO_VERSION ##### -->
+<para>
+  The micro version number of the <systemitem class="library">thunarx</systemitem> library.
+  Like thunarx_micro_version, but from the headers used at application compile time, rather
+  than from the library linked against at application run time.
+</para>
+
+
+
+<!-- ##### MACRO THUNARX_CHECK_VERSION ##### -->
+<para>
+  Checks the version of the <systemitem class="library">thunarx</systemitem> library. Returns
+  %TRUE if the version of the <systemitem class="library">thunarx</systemitem> header files is
+  the same as or newer than the passed-in version.
+</para>
+
+<example>
+  <title>Checking the version of the Thunar Extension library</title>
+
+  <programlisting>
+if (!THUNARX_CHECK_VERSION (0, 1, 0))
+  g_error ("Thunarx version 0.1.0 or above is required");</programlisting>
+</example>
+
+@major: the major version number.
+@minor: the minor version number
+@micro: the micro version number.
+
+
diff --git a/docs/reference/thunarx/version.xml.in b/docs/reference/thunarx/version.xml.in
new file mode 100644 (file)
index 0000000..a24f987
--- /dev/null
@@ -0,0 +1 @@
+@PACKAGE_VERSION@
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644 (file)
index 0000000..0811c7e
--- /dev/null
@@ -0,0 +1,6 @@
+# $Id$
+
+SUBDIRS =                                                              \
+       open-terminal-here
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/examples/open-terminal-here/Makefile.am b/examples/open-terminal-here/Makefile.am
new file mode 100644 (file)
index 0000000..75d0253
--- /dev/null
@@ -0,0 +1,40 @@
+# $Id$
+
+INCLUDES =                                                             \
+       -I$(top_builddir)                                               \
+       -I$(top_srcdir)                                                 \
+       -DG_LOG_DOMAIN=\"OpenTerminalHere\"
+
+extensionsdir = $(libdir)/thunarx-$(THUNAR_VERSION_API)
+extensions_LTLIBRARIES =                                               \
+       open-terminal-here.la
+
+open_terminal_here_la_SOURCES =                                                \
+       open-terminal-here.c
+
+open_terminal_here_la_CFLAGS =                                         \
+       $(GTK_CFLAGS)
+
+open_terminal_here_la_DEPENDENCIES =                                   \
+       $(top_builddir)/thunarx/libthunarx-$(THUNAR_VERSION_API).la
+
+open_terminal_here_la_LIBADD =                                         \
+       $(top_builddir)/thunarx/libthunarx-$(THUNAR_VERSION_API).la     \
+       $(GTK_LIBS)
+
+open_terminal_here_la_LDFLAGS =                                                \
+       -avoid-version                                                  \
+       -export-dynamic                                                 \
+       -module
+
+CLEANFILES =                                                           \
+       open-terminal-here.la
+
+EXTRA_DIST =                                                           \
+       README
+
+# Don't install/uninstall examples by default
+install:
+uninstall:
+
+# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/examples/open-terminal-here/README b/examples/open-terminal-here/README
new file mode 100644 (file)
index 0000000..d56759f
--- /dev/null
@@ -0,0 +1,15 @@
+This is an example for a Thunar Extension that provides additional context
+menu items. It adds an "Open Terminal Here" action to the folder context
+menu and to the file context menu of directories, and thereby allows you
+to open a new Terminal instance in the given folder.
+
+The example is mainly provided for developers to get an idea about how
+to write an extension that implements the ThunarxMenuProvider interface.
+
+The extension is not installed by default, as every installed extension
+increases the resources required to run Thunar. If you want to install
+this extension, you can use the command
+
+  make install-extensionsLTLIBRARIES
+
+in this directory.
diff --git a/examples/open-terminal-here/open-terminal-here.c b/examples/open-terminal-here/open-terminal-here.c
new file mode 100644 (file)
index 0000000..e512b3f
--- /dev/null
@@ -0,0 +1,246 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <thunarx/thunarx.h>
+
+
+
+/* make sure to export the required public functions */
+#ifdef HAVE_GNUC_VISIBILITY
+extern void thunar_extension_initialize (GTypeModule *module) __attribute__((visibility("default")));
+extern void thunar_extension_shutdown (void) __attribute__((visibility("default")));
+extern void thunar_extension_list_types (const GType **types, gint *n_types) __attribute__((visibility("default")));
+#else
+extern G_MODULE_EXPORT void thunar_extension_initialize (GTypeModule *module);
+extern G_MODULE_EXPORT void thunar_extension_shutdown (void);
+extern G_MODULE_EXPORT void thunar_extension_list_types (const GType **types, gint *n_types);
+#endif
+
+
+
+static GType type_list[1];
+
+
+
+typedef struct _OpenTerminalHereClass OpenTerminalHereClass;
+typedef struct _OpenTerminalHere      OpenTerminalHere;
+
+
+
+static void   open_terminal_here_register_type      (GTypeModule              *module);
+static void   open_terminal_here_menu_provider_init (ThunarxMenuProviderIface *iface);
+static GList *open_terminal_here_get_file_actions   (ThunarxMenuProvider      *provider,
+                                                     GtkWidget                *window,
+                                                     GList                    *files);
+static GList *open_terminal_here_get_folder_actions (ThunarxMenuProvider      *provider,
+                                                     GtkWidget                *window,
+                                                     ThunarxFileInfo          *folder);
+static void   open_terminal_here_activated          (GtkAction                *action,
+                                                     GtkWidget                *window);
+
+
+
+struct _OpenTerminalHereClass
+{
+  GObjectClass __parent__;
+};
+
+struct _OpenTerminalHere
+{
+  GObject __parent__;
+};
+
+
+
+static void
+open_terminal_here_register_type (GTypeModule *module)
+{
+  static const GTypeInfo info =
+  {
+    sizeof (OpenTerminalHereClass),
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    sizeof (OpenTerminalHere),
+    0,
+    NULL,
+    NULL,
+  };
+
+  static const GInterfaceInfo menu_provider_info =
+  {
+    (GInterfaceInitFunc) open_terminal_here_menu_provider_init,
+    NULL,
+    NULL,
+  };
+
+  type_list[0] = g_type_module_register_type (module, G_TYPE_OBJECT, "OpenTerminalHere", &info, 0);
+  g_type_module_add_interface (module, type_list[0], THUNARX_TYPE_MENU_PROVIDER, &menu_provider_info);
+}
+
+
+
+static void
+open_terminal_here_menu_provider_init (ThunarxMenuProviderIface *iface)
+{
+  iface->get_file_actions = open_terminal_here_get_file_actions;
+  iface->get_folder_actions = open_terminal_here_get_folder_actions;
+}
+
+
+
+static GList*
+open_terminal_here_get_file_actions (ThunarxMenuProvider *provider,
+                                     GtkWidget           *window,
+                                     GList               *files)
+{
+  /* check if we have a directory here */
+  if (G_LIKELY (files != NULL && files->next == NULL && thunarx_file_info_is_directory (files->data)))
+    return open_terminal_here_get_folder_actions (provider, window, files->data);
+
+  return NULL;
+}
+
+
+
+static GList*
+open_terminal_here_get_folder_actions (ThunarxMenuProvider *provider,
+                                       GtkWidget           *window,
+                                       ThunarxFileInfo     *folder)
+{
+  GtkAction *action = NULL;
+  gchar     *scheme;
+  gchar     *path;
+  gchar     *uri;
+
+  /* determine the uri scheme of the folder and check if we support it */
+  scheme = thunarx_file_info_get_uri_scheme (folder);
+  if (G_LIKELY (strcmp (scheme, "file") == 0))
+    {
+      /* determine the local path to the folder */
+      uri = thunarx_file_info_get_uri (folder);
+      path = g_filename_from_uri (uri, NULL, NULL);
+      g_free (uri);
+
+      /* check if we have a valid path here */
+      if (G_LIKELY (path != NULL))
+        {
+          action = gtk_action_new ("OpenTerminalHere::open-terminal-here", "Open Terminal Here", "Open Terminal in this folder", NULL);
+          g_signal_connect (G_OBJECT (action), "activate", G_CALLBACK (open_terminal_here_activated), window);
+          g_object_set_data_full (G_OBJECT (action), "open-terminal-here-path", path, g_free);
+        }
+    }
+  g_free (scheme);
+
+  return (action != NULL) ? g_list_prepend (NULL, action) : NULL;
+}
+
+
+
+static void
+open_terminal_here_activated (GtkAction *action,
+                              GtkWidget *window)
+{
+  const gchar *path;
+  GtkWidget   *dialog;
+  GError      *error = NULL;
+  gchar       *command;
+
+  /* determine the folder path */
+  path = g_object_get_data (G_OBJECT (action), "open-terminal-here-path");
+  if (G_UNLIKELY (path == NULL))
+    return;
+  
+  /* build up the command line for the terminal */
+  command = g_strdup_printf ("Terminal --working-directory \"%s\"", path);
+
+  //g_message ("COMMAND=\"%s\"", command);return;
+
+  /* try to run the terminal command */
+  if (!gdk_spawn_command_line_on_screen (gtk_widget_get_screen (window), command, &error))
+    {
+      /* display an error dialog */
+      dialog = gtk_message_dialog_new (GTK_WINDOW (window),
+                                       GTK_DIALOG_DESTROY_WITH_PARENT,
+                                       GTK_MESSAGE_ERROR,
+                                       GTK_BUTTONS_CLOSE,
+                                       "Failed to open terminal in folder %s.",
+                                       path);
+      gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s.", error->message);
+      gtk_dialog_run (GTK_DIALOG (dialog));
+      gtk_widget_destroy (dialog);
+      g_error_free (error);
+    }
+
+  /* cleanup */
+  g_free (command);
+}
+
+
+
+void
+thunar_extension_initialize (GTypeModule *module)
+{
+  const gchar *mismatch;
+
+  /* verify that the thunarx versions are compatible */
+  mismatch = thunarx_check_version (THUNARX_MAJOR_VERSION, THUNARX_MINOR_VERSION, THUNARX_MICRO_VERSION);
+  if (G_UNLIKELY (mismatch != NULL))
+    {
+      g_warning ("Version mismatch: %s", mismatch);
+      return;
+    }
+
+  g_message ("Initializing OpenTerminalHere extension");
+
+  open_terminal_here_register_type (module);
+}
+
+
+
+void
+thunar_extension_shutdown (void)
+{
+  g_message ("Shutting down OpenTerminalHere extension");
+}
+
+
+
+void
+thunar_extension_list_types (const GType **types,
+                             gint         *n_types)
+{
+  *types = type_list;
+  *n_types = G_N_ELEMENTS (type_list);
+}
+
index 90f6204..f94282d 100644 (file)
@@ -107,5 +107,6 @@ thunar/thunar-view.c
 thunar/thunar-view.h
 thunar/thunar-window.c
 thunar/thunar-window.h
+thunarx/thunarx-property-page.c
 
 Thunar.desktop.in
index 8181f88..d7f833b 100644 (file)
@@ -6,7 +6,9 @@ INCLUDES =                                                              \
        -DEXO_API_SUBJECT_TO_CHANGE                                     \
        -DEXO_DISABLE_DEPRECATED                                        \
        -DG_LOG_DOMAIN=\"Thunar\"                                       \
-       -DPACKAGE_LOCALE_DIR=\"$(localedir)\"
+       -DLIBDIR=\"$(libdir)\"                                          \
+       -DPACKAGE_LOCALE_DIR=\"$(localedir)\"                           \
+       -DTHUNAR_VERSION_API=\"$(THUNAR_VERSION_API)\"
 
 bin_PROGRAMS =                                                         \
        Thunar
@@ -16,6 +18,7 @@ thunar_built_sources =                                                        \
        thunar-marshal.h
 
 Thunar_SOURCES =                                                       \
+       $(thunar_include_HEADERS)                                       \
        $(thunar_built_sources)                                         \
        main.c                                                          \
        thunar-application.c                                            \
@@ -34,6 +37,8 @@ Thunar_SOURCES =                                                      \
        thunar-details-view.h                                           \
        thunar-dnd.c                                                    \
        thunar-dnd.h                                                    \
+       thunar-extension-manager.c                                      \
+       thunar-extension-manager.h                                      \
        thunar-fallback-icon.c                                          \
        thunar-fallback-icon.h                                          \
        thunar-favourites-model.c                                       \
@@ -46,6 +51,10 @@ Thunar_SOURCES =                                                     \
        thunar-file.h                                                   \
        thunar-folder.c                                                 \
        thunar-folder.h                                                 \
+       thunar-gdk-pixbuf-extensions.c                                  \
+       thunar-gdk-pixbuf-extensions.h                                  \
+       thunar-gtk-extensions.c                                         \
+       thunar-gtk-extensions.h                                         \
        thunar-icon-factory.c                                           \
        thunar-icon-factory.h                                           \
        thunar-icon-renderer.c                                          \
@@ -115,11 +124,11 @@ Thunar_LDFLAGS =                                                  \
 
 Thunar_LDADD =                                                         \
        $(top_builddir)/thunar-vfs/libthunar-vfs-$(THUNAR_VERSION_API).la \
-       $(top_builddir)/thunarx/libthunarx.la
+       $(top_builddir)/thunarx/libthunarx-$(THUNAR_VERSION_API).la
 
 Thunar_DEPENDENCIES =                                                  \
        $(top_builddir)/thunar-vfs/libthunar-vfs-$(THUNAR_VERSION_API).la \
-       $(top_builddir)/thunarx/libthunarx.la
+       $(top_builddir)/thunarx/libthunarx-$(THUNAR_VERSION_API).la
 
 # install symlink to 'thunar'
 install-data-local:
index 7b16dd9..5416481 100644 (file)
@@ -31,8 +31,7 @@
 #include <thunar/thunar-desktop-model.h>
 #include <thunar/thunar-desktop-view.h>
 #include <thunar/thunar-file.h>
-
-#include <thunarx/thunarx-gdk-pixbuf-extensions.h>
+#include <thunar/thunar-gdk-pixbuf-extensions.h>
 
 
 
@@ -553,7 +552,7 @@ thunar_desktop_view_render_item (ThunarDesktopView     *view,
     {
       if (G_UNLIKELY (item->selected))
         {
-          colorized_icon = thunarx_gdk_pixbuf_colorize (icon, &GTK_WIDGET (view)->style->base[GTK_STATE_SELECTED]);
+          colorized_icon = thunar_gdk_pixbuf_colorize (icon, &GTK_WIDGET (view)->style->base[GTK_STATE_SELECTED]);
           g_object_unref (G_OBJECT (icon));
           icon = colorized_icon;
         }
diff --git a/thunar/thunar-extension-manager.c b/thunar/thunar-extension-manager.c
new file mode 100644 (file)
index 0000000..35f1d31
--- /dev/null
@@ -0,0 +1,485 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gmodule.h>
+
+#include <exo/exo.h>
+
+#include <thunar/thunar-extension-manager.h>
+
+
+
+#define THUNAR_EXTENSIONS_DIRECTORY (LIBDIR G_DIR_SEPARATOR_S "thunarx-" THUNAR_VERSION_API)
+
+
+
+enum
+{
+  PROP_0,
+  PROP_RESIDENT,
+};
+
+
+
+typedef struct _ThunarExtensionClass ThunarExtensionClass;
+typedef struct _ThunarExtension      ThunarExtension;
+
+
+
+#define THUNAR_TYPE_EXTENSION             (thunar_extension_get_type ())
+#define THUNAR_EXTENSION(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TYPE_EXTENSION, ThunarExtension))
+#define THUNAR_EXTENSION_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_TYPE_EXTENSION, ThunarExtensionClass))
+#define THUNAR_IS_EXTENSION(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNAR_TYPE_EXTENSION))
+#define THUNAR_IS_EXTENSION_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_EXTENSION))
+#define THUNAR_EXTENSION_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_EXTENSION, ThunarExtensionClass))
+
+
+
+static GType    thunar_extension_get_type     (void) G_GNUC_CONST;
+static void     thunar_extension_class_init   (ThunarExtensionClass *klass);
+static void     thunar_extension_finalize     (GObject              *object);
+static void     thunar_extension_get_property (GObject              *object,
+                                               guint                 prop_id,
+                                               GValue               *value,
+                                               GParamSpec           *pspec);
+static void     thunar_extension_set_property (GObject              *object,
+                                               guint                 prop_id,
+                                               const GValue         *value,
+                                               GParamSpec           *pspec);
+static gboolean thunar_extension_load         (GTypeModule          *module);
+static void     thunar_extension_unload       (GTypeModule          *module);
+static void     thunar_extension_list_types   (ThunarExtension      *extension,
+                                               const GType         **types,
+                                               gint                 *n_types);
+
+
+
+struct _ThunarExtensionClass
+{
+  GTypeModuleClass __parent__;
+};
+
+struct _ThunarExtension
+{
+  GTypeModule __parent__;
+
+  gchar   *path;
+  GModule *module;
+  gboolean resident;
+
+  void (*initialize)  (GTypeModule  *module);
+  void (*shutdown)    (void);
+  void (*list_types)  (const GType **types,
+                       gint         *n_types);
+};
+
+
+
+static GObjectClass *thunar_extension_parent_class;
+
+
+
+static GType
+thunar_extension_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo info =
+      {
+        sizeof (ThunarExtensionClass),
+        NULL,
+        NULL,
+        (GClassInitFunc) thunar_extension_class_init,
+        NULL,
+        NULL,
+        sizeof (ThunarExtension),
+        0,
+        NULL,
+        NULL,
+      };
+
+      type = g_type_register_static (G_TYPE_TYPE_MODULE, "ThunarExtension", &info, 0);
+    }
+
+  return type;
+}
+
+
+
+static void
+thunar_extension_class_init (ThunarExtensionClass *klass)
+{
+  GTypeModuleClass *gtype_module_class;
+  GObjectClass     *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = thunar_extension_finalize;
+  gobject_class->get_property = thunar_extension_get_property;
+  gobject_class->set_property = thunar_extension_set_property;
+
+  gtype_module_class = G_TYPE_MODULE_CLASS (klass);
+  gtype_module_class->load = thunar_extension_load;
+  gtype_module_class->unload = thunar_extension_unload;
+
+  /**
+   * ThunarExtension::resident:
+   *
+   * Tells whether the extension must reside in memory once loaded
+   * for the first time.
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_RESIDENT,
+                                   g_param_spec_boolean ("resident",
+                                                         _("Resident"),
+                                                         _("Ensures that an extension will never be unloaded."),
+                                                         FALSE,
+                                                         EXO_PARAM_READWRITE));
+}
+
+
+
+static void
+thunar_extension_finalize (GObject *object)
+{
+  ThunarExtension *extension = THUNAR_EXTENSION (object);
+
+  /* free the path to the extension */
+  g_free (extension->path);
+
+  (*G_OBJECT_CLASS (thunar_extension_parent_class)->finalize) (object);
+}
+
+
+
+static void
+thunar_extension_get_property (GObject    *object,
+                               guint       prop_id,
+                               GValue     *value,
+                               GParamSpec *pspec)
+{
+  ThunarExtension *extension = THUNAR_EXTENSION (object);
+
+  switch (prop_id)
+    {
+    case PROP_RESIDENT:
+      g_value_set_boolean (value, extension->resident);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static void
+thunar_extension_set_property (GObject      *object,
+                               guint         prop_id,
+                               const GValue *value,
+                               GParamSpec   *pspec)
+{
+  ThunarExtension *extension = THUNAR_EXTENSION (object);
+
+  switch (prop_id)
+    {
+    case PROP_RESIDENT:
+      extension->resident = g_value_get_boolean (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static gboolean
+thunar_extension_load (GTypeModule *module)
+{
+  ThunarExtension *extension = THUNAR_EXTENSION (module);
+
+  /* load the extension using the runtime link editor */
+  extension->module = g_module_open (extension->path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+
+  /* check if the load operation was successful */
+  if (G_UNLIKELY (extension->module == NULL))
+    {
+      g_warning ("Failed to load file manager extension from %s: %s", extension->path, g_module_error ());
+      return FALSE;
+    }
+
+  /* verify that all required public symbols are present in the extension's symbol table */
+  if (!g_module_symbol (extension->module, "thunar_extension_shutdown", (gpointer) &extension->shutdown)
+      || !g_module_symbol (extension->module, "thunar_extension_initialize", (gpointer) &extension->initialize)
+      || !g_module_symbol (extension->module, "thunar_extension_list_types", (gpointer) &extension->list_types))
+    {
+      g_warning ("File manager extension loaded from %s lacks required symbols.", extension->path);
+      g_module_close (extension->module);
+      return FALSE;
+    }
+
+  /* initialize the extension */
+  (*extension->initialize) (module);
+
+  /* ensure that the module will never be unloaded
+   * if the extension requests to be kept in memory
+   */
+  if (G_UNLIKELY (extension->resident))
+    g_module_make_resident (extension->module);
+
+  return TRUE;
+}
+
+
+
+static void
+thunar_extension_unload (GTypeModule *module)
+{
+  ThunarExtension *extension = THUNAR_EXTENSION (module);
+
+  /* shutdown the extension */
+  (*extension->shutdown) ();
+
+  /* unload the extension from memory */
+  g_module_close (extension->module);
+
+  /* reset extension state */
+  extension->module = NULL;
+  extension->shutdown = NULL;
+  extension->initialize = NULL;
+  extension->list_types = NULL;
+}
+
+
+
+static void
+thunar_extension_list_types (ThunarExtension *extension,
+                             const GType    **types,
+                             gint            *n_types)
+{
+  g_return_if_fail (THUNAR_IS_EXTENSION (extension));
+  g_return_if_fail (n_types != NULL);
+  g_return_if_fail (types != NULL);
+
+  (*extension->list_types) (types, n_types);
+}
+
+
+
+
+static void thunar_extension_manager_class_init (ThunarExtensionManagerClass *klass);
+static void thunar_extension_manager_init       (ThunarExtensionManager      *manager);
+static void thunar_extension_manager_finalize   (GObject                     *object);
+static void thunar_extension_manager_add        (ThunarExtensionManager      *manager,
+                                                 ThunarExtension             *extension);
+
+
+
+struct _ThunarExtensionManagerClass
+{
+  GObjectClass __parent__;
+};
+
+struct _ThunarExtensionManager
+{
+  GObject __parent__;
+
+  GList *extensions;
+
+  GType *types;
+  gint   n_types;
+};
+
+
+
+G_DEFINE_TYPE (ThunarExtensionManager, thunar_extension_manager, G_TYPE_OBJECT);
+
+
+
+static void
+thunar_extension_manager_class_init (ThunarExtensionManagerClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->finalize = thunar_extension_manager_finalize;
+}
+
+
+
+static void
+thunar_extension_manager_init (ThunarExtensionManager *manager)
+{
+  ThunarExtension *extension;
+  const gchar     *name;
+  GDir            *dp;
+
+  // FIXME: Perform this in a timer as the extensions aren't required to
+  // be available instantly, maybe even load the files in a separate thread!
+  dp = g_dir_open (THUNAR_EXTENSIONS_DIRECTORY, 0, NULL);
+  if (G_LIKELY (dp != NULL))
+    {
+      /* determine the types for all existing extensions */
+      for (;;)
+        {
+          /* read the next entry from the directory */
+          name = g_dir_read_name (dp);
+          if (G_UNLIKELY (name == NULL))
+            break;
+
+          /* check if this is a valid extension file */
+          if (g_str_has_suffix (name, "." G_MODULE_SUFFIX))
+            {
+              /* generate an extension object for the file */
+              extension = g_object_new (THUNAR_TYPE_EXTENSION, NULL);
+              extension->path = g_build_filename (THUNAR_EXTENSIONS_DIRECTORY, name, NULL);
+
+              /* try to load the extension */
+              if (g_type_module_use (G_TYPE_MODULE (extension)))
+                {
+                  /* add the extension to our list of managed extensions */
+                  thunar_extension_manager_add (manager, extension);
+
+                  /* don't unuse the type plugin if it should be resident in memory */
+                  if (G_LIKELY (!extension->resident))
+                    g_type_module_unuse (G_TYPE_MODULE (extension));
+                }
+
+              /* drop the reference on the extension */
+              g_object_unref (G_OBJECT (extension));
+            }
+        }
+
+      g_dir_close (dp);
+    }
+}
+
+
+
+static void
+thunar_extension_manager_finalize (GObject *object)
+{
+  ThunarExtensionManager *manager = THUNAR_EXTENSION_MANAGER (object);
+
+  /* release the extensions */
+  g_list_foreach (manager->extensions, (GFunc) g_object_unref, NULL);
+  g_list_free (manager->extensions);
+
+  /* free the types list */
+  g_free (manager->types);
+
+  (*G_OBJECT_CLASS (thunar_extension_manager_parent_class)->finalize) (object);
+}
+
+
+
+static void
+thunar_extension_manager_add (ThunarExtensionManager *manager,
+                              ThunarExtension        *extension)
+{
+  const GType *types;
+  gint         n_types;
+
+  /* add the extension to our internal list */
+  manager->extensions = g_list_prepend (manager->extensions, g_object_ref (G_OBJECT (extension)));
+
+  /* determines the types provided by the extension */
+  thunar_extension_list_types (extension, &types, &n_types);
+
+  /* add the types provided by the extension */
+  manager->types = g_realloc (manager->types, sizeof (GType) * (manager->n_types + n_types));
+  for (; n_types-- > 0; ++types)
+    manager->types[manager->n_types++] = *types;
+}
+
+
+
+/**
+ * thunar_extension_manager_get_default:
+ *
+ * Returns a reference to the default #ThunarExtensionManager
+ * instance.
+ *
+ * The caller is responsible to free the returned object
+ * using g_object_unref() when no longer needed.
+ *
+ * Return value: a reference to the default
+ *               #ThunarExtensionManager instance.
+ **/
+ThunarExtensionManager*
+thunar_extension_manager_get_default (void)
+{
+  static ThunarExtensionManager *manager = NULL;
+
+  if (G_UNLIKELY (manager == NULL))
+    manager = g_object_new (THUNAR_TYPE_EXTENSION_MANAGER, NULL);
+
+  g_object_ref (G_OBJECT (manager));
+
+  return manager;
+}
+
+
+
+/**
+ * thunar_extension_manager_list_providers:
+ * @manager : a #ThunarExtensionManager instance.
+ * @type    : the provider #GType.
+ *
+ * Returns all providers of the given @type.
+ *
+ * The caller is responsible to release the returned
+ * list of providers using code like this:
+ * <informalexample><programlisting>
+ * g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ * g_list_free (list);
+ * </programlisting></informalexample>
+ *
+ * Return value: the of providers for @type.
+ **/
+GList*
+thunar_extension_manager_list_providers (ThunarExtensionManager *manager,
+                                         GType                   type)
+{
+  GObject *provider;
+  GList   *providers = NULL;
+  GType   *types;
+  gint     n;
+
+  for (n = manager->n_types, types = manager->types; n > 0; --n, ++types)
+    if (G_LIKELY (g_type_is_a (*types, type)))
+      {
+        provider = g_object_new (*types, NULL);
+        if (G_LIKELY (provider != NULL))
+          providers = g_list_append (providers, provider);
+      }
+
+  return providers;
+}
+
+
+
diff --git a/thunar/thunar-extension-manager.h b/thunar/thunar-extension-manager.h
new file mode 100644 (file)
index 0000000..c8edef8
--- /dev/null
@@ -0,0 +1,46 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __THUNAR_EXTENSION_MANAGER_H__
+#define __THUNAR_EXTENSION_MANAGER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+typedef struct _ThunarExtensionManagerClass ThunarExtensionManagerClass;
+typedef struct _ThunarExtensionManager      ThunarExtensionManager;
+
+#define THUNAR_TYPE_EXTENSION_MANAGER             (thunar_extension_manager_get_type ())
+#define THUNAR_EXTENSION_MANAGER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TYPE_EXTENSION_MANAGER, ThunarExtensionManager))
+#define THUNAR_EXTENSION_MANAGER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_TYPE_EXTENSION_MANAGER, ThunarExtensionManagerClass))
+#define THUNAR_IS_EXTENSION_MANAGER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNAR_TYPE_EXTENSION_MANAGER))
+#define THUNAR_IS_EXTENSION_MANAGER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_EXTENSION_MANAGER))
+#define THUNAR_EXTENSION_MANAGER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_EXTENSION_MANAGER, ThunarExtensionManagerClass))
+
+GType                   thunar_extension_manager_get_type       (void) G_GNUC_CONST;
+
+ThunarExtensionManager *thunar_extension_manager_get_default    (void);
+
+GList                  *thunar_extension_manager_list_providers (ThunarExtensionManager *manager,
+                                                                 GType                   type);
+
+G_END_DECLS;
+
+#endif /* !__THUNAR_EXTENSION_MANAGER_H__ */
index f5cda7e..0eaf4f2 100644 (file)
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
+#ifdef HAVE_MEMORY_H
+#include <memory.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
 #ifdef HAVE_TIME_H
 #include <time.h>
 #endif
@@ -34,6 +40,9 @@
 #include <thunar/thunar-local-file.h>
 #include <thunar/thunar-trash-folder.h>
 
+#include <thunarx/thunarx.h>
+
+
 
 /* the thumbnailing state of a given file */
 typedef enum
@@ -69,10 +78,19 @@ enum
 
 
 static void               thunar_file_class_init               (ThunarFileClass        *klass);
+static void               thunar_file_info_init                (ThunarxFileInfoIface   *iface);
 static void               thunar_file_dispose                  (GObject                *object);
 #ifndef G_DISABLE_CHECKS
 static void               thunar_file_finalize                 (GObject                *object);
 #endif
+static gchar             *thunar_file_info_get_name            (ThunarxFileInfo        *file_info);
+static gchar             *thunar_file_info_get_uri             (ThunarxFileInfo        *file_info);
+static gchar             *thunar_file_info_get_parent_uri      (ThunarxFileInfo        *file_info);
+static gchar             *thunar_file_info_get_uri_scheme      (ThunarxFileInfo        *file_info);
+static gchar             *thunar_file_info_get_mime_type       (ThunarxFileInfo        *file_info);
+static gboolean           thunar_file_info_has_mime_type       (ThunarxFileInfo        *file_info,
+                                                                const gchar            *mime_type);
+static gboolean           thunar_file_info_is_directory        (ThunarxFileInfo        *file_info);
 static ThunarFile        *thunar_file_real_get_parent          (ThunarFile             *file,
                                                                 GError                **error);
 static gboolean           thunar_file_real_execute             (ThunarFile             *file,
@@ -126,9 +144,18 @@ thunar_file_get_type (void)
         NULL,
       };
 
+      static const GInterfaceInfo file_info_info = 
+      {
+        (GInterfaceInitFunc) thunar_file_info_init,
+        NULL,
+        NULL,
+      };
+
       type = g_type_register_static (G_TYPE_OBJECT,
                                      "ThunarFile", &info,
                                      G_TYPE_FLAG_ABSTRACT);
+
+      g_type_add_interface_static (type, THUNARX_TYPE_FILE_INFO, &file_info_info);
     }
 
   return type;
@@ -250,6 +277,20 @@ thunar_file_class_init (ThunarFileClass *klass)
 
 
 static void
+thunar_file_info_init (ThunarxFileInfoIface *iface)
+{
+  iface->get_name = thunar_file_info_get_name;
+  iface->get_uri = thunar_file_info_get_uri;
+  iface->get_parent_uri = thunar_file_info_get_parent_uri;
+  iface->get_uri_scheme = thunar_file_info_get_uri_scheme;
+  iface->get_mime_type = thunar_file_info_get_mime_type;
+  iface->has_mime_type = thunar_file_info_has_mime_type;
+  iface->is_directory = thunar_file_info_is_directory;
+}
+
+
+
+static void
 thunar_file_dispose (GObject *object)
 {
   ThunarFile *file = THUNAR_FILE (object);
@@ -289,6 +330,118 @@ thunar_file_finalize (GObject *object)
 
 
 
+static gchar*
+thunar_file_info_get_name (ThunarxFileInfo *file_info)
+{
+  ThunarVfsURI *uri = thunar_file_get_uri (THUNAR_FILE (file_info));
+  return g_strdup (thunar_vfs_uri_get_name (uri));
+}
+
+
+
+static gchar*
+thunar_file_info_get_uri (ThunarxFileInfo *file_info)
+{
+  ThunarVfsURI *uri = thunar_file_get_uri (THUNAR_FILE (file_info));
+  return g_strdup (thunar_vfs_uri_to_string (uri, THUNAR_VFS_URI_STRING_ESCAPED));
+}
+
+
+
+static gchar*
+thunar_file_info_get_parent_uri (ThunarxFileInfo *file_info)
+{
+  ThunarVfsURI *uri = thunar_file_get_uri (THUNAR_FILE (file_info));
+  gchar        *uri_string = NULL;
+
+  /* determine the parent's URI */
+  uri = thunar_vfs_uri_parent (uri);
+  if (G_LIKELY (uri != NULL))
+    {
+      uri_string = thunar_vfs_uri_to_string (uri, THUNAR_VFS_URI_STRING_ESCAPED);
+      thunar_vfs_uri_unref (uri);
+    }
+
+  return uri_string;
+}
+
+
+
+static gchar*
+thunar_file_info_get_uri_scheme (ThunarxFileInfo *file_info)
+{
+  gchar *uri_string;
+  gchar *colon;
+
+  /* determine the URI for the file */
+  uri_string = thunarx_file_info_get_uri (file_info);
+
+  /* we're only interested in the URI scheme */
+  colon = strchr (uri_string, ':');
+  if (G_LIKELY (colon != NULL))
+    *colon = '\0';
+
+  return uri_string;
+}
+
+
+
+static gchar*
+thunar_file_info_get_mime_type (ThunarxFileInfo *file_info)
+{
+  ThunarVfsMimeInfo *mime_info;
+  gchar             *mime_type = NULL;
+
+  /* determine the mime info for the file */
+  mime_info = thunar_file_get_mime_info (THUNAR_FILE (file_info));
+  if (G_LIKELY (mime_info != NULL))
+    {
+      mime_type = g_strdup (thunar_vfs_mime_info_get_name (mime_info));
+      thunar_vfs_mime_info_unref (mime_info);
+    }
+
+  return mime_type;
+}
+
+
+
+static gboolean
+thunar_file_info_has_mime_type (ThunarxFileInfo *file_info,
+                                const gchar     *mime_type)
+{
+  ThunarVfsMimeDatabase *mime_database;
+  ThunarVfsMimeInfo     *mime_info;
+  gboolean               valid = FALSE;
+  GList                 *mime_infos;
+  GList                 *lp;
+
+  /* determine the mime info for the file */
+  mime_info = thunar_file_get_mime_info (THUNAR_FILE (file_info));
+  if (G_UNLIKELY (mime_info == NULL))
+    return FALSE;
+
+  /* check the related mime types for the file's mime info */
+  mime_database = thunar_vfs_mime_database_get_default ();
+  mime_infos = thunar_vfs_mime_database_get_infos_for_info (mime_database, mime_info);
+  for (lp = mime_infos; lp != NULL && !valid; lp = lp->next)
+    valid = (strcmp (thunar_vfs_mime_info_get_name (lp->data), mime_type) == 0);
+  exo_object_unref (EXO_OBJECT (mime_database));
+  thunar_vfs_mime_info_list_free (mime_infos);
+  thunar_vfs_mime_info_unref (mime_info);
+
+  return valid;
+}
+
+
+
+static gboolean
+thunar_file_info_is_directory (ThunarxFileInfo *file_info)
+{
+  return thunar_file_is_directory (THUNAR_FILE (file_info));
+}
+
+
+
 static ThunarFile*
 thunar_file_real_get_parent (ThunarFile *file,
                              GError    **error)
similarity index 95%
rename from thunarx/thunarx-gdk-pixbuf-extensions.c
rename to thunar/thunar-gdk-pixbuf-extensions.c
index 69752c5..63d4af7 100644 (file)
 #include <mmintrin.h>
 #endif
 
-#include <thunarx/thunarx-gdk-pixbuf-extensions.h>
+#include <thunar/thunar-gdk-pixbuf-extensions.h>
 
 
 
 /**
- * thunarx_gdk_pixbuf_colorize:
+ * thunar_gdk_pixbuf_colorize:
  * @src   : the source #GdkPixbuf.
  * @color : the new color.
  *
@@ -43,8 +43,8 @@
  * Return value: the colorized #GdkPixbuf.
  **/
 GdkPixbuf*
-thunarx_gdk_pixbuf_colorize (const GdkPixbuf *src,
-                             const GdkColor  *color)
+thunar_gdk_pixbuf_colorize (const GdkPixbuf *src,
+                            const GdkColor  *color)
 {
   GdkPixbuf *dst;
   gboolean   has_alpha;
@@ -196,7 +196,7 @@ draw_frame_column (GdkPixbuf *frame_image,
 
 
 /**
- * thunarx_gdk_pixbuf_frame:
+ * thunar_gdk_pixbuf_frame:
  * @src           : the source #GdkPixbuf.
  * @frame         : the frame #GdkPixbuf.
  * @left_offset   : the left frame offset.
@@ -213,12 +213,12 @@ draw_frame_column (GdkPixbuf *frame_image,
  * Return value: the framed version of @src.
  **/
 GdkPixbuf*
-thunarx_gdk_pixbuf_frame (GdkPixbuf *src,
-                          GdkPixbuf *frame,
-                          gint       left_offset,
-                          gint       top_offset,
-                          gint       right_offset,
-                          gint       bottom_offset)
+thunar_gdk_pixbuf_frame (GdkPixbuf *src,
+                         GdkPixbuf *frame,
+                         gint       left_offset,
+                         gint       top_offset,
+                         gint       right_offset,
+                         gint       bottom_offset)
 {
   GdkPixbuf *dst;
   gint       dst_width;
@@ -288,7 +288,7 @@ lighten_channel (guchar cur_value)
 
 
 /**
- * thunarx_gdk_pixbuf_spotlight:
+ * thunar_gdk_pixbuf_spotlight:
  * @src : the source #GdkPixbuf.
  *
  * Creates a lightened version of @src, suitable for
@@ -300,7 +300,7 @@ lighten_channel (guchar cur_value)
  * Return value: the lightened version of @src.
  **/
 GdkPixbuf*
-thunarx_gdk_pixbuf_spotlight (const GdkPixbuf *src)
+thunar_gdk_pixbuf_spotlight (const GdkPixbuf *src)
 {
   GdkPixbuf *dst;
   gboolean   has_alpha;
similarity index 54%
rename from thunarx/thunarx-gdk-pixbuf-extensions.h
rename to thunar/thunar-gdk-pixbuf-extensions.h
index ded8a69..7926e64 100644 (file)
  * Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef __THUNARX_GDK_PIXBUF_EXTENSIONS_H__
-#define __THUNARX_GDK_PIXBUF_EXTENSIONS_H__
+#ifndef __THUNAR_GDK_PIXBUF_EXTENSIONS_H__
+#define __THUNAR_GDK_PIXBUF_EXTENSIONS_H__
 
 #include <gdk/gdk.h>
 
 G_BEGIN_DECLS;
 
-GdkPixbuf *thunarx_gdk_pixbuf_colorize  (const GdkPixbuf *src,
-                                         const GdkColor  *color);
+GdkPixbuf *thunar_gdk_pixbuf_colorize  (const GdkPixbuf *src,
+                                        const GdkColor  *color);
 
-GdkPixbuf *thunarx_gdk_pixbuf_frame     (GdkPixbuf       *src,
-                                         GdkPixbuf       *frame,
-                                         gint             left_offset,
-                                         gint             top_offset,
-                                         gint             right_offset,
-                                         gint             bottom_offset);
+GdkPixbuf *thunar_gdk_pixbuf_frame     (GdkPixbuf       *src,
+                                        GdkPixbuf       *frame,
+                                        gint             left_offset,
+                                        gint             top_offset,
+                                        gint             right_offset,
+                                        gint             bottom_offset);
 
-GdkPixbuf *thunarx_gdk_pixbuf_spotlight (const GdkPixbuf *src);
+GdkPixbuf *thunar_gdk_pixbuf_spotlight (const GdkPixbuf *src);
 
 G_END_DECLS;
 
-#endif /* !__THUNARX_GDK_PIXBUF_EXTENSIONS_H__ */
+#endif /* !__THUNAR_GDK_PIXBUF_EXTENSIONS_H__ */
similarity index 83%
rename from thunarx/thunarx-gtk-extensions.c
rename to thunar/thunar-gtk-extensions.c
index c2b5a72..03196e8 100644 (file)
 #include <config.h>
 #endif
 
-#include <thunarx/thunarx-gtk-extensions.h>
+#include <thunar/thunar-gtk-extensions.h>
 
 
 
 /**
- * thunarx_gtk_action_group_set_action_sensitive:
+ * thunar_gtk_action_group_set_action_sensitive:
  * @action_group : a #GtkActionGroup.
  * @action_name  : the name of a #GtkAction in @action_group.
  * @sensitive    : the new sensitivity.
@@ -35,9 +35,9 @@
  * in @action_group (whose name is @action_name) to @sensitive.
  **/
 void
-thunarx_gtk_action_group_set_action_sensitive (GtkActionGroup *action_group,
-                                               const gchar    *action_name,
-                                               gboolean        sensitive)
+thunar_gtk_action_group_set_action_sensitive (GtkActionGroup *action_group,
+                                              const gchar    *action_name,
+                                              gboolean        sensitive)
 {
   GtkAction *action;
 
similarity index 70%
rename from thunarx/thunarx-gtk-extensions.h
rename to thunar/thunar-gtk-extensions.h
index d24c2bd..078e94e 100644 (file)
  * Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef __THUNARX_GTK_EXTENSIONS_H__
-#define __THUNARX_GTK_EXTENSIONS_H__
+#ifndef __THUNAR_GTK_EXTENSIONS_H__
+#define __THUNAR_GTK_EXTENSIONS_H__
 
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS;
 
-void thunarx_gtk_action_group_set_action_sensitive (GtkActionGroup *action_group,
-                                                    const gchar    *action_name,
-                                                    gboolean        sensitive);
+void thunar_gtk_action_group_set_action_sensitive (GtkActionGroup *action_group,
+                                                   const gchar    *action_name,
+                                                   gboolean        sensitive);
 
 G_END_DECLS;
 
-#endif /* !__THUNARX_GTK_EXTENSIONS_H__ */
+#endif /* !__THUNAR_GTK_EXTENSIONS_H__ */
index fb2241d..31ee631 100644 (file)
@@ -34,9 +34,8 @@
 
 #include <exo/exo.h>
 
-#include <thunarx/thunarx-gdk-pixbuf-extensions.h>
-
 #include <thunar/thunar-fallback-icon.h>
+#include <thunar/thunar-gdk-pixbuf-extensions.h>
 #include <thunar/thunar-icon-factory.h>
 #include <thunar/thunar-thumbnail-frame.h>
 
@@ -441,7 +440,7 @@ thunar_icon_factory_load_from_file (ThunarIconFactory *factory,
           && thumbnail_needs_frame (pixbuf, width, height))
         {
           /* add the frame */
-          tmp = thunarx_gdk_pixbuf_frame (pixbuf, factory->thumbnail_frame, 3, 3, 6, 6);
+          tmp = thunar_gdk_pixbuf_frame (pixbuf, factory->thumbnail_frame, 3, 3, 6, 6);
           g_object_unref (G_OBJECT (pixbuf));
           pixbuf = tmp;
 
index 658e073..d861066 100644 (file)
@@ -22,9 +22,9 @@
 #endif
 
 #include <thunar/thunar-file.h>
+#include <thunar/thunar-gdk-pixbuf-extensions.h>
 #include <thunar/thunar-icon-factory.h>
 #include <thunar/thunar-icon-renderer.h>
-#include <thunarx/thunarx-gdk-pixbuf-extensions.h>
 
 
 
@@ -377,14 +377,14 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
           if ((flags & GTK_CELL_RENDERER_SELECTED) != 0)
             {
               state = GTK_WIDGET_HAS_FOCUS (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
-              temp = thunarx_gdk_pixbuf_colorize (icon, &widget->style->base[state]);
+              temp = thunar_gdk_pixbuf_colorize (icon, &widget->style->base[state]);
               g_object_unref (G_OBJECT (icon));
               icon = temp;
             }
 
           if ((flags & GTK_CELL_RENDERER_PRELIT) != 0)
             {
-              temp = thunarx_gdk_pixbuf_spotlight (icon);
+              temp = thunar_gdk_pixbuf_spotlight (icon);
               g_object_unref (G_OBJECT (icon));
               icon = temp;
             }
index 986f7bc..c60a150 100644 (file)
 
 #include <gdk/gdkkeysyms.h>
 
+#include <thunar/thunar-extension-manager.h>
 #include <thunar/thunar-icon-factory.h>
 #include <thunar/thunar-properties-dialog.h>
 
+#include <thunarx/thunarx.h>
+
 
 
 enum
@@ -65,6 +68,7 @@ static gboolean thunar_properties_dialog_focus_out_event      (GtkWidget
                                                                GdkEventFocus               *event,
                                                                ThunarPropertiesDialog      *dialog);
 static void     thunar_properties_dialog_update               (ThunarPropertiesDialog      *dialog);
+static void     thunar_properties_dialog_update_extensions    (ThunarPropertiesDialog      *dialog);
 static gboolean thunar_properties_dialog_rename_idle          (gpointer                     user_data);
 static void     thunar_properties_dialog_rename_idle_destroy  (gpointer                     user_data);
 
@@ -79,6 +83,9 @@ struct _ThunarPropertiesDialog
 {
   GtkDialog __parent__;
 
+  ThunarExtensionManager *extension_manager;
+  GList                  *extension_pages;
+
   ThunarVfsVolumeManager *volume_manager;
   ThunarFile             *file;
 
@@ -148,6 +155,7 @@ thunar_properties_dialog_init (ThunarPropertiesDialog *dialog)
   gchar     *text;
   gint       row = 0;
 
+  dialog->extension_manager = thunar_extension_manager_get_default ();
   dialog->volume_manager = thunar_vfs_volume_manager_get_default ();
   dialog->rename_idle_id = -1;
 
@@ -334,6 +342,13 @@ thunar_properties_dialog_finalize (GObject *object)
 {
   ThunarPropertiesDialog *dialog = THUNAR_PROPERTIES_DIALOG (object);
 
+  /* release the extension property pages */
+  g_list_foreach (dialog->extension_pages, (GFunc) g_object_unref, NULL);
+  g_list_free (dialog->extension_pages);
+
+  /* drop the reference on the extension manager */
+  g_object_unref (G_OBJECT (dialog->extension_manager));
+
   /* drop the reference on the volume manager */
   g_object_unref (G_OBJECT (dialog->volume_manager));
 
@@ -451,6 +466,53 @@ thunar_properties_dialog_focus_out_event (GtkWidget              *entry,
 
 
 static void
+thunar_properties_dialog_update_extensions (ThunarPropertiesDialog *dialog)
+{
+  GtkWidget *label_widget;
+  GList     *providers;
+  GList     *pages = NULL;
+  GList      files;
+  GList     *tmp;
+  GList     *lp;
+
+  /* load the property page providers from the extension manager */
+  providers = thunar_extension_manager_list_providers (dialog->extension_manager, THUNARX_TYPE_PROPERTY_PAGE_PROVIDER);
+  if (G_LIKELY (providers != NULL))
+    {
+      /* determine the (one-element) file list */
+      files.data = dialog->file; files.next = files.prev = NULL;
+
+      /* load the pages offered by the menu providers */
+      for (lp = providers; lp != NULL; lp = lp->next)
+        {
+          tmp = thunarx_property_page_provider_get_pages (lp->data, &files);
+          pages = g_list_concat (pages, tmp);
+          g_object_unref (G_OBJECT (lp->data));
+        }
+      g_list_free (providers);
+    }
+
+  /* destroy any previous set pages */
+  for (lp = dialog->extension_pages; lp != NULL; lp = lp->next)
+    {
+      gtk_widget_destroy (GTK_WIDGET (lp->data));
+      g_object_unref (G_OBJECT (lp->data));
+    }
+  g_list_free (dialog->extension_pages);
+
+  /* apply the new set of pages */
+  dialog->extension_pages = pages;
+  for (lp = pages; lp != NULL; lp = lp->next)
+    {
+      label_widget = thunarx_property_page_get_label_widget (THUNARX_PROPERTY_PAGE (lp->data));
+      gtk_notebook_append_page (GTK_NOTEBOOK (dialog->notebook), GTK_WIDGET (lp->data), label_widget);
+      g_object_ref (G_OBJECT (lp->data));
+    }
+}
+
+
+
+static void
 thunar_properties_dialog_update (ThunarPropertiesDialog *dialog)
 {
   ThunarIconFactory *icon_factory;
@@ -575,6 +637,9 @@ thunar_properties_dialog_update (ThunarPropertiesDialog *dialog)
       gtk_widget_hide (dialog->size_label);
     }
 
+  /* update the extension property pages */
+  thunar_properties_dialog_update_extensions (dialog);
+
   /* cleanup */
   g_object_unref (G_OBJECT (icon_factory));
 }
index 8fda176..24de3b7 100644 (file)
@@ -55,6 +55,8 @@
     <separator />
     <menuitem action="rename" name="rename" />
     <separator />
+    <placeholder name="placeholder-extensions" />
+    <separator />
     <menuitem action="properties" name="properties" />
   </popup>
 
@@ -62,6 +64,8 @@
     <placeholder name="placeholder-view-items-actions" />
     <separator />
     <menuitem action="paste" name="paste" />
+    <separator />
+    <placeholder name="placeholder-extensions" />
   </popup>
 
 </ui>
index b8999c8..77b6bd9 100644 (file)
@@ -28,9 +28,8 @@
 #include <string.h>
 #endif
 
-#include <thunarx/thunarx-gtk-extensions.h>
-
 #include <thunar/thunar-dnd.h>
+#include <thunar/thunar-extension-manager.h>
 #include <thunar/thunar-icon-renderer.h>
 #include <thunar/thunar-launcher.h>
 #include <thunar/thunar-properties-dialog.h>
@@ -38,6 +37,8 @@
 #include <thunar/thunar-standard-view-ui.h>
 #include <thunar/thunar-text-renderer.h>
 
+#include <thunarx/thunarx.h>
+
 
 
 #define THUNAR_STANDARD_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), THUNAR_TYPE_STANDARD_VIEW, ThunarStandardViewPrivate))
@@ -100,6 +101,8 @@ static GdkDragAction thunar_standard_view_get_dest_actions          (ThunarStand
                                                                      ThunarFile              **file_return);
 static GList        *thunar_standard_view_get_selected_files        (ThunarStandardView       *standard_view);
 static GList        *thunar_standard_view_get_selected_uris         (ThunarStandardView       *standard_view);
+static void          thunar_standard_view_merge_menu_extensions     (ThunarStandardView       *standard_view,
+                                                                     GList                    *selected_items);
 static void          thunar_standard_view_action_properties         (GtkAction                *action,
                                                                      ThunarStandardView       *standard_view);
 static void          thunar_standard_view_action_copy               (GtkAction                *action,
@@ -175,28 +178,33 @@ static void          thunar_standard_view_drag_timer_destroy        (gpointer
 
 struct _ThunarStandardViewPrivate
 {
-  ThunarLauncher *launcher;
-  GtkAction      *action_properties;
-  GtkAction      *action_copy;
-  GtkAction      *action_cut;
-  GtkAction      *action_paste;
-  GtkAction      *action_paste_into_folder;
-  GtkAction      *action_select_all_files;
-  GtkAction      *action_select_by_pattern;
-  GtkAction      *action_rename;
-  GtkAction      *action_show_hidden_files;
+  ThunarLauncher         *launcher;
+  GtkAction              *action_properties;
+  GtkAction              *action_copy;
+  GtkAction              *action_cut;
+  GtkAction              *action_paste;
+  GtkAction              *action_paste_into_folder;
+  GtkAction              *action_select_all_files;
+  GtkAction              *action_select_by_pattern;
+  GtkAction              *action_rename;
+  GtkAction              *action_show_hidden_files;
+
+  /* menu extensions support */
+  ThunarExtensionManager *extension_manager;
+  GtkActionGroup         *extension_actions;
+  gint                    extension_merge_id;
 
   /* right-click drag/popup support */
-  GList          *drag_uri_list;
-  gint            drag_timer_id;
-  gint            drag_x;
-  gint            drag_y;
+  GList                  *drag_uri_list;
+  gint                    drag_timer_id;
+  gint                    drag_x;
+  gint                    drag_y;
 
   /* drop site support */
-  guint           drop_data_ready : 1; /* whether the drop data was received already */
-  guint           drop_highlight : 1;
-  guint           drop_occurred : 1;   /* whether the data was dropped */
-  GList          *drop_uri_list;       /* the list of URIs that are contained in the drop data */
+  guint                   drop_data_ready : 1; /* whether the drop data was received already */
+  guint                   drop_highlight : 1;
+  guint                   drop_occurred : 1;   /* whether the data was dropped */
+  GList                  *drop_uri_list;       /* the list of URIs that are contained in the drop data */
 };
 
 
@@ -361,6 +369,10 @@ thunar_standard_view_init (ThunarStandardView *standard_view)
   standard_view->priv = THUNAR_STANDARD_VIEW_GET_PRIVATE (standard_view);
   standard_view->priv->drag_timer_id = -1;
 
+  /* grab a reference on the extension manager */
+  standard_view->priv->extension_manager = thunar_extension_manager_get_default ();
+
+  /* initialize the scrolled window */
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (standard_view),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
@@ -493,6 +505,9 @@ thunar_standard_view_finalize (GObject *object)
   g_assert (standard_view->ui_manager == NULL);
   g_assert (standard_view->clipboard == NULL);
 
+  /* release our reference on the extension manager */
+  g_object_unref (G_OBJECT (standard_view->priv->extension_manager));
+
   /* release the drag URI list (just in case the drag-end wasn't fired before) */
   thunar_vfs_uri_list_free (standard_view->priv->drag_uri_list);
 
@@ -846,6 +861,21 @@ thunar_standard_view_set_ui_manager (ThunarView   *view,
   /* disconnect from the previous UI manager */
   if (G_LIKELY (standard_view->ui_manager != NULL))
     {
+      /* remove any registered menu extension actions */
+      if (G_LIKELY (standard_view->priv->extension_merge_id != 0))
+        {
+          gtk_ui_manager_remove_ui (standard_view->ui_manager, standard_view->priv->extension_merge_id);
+          standard_view->priv->extension_merge_id = 0;
+        }
+
+      /* drop any previous extensions action group */
+      if (G_LIKELY (standard_view->priv->extension_actions != NULL))
+        {
+          gtk_ui_manager_remove_action_group (standard_view->ui_manager, standard_view->priv->extension_actions);
+          g_object_unref (G_OBJECT (standard_view->priv->extension_actions));
+          standard_view->priv->extension_actions = NULL;
+        }
+
       /* drop our action group from the previous UI manager */
       gtk_ui_manager_remove_action_group (standard_view->ui_manager, standard_view->action_group);
 
@@ -1033,6 +1063,130 @@ thunar_standard_view_get_selected_uris (ThunarStandardView *standard_view)
 
 
 static void
+thunar_standard_view_merge_menu_extensions (ThunarStandardView *standard_view,
+                                            GList              *selected_items)
+{
+  GtkTreeIter iter;
+  ThunarFile *file = NULL;
+  GtkWidget  *window;
+  GList      *providers;
+  GList      *actions = NULL;
+  GList      *files = NULL;
+  GList      *tmp;
+  GList      *lp;
+
+  /* we cannot add anything if we aren't connected to any UI manager */
+  if (G_UNLIKELY (standard_view->ui_manager == NULL))
+    return;
+
+  /* load the menu providers from the extension manager */
+  providers = thunar_extension_manager_list_providers (standard_view->priv->extension_manager, THUNARX_TYPE_MENU_PROVIDER);
+  if (G_LIKELY (providers != NULL))
+    {
+      /* determine the toplevel window we belong to */
+      window = gtk_widget_get_toplevel (GTK_WIDGET (standard_view));
+
+      /* determine the list of selected files or the current folder */
+      if (G_LIKELY (selected_items != NULL))
+        {
+          for (lp = selected_items; lp != NULL; lp = lp->next)
+            {
+              gtk_tree_model_get_iter (GTK_TREE_MODEL (standard_view->model), &iter, lp->data);
+              file = thunar_list_model_get_file (standard_view->model, &iter);
+              files = g_list_append (files, file);
+            }
+        }
+      else
+        {
+          /* grab a reference to the current directory of the view */
+          file = thunar_navigator_get_current_directory (THUNAR_NAVIGATOR (standard_view));
+        }
+
+      /* load the actions offered by the menu providers */
+      for (lp = providers; lp != NULL; lp = lp->next)
+        {
+          if (G_LIKELY (files != NULL))
+            tmp = thunarx_menu_provider_get_file_actions (lp->data, window, files);
+          else if (G_LIKELY (file != NULL))
+            tmp = thunarx_menu_provider_get_folder_actions (lp->data, window, THUNARX_FILE_INFO (file));
+          else
+            tmp = NULL;
+          actions = g_list_concat (actions, tmp);
+          g_object_unref (G_OBJECT (lp->data));
+        }
+      g_list_free (providers);
+
+      /* cleanup the selected files list (if any) */
+      if (G_LIKELY (files != NULL))
+        thunar_file_list_free (files);
+    }
+
+  /* remove the previously determined menu actions from the UI manager */
+  if (G_LIKELY (standard_view->priv->extension_merge_id != 0))
+    {
+      gtk_ui_manager_remove_ui (standard_view->ui_manager, standard_view->priv->extension_merge_id);
+      standard_view->priv->extension_merge_id = 0;
+    }
+
+  /* drop any previous extensions action group */
+  if (G_LIKELY (standard_view->priv->extension_actions != NULL))
+    {
+      gtk_ui_manager_remove_action_group (standard_view->ui_manager, standard_view->priv->extension_actions);
+      g_object_unref (G_OBJECT (standard_view->priv->extension_actions));
+      standard_view->priv->extension_actions = NULL;
+    }
+
+  /* add the actions specified by the menu providers */
+  if (G_LIKELY (actions != NULL))
+    {
+      /* allocate the action group and the merge id for the extensions */
+      standard_view->priv->extension_actions = gtk_action_group_new ("thunar-standard-view-extensions");
+      standard_view->priv->extension_merge_id = gtk_ui_manager_new_merge_id (standard_view->ui_manager);
+      gtk_ui_manager_insert_action_group (standard_view->ui_manager, standard_view->priv->extension_actions, -1);
+
+      /* add the actions */
+      for (lp = actions; lp != NULL; lp = lp->next)
+        {
+          /* add the action to the action group */
+          gtk_action_group_add_action (standard_view->priv->extension_actions, GTK_ACTION (lp->data));
+
+          /* add the action to the UI manager */
+          if (G_LIKELY (selected_items != NULL))
+            {
+              /* add to the file context menu */
+              gtk_ui_manager_add_ui (standard_view->ui_manager,
+                                     standard_view->priv->extension_merge_id,
+                                     "/file-context-menu/placeholder-extensions",
+                                     gtk_action_get_name (GTK_ACTION (lp->data)),
+                                     gtk_action_get_name (GTK_ACTION (lp->data)),
+                                     GTK_UI_MANAGER_MENUITEM, FALSE);
+            }
+          else
+            {
+              /* add to the folder context menu */
+              gtk_ui_manager_add_ui (standard_view->ui_manager,
+                                     standard_view->priv->extension_merge_id,
+                                     "/folder-context-menu/placeholder-extensions",
+                                     gtk_action_get_name (GTK_ACTION (lp->data)),
+                                     gtk_action_get_name (GTK_ACTION (lp->data)),
+                                     GTK_UI_MANAGER_MENUITEM, FALSE);
+            }
+
+          /* release the reference on the action */
+          g_object_unref (G_OBJECT (lp->data));
+        }
+
+      /* be sure to update the UI manager to avoid flickering */
+      gtk_ui_manager_ensure_update (standard_view->ui_manager);
+
+      /* cleanup */
+      g_list_free (actions);
+    }
+}
+
+
+
+static void
 thunar_standard_view_action_properties (GtkAction          *action,
                                         ThunarStandardView *standard_view)
 {
@@ -1697,6 +1851,11 @@ thunar_standard_view_context_menu (ThunarStandardView *standard_view,
     menu = gtk_ui_manager_get_widget (standard_view->ui_manager, "/file-context-menu");
   else
     menu = gtk_ui_manager_get_widget (standard_view->ui_manager, "/folder-context-menu");
+
+  /* merge the menu extensions for the selected items */
+  thunar_standard_view_merge_menu_extensions (standard_view, selected_items);
+
+  /* release the selected items */
   g_list_foreach (selected_items, (GFunc) gtk_tree_path_free, NULL);
   g_list_free (selected_items);
 
index e7fe501..5cf78a1 100644 (file)
 #include <config.h>
 #endif
 
-#include <thunarx/thunarx-gtk-extensions.h>
-
 #include <thunar/thunar-application.h>
 #include <thunar/thunar-details-view.h>
 #include <thunar/thunar-favourites-pane.h>
+#include <thunar/thunar-gtk-extensions.h>
 #include <thunar/thunar-icon-view.h>
 #include <thunar/thunar-location-buttons.h>
 #include <thunar/thunar-location-dialog.h>
@@ -595,7 +594,7 @@ thunar_window_action_about (GtkAction    *action,
   gtk_show_about_dialog (GTK_WINDOW (window),
                          "authors", authors,
                          "comments", _("Thunar is a fast and easy to use file manager\nfor the Xfce Desktop Environment."),
-                         "copyright", "Copyright © 2004-2005 Benedikt Meurer",
+                         "copyright", "Copyright \302\251 2004-2005 Benedikt Meurer",
                          "license", license,
                          "logo", logo,
                          "name", PACKAGE_NAME,
@@ -717,11 +716,11 @@ thunar_window_set_current_directory (ThunarWindow *window,
     }
 
   /* enable the 'Open new window' action if we have a valid directory */
-  thunarx_gtk_action_group_set_action_sensitive (window->action_group, "open-new-window", (current_directory != NULL));
+  thunar_gtk_action_group_set_action_sensitive (window->action_group, "open-new-window", (current_directory != NULL));
 
   /* enable the 'Up' action if possible for the new directory */
-  thunarx_gtk_action_group_set_action_sensitive (window->action_group, "open-parent", (current_directory != NULL
-                                                  && thunar_file_has_parent (current_directory)));
+  thunar_gtk_action_group_set_action_sensitive (window->action_group, "open-parent", (current_directory != NULL
+                                                && thunar_file_has_parent (current_directory)));
 
   /* tell everybody that we have a new "current-directory",
    * we do this first so other widgets display the new
index 7ee6a3c..2e0c4f0 100644 (file)
@@ -2,26 +2,93 @@
 
 INCLUDES =                                                             \
        -I$(top_srcdir)                                                 \
-       -DEXO_API_SUBJECT_TO_CHANGE                                     \
-       -DEXO_DISABLE_DEPRECATED                                        \
-       -DG_LOG_DOMAIN=\"thunarx\"
+       -DG_LOG_DOMAIN=\"thunarx\"                                      \
+       -DTHUNARX_COMPILATION
 
-noinst_LTLIBRARIES =                                                   \
-       libthunarx.la
+libthunarx_built_sources =                                             \
+       thunarx-alias.h                                                 \
+       thunarx-aliasdef.c
 
-libthunarx_la_SOURCES =                                                        \
-       thunarx-gdk-pixbuf-extensions.c                                 \
-       thunarx-gdk-pixbuf-extensions.h                                 \
-       thunarx-gtk-extensions.c                                        \
-       thunarx-gtk-extensions.h
+libthunarx_headers =                                                   \
+       thunarx.h                                                       \
+       thunarx-config.h                                                \
+       thunarx-file-info.h                                             \
+       thunarx-menu-provider.h                                         \
+       thunarx-property-page.h                                         \
+       thunarx-property-page-provider.h
 
-libthunarx_la_CFLAGS =                                                 \
-       $(EXO_CFLAGS)
+libthunarx_includedir =                                                        \
+       $(includedir)/thunarx-$(THUNAR_VERSION_API)/thunarx
 
-libthunarx_la_LDFLAGS =                                                        \
-       -no-undefined
+libthunarx_include_HEADERS =                                           \
+       $(libthunarx_headers)
 
-libthunarx_la_LIBADD =                                                 \
-       $(EXO_LIBS)
+lib_LTLIBRARIES =                                                      \
+       libthunarx-1.la
+
+libthunarx_1_la_SOURCES =                                              \
+       $(libthunarx_built_sources)                                     \
+       $(libthunarx_headers)                                           \
+       thunarx-config.c                                                \
+       thunarx-file-info.c                                             \
+       thunarx-menu-provider.c                                         \
+       thunarx-property-page.c                                         \
+       thunarx-property-page-provider.c
+
+libthunarx_1_la_CFLAGS =                                               \
+       $(GTK_CFLAGS)
+
+libthunarx_1_la_LDFLAGS =                                              \
+       -export-dynamic                                                 \
+       -export-symbols-regex "^[^_].*"                                 \
+       -version-info $(THUNAR_VERINFO)
+
+libthunarx_1_la_LIBADD =                                               \
+       $(GTK_LIBS)
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = thunarx-1.pc
+
+EXTRA_DIST =                                                           \
+       abicheck.sh                                                     \
+       make-thunarx-alias.pl                                           \
+       thunarx.symbols                                                 \
+       thunarx-alias.h                                                 \
+       thunarx-aliasdef.c
+
+##
+## Rules to auto-generate built sources
+##
+## This is a bit tricky with automake, and non-trivial to implement. The
+## rules below seem to work fine and don't seem to break the build, but
+## they are only enabled in maintainer mode, so arbitrary users don't get
+## trapped in automake's oddities. Therefore we ship the autogenerated
+## files as part of the dist tarball.
+##
+if MAINTAINER_MODE
+CLEANFILES =                                                           \
+       actual-abi                                                      \
+       expected-abi
+
+DISTCLEANFILES =                                                       \
+       $(libthunarx_built_sources)
+
+BUILT_SOURCES =                                                                \
+       $(libthunarx_built_sources)
+
+if HAVE_GNUC_VISIBILITY
+TESTS =                                                                        \
+       abicheck.sh
+endif
+
+thunarx-alias.h: make-thunarx-alias.pl thunarx.symbols
+       $(PERL) $(srcdir)/make-thunarx-alias.pl < $(srcdir)/thunarx.symbols > thunarx-alias.h
+
+thunarx-aliasdef.c: make-thunarx-alias.pl thunarx.symbols
+       $(PERL) $(srcdir)/make-thunarx-alias.pl -def < $(srcdir)/thunarx.symbols > thunarx-aliasdef.c
+endif
+
+# required for gtk-doc
+dist-hook: all
 
 # vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/thunarx/abicheck.sh b/thunarx/abicheck.sh
new file mode 100755 (executable)
index 0000000..cbdbd9c
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# Copyright (c) 2004 The GLib Development Team.
+# Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+cpp -P -DALL_FILES ${srcdir:-.}/thunarx.symbols | sed -e '/^$/d' -e 's/ G_GNUC.*$//' -e 's/ PRIVATE//' | sort > expected-abi
+nm -D .libs/libthunarx-1.so | grep " T\|R " | cut -d ' ' -f 3 | grep -v '^_.*' | sort > actual-abi
+diff -u expected-abi actual-abi && rm expected-abi actual-abi
diff --git a/thunarx/make-thunarx-alias.pl b/thunarx/make-thunarx-alias.pl
new file mode 100755 (executable)
index 0000000..69c569d
--- /dev/null
@@ -0,0 +1,155 @@
+#!/usr/bin/env perl -w
+#
+# Copyright (c) 2004 The GLib Development Team.
+# Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+#
+
+my $option_def = 0;
+
+if (($#ARGV >= 0) && ($ARGV[0] eq "-def"))
+  {
+    shift;
+    $option_def = 1;
+  }
+
+print <<EOF;
+/* Generated by make-thunarx-alias.pl. Do not edit this file. */
+
+#ifdef HAVE_GNUC_VISIBILITY
+
+#include <glib.h>
+
+EOF
+
+if ($option_def)
+  {
+    print <<EOF
+#undef IN_HEADER
+#define IN_HEADER(x) 1
+
+#undef IN_SOURCE
+#define IN_SOURCE defined
+
+EOF
+  }
+else
+  {
+    print <<EOF
+#define IN_HEADER defined
+#define IN_SOURCE(x) 1
+
+EOF
+  }
+
+my $in_comment = 0;
+my $in_skipped_section = 0;
+
+while (<>)
+  {
+    # ignore empty lines
+    next if /^\s*$/;
+
+    # skip comments
+    if ($_ =~ /^\s*\/\*/)
+      {
+        $in_comment = 1;
+      }
+    
+    if ($in_comment)
+      {
+        if ($_ =~  /\*\/\s$/)
+          {
+            $in_comment = 0;
+          }
+        next;
+      }
+
+    # handle ifdefs
+    if ($_ =~ /^\#endif/)
+      {
+        if (!$in_skipped_section)
+          {
+            print $_;
+          }
+
+        $in_skipped_section = 0;
+        next;
+      }
+
+    if ($_ =~ /^\#ifdef\s+(INCLUDE_VARIABLES|INCLUDE_INTERNAL_SYMBOLS|ALL_FILES)/)
+      {
+        $in_skipped_section = 1;
+      }
+
+    if ($in_skipped_section)
+      {
+        next;
+      }
+
+    if ($_ =~ /^\#ifn?def\s+G/)
+      {
+        print $_;
+        next;
+      }
+   
+    if ($_ =~ /^\#if.*(IN_SOURCE|IN_HEADER)/)
+      {
+        print $_;
+        next;
+      }
+
+    chop;
+    my $line = $_;
+    my @words;
+    my $attributes = "";
+
+    @words = split (/ /, $line);
+    my $symbol = shift (@words);
+    chomp ($symbol);
+    my $alias = "IA__".$symbol;
+    
+    # Drop any Win32 specific .def file syntax,  but keep attributes
+    foreach $word (@words)
+      {
+        $attributes = "$attributes $word" unless $word eq "PRIVATE";
+      }
+    
+    if (!$option_def)
+      {
+        print <<EOF
+extern __typeof ($symbol) $alias __attribute((visibility("hidden")))$attributes;
+\#define $symbol $alias
+
+EOF
+      }
+    else
+      {
+        print <<EOF
+\#undef $symbol 
+extern __typeof ($symbol) $symbol __attribute((alias("$alias"), visibility("default")));
+
+EOF
+      }
+  }
+
+print <<EOF;
+
+#endif /* HAVE_GNUC_VISIBILITY */
+EOF
+
+
diff --git a/thunarx/thunarx-1.pc.in b/thunarx/thunarx-1.pc.in
new file mode 100644 (file)
index 0000000..0b3179a
--- /dev/null
@@ -0,0 +1,13 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+extensionsdir=${libdir}/thunarx-@THUNAR_VERSION_API@
+
+Name: thunarx
+Description: A library to create Thunar extensions
+Requires: gtk+-2.0
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lthunarx-@THUNAR_VERSION_API@
+Cflags: -I${includedir}/thunarx-@THUNAR_VERSION_API@
diff --git a/thunarx/thunarx-config.c b/thunarx/thunarx-config.c
new file mode 100644 (file)
index 0000000..64a7e18
--- /dev/null
@@ -0,0 +1,131 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <thunarx/thunarx-config.h>
+#include <thunarx/thunarx-alias.h>
+
+
+
+/**
+ * thunarx_major_version:
+ *
+ * The major version number of the
+ * <systemitem class="library">thunarx</systemitem> library (e.g. in
+ * version 0.5.1 this is 0).
+ *
+ * This variable is in the library, so represents the
+ * <systemitem class="library">thunarx</systemitem> library you have
+ * linked against. Contrast with the #THUNARX_MAJOR_VERSION macro, which
+ * represents the major version of the
+ * <systemitem class="library">thunarx</systemitem> headers you have
+ * included.
+ **/
+const guint thunarx_major_version = THUNARX_MAJOR_VERSION;
+
+
+
+/**
+ * thunarx_minor_version:
+ *
+ * The minor version number of the
+ * <systemitem class="library">thunarx</systemitem> library (e.g. in
+ * version 0.5.1 this is 5).
+ *
+ * This variable is in the library, so represents the
+ * <systemitem class="library">thunarx</systemitem> library you have
+ * linked against. Contrast with the #THUNARX_MINOR_VERSION macro, which
+ * represents the minor version of the
+ * <systemitem class="library">thunarx</systemitem> headers you have
+ * included.
+ **/
+const guint thunarx_minor_version = THUNARX_MINOR_VERSION;
+
+
+
+/**
+ * thunarx_micro_version:
+ *
+ * The micro version number of the
+ * <systemitem class="library">thunarx</systemitem> library (e.g. in
+ * version 0.5.1 this is 1).
+ *
+ * This variable is in the library, so represents the
+ * <systemitem class="library">thunarx</systemitem> library you have
+ * linked against. Contrast with the #THUNARX_MICRO_VERSION macro, which
+ * represents the micro version of the
+ * <systemitem class="library">thunarx</systemitem> headers you have
+ * included.
+ **/
+const guint thunarx_micro_version = THUNARX_MICRO_VERSION;
+
+
+
+/**
+ * thunarx_check_version:
+ * @required_major : the required major version.
+ * @required_minor : the required minor version.
+ * @required_micro : the required micro version.
+ *
+ * Checks that the <systemitem class="library">thunarx</systemitem> library
+ * in use is compatible with the given version. Generally you would pass in
+ * the constants #THUNARX_MAJOR_VERSION, #THUNARX_MINOR_VERSION and
+ * #THUNARX_VERSION_MICRO as the three arguments to this function; that produces
+ * a check that the library in use is compatible with the version of
+ * <systemitem class="library">thunarx</systemitem> the extension was
+ * compiled against.
+ *
+ * This function should be called by extensions in the
+ * thunar_extension_initialize() method to verify that the <systemitem
+ * class="library">thunarx</systemitem> library used by file manager is
+ * compatible with the version the extension was compiled with.
+ *
+ * <example>
+ * <title>Checking the runtime version of the Thunar Extension library</title>
+ * <programlisting>
+ * const gchar *mismatch;
+ * mismatch = thunarx_check_version (THUNARX_VERSION_MAJOR,
+ *                                   THUNARX_VERSION_MINOR,
+ *                                   THUNARX_VERSION_MICRO);
+ * if (G_UNLIKELY (mismatch != NULL))
+ *   g_error ("Version mismatch: %<!---->s", mismatch);
+ * </programlisting>
+ * </example>
+ *
+ * Return value: %NULL if the library is compabiel with the given version,
+ *               or a string describing the version mismatch. The returned
+ *               string is owned by the library and must not be freed or
+ *               modified by the caller.
+ **/
+const gchar*
+thunarx_check_version (guint required_major,
+                       guint required_minor,
+                       guint required_micro)
+{
+  return NULL;
+}
+
+
+
+#define __THUNARX_CONFIG_C__
+#include <thunarx/thunarx-aliasdef.c>
diff --git a/thunarx/thunarx-config.h.in b/thunarx/thunarx-config.h.in
new file mode 100644 (file)
index 0000000..7305266
--- /dev/null
@@ -0,0 +1,54 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_CONFIG_H__
+#define __THUNARX_CONFIG_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS;
+
+#define THUNARX_MAJOR_VERSION @THUNAR_VERSION_MAJOR@
+#define THUNARX_MINOR_VERSION @THUNAR_VERSION_MINOR@
+#define THUNARX_MICRO_VERSION @THUNAR_VERSION_MICRO@
+
+#define THUNARX_CHECK_VERSION(major,minor,micro) \
+  (THUNARX_MAJOR_VERSION > (major) \
+   || (THUNARX_MAJOR_VERSION == (major) \
+       && THUNARX_MINOR_VERSION > (minor)) \
+   || (THUNARX_MAJOR_VERSION == (major) \
+       && THUNARX_MINOR_VERSION == (minor) \
+       && THUNARX_MICRO_VERSION >= (micro)))
+
+extern const guint thunarx_major_version;
+extern const guint thunarx_minor_version;
+extern const guint thunarx_micro_version;
+
+const gchar *thunarx_check_version (guint required_major,
+                                    guint required_minor,
+                                    guint required_micro);
+
+G_END_DECLS;
+
+#endif /* !__THUNARX_CONFIG_H__ */
diff --git a/thunarx/thunarx-file-info.c b/thunarx/thunarx-file-info.c
new file mode 100644 (file)
index 0000000..01b6b6e
--- /dev/null
@@ -0,0 +1,277 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <thunarx/thunarx-file-info.h>
+#include <thunarx/thunarx-alias.h>
+
+
+
+GType
+thunarx_file_info_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo info =
+      {
+        sizeof (ThunarxFileInfoIface),
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        0,
+        0,
+        NULL,
+        NULL,
+      };
+
+      type = g_type_register_static (G_TYPE_INTERFACE, "ThunarxFileInfo", &info, 0);
+
+      g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+    }
+
+  return type;
+}
+
+
+
+/**
+ * thunarx_file_info_get_name:
+ * @file_info : a #ThunarxFileInfo.
+ *
+ * Returns the real name of the file represented
+ * by @file_info in the local file system encoding.
+ * You can use g_filename_display_name() or similar
+ * functions to generate an UTF-8 version of the
+ * name, which is suitable for use in the user
+ * interface.
+ *
+ * The caller is responsible to free the returned
+ * string using g_free() when no longer needed.
+ *
+ * Return value: the real name of the file represented
+ *               by @file_info.
+ **/
+gchar*
+thunarx_file_info_get_name (ThunarxFileInfo *file_info)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), NULL);
+  return (*THUNARX_FILE_INFO_GET_IFACE (file_info)->get_name) (file_info);
+}
+
+
+
+/**
+ * thunarx_file_info_get_uri:
+ * @file_info : a #ThunarxFileInfo.
+ *
+ * Returns the escaped, fully qualified URI
+ * of the file object represented by @file_info.
+ * You may use g_filename_from_uri() and similar
+ * functions to work with the returned URI.
+ *
+ * The caller is responsible to free the returned
+ * string using g_free() when no longer needed.
+ *
+ * Return value: the fully qualified URI of @file_info.
+ **/
+gchar*
+thunarx_file_info_get_uri (ThunarxFileInfo *file_info)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), NULL);
+  return (*THUNARX_FILE_INFO_GET_IFACE (file_info)->get_uri) (file_info);
+}
+
+
+
+/**
+ * thunarx_file_info_get_parent_uri:
+ * @file_info : a #ThunarxFileInfo.
+ *
+ * Returns the URI to the parent file of
+ * @file_info or %NULL if @file_info has
+ * no parent. Note that the parent URI
+ * may be of a different type than the
+ * URI of @file_info. For example, the
+ * parent of "file:///" is "computer:///".
+ *
+ * The caller is responsible to free the
+ * returned string using g_free() when no
+ * longer needed.
+ *
+ * Return value: the parent URI for @file_info
+ *               or %NULL.
+ **/
+gchar*
+thunarx_file_info_get_parent_uri (ThunarxFileInfo *file_info)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), NULL);
+  return (*THUNARX_FILE_INFO_GET_IFACE (file_info)->get_parent_uri) (file_info);
+}
+
+
+
+/**
+ * thunarx_file_info_get_uri_scheme:
+ * @file_info : a #ThunarxFileInfo.
+ *
+ * Returns the URI scheme of the file represented
+ * by @file_info. E.g. if @file_info refers to the
+ * file "file:///usr/home", the return value will
+ * be "file".
+ *
+ * The caller is responsible to free the returned
+ * string using g_free() when no longer needed.
+ *
+ * Return value: the URI scheme for @file_info.
+ **/
+gchar*
+thunarx_file_info_get_uri_scheme (ThunarxFileInfo *file_info)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), NULL);
+  return (*THUNARX_FILE_INFO_GET_IFACE (file_info)->get_uri_scheme) (file_info);
+}
+
+
+
+/**
+ * thunarx_file_info_get_mime_type:
+ * @file_info : a #ThunarxFileInfo.
+ *
+ * Returns the MIME-type of the file represented by
+ * @file_info or %NULL if no MIME-type is known for
+ * @file_info.
+ *
+ * The caller is responsible to free the returned
+ * string using g_free() when no longer needed.
+ *
+ * Return value: the MIME-type for @file_info or
+ *               %NULL.
+ **/
+gchar*
+thunarx_file_info_get_mime_type (ThunarxFileInfo *file_info)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), NULL);
+  return (*THUNARX_FILE_INFO_GET_IFACE (file_info)->get_mime_type) (file_info);
+}
+
+
+
+/**
+ * thunarx_file_info_has_mime_type:
+ * @file_info : a #ThunarxFileInfo.
+ * @mime_type : a MIME-type (e.g. "text/plain").
+ *
+ * Checks whether @file_info is of the given @mime_type
+ * or whether the MIME-type of @file_info is a subclass
+ * of @mime_type.
+ *
+ * This is the preferred way for most extensions to check
+ * whether they support a given file or not, and you should
+ * consider using this method rather than
+ * thunarx_file_info_get_mime_type(). A simple example would
+ * be a menu extension that performs a certain action on
+ * text files. In this case you want to check whether a given
+ * #ThunarxFileInfo refers to any kind of text file, not only
+ * to "text/plain" (e.g. this also includes "text/xml" and
+ * "application/x-desktop").
+ *
+ * But you should be aware that this method may take some
+ * time to test whether @mime_type is valid for @file_info,
+ * so don't call it too often.
+ *
+ * Return value: %TRUE if @mime_type is valid for @file_info,
+ *               else %FALSE.
+ **/
+gboolean
+thunarx_file_info_has_mime_type (ThunarxFileInfo *file_info,
+                                 const gchar     *mime_type)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), FALSE);
+  g_return_val_if_fail (mime_type != NULL, FALSE);
+  return (*THUNARX_FILE_INFO_GET_IFACE (file_info)->has_mime_type) (file_info, mime_type);
+}
+
+
+
+/**
+ * thunarx_file_info_is_directory:
+ * @file_info : a #ThunarxFileInfo.
+ *
+ * Checks whether @file_info refers to a directory.
+ *
+ * Return value: %TRUE if @file_info is a directory.
+ **/
+gboolean
+thunarx_file_info_is_directory (ThunarxFileInfo *file_info)
+{
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (file_info), FALSE);
+  return (*THUNARX_FILE_INFO_GET_IFACE (file_info)->is_directory) (file_info);
+}
+
+
+
+/**
+ * thunarx_file_info_list_copy:
+ * @file_infos : a #GList of #ThunarxFileInfo<!---->s.
+ *
+ * Does a deep copy of @file_infos and returns the
+ * new list.
+ *
+ * Return value: a copy of @file_infos.
+ **/
+GList*
+thunarx_file_info_list_copy (GList *file_infos)
+{
+  GList *list;
+
+  list = g_list_copy (file_infos);
+  g_list_foreach (list, (GFunc) g_object_ref, NULL);
+
+  return list;
+}
+
+
+
+/**
+ * thunarx_file_info_list_free:
+ * @file_infos : a #GList of #ThunarxFileInfo<!---->s.
+ *
+ * Frees the resources allocated for the @file_infos
+ * list and decreases the reference count on the
+ * #ThunarxFileInfo<!---->s contained within.
+ **/
+void
+thunarx_file_info_list_free (GList *file_infos)
+{
+  g_list_foreach (file_infos, (GFunc) g_object_unref, NULL);
+  g_list_free (file_infos);
+}
+
+
+
+#define __THUNARX_FILE_INFO_C__
+#include <thunarx/thunarx-aliasdef.c>
diff --git a/thunarx/thunarx-file-info.h b/thunarx/thunarx-file-info.h
new file mode 100644 (file)
index 0000000..a1fa753
--- /dev/null
@@ -0,0 +1,86 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_FILE_INFO_H__
+#define __THUNARX_FILE_INFO_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+typedef struct _ThunarxFileInfoIface ThunarxFileInfoIface;
+typedef struct _ThunarxFileInfo      ThunarxFileInfo;
+
+#define THUNARX_TYPE_FILE_INFO            (thunarx_file_info_get_type ())
+#define THUNARX_FILE_INFO(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNARX_TYPE_FILE_INFO, ThunarxFileInfo))
+#define THUNARX_IS_FILE_INFO(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNARX_TYPE_FILE_INFO))
+#define THUNARX_FILE_INFO_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), THUNARX_TYPE_FILE_INFO, ThunarxFileInfoIface))
+
+struct _ThunarxFileInfoIface
+{
+  /*< private >*/
+  GTypeInterface __parent__;
+
+  /*< public >*/
+  gchar     *(*get_name)        (ThunarxFileInfo *file_info);
+
+  gchar     *(*get_uri)         (ThunarxFileInfo *file_info);
+  gchar     *(*get_parent_uri)  (ThunarxFileInfo *file_info);
+  gchar     *(*get_uri_scheme)  (ThunarxFileInfo *file_info);
+
+  gchar     *(*get_mime_type)   (ThunarxFileInfo *file_info);
+  gboolean   (*has_mime_type)   (ThunarxFileInfo *file_info,
+                                 const gchar     *mime_type);
+
+  gboolean   (*is_directory)    (ThunarxFileInfo *file_info);
+
+  /*< private >*/
+  void (*reserved1) (void);
+  void (*reserved2) (void);
+  void (*reserved3) (void);
+  void (*reserved4) (void);
+  void (*reserved5) (void);
+  void (*reserved6) (void);
+  void (*reserved7) (void);
+};
+
+GType      thunarx_file_info_get_type       (void) G_GNUC_CONST;
+
+gchar     *thunarx_file_info_get_name       (ThunarxFileInfo *file_info);
+gchar     *thunarx_file_info_get_uri        (ThunarxFileInfo *file_info);
+gchar     *thunarx_file_info_get_parent_uri (ThunarxFileInfo *file_info);
+gchar     *thunarx_file_info_get_uri_scheme (ThunarxFileInfo *file_info);
+
+gchar     *thunarx_file_info_get_mime_type  (ThunarxFileInfo *file_info);
+gboolean   thunarx_file_info_has_mime_type  (ThunarxFileInfo *file_info,
+                                             const gchar     *mime_type);
+
+gboolean   thunarx_file_info_is_directory   (ThunarxFileInfo *file_info);
+
+GList     *thunarx_file_info_list_copy      (GList           *file_infos);
+void       thunarx_file_info_list_free      (GList           *file_infos);
+
+G_END_DECLS;
+
+#endif /* !__THUNARX_FILE_INFO_H__ */
diff --git a/thunarx/thunarx-menu-provider.c b/thunarx/thunarx-menu-provider.c
new file mode 100644 (file)
index 0000000..f697a49
--- /dev/null
@@ -0,0 +1,188 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <thunarx/thunarx-menu-provider.h>
+#include <thunarx/thunarx-alias.h>
+
+
+
+static GQuark thunarx_menu_provider_action_quark;
+
+
+
+GType
+thunarx_menu_provider_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo info =
+      {
+        sizeof (ThunarxMenuProviderIface),
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        0,
+        0,
+        NULL,
+        NULL,
+      };
+
+      /* register the menu provider interface */
+      type = g_type_register_static (G_TYPE_INTERFACE, "ThunarxMenuProvider", &info, 0);
+      g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+
+      /* allocate the thunarx-menu-provider-action quark */
+      thunarx_menu_provider_action_quark = g_quark_from_static_string ("thunarx-menu-provider-action");
+    }
+
+  return type;
+}
+
+
+
+/**
+ * thunarx_menu_provider_get_file_actions:
+ * @provider : a #ThunarxMenuProvider.
+ * @window   : the #GtkWindow within which the actions will be used.
+ * @files    : the list of #ThunarxFileInfo<!---->s to which the actions will be applied.
+ *
+ * Returns the list of #GtkAction<!---->s that @provider has to offer for
+ * @files.
+ *
+ * As a special note, this method automatically takes a reference on the
+ * @provider for every #GtkAction object returned from the real implementation
+ * of this method in @provider. This is to make sure that the extension stays
+ * in memory for atleast the time that the actions are used. If the extension
+ * wants to stay in memory for a longer time, it'll need to take care of this
+ * itself (e.g. by taking an additional reference on the @provider itself,
+ * that's released at a later time).
+ *
+ * The caller is responsible to free the returned list of actions using
+ * something like this when no longer needed:
+ * <informalexample><programlisting>
+ * g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ * g_list_free (list);
+ * </programlisting></informalexample>
+ *
+ * Return value: the list of #GtkAction<!---->s that @provider has to offer
+ *               for @files.
+ **/
+GList*
+thunarx_menu_provider_get_file_actions (ThunarxMenuProvider *provider,
+                                        GtkWidget           *window,
+                                        GList               *files)
+{
+  GList *actions;
+  GList *lp;
+
+  g_return_val_if_fail (THUNARX_IS_MENU_PROVIDER (provider), NULL);
+  g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
+  g_return_val_if_fail (files != NULL, NULL);
+
+  if (THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_file_actions != NULL)
+    {
+      /* query the actions and take a reference on the provider for each action */
+      actions = (*THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_file_actions) (provider, window, files);
+      for (lp = actions; lp != NULL; lp = lp->next)
+        {
+          g_object_set_qdata_full (G_OBJECT (lp->data), thunarx_menu_provider_action_quark, provider, g_object_unref);
+          g_object_ref (G_OBJECT (provider));
+        }
+    }
+  else
+    {
+      actions = NULL;
+    }
+
+  return actions;
+}
+
+
+
+/**
+ * thunarx_menu_provider_get_folder_actions:
+ * @provider : a #ThunarxMenuProvider.
+ * @window   : the #GtkWindow within which the actions will be used.
+ * @folder   : the folder to which the actions should will be applied.
+ *
+ * Returns the list of #GtkAction<!---->s that @provider has to offer for
+ * @folder.
+ *
+ * As a special note, this method automatically takes a reference on the
+ * @provider for every #GtkAction object returned from the real implementation
+ * of this method in @provider. This is to make sure that the extension stays
+ * in memory for atleast the time that the actions are used. If the extension
+ * wants to stay in memory for a longer time, it'll need to take care of this
+ * itself (e.g. by taking an additional reference on the @provider itself,
+ * that's released at a later time).
+ *
+ * The caller is responsible to free the returned list of actions using
+ * something like this when no longer needed:
+ * <informalexample><programlisting>
+ * g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ * g_list_free (list);
+ * </programlisting></informalexample>
+ *
+ * Return value: the list of #GtkAction<!---->s that @provider has to offer
+ *               for @folder.
+ **/
+GList*
+thunarx_menu_provider_get_folder_actions (ThunarxMenuProvider *provider,
+                                          GtkWidget           *window,
+                                          ThunarxFileInfo     *folder)
+{
+  GList *actions;
+  GList *lp;
+
+  g_return_val_if_fail (THUNARX_IS_MENU_PROVIDER (provider), NULL);
+  g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
+  g_return_val_if_fail (THUNARX_IS_FILE_INFO (folder), NULL);
+  g_return_val_if_fail (thunarx_file_info_is_directory (folder), NULL);
+
+  if (THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_folder_actions != NULL)
+    {
+      /* query the actions and take a reference on the provider for each action */
+      actions = (*THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_folder_actions) (provider, window, folder);
+      for (lp = actions; lp != NULL; lp = lp->next)
+        {
+          g_object_set_qdata_full (G_OBJECT (lp->data), thunarx_menu_provider_action_quark, provider, g_object_unref);
+          g_object_ref (G_OBJECT (provider));
+        }
+    }
+  else
+    {
+      actions = NULL;
+    }
+
+  return actions;
+}
+
+
+
+#define __THUNARX_MENU_PROVIDER_C__
+#include <thunarx/thunarx-aliasdef.c>
diff --git a/thunarx/thunarx-menu-provider.h b/thunarx/thunarx-menu-provider.h
new file mode 100644 (file)
index 0000000..d6efdd9
--- /dev/null
@@ -0,0 +1,75 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_MENU_PROVIDER_H__
+#define __THUNARX_MENU_PROVIDER_H__
+
+#include <gtk/gtk.h>
+
+#include <thunarx/thunarx-file-info.h>
+
+G_BEGIN_DECLS;
+
+typedef struct _ThunarxMenuProviderIface ThunarxMenuProviderIface;
+typedef struct _ThunarxMenuProvider      ThunarxMenuProvider;
+
+#define THUNARX_TYPE_MENU_PROVIDER           (thunarx_menu_provider_get_type ())
+#define THUNARX_MENU_PROVIDER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNARX_TYPE_MENU_PROVIDER, ThunarxMenuProvider))
+#define THUNARX_IS_MENU_PROVIDER(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNARX_TYPE_MENU_PROVIDER))
+#define THUNARX_MENU_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), THUNARX_TYPE_MENU_PROVIDER, ThunarxMenuProviderIface))
+
+struct _ThunarxMenuProviderIface
+{
+  /*< private >*/
+  GTypeInterface __parent__;
+
+  /*< public >*/
+  GList *(*get_file_actions)    (ThunarxMenuProvider *provider,
+                                 GtkWidget           *window,
+                                 GList               *files);
+
+  GList *(*get_folder_actions)  (ThunarxMenuProvider *provider,
+                                 GtkWidget           *window,
+                                 ThunarxFileInfo     *folder);
+
+  /*< private >*/
+  void (*reserved1) (void);
+  void (*reserved2) (void);
+  void (*reserved3) (void);
+  void (*reserved4) (void);
+};
+
+GType  thunarx_menu_provider_get_type           (void) G_GNUC_CONST;
+
+GList *thunarx_menu_provider_get_file_actions   (ThunarxMenuProvider *provider,
+                                                 GtkWidget           *window,
+                                                 GList               *files);
+
+GList *thunarx_menu_provider_get_folder_actions (ThunarxMenuProvider *provider,
+                                                 GtkWidget           *window,
+                                                 ThunarxFileInfo     *folder);
+
+G_END_DECLS;
+
+#endif /* !__THUNARX_MENU_PROVIDER_H__ */
diff --git a/thunarx/thunarx-property-page-provider.c b/thunarx/thunarx-property-page-provider.c
new file mode 100644 (file)
index 0000000..c1caec6
--- /dev/null
@@ -0,0 +1,126 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <thunarx/thunarx-property-page-provider.h>
+#include <thunarx/thunarx-alias.h>
+
+
+
+static GQuark thunarx_property_page_quark;
+
+
+
+GType
+thunarx_property_page_provider_get_type (void)
+{
+  static GType type = G_TYPE_INVALID;
+
+  if (G_UNLIKELY (type == G_TYPE_INVALID))
+    {
+      static const GTypeInfo info =
+      {
+        sizeof (ThunarxPropertyPageProviderIface),
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        NULL,
+        0,
+        0,
+        NULL,
+        NULL,
+      };
+
+      /* register the property page provider interface */
+      type = g_type_register_static (G_TYPE_INTERFACE, "ThunarxPropertyPageProvider", &info, 0);
+      g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+
+      /* allocate the thunarx-property-page quark */
+      thunarx_property_page_quark = g_quark_from_static_string ("thunarx-property-page");
+    }
+
+  return type;
+}
+
+
+
+/**
+ * thunarx_property_page_provider_get_pages:
+ * @provider : a #ThunarxPropertyPageProvider.
+ * @files    : the list of #ThunarxFileInfo<!---->s for which a properties dialog will be displayed.
+ *
+ * Returns the list of #ThunarxPropertyPage<!---->s that @provider has to offer for @files.
+ *
+ * As a special note, this method automatically takes a reference on the
+ * @provider for every #ThunarxPropertyPage object returned from the real implementation
+ * of this method in @provider. This is to make sure that the extension stays
+ * in memory for atleast the time that the pages are used. If the extension
+ * wants to stay in memory for a longer time, it'll need to take care of this
+ * itself (e.g. by taking an additional reference on the @provider itself,
+ * that's released at a later time).
+ *
+ * The caller is responsible to free the returned list of pages using
+ * something like this when no longer needed:
+ * <informalexample><programlisting>
+ * g_list_foreach (list, (GFunc) g_object_ref, NULL);
+ * g_list_foreach (list, (GFunc) gtk_object_sink, NULL);
+ * g_list_foreach (list, (GFunc) g_object_unref, NULL);
+ * g_list_free (list);
+ * </programlisting></informalexample>
+ *
+ * Return value: the list of #ThunarxPropertyPage<!---->s that @provider has to offer
+ *               for @files.
+ **/
+GList*
+thunarx_property_page_provider_get_pages (ThunarxPropertyPageProvider *provider,
+                                          GList                       *files)
+{
+  GList *pages;
+  GList *lp;
+
+  g_return_val_if_fail (THUNARX_IS_PROPERTY_PAGE_PROVIDER (provider), NULL);
+  g_return_val_if_fail (files != NULL, NULL);
+
+  if (THUNARX_PROPERTY_PAGE_PROVIDER_GET_IFACE (provider)->get_pages != NULL)
+    {
+      /* query the property pages and take a reference on the provider for each page */
+      pages = (*THUNARX_PROPERTY_PAGE_PROVIDER_GET_IFACE (provider)->get_pages) (provider, files);
+      for (lp = pages; lp != NULL; lp = lp->next)
+        {
+          g_object_set_qdata_full (G_OBJECT (lp->data), thunarx_property_page_quark, provider, g_object_unref);
+          g_object_ref (G_OBJECT (provider));
+        }
+    }
+  else
+    {
+      pages = NULL;
+    }
+
+  return pages;
+}
+
+
+
+#define __THUNARX_PROPERTY_PAGE_PROVIDER_C__
+#include <thunarx/thunarx-aliasdef.c>
diff --git a/thunarx/thunarx-property-page-provider.h b/thunarx/thunarx-property-page-provider.h
new file mode 100644 (file)
index 0000000..ccbcc22
--- /dev/null
@@ -0,0 +1,64 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_PROPERTY_PAGE_PROVIDER_H__
+#define __THUNARX_PROPERTY_PAGE_PROVIDER_H__
+
+#include <thunarx/thunarx-property-page.h>
+
+G_BEGIN_DECLS;
+
+typedef struct _ThunarxPropertyPageProviderIface ThunarxPropertyPageProviderIface;
+typedef struct _ThunarxPropertyPageProvider      ThunarxPropertyPageProvider;
+
+#define THUNARX_TYPE_PROPERTY_PAGE_PROVIDER           (thunarx_property_page_provider_get_type ())
+#define THUNARX_PROPERTY_PAGE_PROVIDER(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNARX_TYPE_PROPERTY_PAGE_PROVIDER, ThunarxPropertyPageProvider))
+#define THUNARX_IS_PROPERTY_PAGE_PROVIDER(obj)        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNARX_TYPE_PROPERTY_PAGE_PROVIDER))
+#define THUNARX_PROPERTY_PAGE_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), THUNARX_TYPE_PROPERTY_PAGE_PROVIDER, ThunarxPropertyPageProviderIface))
+
+struct _ThunarxPropertyPageProviderIface
+{
+  /*< private >*/
+  GTypeInterface __parent__;
+
+  /*< public >*/
+  GList *(*get_pages) (ThunarxPropertyPageProvider *provider,
+                       GList                       *files);
+
+  /*< private >*/
+  void (*reserved1) (void);
+  void (*reserved2) (void);
+  void (*reserved3) (void);
+  void (*reserved4) (void);
+  void (*reserved5) (void);
+};
+
+GType  thunarx_property_page_provider_get_type  (void) G_GNUC_CONST;
+
+GList *thunarx_property_page_provider_get_pages (ThunarxPropertyPageProvider *provider,
+                                                 GList                       *files);
+
+G_END_DECLS;
+
+#endif /* !__THUNARX_PROPERTY_PAGE_PROVIDER_H__ */
diff --git a/thunarx/thunarx-property-page.c b/thunarx/thunarx-property-page.c
new file mode 100644 (file)
index 0000000..554ac6f
--- /dev/null
@@ -0,0 +1,401 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include <thunarx/thunarx-property-page.h>
+#include <thunarx/thunarx-alias.h>
+
+
+
+#define THUNARX_PROPERTY_PAGE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), THUNARX_TYPE_PROPERTY_PAGE, ThunarxPropertyPagePrivate))
+
+
+
+/* Property identifiers */
+enum
+{
+  PROP_0,
+  PROP_LABEL,
+  PROP_LABEL_WIDGET,
+};
+
+
+
+static void thunarx_property_page_class_init    (ThunarxPropertyPageClass *klass);
+static void thunarx_property_page_init          (ThunarxPropertyPage      *property_page);
+static void thunarx_property_page_get_property  (GObject                  *object,
+                                                 guint                     prop_id,
+                                                 GValue                   *value,
+                                                 GParamSpec               *pspec);
+static void thunarx_property_page_set_property  (GObject                  *object,
+                                                 guint                     prop_id,
+                                                 const GValue             *value,
+                                                 GParamSpec               *pspec);
+static void thunarx_property_page_destroy       (GtkObject                *object);
+static void thunarx_property_page_size_request  (GtkWidget                *widget,
+                                                 GtkRequisition           *requisition);
+static void thunarx_property_page_size_allocate (GtkWidget                *widget,
+                                                 GtkAllocation            *allocation);
+
+
+
+struct _ThunarxPropertyPagePrivate
+{
+  GtkWidget *label_widget;
+};
+
+
+
+G_DEFINE_TYPE (ThunarxPropertyPage, thunarx_property_page, GTK_TYPE_BIN);
+
+
+
+static void
+thunarx_property_page_class_init (ThunarxPropertyPageClass *klass)
+{
+  GtkObjectClass *gtkobject_class;
+  GtkWidgetClass *gtkwidget_class;
+  GObjectClass   *gobject_class;
+
+  /* add our private data to the class type */
+  g_type_class_add_private (klass, sizeof (ThunarxPropertyPagePrivate));
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  gobject_class->get_property = thunarx_property_page_get_property;
+  gobject_class->set_property = thunarx_property_page_set_property;
+
+  gtkobject_class = GTK_OBJECT_CLASS (klass);
+  gtkobject_class->destroy = thunarx_property_page_destroy;
+
+  gtkwidget_class = GTK_WIDGET_CLASS (klass);
+  gtkwidget_class->size_request = thunarx_property_page_size_request;
+  gtkwidget_class->size_allocate = thunarx_property_page_size_allocate;
+
+  /**
+   * ThunarxPropertyPage::label:
+   *
+   * Text of the page's label.
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_LABEL,
+                                   g_param_spec_string ("label",
+                                                        _("Label"),
+                                                        _("Text of the page's label"),
+                                                        NULL,
+                                                        G_PARAM_READWRITE));
+
+  /**
+   * ThunarxPropertyPage::label-widget:
+   *
+   * A widget to display in place of the usual page label.
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_LABEL_WIDGET,
+                                   g_param_spec_object ("label-widget",
+                                                        _("Label widget"),
+                                                        _("A widget to display in place of the usual page label"),
+                                                        GTK_TYPE_WIDGET,
+                                                        G_PARAM_READWRITE));
+}
+
+
+
+static void
+thunarx_property_page_init (ThunarxPropertyPage *property_page)
+{
+  property_page->priv = THUNARX_PROPERTY_PAGE_GET_PRIVATE (property_page);
+}
+
+
+
+static void
+thunarx_property_page_get_property (GObject    *object,
+                                    guint       prop_id,
+                                    GValue     *value,
+                                    GParamSpec *pspec)
+{
+  ThunarxPropertyPage *property_page = THUNARX_PROPERTY_PAGE (object);
+
+  switch (prop_id)
+    {
+    case PROP_LABEL:
+      g_value_set_string (value, thunarx_property_page_get_label (property_page));
+      break;
+
+    case PROP_LABEL_WIDGET:
+      g_value_set_object (value, thunarx_property_page_get_label_widget (property_page));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static void
+thunarx_property_page_set_property (GObject      *object,
+                                    guint         prop_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
+{
+  ThunarxPropertyPage *property_page = THUNARX_PROPERTY_PAGE (object);
+
+  switch (prop_id)
+    {
+    case PROP_LABEL:
+      thunarx_property_page_set_label (property_page, g_value_get_string (value));
+      break;
+
+    case PROP_LABEL_WIDGET:
+      thunarx_property_page_set_label_widget (property_page, g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+
+
+static void
+thunarx_property_page_destroy (GtkObject *object)
+{
+  ThunarxPropertyPage *property_page = THUNARX_PROPERTY_PAGE (object);
+
+  /* destroy the label widget (if any) */
+  if (G_LIKELY (property_page->priv->label_widget != NULL))
+    {
+      gtk_object_destroy (GTK_OBJECT (property_page->priv->label_widget));
+      g_object_unref (G_OBJECT (property_page->priv->label_widget));
+      property_page->priv->label_widget = NULL;
+    }
+
+  (*GTK_OBJECT_CLASS (thunarx_property_page_parent_class)->destroy) (object);
+}
+
+
+
+static void
+thunarx_property_page_size_request (GtkWidget      *widget,
+                                    GtkRequisition *requisition)
+{
+  GtkBin *bin = GTK_BIN (widget);
+
+  if (G_LIKELY (bin->child != NULL && GTK_WIDGET_VISIBLE (bin->child)))
+    {
+      gtk_widget_size_request (bin->child, requisition);
+    }
+  else
+    {
+      requisition->width = 0;
+      requisition->height = 0;
+    }
+
+  requisition->width += 2 * (GTK_CONTAINER (bin)->border_width + widget->style->xthickness);
+  requisition->height += 2 * (GTK_CONTAINER (bin)->border_width + widget->style->ythickness);
+}
+
+
+
+static void
+thunarx_property_page_size_allocate (GtkWidget     *widget,
+                                     GtkAllocation *allocation)
+{
+  GtkAllocation child_allocation;
+  GtkBin       *bin = GTK_BIN (widget);
+
+  /* apply the allocation to the property page */
+  widget->allocation = *allocation;
+
+  /* apply the child allocation if we have a child */
+  if (G_LIKELY (bin->child != NULL && GTK_WIDGET_VISIBLE (bin->child)))
+    {
+      /* calculate the allocation for the child widget */
+      child_allocation.x = allocation->x + GTK_CONTAINER (bin)->border_width + widget->style->xthickness;
+      child_allocation.y = allocation->y + GTK_CONTAINER (bin)->border_width + widget->style->ythickness;
+      child_allocation.width = allocation->width - 2 * (GTK_CONTAINER (bin)->border_width + widget->style->xthickness);
+      child_allocation.height = allocation->height - 2 * (GTK_CONTAINER (bin)->border_width + widget->style->ythickness);
+
+      /* apply the child allocation */
+      gtk_widget_size_allocate (bin->child, &child_allocation);
+    }
+}
+
+
+
+/**
+ * thunarx_property_page_new:
+ * @label : the text to use as the label of the page.
+ *
+ * Allocates a new #ThunarxPropertyPage widget and sets its label to the
+ * specified @label. If @label is %NULL, the label is omitted.
+ *
+ * Return value: the newly allocated #ThunarxPropertyPage
+ *               widget.
+ **/
+GtkWidget*
+thunarx_property_page_new (const gchar *label)
+{
+  return g_object_new (THUNARX_TYPE_PROPERTY_PAGE, "label", label, NULL);
+}
+
+
+
+/**
+ * thunarx_property_page_new_with_label_widget:
+ * @label_widget : a #GtkWidget, which should be used as label.
+ *
+ * Allocates a new #ThunarxPropertyPage widget and sets its label to
+ * the specified @label_widget.
+ *
+ * Return value: the newly allocated #ThunarxPropertyPage widget.
+ **/
+GtkWidget*
+thunarx_property_page_new_with_label_widget (GtkWidget *label_widget)
+{
+  return g_object_new (THUNARX_TYPE_PROPERTY_PAGE, "label-widget", label_widget, NULL);
+}
+
+
+
+/**
+ * thunarx_property_page_get_label:
+ * @property_page : a #ThunarxPropertyPage.
+ *
+ * If the @property_page's label widget is a #GtkLabel, returns the text
+ * in the label widget (the @property_page will have a #GtkLabel for the
+ * label widget if a non-%NULL argument was passed to thunarx_property_page_new()).
+ *
+ * Return value: the text in the label or %NULL if there was no label widget or
+ *               the label widget was not a #GtkLabel. The returned string is
+ *               owned by the @property_page and must not be modified or freed.
+ **/
+const gchar*
+thunarx_property_page_get_label (ThunarxPropertyPage *property_page)
+{
+  g_return_val_if_fail (THUNARX_IS_PROPERTY_PAGE (property_page), NULL);
+
+  if (property_page->priv->label_widget != NULL && GTK_IS_LABEL (property_page->priv->label_widget))
+    return gtk_label_get_text (GTK_LABEL (property_page->priv->label_widget));
+  else
+    return NULL;
+}
+
+
+
+/**
+ * thunarx_property_page_set_label:
+ * @property_page : a #ThunarxPropertyPage.
+ * @label         : the text to use as the label of the page.
+ *
+ * Sets the text of the label. If @label is %NULL, the current label is
+ * removed.
+ **/
+void
+thunarx_property_page_set_label (ThunarxPropertyPage *property_page,
+                                 const gchar         *label)
+{
+  GtkWidget *widget;
+
+  g_return_if_fail (THUNARX_IS_PROPERTY_PAGE (property_page));
+
+  if (label == NULL)
+    {
+      thunarx_property_page_set_label_widget (property_page, NULL);
+    }
+  else
+    {
+      widget = gtk_label_new (label);
+      thunarx_property_page_set_label_widget (property_page, widget);
+      gtk_widget_show (widget);
+    }
+}
+
+
+
+/**
+ * thunarx_property_page_get_label_widget:
+ * @property_page : a #ThunarxPropertyPage.
+ *
+ * Returns the label widget for the @property_page. See
+ * thunarx_property_page_set_label_widget().
+ *
+ * return value: the label widget or %NULL if there is none.
+ **/
+GtkWidget*
+thunarx_property_page_get_label_widget (ThunarxPropertyPage *property_page)
+{
+  g_return_val_if_fail (THUNARX_IS_PROPERTY_PAGE (property_page), NULL);
+  return property_page->priv->label_widget;
+}
+
+
+
+/**
+ * thunarx_property_page_set_label_widget:
+ * @property_page : a #ThunarxPropertyPage.
+ * @label_widget  : the new label widget.
+ *
+ * Sets the label widget for the @property_page. This is the widget
+ * that will appear in the notebook header for the @property_page.
+ **/
+void
+thunarx_property_page_set_label_widget (ThunarxPropertyPage *property_page,
+                                        GtkWidget           *label_widget)
+{
+  g_return_if_fail (THUNARX_IS_PROPERTY_PAGE (property_page));
+  g_return_if_fail (label_widget == NULL || (GTK_IS_WIDGET (label_widget) && label_widget->parent == NULL));
+
+  if (G_UNLIKELY (label_widget == property_page->priv->label_widget))
+    return;
+
+  /* disconnect from the previous label widget */
+  if (G_LIKELY (property_page->priv->label_widget != NULL))
+    g_object_unref (G_OBJECT (property_page->priv->label_widget));
+
+  /* activate the new label widget */
+  property_page->priv->label_widget = label_widget;
+
+  /* connect to the new label widget */
+  if (G_LIKELY (label_widget != NULL))
+    {
+      g_object_ref (G_OBJECT (label_widget));
+      gtk_object_sink (GTK_OBJECT (label_widget));
+    }
+
+  /* notify listeners */
+  g_object_freeze_notify (G_OBJECT (property_page));
+  g_object_notify (G_OBJECT (property_page), "label");
+  g_object_notify (G_OBJECT (property_page), "label-widget");
+  g_object_thaw_notify (G_OBJECT (property_page));
+}
+
+
+
+#define __THUNARX_PROPERTY_PAGE_C__
+#include <thunarx/thunarx-aliasdef.c>
diff --git a/thunarx/thunarx-property-page.h b/thunarx/thunarx-property-page.h
new file mode 100644 (file)
index 0000000..7c0a261
--- /dev/null
@@ -0,0 +1,77 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined(THUNARX_INSIDE_THUNARX_H) && !defined(THUNARX_COMPILATION)
+#error "Only <thunarx/thunarx.h> can be included directly, this file may disappear or change contents"
+#endif
+
+#ifndef __THUNARX_PROPERTY_PAGE_H__
+#define __THUNARX_PROPERTY_PAGE_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS;
+
+typedef struct _ThunarxPropertyPagePrivate ThunarxPropertyPagePrivate;
+typedef struct _ThunarxPropertyPageClass   ThunarxPropertyPageClass;
+typedef struct _ThunarxPropertyPage        ThunarxPropertyPage;
+
+#define THUNARX_TYPE_PROPERTY_PAGE            (thunarx_property_page_get_type ())
+#define THUNARX_PROPERTY_PAGE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNARX_TYPE_PROPERTY_PAGE, ThunarxPropertyPage))
+#define THUNARX_PROPERTY_PAGE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), THUNARX_TYPE_PROPERTY_PAGE, ThunarxPropertyPageClass))
+#define THUNARX_IS_PROPERTY_PAGE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNARX_TYPE_PROPERTY_PAGE))
+#define THUNARX_IS_PROPERTY_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNARX_TYPE_PROPERTY_PAGE))
+#define THUNARX_PROPERTY_PAGE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNARX_TYPE_PROPERTY_PAGE))
+
+struct _ThunarxPropertyPageClass
+{
+  GtkBinClass __parent__;
+
+  /*< private >*/
+  void (*reserved1) (void);
+  void (*reserved2) (void);
+  void (*reserved3) (void);
+  void (*reserved4) (void);
+};
+
+struct _ThunarxPropertyPage
+{
+  GtkBin __parent__;
+
+  /*< private >*/
+  ThunarxPropertyPagePrivate *priv;
+};
+
+GType        thunarx_property_page_get_type              (void) G_GNUC_CONST;
+
+GtkWidget   *thunarx_property_page_new                   (const gchar         *label) G_GNUC_MALLOC;
+GtkWidget   *thunarx_property_page_new_with_label_widget (GtkWidget           *label_widget) G_GNUC_MALLOC;
+
+const gchar *thunarx_property_page_get_label             (ThunarxPropertyPage *property_page);
+void         thunarx_property_page_set_label             (ThunarxPropertyPage *property_page,
+                                                          const gchar         *label);
+
+GtkWidget   *thunarx_property_page_get_label_widget      (ThunarxPropertyPage *property_page);
+void         thunarx_property_page_set_label_widget      (ThunarxPropertyPage *property_page,
+                                                          GtkWidget           *label_widget);
+
+G_END_DECLS;
+
+#endif /* !__THUNARX_PROPERTY_PAGE_H__ */
diff --git a/thunarx/thunarx.h b/thunarx/thunarx.h
new file mode 100644 (file)
index 0000000..b773342
--- /dev/null
@@ -0,0 +1,34 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __THUNARX_H__
+#define __THUNARX_H__
+
+#define THUNARX_INSIDE_THUNARX_H
+
+#include <thunarx/thunarx-config.h>
+#include <thunarx/thunarx-file-info.h>
+#include <thunarx/thunarx-menu-provider.h>
+#include <thunarx/thunarx-property-page.h>
+#include <thunarx/thunarx-property-page-provider.h>
+
+#undef THUNARX_INSIDE_THUNARX_H
+
+#endif /* !__THUNARX_H__ */
diff --git a/thunarx/thunarx.symbols b/thunarx/thunarx.symbols
new file mode 100644 (file)
index 0000000..aaa7c58
--- /dev/null
@@ -0,0 +1,92 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org>.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* This file lists all exported symbols. It is used to generate
+ * the thunarx.def file used to control exports on Windows and the
+ * thunarx-alias.h/thunarx-aliasdef.c files used to avoid PLT
+ * entries for * internal uses of exported functions (see
+ * make-thunarx-alias.pl).
+ * 
+ * Every symbol must be included in the right
+ * #ifdef IN_HEADER(sym) #endif and
+ * #ifdef IN_SOURCE(sym) #endif sections. 
+ */
+
+#ifdef ALL_FILES
+#define IN_SOURCE(x) 1
+#define IN_HEADER(x) 1
+#endif
+
+/* thunarx-config symbols */
+#if IN_HEADER(__THUNARX_CONFIG_H__)
+#if IN_SOURCE(__THUNARX_CONFIG_C__)
+thunarx_major_version
+thunarx_minor_version
+thunarx_micro_version
+thunarx_check_version
+#endif
+#endif
+
+/* ThunarxFileInfo methods */
+#if IN_HEADER(__THUNARX_FILE_INFO_H__)
+#if IN_SOURCE(__THUNARX_FILE_INFO_C__)
+thunarx_file_info_get_type G_GNUC_CONST
+thunarx_file_info_get_name
+thunarx_file_info_get_uri
+thunarx_file_info_get_parent_uri
+thunarx_file_info_get_uri_scheme
+thunarx_file_info_get_mime_type
+thunarx_file_info_has_mime_type
+thunarx_file_info_is_directory
+thunarx_file_info_list_copy
+thunarx_file_info_list_free
+#endif
+#endif
+
+/* ThunarxMenuProvider methods */
+#if IN_HEADER(__THUNARX_MENU_PROVIDER_H__)
+#if IN_SOURCE(__THUNARX_MENU_PROVIDER_C__)
+thunarx_menu_provider_get_type G_GNUC_CONST
+thunarx_menu_provider_get_file_actions
+thunarx_menu_provider_get_folder_actions
+#endif
+#endif
+
+/* ThunarxPropertyPage methods */
+#if IN_HEADER(__THUNARX_PROPERTY_PAGE_H__)
+#if IN_SOURCE(__THUNARX_PROPERTY_PAGE_C__)
+thunarx_property_page_get_type G_GNUC_CONST
+thunarx_property_page_new G_GNUC_MALLOC
+thunarx_property_page_new_with_label_widget G_GNUC_MALLOC
+thunarx_property_page_get_label
+thunarx_property_page_set_label
+thunarx_property_page_get_label_widget
+thunarx_property_page_set_label_widget
+#endif
+#endif
+
+/* ThunarxPropertyPageProvider methods */
+#if IN_HEADER(__THUNARX_PROPERTY_PAGE_PROVIDER_H__)
+#if IN_SOURCE(__THUNARX_PROPERTY_PAGE_PROVIDER_C__)
+thunarx_property_page_provider_get_type G_GNUC_CONST
+thunarx_property_page_provider_get_pages
+#endif
+#endif
+