summaryrefslogtreecommitdiffstats
path: root/docs/reference/pygio-icon.xml
blob: 5a32d28daaf9008e1a96b067eff8c4f92ad8d46a (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?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-gioicon">
    <refnamediv>
        <refname>gio.Icon</refname>
        <refpurpose>Interface for icons.</refpurpose>
    </refnamediv>

    <refsect1>
        <title>Synopsis</title>

    <classsynopsis language="python">
        <ooclass><classname>gio.Icon</classname></ooclass>
        <ooclass><classname><link linkend="class-gobjectginterface">gobject.GInterface</link></classname></ooclass>

    <methodsynopsis language="python">
        <methodname><link linkend="method-gioicon--equal">equal</link></methodname>
        <methodparam><parameter role="keyword">icon2</parameter></methodparam>
    </methodsynopsis>
    <methodsynopsis language="python">
        <methodname><link linkend="method-gioicon--to-string">to_string</link></methodname>
        <methodparam></methodparam>
    </methodsynopsis>
    
    </classsynopsis>

<programlisting>
<emphasis role="bold">Functions</emphasis>
 
<methodsynopsis language="python">
    <methodname><link linkend="function-gio--icon-new-from-string">gio.icon_new_from_string</link></methodname>
    <methodparam></methodparam>
</methodsynopsis></programlisting>

    </refsect1>

    <refsect1>
        <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobjectginterface">gobject.GInterface</link>
  +-- <link linkend="class-gioicon">gio.Icon</link>
</synopsis>

    </refsect1>
    
    <refsect1>
	<title>Known Derived Interfaces</title>
        <para>
            <link linkend="class-gioicon"><classname>gio.Icon</classname></link> is required by
            <link linkend="class-gioloadableicon"><classname>gio.LoadableIcon</classname></link>.
        </para>
    </refsect1>
    
    <refsect1>
	<title>Known Implementation</title>
        <para>
            <link linkend="class-gioicon"><classname>gio.Icon</classname></link> is implemented by
            <link linkend="class-giothemedicon"><classname>gio.ThemedIcon</classname></link>,
            <link linkend="class-giofileicon"><classname>gio.FileIcon</classname></link>,
            <link linkend="class-gioemblem"><classname>gio.Emblem</classname></link>,
            <link linkend="class-gioemblemedicon"><classname>gio.EmblemedIcon</classname></link>.
        </para>
    </refsect1>

    <refsect1>
        <title>Description</title>

        <para>
            <link linkend="class-gioicon"><classname>gio.Icon</classname></link>
            is a very minimal interface for icons. It provides functions for checking
            the equality of two icons, hashing of icons and serializing an icon to and from strings. 
        </para>
        <para>
            <link linkend="class-gioicon"><classname>gio.Icon</classname></link>
            does not provide the actual pixmap for the icon as this is out of GIO's
            scope, however implementations of
            <link linkend="class-gioicon"><classname>gio.Icon</classname></link>
            may contain the name of an icon (see
            <link linkend="class-giothemedicon"><classname>gio.ThemedIcon</classname></link>),
            or the path to an icon (see
            <link linkend="class-gioloadableicon"><classname>gio.LoadableIcon</classname></link>).
        </para>
        <!--
        <para>
            To obtain a hash of a <link linkend="class-gioicon"><classname>gio.Icon</classname></link>, see
            <methodname><link linkend="method-gioicon- -hash">gio.Icon.hash</link></methodname>().
        </para>
        -->
        <para>
            To check if two GIcons are equal, see
            <methodname><link linkend="method-gioicon--equal">gio.Icon.equal</link></methodname>().
        </para>
        <para>
            For serializing a <link linkend="class-gioicon"><classname>gio.Icon</classname></link>,
            use <methodname><link linkend="method-gioicon- -to-string">gio.Icon.to_string</link></methodname>() and
            <methodname><link linkend="method-gioicon- -new-from-string">gio.Icon.new_from_string</link></methodname>(). 
        </para>
        <para>
            If your application or library provides one or more
            <link linkend="class-gioicon"><classname>gio.Icon</classname></link>
            implementations you need to ensure that each GType is registered
            with the type system prior to calling
            <methodname><link linkend="function-gioicon--new-from-string">gio.icon_new_from_string</link></methodname>(). 
        </para>
    </refsect1>

    <refsect1>
        <title>Methods</title>

        <refsect2 id="method-gioicon--equal">
            <title>gio.Icon.equal</title>

            <programlisting><methodsynopsis language="python">
                <methodname>equal</methodname>
                <methodparam><parameter role="keyword">icon2</parameter></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><parameter>icon2</parameter>&nbsp;:</term>
                    <listitem><simpara>the second
                    <link linkend="class-gioicon"><classname>gio.Icon</classname></link>
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>equal</methodname>() method checks if two icons are equal.
            </para>
        </refsect2>

        <refsect2 id="method-gioicon--to-string">
            <title>gio.Icon.to_string</title>

            <programlisting><methodsynopsis language="python">
                <methodname>to_string</methodname>
                <methodparam></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>An UTF8 string or <literal>None</literal>
		    if icon can't be serialized.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>
    
            <para>
                The <methodname>to_string</methodname>() method generates a textual
		representation of icon that can be used for serialization such as when
		passing icon to a different process or saving it to persistent storage. Use
		<methodname><link linkend="function-gio--icon-new-from-string">gio.icon_new_from_string</link></methodname>()
		to get icon back from the returned string.
            </para>
	    <para>
		The encoding of the returned string is proprietary to GIcon except in the following two cases
	    </para>
	    <para>
		If icon is a <link linkend="class-giofileicon"><classname>gio.FileIcon</classname></link>,
		the returned string is a native path (such as /path/to/my icon.png) without escaping
		if the <link linkend="class-giofile"><classname>gio.File</classname></link>
		for icon is a native file. If the file is not native, the returned string is the result of
		<methodname><link linkend="method-giofile--get-uri">gio.File.get_uri</link></methodname>()
		(such as sftp://path/to/my%20icon.png).
	    </para>
	    <para>
		If icon is a <link linkend="class-giothemedicon"><classname>gio.ThemedIcon</classname></link>
		with exactly one name, the encoding is simply the name (such as network-server).
	    </para>
        </refsect2>
    </refsect1>
    
    <refsect1>
        <title>Functions</title>

        <refsect2 id="function-gio--icon-new-from-string">
            <title>gio.icon_new_from_string</title>

            <programlisting><methodsynopsis language="python">
                <methodname>icon_new_from_string</methodname>
                <methodparam><parameter role="keyword">str</parameter></methodparam>
            </methodsynopsis></programlisting>
            
            <variablelist>
                <varlistentry>
                    <term><parameter>str</parameter>&nbsp;:</term>
                    <listitem><simpara>A string obtained via
		    <methodname><link linkend="method-gioicon--to-string">gio.Icon.to_string</link></methodname>().
                    </simpara></listitem>
                </varlistentry>
                <varlistentry>
                    <term><emphasis>Returns</emphasis>&nbsp;:</term>
                    <listitem><simpara>An object implementing the
		    <link linkend="class-gioicon"><classname>gio.Icon</classname></link>
		    interface or <literal>None</literal> if error is set.
                    </simpara></listitem>
                </varlistentry>
            </variablelist>

            <para>
                The <methodname>icon_new_from_string</methodname>() function generate a
		<link linkend="class-gioicon"><classname>gio.Icon</classname></link>
		instance from str. This function can fail if str is not valid - see
		<methodname><link linkend="method-gioicon--to-string">gio.Icon.to_string</link></methodname>()
		for discussion.
            </para>
            <para>
                If your application or library provides one or more GIcon implementations you need
		to ensure that each GType is registered with the type system prior to calling
		<methodname><link linkend="function-gio--icon-new-from-string">gio.icon_new_from_string</link></methodname>().
            </para>
        </refsect2>
    </refsect1>
</refentry>