Merge: Intro `Task` and use in for Android's `run_on_ui_thread`
[nit.git] / lib / gtk / v3_4 / gdk.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Services from GDK
16 module gdk is pkgconfig "gtk+-3.0"
17
18 import gtk_core
19
20 `{
21 #ifdef GdkCallback_run
22 // Callback to GdkCallaback::run
23 gboolean nit_gdk_callback(gpointer user_data) {
24 GdkCallback_decr_ref(user_data);
25 return GdkCallback_run(user_data);
26 }
27 #endif
28 `}
29
30 # Callback to pass to `gdk_threads_add_idle`
31 class GdkCallback
32
33 # Small unit of code executed by the GDK loop when idle
34 #
35 # Returns true if this object should be invoked again.
36 fun run: Bool do return false
37 end
38
39 # Add a callback to execute whenever there are no higher priority events pending
40 fun gdk_threads_add_idle(callback: GdkCallback): Int import GdkCallback.run `{
41 GdkCallback_incr_ref(callback);
42 return gdk_threads_add_idle(&nit_gdk_callback, callback);
43 `}