2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
55 import tango
.io
.Stdout
; // use the tango loging?
59 private import gtkc
.gtktypes
;
61 private import gtkc
.gtk
;
70 * Before using GTK+, you need to initialize it; initialization connects
71 * to the window system display, and parses some standard command line
72 * arguments. The gtk_init() function initializes GTK+. gtk_init() exits
73 * the application if errors occur; to avoid this, use gtk_init_check().
74 * gtk_init_check() allows you to recover from a failed GTK+
75 * initialization - you might start up your application in text mode instead.
76 * Like all GUI toolkits, GTK+ uses an event-driven programming
77 * model. When the user is doing nothing, GTK+ sits in the
78 * main loop and waits for input. If the user
79 * performs some action - say, a mouse click - then the main loop "wakes
80 * up" and delivers an event to GTK+. GTK+ forwards the event to one or
82 * When widgets receive an event, they frequently emit one or more
83 * signals. Signals notify your program that
84 * "something interesting happened" by invoking functions you've
85 * connected to the signal with g_signal_connect(). Functions connected
86 * to a signal are often termed callbacks.
87 * When your callbacks are invoked, you would typically take some action
88 * - for example, when an Open button is clicked you might display a
89 * GtkFileSelectionDialog. After a callback finishes, GTK+ will return
90 * to the main loop and await more user input.
91 * Example1.Typical main function for a GTK+ application
93 * main (int argc, char **argv)
95 * /+* Initialize i18n support +/
97 * /+* Initialize the widget set +/
98 * gtk_init (argc, argv);
99 * /+* Create the main window +/
100 * mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
101 * /+* Set up our GUI elements +/
103 * /+* Show the application window +/
104 * gtk_widget_show_all (mainwin);
105 * /+* Enter the main event loop, and wait for user interaction +/
107 * /+* The user lost interest +/
110 * It's OK to use the GLib main loop directly instead of gtk_main(),
111 * though it involves slightly more typing. See GMainLoop in the GLib
117 /** Holds all timeout delegates */
118 bool delegate()[] timeoutListeners
;
119 /** our gtk timeout ID */
124 * Creates a new timeout cycle.
126 * interval = the timeout in milieconds
127 * delegate() = the delegate to be executed
128 * fireNow = When true the delegate will be executed emmidiatly
131 this(uint interval
, bool delegate() dlg
, bool fireNow
=false)
133 timeoutListeners
~= dlg
;
134 timeoutID
= gtk_timeout_add(interval
, cast(GtkFunction
)&timeoutCallback
, cast(void*)this);
139 timeoutListeners
.length
= 0;
148 gtk_timeout_remove(timeoutID
);
150 timeoutListeners
.length
= 0;
154 * Removes the timeout from gtk
163 * Adds a new delegate to this timeout cycle
168 public void addListener(bool delegate() dlg
, bool fireNow
=false)
170 timeoutListeners
~= dlg
;
175 timeoutListeners
.length
= timeoutListeners
.length
- 1;
181 * The callback execution from glib
186 extern(C
) static bool timeoutCallback(Timeout timeout
)
188 return timeout
.callAllListeners();
192 * Executes all delegates on the execution list
195 private bool callAllListeners()
197 bool runAgain
= false;
201 while ( i
<timeoutListeners
.length
)
203 if ( !timeoutListeners
[i
]() )
205 timeoutListeners
= timeoutListeners
[0..i
] ~ timeoutListeners
[i
+1..timeoutListeners
.length
];
250 * gtk_timeout_add_full has been deprecated since version 2.4 and should not be used in newly-written code. Use g_timeout_add_full() instead.
251 * Registers a function to be called periodically. The function will be called
252 * repeatedly after interval milliseconds until it returns FALSE at which
253 * point the timeout is destroyed and will not be called again.
255 * The time between calls to the function, in milliseconds
256 * (1/1000ths of a second.)
258 * The function to call periodically.
260 * The marshaller to use instead of the function (if non-NULL).
262 * The data to pass to the function.
264 * Function to call when the timeout is destroyed or NULL.
266 * A unique id for the event source.
268 public static uint addFull(uint interval
, GtkFunction funct
, GtkCallbackMarshal marshal
, void* data
, GtkDestroyNotify destroy
)
270 // guint gtk_timeout_add_full (guint32 interval, GtkFunction function, GtkCallbackMarshal marshal, gpointer data, GtkDestroyNotify destroy);
271 return gtk_timeout_add_full(interval
, funct
, marshal
, data
, destroy
);
276 * gtk_timeout_add has been deprecated since version 2.4 and should not be used in newly-written code. Use g_timeout_add() instead.
277 * Registers a function to be called periodically. The function will be called
278 * repeatedly after interval milliseconds until it returns FALSE at which
279 * point the timeout is destroyed and will not be called again.
281 * The time between calls to the function, in milliseconds
282 * (1/1000ths of a second.)
284 * The function to call periodically.
286 * The data to pass to the function.
288 * A unique id for the event source.
290 public static uint add(uint interval
, GtkFunction funct
, void* data
)
292 // guint gtk_timeout_add (guint32 interval, GtkFunction function, gpointer data);
293 return gtk_timeout_add(interval
, funct
, data
);
298 * gtk_timeout_remove has been deprecated since version 2.4 and should not be used in newly-written code. Use g_source_remove() instead.
299 * Removes the given timeout destroying all information about it.
300 * timeout_handler_id:
301 * The identifier returned when installing the timeout.
303 public static void remove(uint timeoutHandlerId
)
305 // void gtk_timeout_remove (guint timeout_handler_id);
306 gtk_timeout_remove(timeoutHandlerId
);