Created
February 14, 2019 11:55
-
-
Save jonathanballs/7697041eedc295b5ebc4af3fc441d146 to your computer and use it in GitHub Desktop.
GtkD tick callbacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This file is part of gtkD. | |
* | |
* gtkD is free software; you can redistribute it and/or modify | |
* it under the terms of the GNU Lesser General Public License as published by | |
* the Free Software Foundation; either version 3 of the License, or | |
* (at your option) any later version. | |
* | |
* gtkD is distributed in the hope that it will be useful, | |
* but WITHOUT ANY WARRANTY; without even the implied warranty of | |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
* GNU Lesser General Public License for more details. | |
* | |
* You should have received a copy of the GNU Lesser General Public License | |
* along with gtkD; if not, write to the Free Software | |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA | |
*/ | |
module gtk.HelloWorld; | |
import std.stdio; | |
import gio.Application : GioApplication = Application; | |
import gtk.Application; | |
import gtk.ApplicationWindow; | |
import gtk.Label; | |
import gtk.Widget; | |
import gdk.FrameClock; | |
class HelloWorld : ApplicationWindow | |
{ | |
this(Application application) | |
{ | |
super(application); | |
setTitle("GtkD"); | |
setBorderWidth(10); | |
auto label = new Label("Hello World"); | |
add(label); | |
// First callback | |
this.addTickCallback(delegate bool(Widget w, FrameClock f) { | |
writeln("Callback 1"); | |
return true; | |
}); | |
// Second callback | |
this.addTickCallback(delegate bool(Widget w, FrameClock f) { | |
writeln("Callback 2"); | |
return true; | |
}); | |
// Callback from a different widget | |
label.addTickCallback(delegate bool(Widget w, FrameClock f) { | |
writeln("Callback 3"); | |
return true; | |
}); | |
// Callback that should only get called once | |
label.addTickCallback(delegate bool(Widget w, FrameClock f) { | |
writeln("Callback 4"); | |
return false; | |
}); | |
showAll(); | |
} | |
} | |
int main(string[] args) | |
{ | |
auto application = new Application("org.gtkd.demo.helloworld", GApplicationFlags.FLAGS_NONE); | |
application.addOnActivate(delegate void(GioApplication app) { new HelloWorld(application); }); | |
return application.run(args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment