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 idle delegates */
118 bool delegate()[] idleListeners
;
119 /** our gtk idle ID */
123 * Creates a new idle cycle.
125 * interval = the idle in milieconds
126 * delegate() = the delegate to be executed
127 * fireNow = When true the delegate will be executed emmidiatly
130 this(bool delegate() dlg
, bool fireNow
=false)
132 idleListeners
~= dlg
;
133 idleID
= gtk_idle_add(cast(GtkFunction
)&idleCallback
, cast(void*)this);
138 idleListeners
.length
= 0;
147 gtk_idle_remove(idleID
);
149 idleListeners
.length
= 0;
153 * Removes the idle from gtk
162 * Adds a new delegate to this idle cycle
167 public void addListener(bool delegate() dlg
, bool fireNow
=false)
169 idleListeners
~= dlg
;
174 idleListeners
.length
= idleListeners
.length
- 1;
180 * The callback execution from glib
185 extern(C
) static bool idleCallback(Idle idle
)
187 return idle
.callAllListeners();
191 * Executes all delegates on the execution list
194 private bool callAllListeners()
196 bool runAgain
= false;
200 while ( i
<idleListeners
.length
)
202 if ( !idleListeners
[i
]() )
204 idleListeners
= idleListeners
[0..i
] ~ idleListeners
[i
+1..idleListeners
.length
];
252 * gtk_idle_add has been deprecated since version 2.4 and should not be used in newly-written code. Use g_idle_add() instead.
253 * Causes the mainloop to call the given function whenever no events with
254 * higher priority are to be processed. The default priority is
255 * GTK_PRIORITY_DEFAULT, which is rather low.
257 * The function to call.
259 * The information to pass to the function.
261 * a unique handle for this registration.
263 public static uint add(GtkFunction funct
, void* data
)
265 // guint gtk_idle_add (GtkFunction function, gpointer data);
266 return gtk_idle_add(funct
, data
);
271 * gtk_idle_add_priority has been deprecated since version 2.4 and should not be used in newly-written code. Use g_idle_add_full() instead.
272 * Like gtk_idle_add() this function allows you to have a function called
273 * when the event loop is idle. The difference is that you can give a
274 * priority different from GTK_PRIORITY_DEFAULT to the idle function.
276 * The priority which should not be above G_PRIORITY_HIGH_IDLE.
277 * Note that you will interfere with GTK+ if you use a priority above
278 * GTK_PRIORITY_RESIZE.
280 * The function to call.
282 * Data to pass to that function.
284 * A unique id for the event source.
286 public static uint addPriority(int priority
, GtkFunction funct
, void* data
)
288 // guint gtk_idle_add_priority (gint priority, GtkFunction function, gpointer data);
289 return gtk_idle_add_priority(priority
, funct
, data
);
294 * gtk_idle_add_full has been deprecated since version 2.4 and should not be used in newly-written code. Use g_idle_add_full() instead.
295 * Like gtk_idle_add() this function allows you to have a function called
296 * when the event loop is idle. The difference is that you can give a
297 * priority different from GTK_PRIORITY_DEFAULT to the idle function.
299 * The priority which should not be above G_PRIORITY_HIGH_IDLE.
300 * Note that you will interfere with GTK+ if you use a priority above
301 * GTK_PRIORITY_RESIZE.
303 * The function to call.
305 * The marshaller to use instead of the function (if non-NULL).
307 * Data to pass to that function.
309 * Function to call when the timeout is destroyed or NULL.
311 * A unique id for the event source.
313 public static uint addFull(int priority
, GtkFunction funct
, GtkCallbackMarshal marshal
, void* data
, GtkDestroyNotify destroy
)
315 // guint gtk_idle_add_full (gint priority, GtkFunction function, GtkCallbackMarshal marshal, gpointer data, GtkDestroyNotify destroy);
316 return gtk_idle_add_full(priority
, funct
, marshal
, data
, destroy
);
321 * gtk_idle_remove has been deprecated since version 2.4 and should not be used in newly-written code. Use g_source_remove() instead.
322 * Removes the idle function with the given id.
324 * Identifies the idle function to remove.
326 public static void remove(uint idleHandlerId
)
328 // void gtk_idle_remove (guint idle_handler_id);
329 gtk_idle_remove(idleHandlerId
);
334 * gtk_idle_remove_by_data has been deprecated since version 2.4 and should not be used in newly-written code. Use g_idle_remove_by_data() instead.
335 * Removes the idle function identified by the user data.
337 * remove the idle function which was registered with this user data.
339 public static void removeByData(void* data
)
341 // void gtk_idle_remove_by_data (gpointer data);
342 gtk_idle_remove_by_data(data
);