## ThunarxPreferencesProvider

ThunarxPreferencesProvider — The interface to extensions that provide preferences

## Stability Level

Stable, unless otherwise indicated

## Synopsis

    #include <thunarx/thunarx.h>

                        ThunarxPreferencesProviderIface;
                        ThunarxPreferencesProvider;
    GList *             thunarx_preferences_provider_get_actions
                                                            (ThunarxPreferencesProvider *provider,
                                                             GtkWidget *window);

## Object Hierarchy

      GInterface
       +----ThunarxPreferencesProvider

## Prerequisites

ThunarxPreferencesProvider requires GObject.

## Description

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 Compress file and Uncompress file 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

    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

    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);
    }

## Details

### ThunarxPreferencesProviderIface

    typedef struct {
      GList *(*get_actions) (ThunarxPreferencesProvider *provider,
                             GtkWidget                  *window);
    } ThunarxPreferencesProviderIface;

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.

`get_actions` () | See `thunarx_preferences_provider_get_actions()`.

### ThunarxPreferencesProvider

    typedef struct _ThunarxPreferencesProvider ThunarxPreferencesProvider;

Preferences provider type.

### thunarx_preferences_provider_get_actions ()

    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:

    1
    2

    g_list_foreach (list, (GFunc) g_object_unref, NULL);
    g_list_free (list);

`provider` : | a ThunarxPreferencesProvider.
`window` : | the GtkWindow within which the actions will be used.
Returns : | the list of GtkActions that `provider` has to offer as preferences within `window`.