summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am1
-rwxr-xr-xexamples/thunar-file-manager.py58
2 files changed, 59 insertions, 0 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
index abebb194..8ced9db8 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -4,6 +4,7 @@ SUBDIRS = \
tex-open-terminal
EXTRA_DIST = \
+ thunar-file-manager.py \
xfce-file-manager.py
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
diff --git a/examples/thunar-file-manager.py b/examples/thunar-file-manager.py
new file mode 100755
index 00000000..23991c29
--- /dev/null
+++ b/examples/thunar-file-manager.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# $Id$
+#
+# Copyright (c) 2006 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
+#
+
+# ------------------------------------------------------------ #
+# Simple example of how to communicate with Thunar using the #
+# org.xfce.Thunar D-BUS interface. #
+# #
+# Thunar must be compiled with D-BUS support for this to work. #
+# ------------------------------------------------------------ #
+
+import gtk
+import dbus
+import dbus.service
+if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
+ import dbus.glib
+
+# acquire a reference to the Thunar object
+bus = dbus.SessionBus()
+thunar_object = bus.get_object('org.xfce.Thunar', '/org/xfce/FileManager')
+thunar = dbus.Interface(thunar_object, 'org.xfce.Thunar')
+
+# You can now invoke methods on the thunar object, for
+# example, to terminate a running Thunar instance (just
+# like Thunar -q), you can use:
+#
+# thunar.Terminate()
+#
+# or, if you want to open the bulk rename dialog in the
+# standalone version with an empty file list and /tmp
+# as default folder for the "Add Files" dialog, use:
+#
+# thunar.BulkRename('/tmp', [], True, '')
+#
+# See the thunar-dbus-service-infos.xml file for the exact
+# interface definition.
+#
+
+# We just popup the bulk rename dialog to
+# demonstrate that it works. ;-)
+thunar.BulkRename('/tmp', [], True, '')