summaryrefslogtreecommitdiff
path: root/examples/xfce-file-manager.py
blob: 6873d794d41d2c8563aa4908bb0457f51c5fb085 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
#
# 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 (and any other Xfce file   #
# file manager) using the org.xfce.FileManager 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 FileManager object
bus = dbus.SessionBus()
xfce_file_manager_object = bus.get_object('org.xfce.FileManager', '/org/xfce/FileManager')
xfce_file_manager = dbus.Interface(xfce_file_manager_object, 'org.xfce.FileManager')

# You can now invoke methods on the xfce_file_manager object,
# for example, to open a new file manager window for /tmp, you
# would use the following method:
#
# xfce_file_manager.DisplayFolder('/tmp', '', '')
#
# or, if you also want to pre-select a file in the folder, you
# can use:
#
# xfce_file_manager.DisplayFolderAndSelect('/tmp', 'file.txt', '', '')
#
# else if you want to display the file managers preferences
# dialog, you'd use
#
# xfce_file_manager.DisplayPreferencesDialog('', '')
#
# and to open the file properties dialog of a given file, use
#
# xfce_file_manager.DisplayFileProperties('/path/to/file', '', '')
#
# and last but not least, to launch a given file (or open
# a folder), use
#
# xfce_file_manager.Launch('/path/to/file', '', '')
#
# See the thunar-dbus-service-infos.xml file for the exact
# interface definition.
#

# We just popup a new window for the root directory here to
# demonstrate that it works. ;-)
xfce_file_manager.Launch('/', '', '')