File: thunarx-python-preferences-provider.xml

package info (click to toggle)
thunarx-python 0.5.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: xml: 1,500; ansic: 678; python: 136; makefile: 106; sh: 11
file content (114 lines) | stat: -rw-r--r-- 4,955 bytes parent folder | download | duplicates (2)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-thunarx-python-preferences-provider">
  <refnamediv>
    <refname>Thunarx.PreferencesProvider</refname>
    <refpurpose>Thunarx.PreferencesProvider Reference</refpurpose>
  </refnamediv>

<!-- ******************************* -->
<!-- BEGIN OF SYNOPSIS -->
<!-- ******************************* -->

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>Thunarx.PreferencesProvider</classname></ooclass>

      <methodsynopsis language="python">
        <methodname><link linkend="method-Thunarx-preferences-provider--get-preferences-menu-items">get_preferences_menu_items</link></methodname>
        <methodparam><parameter role="keyword">window</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>
  </refsect1>

<!-- ********************************** -->
<!-- BEGIN OF DESCRIPTION -->
<!-- ********************************** -->

  <refsect1 id="description-preferences-provider">
    <title>Description</title>

      <para>
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).
</para><para>
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.
      </para>
  </refsect1>

<example>
    <title>A Thunarx.PreferencesProvider plugin</title>
    <programlisting>
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()

    </programlisting>
</example>

<!-- ****************************** -->
<!-- BEGIN OF METHODS -->
<!-- ****************************** -->

  <refsect1>
        <title>Passive Methods</title>

        <refsect2 id="method-Thunarx-preferences-provider--get-preferences-menu-items">
          <title>Thunarx.PreferencesProvider.get_preferences_menu_items</title>

          <programlisting><methodsynopsis language="python">
            <methodname>get_preferences_menu_items</methodname>
              <methodparam></methodparam>
          </methodsynopsis></programlisting>

          <variablelist>
            <varlistentry>
	            <term><parameter role="keyword">window</parameter>&nbsp;:</term>
	            <listitem><simpara>a Gtk.Window</simpara></listitem>
            </varlistentry>
            <varlistentry>
              <term><emphasis>Returns</emphasis>&nbsp;:</term>
              <listitem><simpara>the list of Thunarx.MenuItem objects that provider has to offer as preferences within window.</simpara></listitem>
            </varlistentry>
          </variablelist>

          <para>
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.
</para><para>
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!
          </para>
        </refsect2>
    </refsect1>

</refentry>