summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gtkcelllayout.xml
blob: 44ef82aae1c7cef147d4aae549696a08d88d0a6b (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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<?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-gtkcelllayout">
  <refnamediv>
    <refname>gtk.CellLayout</refname>
    <refpurpose>an interface for packing cells</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.CellLayout</classname></ooclass>
      <ooclass><classname>gobject.GInterface</classname></ooclass>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--pack-start">pack_start</link></methodname>
	<methodparam><parameter role="keyword">cell</parameter></methodparam>
	<methodparam><parameter role="keyword">expand</parameter><initializer>True</initializer></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--pack-end">pack_end</link></methodname>
	<methodparam><parameter role="keyword">cell</parameter></methodparam>
	<methodparam><parameter role="keyword">expand</parameter><initializer>True</initializer></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--clear">clear</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--set-attributes">set_attributes</link></methodname>
	<methodparam><parameter>cell</parameter></methodparam>
	<methodparam><parameter>...</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--add-attribute">add_attribute</link></methodname>
	<methodparam><parameter role="keyword">cell</parameter></methodparam>
	<methodparam><parameter role="keyword">attribute</parameter></methodparam>
	<methodparam><parameter role="keyword">column</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--set-cell-data-func">set_cell_data_func</link></methodname>
	<methodparam><parameter role="keyword">cell</parameter></methodparam>
	<methodparam><parameter role="keyword">func</parameter></methodparam>
	<methodparam><parameter role="keyword">func_data</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--clear-attributes">clear_attributes</link></methodname>
	<methodparam><parameter role="keyword">cell</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcelllayout--reorder">reorder</link></methodname>
	<methodparam><parameter role="keyword">cell</parameter></methodparam>
	<methodparam><parameter role="keyword">position</parameter></methodparam>
      </methodsynopsis>
    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <note>
      <para>This interface is available in PyGTK 2.4 and above.</para>
    </note>

    <para><link
linkend="class-gtkcelllayout"><classname>gtk.CellLayout</classname></link>
is an interface to be implemented by all objects that want to provide a
<link
linkend="class-gtktreeviewcolumn"><classname>gtk.TreeViewColumn</classname></link>-like
API for packing cells, setting attributes and data funcs. The <link
linkend="class-gtkcelllayout"><classname>gtk.CellLayout</classname></link>
interface is implemented by the <link
linkend="class-gtkcomboboxentry"><classname>gtk.ComboBoxEntry</classname></link>,
<link
linkend="class-gtkcombobox"><classname>gtk.ComboBox</classname></link>,
<link
linkend="class-gtkentrycompletion"><classname>gtk.EntryCompletion</classname></link>
and <link
linkend="class-gtktreeviewcolumn"><classname>gtk.TreeViewColumn</classname></link>
widgets.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gtkcelllayout--pack-start">
      <title>gtk.CellLayout.pack_start</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>pack_start</methodname>
	  <methodparam><parameter role="keyword">cell</parameter></methodparam>
	  <methodparam><parameter role="keyword">expand</parameter><initializer>True</initializer></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">cell</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">expand</parameter>&nbsp;:</term>
	  <listitem><simpara>if <literal>True</literal>, the
	  <parameter>cell</parameter> is to be given extra space that is
	  allocated to the cell layout.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>pack_start</methodname>() method packs the <link
linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>
specified by <parameter>cell</parameter> into the beginning of the cell
layout. If the optional parameter <parameter>expand</parameter> is
<literal>False</literal>, then <parameter>cell</parameter> is allocated no
more space than it needs. Any unused space is divided evenly between cells
for which <parameter>expand</parameter> is <literal>True</literal>.</para>

    </refsect2>

    <refsect2 id="method-gtkcelllayout--pack-end">
      <title>gtk.CellLayout.pack_end</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>pack_end</methodname>
	  <methodparam><parameter role="keyword">cell</parameter></methodparam>
	  <methodparam><parameter role="keyword">expand</parameter><initializer>True</initializer></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">cell</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">expand</parameter>&nbsp;:</term>
	  <listitem><simpara>if <literal>True</literal>, the
	  <parameter>cell</parameter> is to be given extra space that is
	  allocated to the cell layout.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>pack_end</methodname>() method adds the <link
linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>
specified by <parameter>cell</parameter> to the end of the cell layout. If
the optional parameter <parameter>expand</parameter> is
<literal>False</literal>, then the <parameter>cell</parameter> is allocated
no more space than it needs. Any unused space is divided evenly between
cells for which <parameter>expand</parameter> is
<literal>True</literal>.</para>

    </refsect2>

    <refsect2 id="method-gtkcelllayout--clear">
      <title>gtk.CellLayout.clear</title>

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

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>clear</methodname>() method unsets all the
attribute mappings on all cell renderers in the cell layout.</para>

    </refsect2>

    <refsect2 id="method-gtkcelllayout--set-attributes">
      <title>gtk.CellLayout.set_attributes</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_attributes</methodname>
	  <methodparam><parameter>cell</parameter></methodparam>
	<methodparam><parameter>...</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter>cell</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link
	  linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>...</parameter>&nbsp;:</term>
	  <listitem><simpara>Zero or more keyword-value arguments in the format
	  attribute=column.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>set_attributes</methodname>() method sets the
attributes provided as a keyword argument list as the attributes of the
<link
linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>
specified by <parameter>cell</parameter>. The attributes should be supplied
as keyword-value arguments in the format: attribute=column (e.g. text=0,
background=1). All existing attributes are removed, and replaced with the
new attributes.</para>

    </refsect2>

    <refsect2 id="method-gtkcelllayout--add-attribute">
      <title>gtk.CellLayout.add_attribute</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>add_attribute</methodname>
	  <methodparam><parameter role="keyword">cell</parameter></methodparam>
	  <methodparam><parameter role="keyword">attribute</parameter></methodparam>
	  <methodparam><parameter role="keyword">column</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">cell</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">attribute</parameter>&nbsp;:</term>
	  <listitem><simpara>An attribute on the renderer.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">column</parameter>&nbsp;:</term>
	  <listitem><simpara>The column number in the model to get the attribute from.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>add_attribute</methodname>() method adds an
attribute mapping to the list in the cell layout. The
<parameter>column</parameter> parameter is the column of the model to get a
value from, and the <parameter>attribute</parameter> parameter is the
attribute of <parameter>cell</parameter> to be set from the value. So for
example if column 2 of the model contains strings, you could have the "text"
attribute of a <link
linkend="class-gtkcellrenderertext"><classname>gtk.CellRendererText</classname></link>
get its values from column 2.</para>

    </refsect2>

    <refsect2 id="method-gtkcelllayout--set-cell-data-func">
      <title>gtk.CellLayout.set_cell_data_func</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_cell_data_func</methodname>
	  <methodparam><parameter role="keyword">cell</parameter></methodparam>
	  <methodparam><parameter role="keyword">func</parameter></methodparam>
	  <methodparam><parameter role="keyword">func_data</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">cell</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">func</parameter>&nbsp;:</term>
	  <listitem><simpara>The function to use.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">func_data</parameter>&nbsp;:</term>
	  <listitem><simpara>The user data for <parameter>func</parameter>.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>set_cell_data_func</methodname>() method sets
the function (or method) specified by <parameter>func</parameter> to be used
for setting the column value of the <link
linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>
specified by <parameter>cell</parameter> instead of using the standard
attribute mapping method. <parameter>func</parameter> may be
<literal>None</literal> to remove the current function. The signature of
<parameter>func</parameter> is:</para>

      <programlisting>
<methodsynopsis language="python">
          <methodname>celldatafunction</methodname>
          <methodparam><parameter>celllayout</parameter></methodparam>
          <methodparam><parameter>cell</parameter></methodparam>
          <methodparam><parameter>model</parameter></methodparam>
          <methodparam><parameter>iter</parameter></methodparam>
          <methodparam><parameter>user_data</parameter></methodparam>
        </methodsynopsis>
<methodsynopsis language="python">
          <methodname>celldatamethod</methodname>
          <methodparam><parameter>self</parameter></methodparam>
          <methodparam><parameter>celllayout</parameter></methodparam>
          <methodparam><parameter>cell</parameter></methodparam>
          <methodparam><parameter>model</parameter></methodparam>
          <methodparam><parameter>iter</parameter></methodparam>
          <methodparam><parameter>user_data</parameter></methodparam>
        </methodsynopsis>
</programlisting>

      <para>where <parameter>celllayout</parameter> is the <link
linkend="class-gtkcelllayout"><classname>gtk.CellLayout</classname></link>,
<parameter>cell</parameter> is the <link
linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>
for <parameter>celllayout</parameter>, <parameter>model</parameter> is the
<link
linkend="class-gtktreemodel"><classname>gtk.TreeModel</classname></link> and
<parameter>iter</parameter> is the <link
linkend="class-gtktreeiter"><classname>gtk.TreeIter</classname></link>
pointing at the row.</para>

    </refsect2>

    <refsect2 id="method-gtkcelllayout--clear-attributes">
      <title>gtk.CellLayout.clear_attributes</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>clear_attributes</methodname>
	  <methodparam><parameter role="keyword">cell</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">cell</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link> to clear the attribute mapping on.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>clear_attributes</methodname>() method clears
all existing attribute mappings from the <link
linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>
specified by <parameter>cell</parameter> previously set with the <link
linkend="method-gtkcelllayout--set-attributes"><methodname>set_attributes</methodname>()</link>
or <link
linkend="method-gtkcelllayout--add-attribute"><methodname>add_attribute</methodname>()</link>
methods.</para>

    </refsect2>

    <refsect2 id="method-gtkcelllayout--reorder">
      <title>gtk.CellLayout.reorder</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>reorder</methodname>
	  <methodparam><parameter role="keyword">cell</parameter></methodparam>
	  <methodparam><parameter role="keyword">position</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">cell</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link> to reorder.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter role="keyword">position</parameter>&nbsp;:</term>
	  <listitem><simpara>New position to insert <parameter>cell</parameter> at.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>reorder</methodname>() method re-inserts the
<link
linkend="class-gtkcellrenderer"><classname>gtk.CellRenderer</classname></link>
specified by <parameter>cell</parameter> at
<parameter>position</parameter>. Note that <parameter>cell</parameter> has
to already be packed into <parameter>cell_layout</parameter> for this to
function properly.</para>

    </refsect2>

  </refsect1>

</refentry>