diff --git a/acinclude.m4 b/acinclude.m4 index caa0a415c9b4a7ff3d36e877986ed7409acf6d9a..2649a6cefa1a64c6249e8adc46dc5b6e8a0a0935 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -57,7 +57,7 @@ AC_DEFUN([BM_THUNAR_PLUGIN_TPA], AC_ARG_ENABLE([tpa-plugin], AC_HELP_STRING([--disable-tpa-plugin], [Don't build the thunar-tpa plugin, see plugins/thunar-tpa/README]), [ac_bm_thunar_plugin_tpa=$enableval], [ac_bm_thunar_plugin_tpa=yes]) if test x"$ac_bm_thunar_plugin_tpa" = x"yes"; then - XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.3.90], + XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [4.7.0], [ dnl # Can only build thunar-tpa if D-BUS was found previously ac_bm_thunar_plugin_tpa=$DBUS_FOUND diff --git a/plugins/thunar-tpa/Makefile.am b/plugins/thunar-tpa/Makefile.am index 26eecd1aced213cef6e61d1365352aa6969534ae..b214355ec76193aae0d0ad18e39356c3d6759822 100644 --- a/plugins/thunar-tpa/Makefile.am +++ b/plugins/thunar-tpa/Makefile.am @@ -1,36 +1,45 @@ -# $Id$ INCLUDES = \ -I$(top_builddir) \ -I$(top_builddir)/plugins \ -I$(top_srcdir) \ -I$(top_srcdir)/plugins \ - -DG_LOG_DOMAIN=\"thunar-tpa\" \ - -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \ + -DG_LOG_DOMAIN=\"libthunar-tpa\" \ $(PLATFORM_CPPFLAGS) -pluginsdir = $(libexecdir)/xfce4/panel-plugins -plugins_PROGRAMS = \ - thunar-tpa +plugindir = $(libdir)/xfce4/panel-plugins +plugin_LTLIBRARIES = \ + libthunar-tpa.la -thunar_tpa_SOURCES = \ - main.c \ - thunar-tpa-bindings.h \ - thunar-tpa-icon.c \ - thunar-tpa-icon.h +libthunar_tpa_la_SOURCES = \ + thunar-tpa.c \ + thunar-tpa-bindings.h -thunar_tpa_CFLAGS = \ +libthunar_tpa_la_CFLAGS = \ $(DBUS_CFLAGS) \ - $(EXO_CFLAGS) \ + $(LIBXFCE4UI_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ $(LIBXFCE4PANEL_CFLAGS) \ $(PLATFORM_CFLAGS) -thunar_tpa_LDADD = \ +libthunar_tpa_la_LIBADD = \ $(DBUS_LIBS) \ - $(EXO_LIBS) \ - $(LIBXFCE4PANEL_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ + $(LIBXFCE4UI_LIBS) \ + $(LIBXFCE4PANEL_LIBS) + +libthunar_tpa_la_LDFLAGS = \ + -avoid-version \ + -module \ + -no-undefined \ + -export-symbols-regex '^xfce_panel_module_(preinit|init|construct)' \ $(PLATFORM_LDFLAGS) +desktopdir = $(datadir)/xfce4/panel-plugins +desktop_in_files = thunar-tpa.desktop.in +desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) +@INTLTOOL_DESKTOP_RULE@ + if MAINTAINER_MODE BUILT_SOURCES = \ thunar-tpa-bindings.h @@ -42,21 +51,12 @@ thunar-tpa-bindings.h: $(srcdir)/thunar-tpa-bindings.xml Makefile $(AM_V_GEN) dbus-binding-tool --prefix=thunar_tpa_dbus --mode=glib-client $(srcdir)/thunar-tpa-bindings.xml > thunar-tpa-bindings.h endif -desktopdir = $(datadir)/xfce4/panel-plugins -desktop_in_in_files = thunar-tpa.desktop.in.in -desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in) -%.desktop.in: %.desktop.in.in - $(AM_V_GEN) sed -e "s,\@libexecdir\@,$(libexecdir),g" < $< > $@ -desktop_DATA = $(desktop_in_files:.desktop.in=.desktop) -@INTLTOOL_DESKTOP_RULE@ - EXTRA_DIST = \ - $(desktop_in_in_files) \ + $(desktop_in_files) \ thunar-tpa-bindings.xml \ README CLEANFILES = \ - $(desktop_in_files) \ $(desktop_DATA) # vi:set ts=8 sw=8 noet ai nocindent syntax=automake: diff --git a/plugins/thunar-tpa/main.c b/plugins/thunar-tpa/main.c deleted file mode 100644 index d7a5adf7174b22f06f259be120c8130c50a82d1e..0000000000000000000000000000000000000000 --- a/plugins/thunar-tpa/main.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $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 - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <thunar-tpa/thunar-tpa-icon.h> - -#include <libxfce4panel/xfce-panel-plugin.h> - - - -static void thunar_tpa_construct (XfcePanelPlugin *panel_plugin); - - - -static void -thunar_tpa_construct (XfcePanelPlugin *panel_plugin) -{ - GtkWidget *icon; - GtkWidget *item; - - xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8"); - - /* setup the trash icon */ - icon = thunar_tpa_icon_new (); - gtk_container_add (GTK_CONTAINER (panel_plugin), icon); - xfce_panel_plugin_add_action_widget (panel_plugin, gtk_bin_get_child (GTK_BIN (icon))); - gtk_widget_show (icon); - - /* add the "Empty Trash" menu item */ - item = gtk_menu_item_new_with_mnemonic (_("_Empty Trash")); - exo_binding_new (G_OBJECT (icon), "full", G_OBJECT (item), "sensitive"); - g_signal_connect_swapped (G_OBJECT (item), "activate", G_CALLBACK (thunar_tpa_icon_empty_trash), icon); - xfce_panel_plugin_menu_insert_item (panel_plugin, GTK_MENU_ITEM (item)); - gtk_widget_show (item); - - /* configure the plugin */ - g_signal_connect_swapped (G_OBJECT (panel_plugin), "size-changed", G_CALLBACK (thunar_tpa_icon_set_size), icon); -} - - - -XFCE_PANEL_PLUGIN_REGISTER_EXTERNAL (thunar_tpa_construct); diff --git a/plugins/thunar-tpa/thunar-tpa-icon.c b/plugins/thunar-tpa/thunar-tpa-icon.c deleted file mode 100644 index c2268c4986e1fb4605e8f47e2797df60b65aedc9..0000000000000000000000000000000000000000 --- a/plugins/thunar-tpa/thunar-tpa-icon.c +++ /dev/null @@ -1,675 +0,0 @@ -/* $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 - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <thunar-tpa/thunar-tpa-bindings.h> -#include <thunar-tpa/thunar-tpa-icon.h> - -#include <libxfce4panel/xfce-panel-convenience.h> - - - -/* Property identifiers */ -enum -{ - PROP_0, - PROP_FULL, -}; - -/* Identifiers for DnD target ypes */ -enum -{ - TARGET_TEXT_URI_LIST, -}; - - - -static void thunar_tpa_icon_finalize (GObject *object); -static void thunar_tpa_icon_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void thunar_tpa_icon_error (ThunarTpaIcon *icon, - GError *error); -static void thunar_tpa_icon_state (ThunarTpaIcon *icon, - gboolean full); -static void thunar_tpa_icon_display_trash_reply (DBusGProxy *proxy, - GError *error, - gpointer user_data); -static void thunar_tpa_icon_empty_trash_reply (DBusGProxy *proxy, - GError *error, - gpointer user_data); -static void thunar_tpa_icon_move_to_trash_reply (DBusGProxy *proxy, - GError *error, - gpointer user_data); -static void thunar_tpa_icon_query_trash_reply (DBusGProxy *proxy, - gboolean full, - GError *error, - gpointer user_data); -static void thunar_tpa_icon_clicked (GtkWidget *button, - ThunarTpaIcon *icon); -static void thunar_tpa_icon_drag_data_received (GtkWidget *button, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection_data, - guint info, - guint time, - ThunarTpaIcon *icon); -static gboolean thunar_tpa_icon_enter_notify_event (GtkWidget *button, - GdkEventCrossing *event, - ThunarTpaIcon *icon); -static gboolean thunar_tpa_icon_leave_notify_event (GtkWidget *button, - GdkEventCrossing *event, - ThunarTpaIcon *icon); -static void thunar_tpa_icon_trash_changed (DBusGProxy *proxy, - gboolean full, - ThunarTpaIcon *icon); - - - -struct _ThunarTpaIconClass -{ - GtkAlignmentClass __parent__; -}; - -struct _ThunarTpaIcon -{ - GtkAlignment __parent__; - - gboolean full; - - GtkWidget *button; - GtkWidget *image; - - DBusGProxy *proxy; - DBusGProxyCall *display_trash_call; - DBusGProxyCall *empty_trash_call; - DBusGProxyCall *move_to_trash_call; - DBusGProxyCall *query_trash_call; -}; - - - -/* Target types for dropping to the trash can */ -static const GtkTargetEntry drop_targets[] = -{ - { "text/uri-list", 0, TARGET_TEXT_URI_LIST, }, -}; - - - -G_DEFINE_TYPE (ThunarTpaIcon, thunar_tpa_icon, GTK_TYPE_ALIGNMENT); - - - -static void -thunar_tpa_icon_class_init (ThunarTpaIconClass *klass) -{ - GObjectClass *gobject_class; - - gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = thunar_tpa_icon_finalize; - gobject_class->get_property = thunar_tpa_icon_get_property; - - /** - * ThunarTpaIcon:full: - * - * The current state of the trash can. - **/ - g_object_class_install_property (gobject_class, - PROP_FULL, - g_param_spec_boolean ("full", - "full", - "full", - FALSE, - EXO_PARAM_READABLE)); -} - - - -static void -thunar_tpa_icon_init (ThunarTpaIcon *icon) -{ - DBusGConnection *connection; - GError *err = NULL; - - gtk_alignment_set (GTK_ALIGNMENT (icon), 0.5f, 0.5f, 1.0f, 1.0f); - - /* setup the button for the trash icon */ - icon->button = xfce_create_panel_button (); - GTK_WIDGET_UNSET_FLAGS (icon->button, GTK_CAN_DEFAULT); - gtk_drag_dest_set (icon->button, GTK_DEST_DEFAULT_ALL, drop_targets, G_N_ELEMENTS (drop_targets), GDK_ACTION_MOVE); - g_signal_connect (G_OBJECT (icon->button), "clicked", G_CALLBACK (thunar_tpa_icon_clicked), icon); - g_signal_connect (G_OBJECT (icon->button), "drag-data-received", G_CALLBACK (thunar_tpa_icon_drag_data_received), icon); - g_signal_connect (G_OBJECT (icon->button), "enter-notify-event", G_CALLBACK (thunar_tpa_icon_enter_notify_event), icon); - g_signal_connect (G_OBJECT (icon->button), "leave-notify-event", G_CALLBACK (thunar_tpa_icon_leave_notify_event), icon); - gtk_container_add (GTK_CONTAINER (icon), icon->button); - gtk_widget_show (icon->button); - - /* setup the image for the trash icon */ - icon->image = gtk_image_new_from_icon_name ("user-trash", GTK_ICON_SIZE_BUTTON); - gtk_container_add (GTK_CONTAINER (icon->button), icon->image); - gtk_widget_show (icon->image); - - /* try to connect to the D-BUS session daemon */ - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &err); - if (G_UNLIKELY (connection == NULL)) - { - /* we failed to connect, display an error icon/tooltip */ - thunar_tpa_icon_error (icon, err); - g_error_free (err); - } - else - { - /* grab a proxy for the /org/xfce/FileManager object on org.xfce.FileManager */ - icon->proxy = dbus_g_proxy_new_for_name (connection, "org.xfce.FileManager", "/org/xfce/FileManager", "org.xfce.Trash"); - - /* connect to the "TrashChanged" signal */ - dbus_g_proxy_add_signal (icon->proxy, "TrashChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID); - dbus_g_proxy_connect_signal (icon->proxy, "TrashChanged", G_CALLBACK (thunar_tpa_icon_trash_changed), icon, NULL); - - /* update the state of the trash icon */ - thunar_tpa_icon_query_trash (icon); - } -} - - - -static void -thunar_tpa_icon_finalize (GObject *object) -{ - ThunarTpaIcon *icon = THUNAR_TPA_ICON (object); - - /* release the proxy object */ - if (G_LIKELY (icon->proxy != NULL)) - { - /* cancel any pending calls */ - if (G_UNLIKELY (icon->display_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->display_trash_call); - if (G_UNLIKELY (icon->empty_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->empty_trash_call); - if (G_UNLIKELY (icon->move_to_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->move_to_trash_call); - if (G_UNLIKELY (icon->query_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->query_trash_call); - - /* disconnect the signal and release the proxy */ - dbus_g_proxy_disconnect_signal (icon->proxy, "TrashChanged", G_CALLBACK (thunar_tpa_icon_trash_changed), icon); - g_object_unref (G_OBJECT (icon->proxy)); - } - - (*G_OBJECT_CLASS (thunar_tpa_icon_parent_class)->finalize) (object); -} - - - -static void -thunar_tpa_icon_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ThunarTpaIcon *icon = THUNAR_TPA_ICON (object); - - switch (prop_id) - { - case PROP_FULL: - g_value_set_boolean (value, icon->full); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - - -static void -thunar_tpa_icon_error (ThunarTpaIcon *icon, - GError *error) -{ - gchar *tooltip; - - /* reset to empty first */ - thunar_tpa_icon_state (icon, FALSE); - - /* strip off additional whitespace */ - g_strstrip (error->message); - - /* tell the user that we failed to connect to the trash */ - tooltip = g_strdup_printf ("%s: %s.", _("Failed to connect to the Trash"), error->message); - gtk_widget_set_tooltip_text (icon->button, tooltip); - g_free (tooltip); - - /* setup an error icon */ - gtk_image_set_from_icon_name (GTK_IMAGE (icon->image), "stock_dialog-error", GTK_ICON_SIZE_BUTTON); -} - - - -static void -thunar_tpa_icon_state (ThunarTpaIcon *icon, - gboolean full) -{ - /* tell the user whether the trash is full or empty */ - gtk_widget_set_tooltip_text (icon->button, full ? _("Trash contains files") : _("Trash is empty")); - - /* setup the appropriate icon */ - gtk_image_set_from_icon_name (GTK_IMAGE (icon->image), full ? "user-trash-full" : "user-trash", GTK_ICON_SIZE_BUTTON); - - /* apply the new state */ - icon->full = full; - g_object_notify (G_OBJECT (icon), "full"); -} - - - -static void -thunar_tpa_icon_display_trash_reply (DBusGProxy *proxy, - GError *error, - gpointer user_data) -{ - ThunarTpaIcon *icon = THUNAR_TPA_ICON (user_data); - GtkWidget *message; - - /* reset the call */ - icon->display_trash_call = NULL; - - /* check if we failed */ - if (G_UNLIKELY (error != NULL)) - { - /* strip off additional whitespace */ - g_strstrip (error->message); - - /* display an error message to the user */ - message = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s.", _("Failed to connect to the Trash")); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", error->message); - gtk_window_set_screen (GTK_WINDOW (message), gtk_widget_get_screen (GTK_WIDGET (icon))); - gtk_dialog_run (GTK_DIALOG (message)); - gtk_widget_destroy (message); - g_error_free (error); - } -} - - - -static void -thunar_tpa_icon_empty_trash_reply (DBusGProxy *proxy, - GError *error, - gpointer user_data) -{ - ThunarTpaIcon *icon = THUNAR_TPA_ICON (user_data); - GtkWidget *message; - - /* reset the call */ - icon->empty_trash_call = NULL; - - /* check if we failed */ - if (G_UNLIKELY (error != NULL)) - { - /* strip off additional whitespace */ - g_strstrip (error->message); - - /* display an error message to the user */ - message = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s.", _("Failed to connect to the Trash")); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", error->message); - gtk_window_set_screen (GTK_WINDOW (message), gtk_widget_get_screen (GTK_WIDGET (icon))); - gtk_dialog_run (GTK_DIALOG (message)); - gtk_widget_destroy (message); - g_error_free (error); - } - else - { - /* query the new state of the trash */ - thunar_tpa_icon_query_trash (icon); - } -} - - - -static void -thunar_tpa_icon_move_to_trash_reply (DBusGProxy *proxy, - GError *error, - gpointer user_data) -{ - ThunarTpaIcon *icon = THUNAR_TPA_ICON (user_data); - GtkWidget *message; - - /* reset the call */ - icon->move_to_trash_call = NULL; - - /* check if we failed */ - if (G_UNLIKELY (error != NULL)) - { - /* strip off additional whitespace */ - g_strstrip (error->message); - - /* display an error message to the user */ - message = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s.", _("Failed to connect to the Trash")); - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message), "%s.", error->message); - gtk_window_set_screen (GTK_WINDOW (message), gtk_widget_get_screen (GTK_WIDGET (icon))); - gtk_dialog_run (GTK_DIALOG (message)); - gtk_widget_destroy (message); - g_error_free (error); - } - else - { - /* query the new state of the trash */ - thunar_tpa_icon_query_trash (icon); - } -} - - - -static void -thunar_tpa_icon_query_trash_reply (DBusGProxy *proxy, - gboolean full, - GError *error, - gpointer user_data) -{ - ThunarTpaIcon *icon = THUNAR_TPA_ICON (user_data); - - /* reset the call */ - icon->query_trash_call = NULL; - - /* check if we failed */ - if (G_UNLIKELY (error != NULL)) - { - /* setup an error tooltip/icon */ - thunar_tpa_icon_error (icon, error); - g_error_free (error); - } - else - { - /* update the tooltip/icon accordingly */ - thunar_tpa_icon_state (icon, full); - } -} - - - -static void -thunar_tpa_icon_clicked (GtkWidget *button, - ThunarTpaIcon *icon) -{ - g_return_if_fail (THUNAR_TPA_IS_ICON (icon)); - g_return_if_fail (icon->button == button); - - /* display the trash folder */ - thunar_tpa_icon_display_trash (icon); -} - - - -static void -thunar_tpa_icon_drag_data_received (GtkWidget *button, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *selection_data, - guint info, - guint timestamp, - ThunarTpaIcon *icon) -{ - gboolean succeed = FALSE; - gchar **uri_list; - - g_return_if_fail (THUNAR_TPA_IS_ICON (icon)); - g_return_if_fail (icon->button == button); - - /* determine the type of drop we received */ - if (G_LIKELY (info == TARGET_TEXT_URI_LIST)) - { - /* check if the data is valid for text/uri-list */ - if (G_LIKELY (selection_data->length >= 0 && selection_data->format == 8)) - { - /* parse the URI list according to RFC 2483 */ - uri_list = g_uri_list_extract_uris ((const gchar *) selection_data->data); - succeed = thunar_tpa_icon_move_to_trash (icon, (const gchar **) uri_list); - g_strfreev (uri_list); - } - } - - /* finish the drag */ - gtk_drag_finish (context, succeed, TRUE, timestamp); -} - - - -static gboolean -thunar_tpa_icon_enter_notify_event (GtkWidget *button, - GdkEventCrossing *event, - ThunarTpaIcon *icon) -{ - g_return_val_if_fail (THUNAR_TPA_IS_ICON (icon), FALSE); - g_return_val_if_fail (icon->button == button, FALSE); - - /* query the new state of the trash */ - thunar_tpa_icon_query_trash (icon); - - return FALSE; -} - - - -static gboolean -thunar_tpa_icon_leave_notify_event (GtkWidget *button, - GdkEventCrossing *event, - ThunarTpaIcon *icon) -{ - g_return_val_if_fail (THUNAR_TPA_IS_ICON (icon), FALSE); - g_return_val_if_fail (icon->button == button, FALSE); - - /* query the new state of the trash */ - thunar_tpa_icon_query_trash (icon); - - return FALSE; -} - - - -static void -thunar_tpa_icon_trash_changed (DBusGProxy *proxy, - gboolean full, - ThunarTpaIcon *icon) -{ - g_return_if_fail (THUNAR_TPA_IS_ICON (icon)); - g_return_if_fail (icon->proxy == proxy); - - /* change the status icon/tooltip appropriately */ - thunar_tpa_icon_state (icon, full); -} - - - -/** - * thunar_tpa_icon_new: - * - * Allocates a new #ThunarTpaIcon instance. - * - * Return value: the newly allocated #ThunarTpaIcon. - **/ -GtkWidget* -thunar_tpa_icon_new (void) -{ - return g_object_new (THUNAR_TPA_TYPE_ICON, NULL); -} - - - -/** - * thunar_tpa_icon_set_size: - * @icon : a #ThunarTpaIcon. - * @size : the new width and height for the @icon. - * - * Sets the width and height for the @icon to the specified - * @size. - **/ -void -thunar_tpa_icon_set_size (ThunarTpaIcon *icon, - gint size) -{ - gint focus_line_width; - gint focus_padding; - gint pixel_size = size; - - g_return_if_fail (THUNAR_TPA_IS_ICON (icon)); - g_return_if_fail (size > 0); - - /* determine the style properties affecting the button size */ - gtk_widget_style_get (GTK_WIDGET (icon->button), - "focus-line-width", &focus_line_width, - "focus-padding", &focus_padding, - NULL); - - /* determine the pixel size for the image */ - pixel_size -= 2 + 2 * (focus_line_width + focus_padding); - pixel_size -= GTK_CONTAINER (icon->button)->border_width * 2; - pixel_size -= MAX (icon->button->style->xthickness, icon->button->style->ythickness) * 2; - - /* setup the pixel size for the image */ - gtk_image_set_pixel_size (GTK_IMAGE (icon->image), pixel_size); -} - - - -/** - * thunar_tpa_icon_display_trash: - * @icon : a #ThunarTpaIcon. - * - * Displays the trash folder. - **/ -void -thunar_tpa_icon_display_trash (ThunarTpaIcon *icon) -{ - gchar *display_name; - - g_return_if_fail (THUNAR_TPA_IS_ICON (icon)); - - /* check if we are connected to the bus */ - if (G_LIKELY (icon->proxy != NULL)) - { - /* cancel any pending call */ - if (G_UNLIKELY (icon->display_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->display_trash_call); - - /* schedule a new call */ - display_name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (icon))); - icon->display_trash_call = org_xfce_Trash_display_trash_async (icon->proxy, display_name, thunar_tpa_icon_display_trash_reply, icon); - g_free (display_name); - } -} - - - -/** - * thunar_tpa_icon_empty_trash: - * @icon : a #ThunarTpaIcon. - * - * Empties the trash can. - **/ -void -thunar_tpa_icon_empty_trash (ThunarTpaIcon *icon) -{ - gchar *display_name; - - g_return_if_fail (THUNAR_TPA_IS_ICON (icon)); - - /* check if we are connected to the bus */ - if (G_LIKELY (icon->proxy != NULL)) - { - /* cancel any pending call */ - if (G_UNLIKELY (icon->empty_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->empty_trash_call); - - /* schedule a new call */ - display_name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (icon))); - icon->empty_trash_call = org_xfce_Trash_empty_trash_async (icon->proxy, display_name, thunar_tpa_icon_empty_trash_reply, icon); - g_free (display_name); - } -} - - - -/** - * thunar_tpa_icon_move_to_trash: - * @icon : a #ThunarTpaIcon. - * @uri_list : the URIs of the files to move to the trash. - * - * Tells the trash to move the files in the @uri_list to the - * trash. - * - * Return value: %TRUE if the command was send successfully, - * %FALSE otherwise. - **/ -gboolean -thunar_tpa_icon_move_to_trash (ThunarTpaIcon *icon, - const gchar **uri_list) -{ - gchar *display_name; - - g_return_val_if_fail (THUNAR_TPA_IS_ICON (icon), FALSE); - g_return_val_if_fail (uri_list != NULL, FALSE); - - /* check if we are connected to the bus */ - if (G_UNLIKELY (icon->proxy == NULL)) - return FALSE; - - /* cancel any pending call */ - if (G_UNLIKELY (icon->move_to_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->move_to_trash_call); - - /* schedule a new call */ - display_name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (icon))); - icon->move_to_trash_call = org_xfce_Trash_move_to_trash_async (icon->proxy, uri_list, display_name, thunar_tpa_icon_move_to_trash_reply, icon); - g_free (display_name); - - return TRUE; -} - - - -/** - * thunar_tpa_icon_query_trash: - * @icon : a #ThunarTpaIcon. - * - * Queries the state of the trash can. - **/ -void -thunar_tpa_icon_query_trash (ThunarTpaIcon *icon) -{ - g_return_if_fail (THUNAR_TPA_IS_ICON (icon)); - - /* check if we are connected to the bus */ - if (G_LIKELY (icon->proxy != NULL)) - { - /* cancel any pending call */ - if (G_UNLIKELY (icon->query_trash_call != NULL)) - dbus_g_proxy_cancel_call (icon->proxy, icon->query_trash_call); - - /* schedule a new call */ - icon->query_trash_call = org_xfce_Trash_query_trash_async (icon->proxy, thunar_tpa_icon_query_trash_reply, icon); - } -} - diff --git a/plugins/thunar-tpa/thunar-tpa-icon.h b/plugins/thunar-tpa/thunar-tpa-icon.h deleted file mode 100644 index 12e2a4a893fd168d4aed2a494afdf0b6621d9af7..0000000000000000000000000000000000000000 --- a/plugins/thunar-tpa/thunar-tpa-icon.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $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 - */ - -#ifndef __THUNAR_TPA_ICON_H__ -#define __THUNAR_TPA_ICON_H__ - -#include <exo/exo.h> - -G_BEGIN_DECLS; - -typedef struct _ThunarTpaIconClass ThunarTpaIconClass; -typedef struct _ThunarTpaIcon ThunarTpaIcon; - -#define THUNAR_TPA_TYPE_ICON (thunar_tpa_icon_get_type ()) -#define THUNAR_TPA_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TPA_TYPE_ICON, ThunarTpaIcon)) -#define THUNAR_TPA_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_TPA_TYPE_ICON, ThunarTpaIconClass)) -#define THUNAR_TPA_IS_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNAR_TPA_TYPE_ICON)) -#define THUNAR_TPA_IS_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TPA_TYPE_ICON)) -#define THUNAR_TPA_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TPA_TYPE_ICON, ThunarTpaIconClass)) - -GType thunar_tpa_icon_get_type (void) G_GNUC_CONST; - -GtkWidget *thunar_tpa_icon_new (void) G_GNUC_MALLOC; - -void thunar_tpa_icon_set_size (ThunarTpaIcon *icon, - gint size); - -void thunar_tpa_icon_display_trash (ThunarTpaIcon *icon); -void thunar_tpa_icon_empty_trash (ThunarTpaIcon *icon); -gboolean thunar_tpa_icon_move_to_trash (ThunarTpaIcon *icon, - const gchar **uri_list); -void thunar_tpa_icon_query_trash (ThunarTpaIcon *icon); - -G_END_DECLS; - -#endif /* !__THUNAR_TPA_ICON_H__ */ diff --git a/plugins/thunar-tpa/thunar-tpa.c b/plugins/thunar-tpa/thunar-tpa.c new file mode 100644 index 0000000000000000000000000000000000000000..c4f334a177211cd1d2c0ac223cf3cb4c039ddd2d --- /dev/null +++ b/plugins/thunar-tpa/thunar-tpa.c @@ -0,0 +1,547 @@ +/*- + * Copyright (c) 2006 Benedikt Meurer <benny@xfce.org> + * Copyright (c) 2010 Nick Schermer <nick@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 <gtk/gtk.h> +#include <libxfce4util/libxfce4util.h> +#include <libxfce4ui/libxfce4ui.h> +#include <libxfce4panel/libxfce4panel.h> +#include <thunar-tpa/thunar-tpa-bindings.h> + + + +typedef struct _ThunarTpaClass ThunarTpaClass; +typedef struct _ThunarTpa ThunarTpa; + + + +#define THUNAR_TYPE_TPA (thunar_tpa_get_type ()) +#define THUNAR_TPA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TYPE_TPA, ThunarTpa)) +#define THUNAR_TPA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_TYPE_TPA, ThunarTpaClass)) +#define THUNAR_IS_TPA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNAR_TYPE_TPA)) +#define THUNAR_IS_TPA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_TPA)) +#define THUNAR_TPA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_TPA, ThunarTpaClass)) + + + +GType thunar_tpa_get_type (void); +void thunar_tpa_register_type (XfcePanelTypeModule *type_module); +static void thunar_tpa_finalize (GObject *object); +static void thunar_tpa_construct (XfcePanelPlugin *panel_plugin); +static void thunar_tpa_error (ThunarTpa *plugin, + GError *error); +static void thunar_tpa_state (ThunarTpa *plugin, + gboolean full); +static void thunar_tpa_display_trash_reply (DBusGProxy *proxy, + GError *error, + gpointer user_data); +static void thunar_tpa_empty_trash_reply (DBusGProxy *proxy, + GError *error, + gpointer user_data); +static void thunar_tpa_move_to_trash_reply (DBusGProxy *proxy, + GError *error, + gpointer user_data); +static void thunar_tpa_query_trash_reply (DBusGProxy *proxy, + gboolean full, + GError *error, + gpointer user_data); +static void thunar_tpa_drag_data_received (GtkWidget *button, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + ThunarTpa *plugin); +static gboolean thunar_tpa_enter_notify_event (GtkWidget *button, + GdkEventCrossing *event, + ThunarTpa *plugin); +static gboolean thunar_tpa_leave_notify_event (GtkWidget *button, + GdkEventCrossing *event, + ThunarTpa *plugin); +static void thunar_tpa_trash_changed (DBusGProxy *proxy, + gboolean full, + ThunarTpa *plugin); +static void thunar_tpa_display_trash (ThunarTpa *plugin); +static void thunar_tpa_empty_trash (ThunarTpa *plugin); +static gboolean thunar_tpa_move_to_trash (ThunarTpa *plugin, + const gchar **uri_list); +static void thunar_tpa_query_trash (ThunarTpa *plugin); + + + +struct _ThunarTpaClass +{ + XfcePanelPluginClass __parent__; +}; + +struct _ThunarTpa +{ + XfcePanelPlugin __parent__; + + /* widgets */ + GtkWidget *button; + GtkWidget *image; + GtkWidget *mi; + + DBusGProxy *proxy; + DBusGProxyCall *display_trash_call; + DBusGProxyCall *empty_trash_call; + DBusGProxyCall *move_to_trash_call; + DBusGProxyCall *query_trash_call; +}; + +/* Target types for dropping to the trash can */ +enum +{ + TARGET_TEXT_URI_LIST, +}; + +static const GtkTargetEntry drop_targets[] = +{ + { "text/uri-list", 0, TARGET_TEXT_URI_LIST, }, +}; + + + +/* define the plugin */ +XFCE_PANEL_DEFINE_PLUGIN (ThunarTpa, thunar_tpa) + + + +static void +thunar_tpa_class_init (ThunarTpaClass *klass) +{ + XfcePanelPluginClass *plugin_class; + GObjectClass *gobject_class; + + gobject_class = G_OBJECT_CLASS (klass); + gobject_class->finalize = thunar_tpa_finalize; + + plugin_class = XFCE_PANEL_PLUGIN_CLASS (klass); + plugin_class->construct = thunar_tpa_construct; +} + + + +static void +thunar_tpa_init (ThunarTpa *plugin) +{ + DBusGConnection *connection; + GError *err = NULL; + + /* setup the button for the trash plugin */ + plugin->button = xfce_create_panel_button (); + xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (plugin), plugin->button); + gtk_drag_dest_set (plugin->button, GTK_DEST_DEFAULT_ALL, drop_targets, G_N_ELEMENTS (drop_targets), GDK_ACTION_MOVE); + g_signal_connect_swapped (G_OBJECT (plugin->button), "clicked", G_CALLBACK (thunar_tpa_display_trash), plugin); + g_signal_connect (G_OBJECT (plugin->button), "drag-data-received", G_CALLBACK (thunar_tpa_drag_data_received), plugin); + g_signal_connect (G_OBJECT (plugin->button), "enter-notify-event", G_CALLBACK (thunar_tpa_enter_notify_event), plugin); + g_signal_connect (G_OBJECT (plugin->button), "leave-notify-event", G_CALLBACK (thunar_tpa_leave_notify_event), plugin); + gtk_container_add (GTK_CONTAINER (plugin), plugin->button); + gtk_widget_show (plugin->button); + + /* setup the image for the trash plugin */ + plugin->image = xfce_panel_image_new_from_source ("user-trash"); + gtk_container_add (GTK_CONTAINER (plugin->button), plugin->image); + gtk_widget_show (plugin->image); + + /* prepare the menu item */ + plugin->mi = gtk_menu_item_new_with_mnemonic (_("_Empty Trash")); + g_signal_connect_swapped (G_OBJECT (plugin->mi), "activate", G_CALLBACK (thunar_tpa_empty_trash), plugin); + gtk_widget_show (plugin->mi); + + /* try to connect to the D-BUS session daemon */ + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &err); + if (G_UNLIKELY (connection == NULL)) + { + /* we failed to connect, display an error plugin/tooltip */ + thunar_tpa_error (plugin, err); + g_error_free (err); + } + else + { + /* grab a proxy for the /org/xfce/FileManager object on org.xfce.FileManager */ + plugin->proxy = dbus_g_proxy_new_for_name (connection, "org.xfce.FileManager", "/org/xfce/FileManager", "org.xfce.Trash"); + + /* connect to the "TrashChanged" signal */ + dbus_g_proxy_add_signal (plugin->proxy, "TrashChanged", G_TYPE_BOOLEAN, G_TYPE_INVALID); + dbus_g_proxy_connect_signal (plugin->proxy, "TrashChanged", G_CALLBACK (thunar_tpa_trash_changed), plugin, NULL); + } +} + + + +static void +thunar_tpa_finalize (GObject *object) +{ + ThunarTpa *plugin = THUNAR_TPA (object); + + /* release the proxy object */ + if (G_LIKELY (plugin->proxy != NULL)) + { + /* cancel any pending calls */ + if (G_UNLIKELY (plugin->display_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->display_trash_call); + if (G_UNLIKELY (plugin->empty_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->empty_trash_call); + if (G_UNLIKELY (plugin->move_to_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->move_to_trash_call); + if (G_UNLIKELY (plugin->query_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->query_trash_call); + + /* disconnect the signal and release the proxy */ + dbus_g_proxy_disconnect_signal (plugin->proxy, "TrashChanged", G_CALLBACK (thunar_tpa_trash_changed), plugin); + g_object_unref (G_OBJECT (plugin->proxy)); + } + + (*G_OBJECT_CLASS (thunar_tpa_parent_class)->finalize) (object); +} + + + +static void +thunar_tpa_construct (XfcePanelPlugin *panel_plugin) +{ + ThunarTpa *plugin = THUNAR_TPA (panel_plugin); + + /* add the "Empty Trash" menu item */ + xfce_panel_plugin_menu_insert_item (panel_plugin, GTK_MENU_ITEM (plugin->mi)); + + /* update the state of the trash plugin */ + thunar_tpa_query_trash (plugin); +} + + + +static void +thunar_tpa_error (ThunarTpa *plugin, + GError *error) +{ + gchar *tooltip; + + /* reset to empty first */ + thunar_tpa_state (plugin, FALSE); + + /* strip off additional whitespace */ + g_strstrip (error->message); + + /* tell the user that we failed to connect to the trash */ + tooltip = g_strdup_printf ("%s: %s.", _("Failed to connect to the Trash"), error->message); + gtk_widget_set_tooltip_text (plugin->button, tooltip); + g_free (tooltip); + + /* setup an error plugin */ + xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (plugin->image), "stock_dialog-error"); +} + + + +static void +thunar_tpa_state (ThunarTpa *plugin, + gboolean full) +{ + /* tell the user whether the trash is full or empty */ + gtk_widget_set_tooltip_text (plugin->button, full ? _("Trash contains files") : _("Trash is empty")); + + /* setup the appropriate plugin */ + xfce_panel_image_set_from_source (XFCE_PANEL_IMAGE (plugin->image), full ? "user-trash-full" : "user-trash"); + + /* sensitivity of the menu item */ + gtk_widget_set_sensitive (plugin->mi, full); +} + + + +static void +thunar_tpa_display_trash_reply (DBusGProxy *proxy, + GError *error, + gpointer user_data) +{ + ThunarTpa *plugin = THUNAR_TPA (user_data); + + /* reset the call */ + plugin->display_trash_call = NULL; + + /* check if we failed */ + if (G_UNLIKELY (error != NULL)) + { + /* display an error message to the user */ + g_strstrip (error->message); + xfce_dialog_show_error (NULL, error, "%s.", _("Failed to connect to the Trash")); + g_error_free (error); + } +} + + + +static void +thunar_tpa_empty_trash_reply (DBusGProxy *proxy, + GError *error, + gpointer user_data) +{ + ThunarTpa *plugin = THUNAR_TPA (user_data); + + /* reset the call */ + plugin->empty_trash_call = NULL; + + /* check if we failed */ + if (G_UNLIKELY (error != NULL)) + { + /* display an error message to the user */ + g_strstrip (error->message); + xfce_dialog_show_error (NULL, error, "%s.", _("Failed to connect to the Trash")); + g_error_free (error); + } + else + { + /* query the new state of the trash */ + thunar_tpa_query_trash (plugin); + } +} + + + +static void +thunar_tpa_move_to_trash_reply (DBusGProxy *proxy, + GError *error, + gpointer user_data) +{ + ThunarTpa *plugin = THUNAR_TPA (user_data); + + /* reset the call */ + plugin->move_to_trash_call = NULL; + + /* check if we failed */ + if (G_UNLIKELY (error != NULL)) + { + /* display an error message to the user */ + g_strstrip (error->message); + xfce_dialog_show_error (NULL, error, "%s.", _("Failed to connect to the Trash")); + g_error_free (error); + } + else + { + /* query the new state of the trash */ + thunar_tpa_query_trash (plugin); + } +} + + + +static void +thunar_tpa_query_trash_reply (DBusGProxy *proxy, + gboolean full, + GError *error, + gpointer user_data) +{ + ThunarTpa *plugin = THUNAR_TPA (user_data); + + /* reset the call */ + plugin->query_trash_call = NULL; + + /* check if we failed */ + if (G_UNLIKELY (error != NULL)) + { + /* setup an error tooltip/plugin */ + thunar_tpa_error (plugin, error); + g_error_free (error); + } + else + { + /* update the tooltip/plugin accordingly */ + thunar_tpa_state (plugin, full); + } +} + + + +static void +thunar_tpa_drag_data_received (GtkWidget *button, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint timestamp, + ThunarTpa *plugin) +{ + gboolean succeed = FALSE; + gchar **uri_list; + + g_return_if_fail (THUNAR_IS_TPA (plugin)); + g_return_if_fail (plugin->button == button); + + /* determine the type of drop we received */ + if (G_LIKELY (info == TARGET_TEXT_URI_LIST)) + { + /* check if the data is valid for text/uri-list */ + if (G_LIKELY (selection_data->length >= 0 && selection_data->format == 8)) + { + /* parse the URI list according to RFC 2483 */ + uri_list = g_uri_list_extract_uris ((const gchar *) selection_data->data); + succeed = thunar_tpa_move_to_trash (plugin, (const gchar **) uri_list); + g_strfreev (uri_list); + } + } + + /* finish the drag */ + gtk_drag_finish (context, succeed, TRUE, timestamp); +} + + + +static gboolean +thunar_tpa_enter_notify_event (GtkWidget *button, + GdkEventCrossing *event, + ThunarTpa *plugin) +{ + g_return_val_if_fail (THUNAR_IS_TPA (plugin), FALSE); + g_return_val_if_fail (plugin->button == button, FALSE); + + /* query the new state of the trash */ + thunar_tpa_query_trash (plugin); + + return FALSE; +} + + + +static gboolean +thunar_tpa_leave_notify_event (GtkWidget *button, + GdkEventCrossing *event, + ThunarTpa *plugin) +{ + g_return_val_if_fail (THUNAR_IS_TPA (plugin), FALSE); + g_return_val_if_fail (plugin->button == button, FALSE); + + /* query the new state of the trash */ + thunar_tpa_query_trash (plugin); + + return FALSE; +} + + + +static void +thunar_tpa_trash_changed (DBusGProxy *proxy, + gboolean full, + ThunarTpa *plugin) +{ + g_return_if_fail (THUNAR_IS_TPA (plugin)); + g_return_if_fail (plugin->proxy == proxy); + + /* change the status plugin/tooltip appropriately */ + thunar_tpa_state (plugin, full); +} + + + +static void +thunar_tpa_display_trash (ThunarTpa *plugin) +{ + gchar *display_name; + + g_return_if_fail (THUNAR_IS_TPA (plugin)); + + /* check if we are connected to the bus */ + if (G_LIKELY (plugin->proxy != NULL)) + { + /* cancel any pending call */ + if (G_UNLIKELY (plugin->display_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->display_trash_call); + + /* schedule a new call */ + display_name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (plugin))); + plugin->display_trash_call = org_xfce_Trash_display_trash_async (plugin->proxy, display_name, thunar_tpa_display_trash_reply, plugin); + g_free (display_name); + } +} + + + +static void +thunar_tpa_empty_trash (ThunarTpa *plugin) +{ + gchar *display_name; + + g_return_if_fail (THUNAR_IS_TPA (plugin)); + + /* check if we are connected to the bus */ + if (G_LIKELY (plugin->proxy != NULL)) + { + /* cancel any pending call */ + if (G_UNLIKELY (plugin->empty_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->empty_trash_call); + + /* schedule a new call */ + display_name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (plugin))); + plugin->empty_trash_call = org_xfce_Trash_empty_trash_async (plugin->proxy, display_name, thunar_tpa_empty_trash_reply, plugin); + g_free (display_name); + } +} + + + +static gboolean +thunar_tpa_move_to_trash (ThunarTpa *plugin, + const gchar **uri_list) +{ + gchar *display_name; + + g_return_val_if_fail (THUNAR_IS_TPA (plugin), FALSE); + g_return_val_if_fail (uri_list != NULL, FALSE); + + /* check if we are connected to the bus */ + if (G_UNLIKELY (plugin->proxy == NULL)) + return FALSE; + + /* cancel any pending call */ + if (G_UNLIKELY (plugin->move_to_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->move_to_trash_call); + + /* schedule a new call */ + display_name = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (plugin))); + plugin->move_to_trash_call = org_xfce_Trash_move_to_trash_async (plugin->proxy, uri_list, display_name, thunar_tpa_move_to_trash_reply, plugin); + g_free (display_name); + + return TRUE; +} + + + +static void +thunar_tpa_query_trash (ThunarTpa *plugin) +{ + g_return_if_fail (THUNAR_IS_TPA (plugin)); + + /* check if we are connected to the bus */ + if (G_LIKELY (plugin->proxy != NULL)) + { + /* cancel any pending call */ + if (G_UNLIKELY (plugin->query_trash_call != NULL)) + dbus_g_proxy_cancel_call (plugin->proxy, plugin->query_trash_call); + + /* schedule a new call */ + plugin->query_trash_call = org_xfce_Trash_query_trash_async (plugin->proxy, thunar_tpa_query_trash_reply, plugin); + } +} diff --git a/plugins/thunar-tpa/thunar-tpa.desktop.in.in b/plugins/thunar-tpa/thunar-tpa.desktop.in similarity index 58% rename from plugins/thunar-tpa/thunar-tpa.desktop.in.in rename to plugins/thunar-tpa/thunar-tpa.desktop.in index f6475219ac26baa84d24a32de337bcc61060ccf0..7ee18537312b890d4357e23eb43984cd63d04926 100644 --- a/plugins/thunar-tpa/thunar-tpa.desktop.in.in +++ b/plugins/thunar-tpa/thunar-tpa.desktop.in @@ -1,8 +1,7 @@ [Xfce Panel] Type=X-XFCE-PanelPlugin -Encoding=UTF-8 _Name=Trash Applet _Comment=Display the trash can Icon=user-trash -X-XFCE-Exec=@libexecdir@/xfce4/panel-plugins/thunar-tpa - +X-XFCE-Module=thunar-tpa +X-XFCE-Internal=FALSE diff --git a/po/POTFILES.in b/po/POTFILES.in index 84ff4e67974c6500813311ec462f12876d6345c8..a067d77d2045697c26fd6f0611be7cd99c64e827 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -112,9 +112,8 @@ plugins/thunar-sbr/thunar-sbr-replace-renamer.c plugins/thunar-sendto-email/main.c plugins/thunar-sendto-email/thunar-sendto-email.desktop.in.in -plugins/thunar-tpa/main.c -plugins/thunar-tpa/thunar-tpa-icon.c -plugins/thunar-tpa/thunar-tpa.desktop.in.in +plugins/thunar-tpa/thunar-tpa.c +plugins/thunar-tpa/thunar-tpa.desktop.in plugins/thunar-uca/thunar-uca-chooser.c plugins/thunar-uca/thunar-uca-context.c