Thunarx.PreferencesProvider

Thunarx.PreferencesProvider — Thunarx.PreferencesProvider Reference

Synopsis

 Thunarx.PreferencesProvider {
  get_preferences_menu_items(window);
}

Description

The Thunarx.PreferencesProvider 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 Thunarx.MenuItem objects returned from the Thunarx.PreferencesProvider.get_preferences_menu_items() 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. A Thunarx.PreferencesProvider plugin

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
from gi.repository import GObject, Gtk, Thunarx

class DialogExample(Gtk.Dialog):
    def __init__(self, parent):
        Gtk.Dialog.__init__(self, "My Dialog", parent, 0,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
             Gtk.STOCK_OK, Gtk.ResponseType.OK))

        self.set_default_size(150, 100)
        self.set_transient_for(parent)

        label = Gtk.Label("This is a dialog to display additional information")

        box = self.get_content_area()
        box.add(label)
        self.show_all()

class ThunarxPreferencesPlugin(GObject.GObject, Thunarx.PreferencesProvider):
    def __init__(self):
        pass
    
    def get_preferences_menu_items(self, window):
        item = Thunarx.MenuItem(name="TPP:PrefItem", label="My Example Preferences", tooltip=None, icon=None)
        item.connect("activate", self.__open_preferences, window)
        return item,
    
    def __open_preferences(self, action, window):
        dialog = DialogExample(window)
        response = dialog.run()
        dialog.destroy()

Passive Methods

Thunarx.PreferencesProvider.get_preferences_menu_items

get_preferences_menu_items();

window :

a Gtk.Window

Returns :

the list of Thunarx.MenuItem objects that provider has to offer as preferences within window.

Returns the list of ThunarxMenuItems 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!