thunar 4.20.2 upstream
Tree of tag thunar-4.20.2 (commit 11a519f) from https://gitlab.xfce.org/xfce/thunar. Upstream history is not included here to keep the repository small.
This commit is contained in:
commit
e969f94310
430 changed files with 482388 additions and 0 deletions
9
examples/Makefile.am
Normal file
9
examples/Makefile.am
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
SUBDIRS = \
|
||||
tex-open-terminal
|
||||
|
||||
EXTRA_DIST = \
|
||||
nautilus-bulk-rename.py \
|
||||
thunar-file-manager.py \
|
||||
xfce-file-manager.py
|
||||
|
||||
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
|
||||
65
examples/nautilus-bulk-rename.py
Normal file
65
examples/nautilus-bulk-rename.py
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#!/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
|
||||
#
|
||||
|
||||
# --------------------------------------------------------------- #
|
||||
# This example demonstrates how to integrate Thunar's Bulk Rename #
|
||||
# functionality into Nautilus. You'll need the nautilus-python #
|
||||
# bindings to actually try this example. #
|
||||
# #
|
||||
# Just copy this file to #
|
||||
# #
|
||||
# ~/.nautilus/python-extensions/ #
|
||||
# #
|
||||
# creating the directory if it does not already exist, and re- #
|
||||
# start Nautilus. Afterwards you'll see an action labeled "Bulk #
|
||||
# Rename" in the file context menu, which can be used to rename #
|
||||
# the selected files. #
|
||||
# #
|
||||
# Thunar must be compiled with D-BUS support for this to work. #
|
||||
# --------------------------------------------------------------- #
|
||||
|
||||
|
||||
import gtk
|
||||
import nautilus
|
||||
|
||||
import dbus
|
||||
import dbus.service
|
||||
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
|
||||
import dbus.glib
|
||||
|
||||
class NautilusBulkRename(nautilus.MenuProvider):
|
||||
def __init__(self):
|
||||
bus = dbus.SessionBus()
|
||||
thunar_object = bus.get_object('org.xfce.Thunar', '/org/xfce/FileManager')
|
||||
self.thunar = dbus.Interface(thunar_object, 'org.xfce.Thunar')
|
||||
|
||||
def menu_activate_cb(self, item, files):
|
||||
uris = []
|
||||
for file in files:
|
||||
uris.append(file.get_uri())
|
||||
self.thunar.BulkRename(files[0].get_parent_uri(), uris, False, item.get_data('display'))
|
||||
|
||||
def get_file_items(self, window, files):
|
||||
if len(files) == 0:
|
||||
return
|
||||
|
||||
item = nautilus.MenuItem('NautilusBulkRename::bulk-rename', 'Bulk Rename', 'Rename all selected files at once')
|
||||
item.set_data('display', window.get_screen().make_display_name())
|
||||
item.connect('activate', self.menu_activate_cb, files)
|
||||
return item,
|
||||
44
examples/tex-open-terminal/Makefile.am
Normal file
44
examples/tex-open-terminal/Makefile.am
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
AM_CPPFLAGS = \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/examples \
|
||||
-DG_LOG_DOMAIN=\"TexOpenTerminal\" \
|
||||
$(PLATFORM_CPPFLAGS)
|
||||
|
||||
extensionsdir = $(libdir)/thunarx-$(THUNARX_VERSION_API)
|
||||
extensions_LTLIBRARIES = \
|
||||
tex-open-terminal.la
|
||||
|
||||
tex_open_terminal_la_SOURCES = \
|
||||
tex-open-terminal-plugin.c \
|
||||
tex-open-terminal.c \
|
||||
tex-open-terminal.h
|
||||
|
||||
tex_open_terminal_la_CFLAGS = \
|
||||
$(GTK_CFLAGS) \
|
||||
$(LIBXFCE4UI_CFLAGS) \
|
||||
$(PLATFORM_CFLAGS)
|
||||
|
||||
tex_open_terminal_la_DEPENDENCIES = \
|
||||
$(top_builddir)/thunarx/libthunarx-$(THUNARX_VERSION_API).la
|
||||
|
||||
tex_open_terminal_la_LIBADD = \
|
||||
$(top_builddir)/thunarx/libthunarx-$(THUNARX_VERSION_API).la \
|
||||
$(LIBXFCE4UI_LIBS) \
|
||||
$(GTK_LIBS)
|
||||
|
||||
tex_open_terminal_la_LDFLAGS = \
|
||||
-avoid-version \
|
||||
-export-dynamic \
|
||||
-export-symbols-regex="^thunar_extension_(shutdown|initialize|list_types)" \
|
||||
-module \
|
||||
$(PLATFORM_LDFLAGS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
README.md
|
||||
|
||||
# Don't install/uninstall examples by default
|
||||
install:
|
||||
uninstall:
|
||||
|
||||
# vi:set ts=8 sw=8 noet ai nocindent syntax=automake:
|
||||
9
examples/tex-open-terminal/README.md
Normal file
9
examples/tex-open-terminal/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
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. If you want to uninstall it, you can use the command `make uninstall-extensionsLTLIBRARIES` in this directory.
|
||||
|
||||
Please note that this extension is not meant for daily use, but should just serve as an example of how to write a simple Thunar extension. If you want to be able to open a terminal in a specific folder, you should consider installing the thunar-uca extension (see thunar-uca/README.md) and adding an "Open Terminal Here" action there (there's already such an action available by default).
|
||||
81
examples/tex-open-terminal/tex-open-terminal-plugin.c
Normal file
81
examples/tex-open-terminal/tex-open-terminal-plugin.c
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/* vi:set et ai sw=2 sts=2 ts=2: */
|
||||
/*-
|
||||
* 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 <tex-open-terminal/tex-open-terminal.h>
|
||||
|
||||
|
||||
|
||||
G_MODULE_EXPORT void
|
||||
thunar_extension_initialize (ThunarxProviderPlugin *plugin);
|
||||
G_MODULE_EXPORT void
|
||||
thunar_extension_shutdown (void);
|
||||
G_MODULE_EXPORT void
|
||||
thunar_extension_list_types (const GType **types,
|
||||
gint *n_types);
|
||||
|
||||
|
||||
|
||||
static GType type_list[1];
|
||||
|
||||
|
||||
|
||||
void
|
||||
thunar_extension_initialize (ThunarxProviderPlugin *plugin)
|
||||
{
|
||||
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 TexOpenTerminal extension");
|
||||
|
||||
/* register the types provided by this plugin */
|
||||
tex_open_terminal_register_type (plugin);
|
||||
|
||||
/* setup the plugin type list */
|
||||
type_list[0] = TEX_TYPE_OPEN_TERMINAL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
thunar_extension_shutdown (void)
|
||||
{
|
||||
g_message ("Shutting down TexOpenTerminal extension");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
thunar_extension_list_types (const GType **types,
|
||||
gint *n_types)
|
||||
{
|
||||
*types = type_list;
|
||||
*n_types = G_N_ELEMENTS (type_list);
|
||||
}
|
||||
172
examples/tex-open-terminal/tex-open-terminal.c
Normal file
172
examples/tex-open-terminal/tex-open-terminal.c
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/* vi:set et ai sw=2 sts=2 ts=2: */
|
||||
/*-
|
||||
* 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 <libxfce4ui/libxfce4ui.h>
|
||||
#include <tex-open-terminal/tex-open-terminal.h>
|
||||
|
||||
|
||||
|
||||
static void
|
||||
tex_open_terminal_menu_provider_init (ThunarxMenuProviderIface *iface);
|
||||
static GList *
|
||||
tex_open_terminal_get_file_menu_items (ThunarxMenuProvider *provider,
|
||||
GtkWidget *window,
|
||||
GList *files);
|
||||
static GList *
|
||||
tex_open_terminal_get_folder_menu_items (ThunarxMenuProvider *provider,
|
||||
GtkWidget *window,
|
||||
ThunarxFileInfo *folder);
|
||||
static void
|
||||
tex_open_terminal_activated (ThunarxMenuItem *item,
|
||||
GtkWidget *window);
|
||||
|
||||
|
||||
|
||||
struct _TexOpenTerminalClass
|
||||
{
|
||||
GObjectClass __parent__;
|
||||
};
|
||||
|
||||
struct _TexOpenTerminal
|
||||
{
|
||||
GObject __parent__;
|
||||
};
|
||||
|
||||
|
||||
|
||||
THUNARX_DEFINE_TYPE_WITH_CODE (TexOpenTerminal,
|
||||
tex_open_terminal,
|
||||
G_TYPE_OBJECT,
|
||||
THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_MENU_PROVIDER,
|
||||
tex_open_terminal_menu_provider_init));
|
||||
|
||||
|
||||
|
||||
static void
|
||||
tex_open_terminal_class_init (TexOpenTerminalClass *klass)
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
tex_open_terminal_init (TexOpenTerminal *open_terminal)
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
tex_open_terminal_menu_provider_init (ThunarxMenuProviderIface *iface)
|
||||
{
|
||||
iface->get_file_menu_items = tex_open_terminal_get_file_menu_items;
|
||||
iface->get_folder_menu_items = tex_open_terminal_get_folder_menu_items;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GList *
|
||||
tex_open_terminal_get_file_menu_items (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 tex_open_terminal_get_folder_menu_items (provider, window, files->data);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GList *
|
||||
tex_open_terminal_get_folder_menu_items (ThunarxMenuProvider *provider,
|
||||
GtkWidget *window,
|
||||
ThunarxFileInfo *folder)
|
||||
{
|
||||
ThunarxMenuItem *item = 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))
|
||||
{
|
||||
item = thunarx_menu_item_new ("TexOpenTerminal::open-terminal-here", "Open Terminal Here", "Open Terminal in this folder", "utilities-terminal");
|
||||
g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (tex_open_terminal_activated), window);
|
||||
g_object_set_data_full (G_OBJECT (item), "open-terminal-here-path", path, g_free);
|
||||
}
|
||||
}
|
||||
g_free (scheme);
|
||||
|
||||
return (item != NULL) ? g_list_prepend (NULL, item) : NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
tex_open_terminal_activated (ThunarxMenuItem *item,
|
||||
GtkWidget *window)
|
||||
{
|
||||
const gchar *path;
|
||||
GError *error = NULL;
|
||||
gchar *command;
|
||||
|
||||
/* determine the folder path */
|
||||
path = g_object_get_data (G_OBJECT (item), "open-terminal-here-path");
|
||||
if (G_UNLIKELY (path == NULL))
|
||||
return;
|
||||
|
||||
/* build up the command line for the terminal */
|
||||
command = g_strdup_printf ("exo-open --launch TerminalEmulator --working-directory \"%s\"", path);
|
||||
|
||||
/* try to run the terminal command */
|
||||
if (!xfce_spawn_command_line (NULL, command, FALSE, FALSE, TRUE, &error))
|
||||
{
|
||||
/* display an error dialog */
|
||||
xfce_dialog_show_error (GTK_WINDOW (window), error, "Failed to open terminal in folder %s.", path);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
g_free (command);
|
||||
}
|
||||
45
examples/tex-open-terminal/tex-open-terminal.h
Normal file
45
examples/tex-open-terminal/tex-open-terminal.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* vi:set et ai sw=2 sts=2 ts=2: */
|
||||
/*-
|
||||
* 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 __TEX_OPEN_TERMINAL_H__
|
||||
#define __TEX_OPEN_TERMINAL_H__
|
||||
|
||||
#include <thunarx/thunarx.h>
|
||||
|
||||
G_BEGIN_DECLS;
|
||||
|
||||
typedef struct _TexOpenTerminalClass TexOpenTerminalClass;
|
||||
typedef struct _TexOpenTerminal TexOpenTerminal;
|
||||
|
||||
#define TEX_TYPE_OPEN_TERMINAL (tex_open_terminal_get_type ())
|
||||
#define TEX_OPEN_TERMINAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEX_TYPE_OPEN_TERMINAL, TexOpenTerminal))
|
||||
#define TEX_OPEN_TERMINAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TEX_TYPE_OPEN_TERMINAL, TexOpenTerminalClass))
|
||||
#define TEX_IS_OPEN_TERMINAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEX_TYPE_OPEN_TERMINAL))
|
||||
#define TEX_IS_OPEN_TERMINAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TEX_TYPE_OPEN_TERMINAL))
|
||||
#define TEX_OPEN_TERMINAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEX_TYPE_OPEN_TERMINAL, TexOpenTerminalClass))
|
||||
|
||||
GType
|
||||
tex_open_terminal_get_type (void) G_GNUC_CONST;
|
||||
void
|
||||
tex_open_terminal_register_type (ThunarxProviderPlugin *plugin);
|
||||
|
||||
G_END_DECLS;
|
||||
|
||||
#endif /* !__TEX_OPEN_TERMINAL_H__ */
|
||||
56
examples/thunar-file-manager.py
Executable file
56
examples/thunar-file-manager.py
Executable file
|
|
@ -0,0 +1,56 @@
|
|||
#!/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 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, '', '')
|
||||
69
examples/xfce-file-manager.py
Executable file
69
examples/xfce-file-manager.py
Executable file
|
|
@ -0,0 +1,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('/', '', '')
|
||||
Loading…
Add table
Add a link
Reference in a new issue