2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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:
50 private import gtk
.gtktypes
;
52 private import lib
.gtk
;
57 * Before using GTK+, you need to initialize it; initialization connects
58 * to the window system display, and parses some standard command line
59 * arguments. The gtk_init() function initializes GTK+. gtk_init() exits
60 * the application if errors occur; to avoid this, use gtk_init_check().
61 * gtk_init_check() allows you to recover from a failed GTK+
62 * initialization - you might start up your application in text mode instead.
63 * Like all GUI toolkits, GTK+ uses an event-driven programming
64 * model. When the user is doing nothing, GTK+ sits in the
65 * main loop and waits for input. If the user
66 * performs some action - say, a mouse click - then the main loop "wakes
67 * up" and delivers an event to GTK+. GTK+ forwards the event to one or
69 * When widgets receive an event, they frequently emit one or more
70 * signals. Signals notify your program that
71 * "something interesting happened" by invoking functions you've
72 * connected to the signal with g_signal_connect(). Functions connected
73 * to a signal are often termed callbacks.
74 * When your callbacks are invoked, you would typically take some action
75 * - for example, when an Open button is clicked you might display a
76 * GtkFileSelectionDialog. After a callback finishes, GTK+ will return
77 * to the main loop and await more user input.
78 * Example1.Typical main function for a GTK+ application
80 * main (int argc, char **argv)
82 * /+* Initialize i18n support +/
84 * /+* Initialize the widget set +/
85 * gtk_init (argc, argv);
86 * /+* Create the main window +/
87 * mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
88 * /+* Set up our GUI elements +/
90 * /+* Show the application window +/
91 * gtk_widget_show_all (mainwin);
92 * /+* Enter the main event loop, and wait for user interaction +/
94 * /+* The user lost interest +/
97 * It's OK to use the GLib main loop directly instead of gtk_main(),
98 * though it involves slightly more typing. See GMainLoop in the GLib
104 /** Holds all idle delegates */
105 bit
delegate()[] idleListeners
;
106 /** our gtk idle ID */
110 * Creates a new idle cycle.
112 * interval = the idle in milieconds
113 * delegate() = the delegate to be executed
114 * fireNow = When true the delegate will be executed emmidiatly
117 this(bit
delegate() dlg
, bit fireNow
=false)
119 idleListeners
~= dlg
;
120 idleID
= gtk_idle_add(cast(GtkFunction
)&idleCallback
, this);
125 idleListeners
.length
= 0;
134 gtk_idle_remove(idleID
);
136 idleListeners
.length
= 0;
140 * Removes the idle from gtk
149 * Adds a new delegate to this idle cycle
154 public void addListener(bit
delegate() dlg
, bit fireNow
=false)
156 idleListeners
~= dlg
;
161 idleListeners
.length
= idleListeners
.length
- 1;
167 * The callback execution from glib
172 extern(C
) static bit
idleCallback(Idle idle
)
174 return idle
.callAllListeners();
178 * Executes all delegates on the execution list
181 private bit
callAllListeners()
183 bit runAgain
= false;
187 while ( i
<idleListeners
.length
)
189 if ( !idleListeners
[i
]() )
191 idleListeners
= idleListeners
[0..i
] ~ idleListeners
[i
+1..idleListeners
.length
];
239 * gtk_idle_add has been deprecated since version 2.4 and should not be used in newly-written code. Use g_idle_add() instead.
240 * Causes the mainloop to call the given function whenever no events with
241 * higher priority are to be processed. The default priority is
242 * GTK_PRIORITY_DEFAULT, which is rather low.
244 * The function to call.
246 * The information to pass to the function.
248 * a unique handle for this registration.
250 public static uint add(GtkFunction funct
, void* data
)
252 // guint gtk_idle_add (GtkFunction function, gpointer data);
253 return gtk_idle_add(funct
, data
);
258 * 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.
259 * Like gtk_idle_add() this function allows you to have a function called
260 * when the event loop is idle. The difference is that you can give a
261 * priority different from GTK_PRIORITY_DEFAULT to the idle function.
263 * The priority which should not be above G_PRIORITY_HIGH_IDLE.
264 * Note that you will interfere with GTK+ if you use a priority above
265 * GTK_PRIORITY_RESIZE.
267 * The function to call.
269 * Data to pass to that function.
271 * A unique id for the event source.
273 public static uint addPriority(int priority
, GtkFunction funct
, void* data
)
275 // guint gtk_idle_add_priority (gint priority, GtkFunction function, gpointer data);
276 return gtk_idle_add_priority(priority
, funct
, data
);
281 * 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.
282 * Like gtk_idle_add() this function allows you to have a function called
283 * when the event loop is idle. The difference is that you can give a
284 * priority different from GTK_PRIORITY_DEFAULT to the idle function.
286 * The priority which should not be above G_PRIORITY_HIGH_IDLE.
287 * Note that you will interfere with GTK+ if you use a priority above
288 * GTK_PRIORITY_RESIZE.
290 * The function to call.
292 * The marshaller to use instead of the function (if non-NULL).
294 * Data to pass to that function.
296 * Function to call when the timeout is destroyed or NULL.
298 * A unique id for the event source.
300 public static uint addFull(int priority
, GtkFunction funct
, GtkCallbackMarshal marshal
, void* data
, GtkDestroyNotify destroy
)
302 // guint gtk_idle_add_full (gint priority, GtkFunction function, GtkCallbackMarshal marshal, gpointer data, GtkDestroyNotify destroy);
303 return gtk_idle_add_full(priority
, funct
, marshal
, data
, destroy
);
308 * gtk_idle_remove has been deprecated since version 2.4 and should not be used in newly-written code. Use g_source_remove() instead.
309 * Removes the idle function with the given id.
311 * Identifies the idle function to remove.
313 public static void remove(uint idleHandlerId
)
315 // void gtk_idle_remove (guint idle_handler_id);
316 gtk_idle_remove(idleHandlerId
);
321 * 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.
322 * Removes the idle function identified by the user data.
324 * remove the idle function which was registered with this user data.
326 public static void removeByData(void* data
)
328 // void gtk_idle_remove_by_data (gpointer data);
329 gtk_idle_remove_by_data(data
);