summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gobject-maincontext.xml
blob: ef688780e78340f3bfbbe63836a7083ec3fa03ed (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
<?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-gobjectmaincontext">
  <refnamediv>
    <refname>gobject.MainContext</refname>

    <refpurpose>an object representing a set of event sources to be handled
in a <link
linkend="class-gobjectmainloop"><classname>gobject.MainLoop</classname></link>.</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

<classsynopsis language="python">
  <ooclass><classname>gobject.MainContext</classname></ooclass>
<constructorsynopsis language="python">
    <methodname><link linkend="constructor-gobjectmaincontext">gobject.MainContext</link></methodname>
  </constructorsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gobjectmaincontext--iteration">iteration</link></methodname>
    <methodparam><parameter>may_block</parameter></methodparam>
  </methodsynopsis>
<methodsynopsis language="python">
    <methodname><link linkend="method-gobjectmaincontext--pending">pending</link></methodname>
  </methodsynopsis>
</classsynopsis>

</refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobjectmaincontext">gobject.MainContext</link>
</synopsis>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>A <link
linkend="class-gobjectmaincontext"><classname>gobject.MainContext</classname></link>
represents a set of event sources that can be run in a single thread. File
descriptors (plain files, pipes or sockets) and timeouts are the standard
event sources for <literal>GTK</literal> and <literal>PyGTK</literal> though
others can be added. Each event source is assigned a priority. The default
priority, <literal>gobject.PRIORITY_DEFAULT</literal>, is 0. Values less
than 0 denote higher priorities. Values greater than 0 denote lower
priorities. Events from high priority sources are always processed before
events from lower priority sources. Single iterations of a <link
linkend="class-gobjectmaincontext"><classname>gobject.MainContext</classname></link>
can be run with the <link
linkend="method-gobjectmaincontext--iteration"><methodname>iteration</methodname>()</link>
method.</para>

  </refsect1>

  <refsect1 id="constructor-gobjectmaincontext">
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
        <methodname>gobject.MainContext</methodname>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
        <term><emphasis>Returns</emphasis>&nbsp;:</term>
        <listitem><simpara>a new <link
        linkend="class-gobjectmaincontext"><classname>gobject.MainContext</classname></link>
        object.</simpara></listitem>
      </varlistentry>
    </variablelist>

    <para>Creates a new <link
linkend="class-gobjectmaincontext"><classname>gobject.MainContext</classname></link>
object.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gobjectmaincontext--iteration">
      <title>gobject.MainContext.iteration</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>iteration</methodname>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter>may_block</parameter>&nbsp;:</term>
	  <listitem><simpara>if <literal>True</literal> the call may block
	  waiting for an event.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if events were
	  dispatched.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>iteration</methodname>() method runs a single
iteration. This involves:</para>

    <itemizedlist>
      <listitem>
	<simpara>checking to see if any associated event sources are ready
to be processed;</simpara>
      </listitem>
      <listitem>
	<simpara>then if no events sources are ready and
<parameter>may_block</parameter> is <literal>True</literal>, waiting for a
source to become ready;</simpara>
      </listitem>
      <listitem>
	<simpara>and finally, dispatching the highest priority events
sources that are ready</simpara>
      </listitem>
   </itemizedlist>

      <para>Note that even when <parameter>may_block</parameter> is
<literal>True</literal>, it is still possible for
<methodname>iteration</methodname>() to return <literal>False</literal>,
since the the wait may be interrupted for other reasons than an event source
becoming ready.</para>

    </refsect2>

    <refsect2 id="method-gobjectmaincontext--pending">
      <title>gobject.MainContext.pending</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>pending</methodname>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if events are
	  pending.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <para>The <methodname>pending</methodname>() method checks if any
associated sources have pending events.</para>

    </refsect2>

  </refsect1>

</refentry>