Thunar Extensions Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Prerequisites |
ThunarxPreferencesProviderThunarxPreferencesProvider — The interface to extensions that provide preferences |
#include <thunarx/thunarx.h> struct ThunarxPreferencesProviderIface; ThunarxPreferencesProvider; GList * thunarx_preferences_provider_get_actions (ThunarxPreferencesProvider *provider
,GtkWidget *window
);
The ThunarxPreferencesProvider interface is implemented by extensions that
want to register additional actions in the preferences menu of the file
manager. In general this should only be done by extensions that are closely
tied to the file manager (for example, the thunar-uca
is
such an extension, while an extension that just adds and to the
context menu of compressed files should not add their own preferences to
the file manager menu, because it should use desktop-wide settings for
archive managers instead).
The GtkActions returned from the
thunarx_preferences_provider_get_actions()
method must be namespaced with the
model to avoid collision with internal file manager actions and actions provided
by other extensions. For example, the preferences action provided by the
thunar-uca
extension is called
ThunarUca::manage-actions
.
Example 6. Preferences provider example
static void hello_preferences_provider_init (ThunarxPreferencesProviderIface *iface); static void hello_get_actions (ThunarxPreferencesProvider *provider, GtkWidget *window); THUNARX_DEFINE_TYPE_WITH_CODE (Hello, hello, G_TYPE_OBJECT, THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_PREFERENCES_PROVIDER, hello_preferences_provider_init)); static void hello_preferences_provider_init (ThunarxPreferencesProviderIface *iface) { iface->get_actions = hello_get_actions; } static void hello_activated (GtkWidget *window) { GtkWidget *dialog; dialog = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Hello World!"); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); } static GList* hello_get_actions (ThunarxPreferencesProvider *provider, GtkWidget *window) { GtkAction *action; GClosure *closure; action = gtk_action_new ("Hello::say-hello", "Say hello", "Say hello", NULL); closure = g_cclosure_object_new_swap (G_CALLBACK (hello_activated), G_OBJECT (window)); g_signal_connect_closure (G_OBJECT (action), "activate", closure, TRUE); return g_list_prepend (NULL, action); }
struct ThunarxPreferencesProviderIface { GList *(*get_actions) (ThunarxPreferencesProvider *provider, GtkWidget *window); };
Interface with virtual methods implementation by extensions that want to install preferences actions in the file managers menu.
Providers don't need to implement all of the virtual methods listed in the interface.
typedef struct _ThunarxPreferencesProvider ThunarxPreferencesProvider;
Preferences provider type.
GList * thunarx_preferences_provider_get_actions (ThunarxPreferencesProvider *provider
,GtkWidget *window
);
Returns the list of GtkActions that provider
has to offer
as preferences within window
. These actions will usually be added
to the builtin list of preferences in the "Edit" menu of the file
manager's window
.
Plugin writers that implement this interface should make sure to choose descriptive action names and tooltips, and not to crowd the "Edit" menu too much. That said, think twice before implementing this interface, as too many preference actions will render the file manager useless over 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);
|
a ThunarxPreferencesProvider. |
|
the GtkWindow within which the actions will be used. |
Returns : |
the list of GtkActions that provider has
to offer as preferences within window . |