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 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Threads</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="GDK Reference Manual">
<link rel="up" href="reference.html" title="API Reference">
<link rel="prev" href="gdk-Properties-and-Atoms.html" title="Properties and Atoms">
<link rel="next" href="gdk-Input.html" title="Input">
<meta name="generator" content="GTK-Doc V1.14 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gdk-Properties-and-Atoms.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GDK Reference Manual</th>
<td><a accesskey="n" href="gdk-Input.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gdk-Threads.synopsis" class="shortcut">Top</a>
|
<a href="#gdk-Threads.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry" title="Threads">
<a name="gdk-Threads"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gdk-Threads.top_of_page"></a>Threads</span></h2>
<p>Threads — Functions for using GDK in multi-threaded programs</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv" title="Synopsis">
<a name="gdk-Threads.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include <gdk/gdk.h>
#define <a class="link" href="gdk-Threads.html#GDK-THREADS-ENTER:CAPS" title="GDK_THREADS_ENTER">GDK_THREADS_ENTER</a>
#define <a class="link" href="gdk-Threads.html#GDK-THREADS-LEAVE:CAPS" title="GDK_THREADS_LEAVE">GDK_THREADS_LEAVE</a>
<span class="returnvalue">void</span> <a class="link" href="gdk-Threads.html#gdk-threads-init" title="gdk_threads_init ()">gdk_threads_init</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span> <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()">gdk_threads_enter</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">void</span> <a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()">gdk_threads_leave</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
extern GMutex *<a class="link" href="gdk-Threads.html#gdk-threads-mutex" title="gdk_threads_mutex">gdk_threads_mutex</a>;
<span class="returnvalue">void</span> <a class="link" href="gdk-Threads.html#gdk-threads-set-lock-functions" title="gdk_threads_set_lock_functions ()">gdk_threads_set_lock_functions</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GCallback"><span class="type">GCallback</span></a> enter_fn</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GCallback"><span class="type">GCallback</span></a> leave_fn</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> <a class="link" href="gdk-Threads.html#gdk-threads-add-idle" title="gdk_threads_add_idle ()">gdk_threads_add_idle</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> <a class="link" href="gdk-Threads.html#gdk-threads-add-idle-full" title="gdk_threads_add_idle_full ()">gdk_threads_add_idle_full</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> priority</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> notify</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout" title="gdk_threads_add_timeout ()">gdk_threads_add_timeout</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout-full" title="gdk_threads_add_timeout_full ()">gdk_threads_add_timeout_full</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> priority</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> notify</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout-seconds" title="gdk_threads_add_timeout_seconds ()">gdk_threads_add_timeout_seconds</a> (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);
<a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout-seconds-full" title="gdk_threads_add_timeout_seconds_full ()">gdk_threads_add_timeout_seconds_full</a>
(<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> priority</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> notify</code></em>);
</pre>
</div>
<div class="refsect1" title="Description">
<a name="gdk-Threads.description"></a><h2>Description</h2>
<p>
For thread safety, GDK relies on the thread primitives in GLib,
and on the thread-safe GLib main loop.
</p>
<p>
GLib is completely thread safe (all global data is automatically
locked), but individual data structure instances are not automatically
locked for performance reasons. So e.g. you must coordinate
accesses to the same <a href="/usr/share/gtk-doc/html/glib/glib-Hash-Tables.html#GHashTable"><span class="type">GHashTable</span></a> from multiple threads.
</p>
<p>
GTK+ is "thread aware" but not thread safe — it provides a
global lock controlled by <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a>/<a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a>
which protects all use of GTK+. That is, only one thread can use GTK+
at any given time.
</p>
<p>
Unfortunately the above holds with the X11 backend only. With the
Win32 backend, GDK calls should not be attempted from multiple threads
at all.
</p>
<p>
You must call <a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#g-thread-init"><code class="function">g_thread_init()</code></a> and <a class="link" href="gdk-Threads.html#gdk-threads-init" title="gdk_threads_init ()"><code class="function">gdk_threads_init()</code></a> before executing
any other GTK+ or GDK functions in a threaded GTK+ program.
</p>
<p>
Idles, timeouts, and input functions from GLib, such as <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-idle-add"><code class="function">g_idle_add()</code></a>, are
executed outside of the main GTK+ lock.
So, if you need to call GTK+ inside of such a callback, you must surround
the callback with a <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a>/<a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a> pair or use
<a class="link" href="gdk-Threads.html#gdk-threads-add-idle-full" title="gdk_threads_add_idle_full ()"><code class="function">gdk_threads_add_idle_full()</code></a> which does this for you.
However, event dispatching from the mainloop is still executed within
the main GTK+ lock, so callback functions connected to event signals
like GtkWidget::button-press-event, do not need thread protection.
</p>
<p>
In particular, this means, if you are writing widgets that might
be used in threaded programs, you <span class="emphasis"><em>must</em></span> surround
timeouts and idle functions in this matter.
</p>
<p>
As always, you must also surround any calls to GTK+ not made within
a signal handler with a <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a>/<a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a> pair.
</p>
<p>
Before calling <a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a> from a thread other
than your main thread, you probably want to call <a class="link" href="gdk-General.html#gdk-flush" title="gdk_flush ()"><code class="function">gdk_flush()</code></a>
to send all pending commands to the windowing system.
(The reason you don't need to do this from the main thread
is that GDK always automatically flushes pending commands
when it runs out of incoming events to process and has
to sleep while waiting for more events.)
</p>
<p>A minimal main program for a threaded GTK+ application
looks like:</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="type">int</span>
<span class="function">main</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> argc</span><span class="symbol">,</span><span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">argv</span><span class="symbol">[])</span>
<span class="cbracket">{</span>
<span class="normal"> <a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html">GtkWidget</a> </span><span class="symbol">*</span><span class="normal">window</span><span class="symbol">;</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#g-thread-init">g_thread_init</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-init">gdk_threads_init</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-enter">gdk_threads_enter</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-init">gtk_init</a></span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">argc</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">argv</span><span class="symbol">);</span>
<span class="normal"> window </span><span class="symbol">=</span><span class="normal"> </span><span class="function">create_window</span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-show">gtk_widget_show</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">window</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-main">gtk_main</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-leave">gdk_threads_leave</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
Callbacks require a bit of attention. Callbacks from GTK+ signals
are made within the GTK+ lock. However callbacks from GLib (timeouts,
IO callbacks, and idle functions) are made outside of the GTK+
lock. So, within a signal handler you do not need to call
<a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a>, but within the other types of callbacks, you
do.
</p>
<p>Erik Mouw contributed the following code example to
illustrate how to use threads within GTK+ programs.
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>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</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="comment">/*-------------------------------------------------------------------------</span>
<span class="comment"> * Filename: gtk-thread.c</span>
<span class="comment"> * Version: 0.99.1</span>
<span class="comment"> * Copyright: Copyright (C) 1999, Erik Mouw</span>
<span class="comment"> * Author: Erik Mouw </span><span class="url"><a href="<J.A.K.Mouw@its.tudelft.nl>"><J.A.K.Mouw@its.tudelft.nl></a></span>
<span class="comment"> * Description: GTK threads example.</span>
<span class="comment"> * Created at: Sun Oct 17 21:27:09 1999</span>
<span class="comment"> * Modified by: Erik Mouw </span><span class="url"><a href="<J.A.K.Mouw@its.tudelft.nl>"><J.A.K.Mouw@its.tudelft.nl></a></span>
<span class="comment"> * Modified at: Sun Oct 24 17:21:41 1999</span>
<span class="comment"> *-----------------------------------------------------------------------*/</span>
<span class="comment">/*</span>
<span class="comment"> * Compile with:</span>
<span class="comment"> *</span>
<span class="comment"> * cc -o gtk-thread gtk-thread.c `gtk-config --cflags --libs gthread`</span>
<span class="comment"> *</span>
<span class="comment"> * Thanks to Sebastian Wilhelmi and Owen Taylor for pointing out some</span>
<span class="comment"> * bugs.</span>
<span class="comment"> *</span>
<span class="comment"> */</span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string"><stdio.h></span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string"><stdlib.h></span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string"><unistd.h></span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string"><time.h></span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string"><gtk/gtk.h></span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string"><glib.h></span>
<span class="preproc">#include</span><span class="normal"> </span><span class="string"><pthread.h></span>
<span class="preproc">#define</span><span class="normal"> </span><span class="function">YES_IT_IS</span><span class="normal"> </span><span class="symbol">(</span><span class="number">1</span><span class="symbol">)</span>
<span class="preproc">#define</span><span class="normal"> </span><span class="function">NO_IT_IS_NOT</span><span class="normal"> </span><span class="symbol">(</span><span class="number">0</span><span class="symbol">)</span>
<span class="keyword">typedef</span><span class="normal"> </span><span class="keyword">struct</span>
<span class="cbracket">{</span>
<span class="normal"> <a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html">GtkWidget</a> </span><span class="symbol">*</span><span class="normal">label</span><span class="symbol">;</span>
<span class="normal"> </span><span class="type">int</span><span class="normal"> what</span><span class="symbol">;</span>
<span class="cbracket">}</span><span class="normal"> yes_or_no_args</span><span class="symbol">;</span>
<span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#G-LOCK-DEFINE-STATIC:CAPS">G_LOCK_DEFINE_STATIC</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">yes_or_no</span><span class="symbol">);</span>
<span class="keyword">static</span><span class="normal"> </span><span class="keyword">volatile</span><span class="normal"> </span><span class="type">int</span><span class="normal"> yes_or_no </span><span class="symbol">=</span><span class="normal"> YES_IT_IS</span><span class="symbol">;</span>
<span class="type">void</span><span class="normal"> </span><span class="function">destroy</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html">GtkWidget</a> </span><span class="symbol">*</span><span class="normal">widget</span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-main-quit">gtk_main_quit</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="cbracket">}</span>
<span class="type">void</span><span class="normal"> </span><span class="symbol">*</span><span class="function">argument_thread</span><span class="normal"> </span><span class="symbol">(</span><span class="type">void</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">args</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> yes_or_no_args </span><span class="symbol">*</span><span class="normal">data </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">yes_or_no_args </span><span class="symbol">*)</span><span class="normal">args</span><span class="symbol">;</span>
<span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> say_something</span><span class="symbol">;</span>
<span class="normal"> </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(;;)</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">/* sleep a while */</span>
<span class="normal"> </span><span class="function">sleep</span><span class="symbol">(</span><span class="function">rand</span><span class="symbol">()</span><span class="normal"> </span><span class="symbol">/</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">RAND_MAX </span><span class="symbol">/</span><span class="normal"> </span><span class="number">3</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">+</span><span class="normal"> </span><span class="number">1</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* lock the yes_or_no_variable */</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#G-LOCK:CAPS">G_LOCK</a></span><span class="symbol">(</span><span class="normal">yes_or_no</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* do we have to say something? */</span>
<span class="normal"> say_something </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">yes_or_no </span><span class="symbol">!=</span><span class="normal"> data</span><span class="symbol">-></span><span class="normal">what</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">if</span><span class="symbol">(</span><span class="normal">say_something</span><span class="symbol">)</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">/* set the variable */</span>
<span class="normal"> yes_or_no </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">-></span><span class="normal">what</span><span class="symbol">;</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="normal"> </span><span class="comment">/* Unlock the yes_or_no variable */</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#G-UNLOCK:CAPS">G_UNLOCK</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">yes_or_no</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">say_something</span><span class="symbol">)</span>
<span class="normal"> </span><span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">/* get GTK thread lock */</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-enter">gdk_threads_enter</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="comment">/* set label text */</span>
<span class="normal"> </span><span class="keyword">if</span><span class="symbol">(</span><span class="normal">data</span><span class="symbol">-></span><span class="normal">what </span><span class="symbol">==</span><span class="normal"> YES_IT_IS</span><span class="symbol">)</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkLabel.html#gtk-label-set-text">gtk_label_set_text</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">GTK_LABEL</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">data</span><span class="symbol">-></span><span class="normal">label</span><span class="symbol">),</span><span class="normal"> </span><span class="string">"O yes, it is!"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">else</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkLabel.html#gtk-label-set-text">gtk_label_set_text</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">GTK_LABEL</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">data</span><span class="symbol">-></span><span class="normal">label</span><span class="symbol">),</span><span class="normal"> </span><span class="string">"O no, it isn't!"</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* release GTK thread lock */</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-leave">gdk_threads_leave</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="normal"> </span><span class="cbracket">}</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">;</span>
<span class="cbracket">}</span>
<span class="type">int</span><span class="normal"> </span><span class="function">main</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> argc</span><span class="symbol">,</span><span class="normal"> </span><span class="type">char</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">argv</span><span class="symbol">[])</span>
<span class="cbracket">{</span>
<span class="normal"> <a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html">GtkWidget</a> </span><span class="symbol">*</span><span class="normal">window</span><span class="symbol">;</span>
<span class="normal"> <a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html">GtkWidget</a> </span><span class="symbol">*</span><span class="normal">label</span><span class="symbol">;</span>
<span class="normal"> yes_or_no_args yes_args</span><span class="symbol">,</span><span class="normal"> no_args</span><span class="symbol">;</span>
<span class="normal"> pthread_t no_tid</span><span class="symbol">,</span><span class="normal"> yes_tid</span><span class="symbol">;</span>
<span class="normal"> </span><span class="comment">/* init threads */</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#g-thread-init">g_thread_init</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-init">gdk_threads_init</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-enter">gdk_threads_enter</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="comment">/* init gtk */</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-init">gtk_init</a></span><span class="symbol">(&</span><span class="normal">argc</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">argv</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* init random number generator */</span>
<span class="normal"> </span><span class="function">srand</span><span class="normal"> </span><span class="symbol">((</span><span class="type">unsigned</span><span class="normal"> </span><span class="type">int</span><span class="symbol">)</span><span class="normal"> </span><span class="function">time</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">));</span>
<span class="normal"> </span><span class="comment">/* create a window */</span>
<span class="normal"> window </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkWindow.html#gtk-window-new">gtk_window_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="http://library.gnome.org/devel/gtk/unstable/gtk-Standard-Enumerations.html#GTK-WINDOW-TOPLEVEL:CAPS">GTK_WINDOW_TOPLEVEL</a></span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Signals.html#g-signal-connect">g_signal_connect</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">window</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"destroy"</span><span class="symbol">,</span><span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#G-CALLBACK:CAPS">G_CALLBACK</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">destroy</span><span class="symbol">),</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkContainer.html#gtk-container-set-border-width">gtk_container_set_border_width</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">GTK_CONTAINER</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">window</span><span class="symbol">),</span><span class="normal"> </span><span class="number">10</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* create a label */</span>
<span class="normal"> label </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkLabel.html#gtk-label-new">gtk_label_new</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"And now for something completely different ..."</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkContainer.html#gtk-container-add">gtk_container_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">GTK_CONTAINER</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">window</span><span class="symbol">),</span><span class="normal"> label</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* show everything */</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-show">gtk_widget_show</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">label</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/GtkWidget.html#gtk-widget-show">gtk_widget_show</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">window</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* create the threads */</span>
<span class="normal"> yes_args</span><span class="symbol">.</span><span class="normal">label </span><span class="symbol">=</span><span class="normal"> label</span><span class="symbol">;</span>
<span class="normal"> yes_args</span><span class="symbol">.</span><span class="normal">what </span><span class="symbol">=</span><span class="normal"> YES_IT_IS</span><span class="symbol">;</span>
<span class="normal"> </span><span class="function">pthread_create</span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">yes_tid</span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> argument_thread</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">yes_args</span><span class="symbol">);</span>
<span class="normal"> no_args</span><span class="symbol">.</span><span class="normal">label </span><span class="symbol">=</span><span class="normal"> label</span><span class="symbol">;</span>
<span class="normal"> no_args</span><span class="symbol">.</span><span class="normal">what </span><span class="symbol">=</span><span class="normal"> NO_IT_IS_NOT</span><span class="symbol">;</span>
<span class="normal"> </span><span class="function">pthread_create</span><span class="normal"> </span><span class="symbol">(&</span><span class="normal">no_tid</span><span class="symbol">,</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS">NULL</a></span><span class="symbol">,</span><span class="normal"> argument_thread</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">no_args</span><span class="symbol">);</span>
<span class="normal"> </span><span class="comment">/* enter the GTK main loop */</span>
<span class="normal"> </span><span class="function"><a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-main">gtk_main</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-leave">gdk_threads_leave</a></span><span class="normal"> </span><span class="symbol">();</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="refsect1" title="Details">
<a name="gdk-Threads.details"></a><h2>Details</h2>
<div class="refsect2" title="GDK_THREADS_ENTER">
<a name="GDK-THREADS-ENTER:CAPS"></a><h3>GDK_THREADS_ENTER</h3>
<pre class="programlisting">#define GDK_THREADS_ENTER()</pre>
<p>
This macro marks the beginning of a critical section in which GDK and
GTK+ functions can be called safely and without causing race
conditions. Only one thread at a time can be in such a critial
section. The macro expands to a no-op if <a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#G-THREADS-ENABLED:CAPS"><span class="type">G_THREADS_ENABLED</span></a> has not
been defined. Typically <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a> should be used instead of
this macro.
</p>
</div>
<hr>
<div class="refsect2" title="GDK_THREADS_LEAVE">
<a name="GDK-THREADS-LEAVE:CAPS"></a><h3>GDK_THREADS_LEAVE</h3>
<pre class="programlisting">#define GDK_THREADS_LEAVE()</pre>
<p>
This macro marks the end of a critical section
begun with <a class="link" href="gdk-Threads.html#GDK-THREADS-ENTER:CAPS" title="GDK_THREADS_ENTER"><span class="type">GDK_THREADS_ENTER</span></a>.
</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_init ()">
<a name="gdk-threads-init"></a><h3>gdk_threads_init ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> gdk_threads_init (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Initializes GDK so that it can be used from multiple threads
in conjunction with <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a> and <a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a>.
<a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#g-thread-init"><code class="function">g_thread_init()</code></a> must be called previous to this function.
</p>
<p>
This call must be made before any use of the main loop from
GTK+; to be safe, call it before <a href="http://library.gnome.org/devel/gtk/unstable/gtk-General.html#gtk-init"><code class="function">gtk_init()</code></a>.
</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_enter ()">
<a name="gdk-threads-enter"></a><h3>gdk_threads_enter ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> gdk_threads_enter (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
This macro marks the beginning of a critical section in which GDK and
GTK+ functions can be called safely and without causing race
conditions. Only one thread at a time can be in such a critial
section.
</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_leave ()">
<a name="gdk-threads-leave"></a><h3>gdk_threads_leave ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> gdk_threads_leave (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Leaves a critical region begun with <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a>.
</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_mutex">
<a name="gdk-threads-mutex"></a><h3>gdk_threads_mutex</h3>
<pre class="programlisting">extern GMutex *gdk_threads_mutex; /* private */
</pre>
<div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Warning</h3>
<p><code class="literal">gdk_threads_mutex</code> is deprecated and should not be used in newly-written code.</p>
</div>
<p>
The <a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#GMutex"><span class="type">GMutex</span></a> used to implement the critical region for
<a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a>/<a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a>.
</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_set_lock_functions ()">
<a name="gdk-threads-set-lock-functions"></a><h3>gdk_threads_set_lock_functions ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span> gdk_threads_set_lock_functions (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GCallback"><span class="type">GCallback</span></a> enter_fn</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/gobject/gobject-Closures.html#GCallback"><span class="type">GCallback</span></a> leave_fn</code></em>);</pre>
<p>
Allows the application to replace the standard method that
GDK uses to protect its data structures. Normally, GDK
creates a single <a href="/usr/share/gtk-doc/html/glib/glib-Threads.html#GMutex"><span class="type">GMutex</span></a> that is locked by <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a>,
and released by <a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a>; using this function an
application provides, instead, a function <em class="parameter"><code>enter_fn</code></em> that is
called by <a class="link" href="gdk-Threads.html#gdk-threads-enter" title="gdk_threads_enter ()"><code class="function">gdk_threads_enter()</code></a> and a function <em class="parameter"><code>leave_fn</code></em> that is
called by <a class="link" href="gdk-Threads.html#gdk-threads-leave" title="gdk_threads_leave ()"><code class="function">gdk_threads_leave()</code></a>.
</p>
<p>
The functions must provide at least same locking functionality
as the default implementation, but can also do extra application
specific processing.
</p>
<p>
As an example, consider an application that has its own recursive
lock that when held, holds the GTK+ lock as well. When GTK+ unlocks
the GTK+ lock when entering a recursive main loop, the application
must temporarily release its lock as well.
</p>
<p>
Most threaded GTK+ apps won't need to use this method.
</p>
<p>
This method must be called before <a class="link" href="gdk-Threads.html#gdk-threads-init" title="gdk_threads_init ()"><code class="function">gdk_threads_init()</code></a>, and cannot
be called multiple times.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>enter_fn</code></em> :</span></p></td>
<td>function called to guard GDK
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>leave_fn</code></em> :</span></p></td>
<td>function called to release the guard
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_add_idle ()">
<a name="gdk-threads-add-idle"></a><h3>gdk_threads_add_idle ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> gdk_threads_add_idle (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>
A wrapper for the common usage of <a class="link" href="gdk-Threads.html#gdk-threads-add-idle-full" title="gdk_threads_add_idle_full ()"><code class="function">gdk_threads_add_idle_full()</code></a>
assigning the default priority, <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a>.
</p>
<p>
See <a class="link" href="gdk-Threads.html#gdk-threads-add-idle-full" title="gdk_threads_add_idle_full ()"><code class="function">gdk_threads_add_idle_full()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>function to call
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>function</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the ID (greater than 0) of the event source.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.12</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_add_idle_full ()">
<a name="gdk-threads-add-idle-full"></a><h3>gdk_threads_add_idle_full ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> gdk_threads_add_idle_full (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> priority</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
<p>
Adds a function to be called whenever there are no higher priority
events pending. If the function returns <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> it is automatically
removed from the list of event sources and will not be called again.
</p>
<p>
This variant of <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-idle-add-full"><code class="function">g_idle_add_full()</code></a> calls <em class="parameter"><code>function</code></em> with the GDK lock
held. It can be thought of a MT-safe version for GTK+ widgets for the
following use case, where you have to worry about <code class="function">idle_callback()</code>
running in thread A and accessing <em class="parameter"><code>self</code></em> after it has been finalized
in thread B:
</p>
<p>
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>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</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a></span>
<span class="function">idle_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> </span><span class="comment">/* gdk_threads_enter(); would be needed for g_idle_add() */</span>
<span class="normal"> SomeWidget </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span>
<span class="normal"> </span><span class="comment">/* do stuff with self */</span>
<span class="normal"> self</span><span class="symbol">-></span><span class="normal">idle_id </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="normal"> </span><span class="comment">/* gdk_threads_leave(); would be needed for g_idle_add() */</span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span>
<span class="cbracket">}</span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">some_widget_do_stuff_later</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">SomeWidget </span><span class="symbol">*</span><span class="normal">self</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> self</span><span class="symbol">-></span><span class="normal">idle_id </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="gdk-Threads.html#gdk-threads-add-idle">gdk_threads_add_idle</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">idle_callback</span><span class="symbol">,</span><span class="normal"> self</span><span class="symbol">)</span>
<span class="normal"> </span><span class="comment">/* using g_idle_add() here would require thread protection in the callback */</span>
<span class="cbracket">}</span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span>
<span class="function">some_widget_finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> </span><span class="symbol">*</span><span class="normal">object</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> SomeWidget </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> </span><span class="function">SOME_WIDGET</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-></span><span class="normal">idle_id</span><span class="symbol">)</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-source-remove">g_source_remove</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-></span><span class="normal">idle_id</span><span class="symbol">);</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#G-OBJECT-CLASS:CAPS">G_OBJECT_CLASS</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">parent_class</span><span class="symbol">)-></span><span class="function">finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
<td>the priority of the idle source. Typically this will be in the
range btweeen <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a> and <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS"><span class="type">G_PRIORITY_HIGH_IDLE</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>function to call
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>function</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
<td> function to call when the idle is removed, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>. </td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the ID (greater than 0) of the event source.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.12</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_add_timeout ()">
<a name="gdk-threads-add-timeout"></a><h3>gdk_threads_add_timeout ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> gdk_threads_add_timeout (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>
A wrapper for the common usage of <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout-full" title="gdk_threads_add_timeout_full ()"><code class="function">gdk_threads_add_timeout_full()</code></a>
assigning the default priority, <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS"><span class="type">G_PRIORITY_DEFAULT</span></a>.
</p>
<p>
See <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout-full" title="gdk_threads_add_timeout_full ()"><code class="function">gdk_threads_add_timeout_full()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
<td>the time between calls to the function, in milliseconds
(1/1000ths of a second)
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>function to call
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>function</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the ID (greater than 0) of the event source.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.12</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_add_timeout_full ()">
<a name="gdk-threads-add-timeout-full"></a><h3>gdk_threads_add_timeout_full ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> gdk_threads_add_timeout_full (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> priority</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
<p>
Sets a function to be called at regular intervals holding the GDK lock,
with the given priority. The function is called repeatedly until it
returns <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>, at which point the timeout is automatically destroyed
and the function will not be called again. The <em class="parameter"><code>notify</code></em> function is
called when the timeout is destroyed. The first call to the
function will be at the end of the first <em class="parameter"><code>interval</code></em>.
</p>
<p>
Note that timeout functions may be delayed, due to the processing of other
event sources. Thus they should not be relied on for precise timing.
After each call to the timeout function, the time of the next
timeout is recalculated based on the current time and the given interval
(it does not try to 'catch up' time lost in delays).
</p>
<p>
This variant of <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-timeout-add-full"><code class="function">g_timeout_add_full()</code></a> can be thought of a MT-safe version
for GTK+ widgets for the following use case:
</p>
<p>
</p>
<div class="informalexample">
<table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="listing_lines" align="right"><pre>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</pre></td>
<td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> </span><span class="function">timeout_callback</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer">gpointer</a> data</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> SomeWidget </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> data</span><span class="symbol">;</span>
<span class="normal"> </span>
<span class="normal"> </span><span class="comment">/* do stuff with self */</span>
<span class="normal"> </span>
<span class="normal"> self</span><span class="symbol">-></span><span class="normal">timeout_id </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="normal"> </span>
<span class="normal"> </span><span class="keyword">return</span><span class="normal"> <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#FALSE:CAPS">FALSE</a></span><span class="symbol">;</span>
<span class="cbracket">}</span>
<span class="normal"> </span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">some_widget_do_stuff_later</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">SomeWidget </span><span class="symbol">*</span><span class="normal">self</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> self</span><span class="symbol">-></span><span class="normal">timeout_id </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-timeout-add">g_timeout_add</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">timeout_callback</span><span class="symbol">,</span><span class="normal"> self</span><span class="symbol">)</span>
<span class="cbracket">}</span>
<span class="normal"> </span>
<span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">some_widget_finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a> </span><span class="symbol">*</span><span class="normal">object</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal"> SomeWidget </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> </span><span class="function">SOME_WIDGET</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
<span class="normal"> </span>
<span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-></span><span class="normal">timeout_id</span><span class="symbol">)</span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-source-remove">g_source_remove</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">self</span><span class="symbol">-></span><span class="normal">timeout_id</span><span class="symbol">);</span>
<span class="normal"> </span>
<span class="normal"> </span><span class="function"><a href="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#G-OBJECT-CLASS:CAPS">G_OBJECT_CLASS</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">parent_class</span><span class="symbol">)-></span><span class="function">finalize</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">object</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
</tr>
</tbody>
</table>
</div>
<p>
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
<td>the priority of the timeout source. Typically this will be in the
range between <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a> and <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS"><span class="type">G_PRIORITY_HIGH_IDLE</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
<td>the time between calls to the function, in milliseconds
(1/1000ths of a second)
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>function to call
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>function</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
<td> function to call when the timeout is removed, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>. </td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the ID (greater than 0) of the event source.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.12</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_add_timeout_seconds ()">
<a name="gdk-threads-add-timeout-seconds"></a><h3>gdk_threads_add_timeout_seconds ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> gdk_threads_add_timeout_seconds (<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>);</pre>
<p>
A wrapper for the common usage of <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout-seconds-full" title="gdk_threads_add_timeout_seconds_full ()"><code class="function">gdk_threads_add_timeout_seconds_full()</code></a>
assigning the default priority, <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT:CAPS"><span class="type">G_PRIORITY_DEFAULT</span></a>.
</p>
<p>
For details, see <a class="link" href="gdk-Threads.html#gdk-threads-add-timeout-full" title="gdk_threads_add_timeout_full ()"><code class="function">gdk_threads_add_timeout_full()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
<td>the time between calls to the function, in seconds
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>function to call
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>function</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the ID (greater than 0) of the event source.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
<hr>
<div class="refsect2" title="gdk_threads_add_timeout_seconds_full ()">
<a name="gdk-threads-add-timeout-seconds-full"></a><h3>gdk_threads_add_timeout_seconds_full ()</h3>
<pre class="programlisting"><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="returnvalue">guint</span></a> gdk_threads_add_timeout_seconds_full
(<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a> priority</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> interval</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#GSourceFunc"><span class="type">GSourceFunc</span></a> function</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> data</code></em>,
<em class="parameter"><code><a href="/usr/share/gtk-doc/html/glib/glib-Datasets.html#GDestroyNotify"><span class="type">GDestroyNotify</span></a> notify</code></em>);</pre>
<p>
A variant of <code class="function">gdk_threads_add_timout_full()</code> with second-granularity.
See <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#g-timeout-add-seconds-full"><code class="function">g_timeout_add_seconds_full()</code></a> for a discussion of why it is
a good idea to use this function if you don't need finer granularity.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>priority</code></em> :</span></p></td>
<td>the priority of the timeout source. Typically this will be in the
range between <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-DEFAULT-IDLE:CAPS"><span class="type">G_PRIORITY_DEFAULT_IDLE</span></a> and <a href="/usr/share/gtk-doc/html/glib/glib-The-Main-Event-Loop.html#G-PRIORITY-HIGH-IDLE:CAPS"><span class="type">G_PRIORITY_HIGH_IDLE</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>interval</code></em> :</span></p></td>
<td>the time between calls to the function, in seconds
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>function</code></em> :</span></p></td>
<td>function to call
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>data</code></em> :</span></p></td>
<td>data to pass to <em class="parameter"><code>function</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>notify</code></em> :</span></p></td>
<td> function to call when the timeout is removed, or <a href="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>. <acronym title="NULL is ok, both for passing and for returning."><span class="acronym">allow-none</span></acronym>. </td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the ID (greater than 0) of the event source.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.14</p>
</div>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.14</div>
</body>
</html>
|