Overview | Comparisons | Discuss |
Examples | GTK | Injection |
Install | Library | Logging |
Nulls | Plans | Syntax |
Types |
The Delight standard library includes support for creating graphical applications using GTK. A simple Hello World program:
import dlt.gtk: *
class Main:
in Gtk gtk
void main(string[] args):
args = gtk.init_check(args)
auto window = gtk.gtkWindow()
auto label = gtk.gtkLabel("Hello world")
window.add(label)
window.show_all()
gtk.main()
Note that you must link GTK programs with the -ldltgtk option.
D provides two libraries for GTK. BCD provides low-level C-style bindings, which GtkD wraps GTK objects in D objects to provide a nicer API.
Delight, instead, adds a new external linkage type for GObject. For example:
extern (GObject):
interface GtkWidget:
void show()
interface GtkWindow extends GtkWidget:
void set_title(const(char) *title)
GtkWindow gtk_window_new(int type)
void gtk_init(int*? argc, char**? argv)
void gtk_main()
class Main:
void main():
gtk_init(null, null)
GtkWindow window = gtk_window_new(0)
window.set_title("GObject demo")
window.show()
gtk_main()
No wrapping is done here. When you call window.show, Delight searches the GtkWindow and GtkWidget interfaces (at compile time) to find the show method. Due to the GObject linkage, this turns into a call to the C symbol gtk_widget_show.
Advantages:
Disadvantages:
So, it may be worth wrapping the objects anyway. However, GtkD doesn't work with GDC currently.
Overview | Comparisons | Discuss |
Examples | GTK | Injection |
Install | Library | Logging |
Nulls | Plans | Syntax |
Types |