From c6505454dca4a33a1bceaf96484b9ed8c03e560a Mon Sep 17 00:00:00 2001 From: Benedikt Meurer Date: Wed, 13 Sep 2006 23:36:10 +0000 Subject: 2006-09-14 Benedikt Meurer * thunarx/thunarx-menu-provider.{c,h}, thunarx/thunarx.symbols: Add a new method get_dnd_actions() to the ThunarxMenuProvider, which allows menu providers to install additional actions into the Drag'n'Drop menu of the file manager. * docs/reference/thunarx/: Update the thunarx reference manual. * thunar/thunar-dnd.{c,h}, thunar/thunar-location-button.c, thunar/thunar-shortcuts-view.c, thunar/thunar-standard-view.c, thunar/thunar-tree-view.c: Insert the additional actions supplied by the installed menu providers into the Drag'n'Drop menu. (Old svn revision: 23151) --- thunarx/thunarx-menu-provider.c | 67 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'thunarx/thunarx-menu-provider.c') diff --git a/thunarx/thunarx-menu-provider.c b/thunarx/thunarx-menu-provider.c index 7c6f5f11..5bb5be29 100644 --- a/thunarx/thunarx-menu-provider.c +++ b/thunarx/thunarx-menu-provider.c @@ -1,6 +1,6 @@ /* $Id$ */ /*- - * Copyright (c) 2005 Benedikt Meurer + * Copyright (c) 2005-2006 Benedikt Meurer * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -172,5 +172,70 @@ thunarx_menu_provider_get_folder_actions (ThunarxMenuProvider *provider, +/** + * thunarx_menu_provider_get_dnd_actions: + * @provider : a #ThunarxMenuProvider. + * @window : the #GtkWindow within which the actions will be used. + * @folder : the folder into which the @files are being dropped + * @files : the list of #ThunarxFileInfos for the files that are + * being dropped to @folder in @window. + * + * Returns the list of #GtkActions that @provider has to offer for + * dropping the @files into the @folder. For example, the thunar-archive-plugin + * provides Extract Here actions when dropping archive + * files into a folder that is writable by the user. + * + * 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: + * + * g_list_foreach (list, (GFunc) g_object_unref, NULL); + * g_list_free (list); + * + * + * Return value: the list of #GtkActions that @provider has to offer + * for dropping @files to @folder. + * + * Since: 0.4.1 + **/ +GList* +thunarx_menu_provider_get_dnd_actions (ThunarxMenuProvider *provider, + GtkWidget *window, + ThunarxFileInfo *folder, + GList *files) +{ + GList *actions; + + 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); + g_return_val_if_fail (files != NULL, NULL); + + if (THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_dnd_actions != NULL) + { + /* query the actions from the implementation */ + actions = (*THUNARX_MENU_PROVIDER_GET_IFACE (provider)->get_dnd_actions) (provider, window, folder, files); + + /* take a reference on the provider for each action */ + thunarx_object_list_take_reference (actions, provider); + } + else + { + actions = NULL; + } + + return actions; +} + + + #define __THUNARX_MENU_PROVIDER_C__ #include -- cgit v1.2.1