Gtk Marries Ada: the GUI Technology Revolution
Total Page:16
File Type:pdf, Size:1020Kb
GtkGtk MarriesMarries AdaAda:: TheThe GUIGUI TechnologyTechnology RevolutionRevolution [email protected] OverviewOverview History of GtkAda GtkAda Features Why Gtk Rather Than Other Toolkits? Why GtkAda rather than Gtk+? GtkAdaGtkAda -- HistoryHistory á The GIMP – GNU Photoshop clone á The Gtk+ library – Becomes independent á GtkGlade: a Gtk+ GUI builder á Gnome: a desktop manager á GVD: the GNU Visual Debugger GtkAdaGtkAda FeaturesFeatures ááHigh-level binding to the Gtk+ library – object-oriented – type safety – small and efficient ááHighly portable – Unixes: Linux, Solaris, … – Windows NT ááNative GtkAdaGtkAda FeaturesFeatures (2)(2) ááEvent handling ááDrawing services – Lines, rectangles, … – OpenGL (3D graphics) ááStyle support ááLarge set of widgets GtkAdaGtkAda -- WidgetWidget setset á Two types of widgets – containers and visual objects á About 100 widgets are provided á High-level widgets – notebook, text widget, tree, spin button, table, toolbar, ... GtkAdaGtkAda -- ScreenshotsScreenshots á Ctree GtkAdaGtkAda -- ScreenshotsScreenshots (2)(2) á OpenGL WhyWhy Gtk+?Gtk+? á Portable á Native á Extensible á Open Source á Actively developped á Thread-safe WhyWhy Gtk+?Gtk+? (2)(2) á High level widgets á Easy to use scrolling capabilities á Wide range of users á Very powerful layout capabilities – Complete set of containers á Powerful and easy to use GUI builder á Easy to bind TheThe GUIGUI BuilderBuilder ááMulti-language GUI builder – Language-independent save file (XML). – Code-generation specific to each language. – Dynamic loading of XML files WhyWhy GtkAda?GtkAda? á Compile time checks á Real Object Oriented hierarchy á Code readability á Group most popular Gtk widgets á Can create new types and extend widgets á More extensive documentation GtkAdaGtkAda vsvs Gtk+:Gtk+: ExampleExample #include <gtk/gtk.h> with Gtk.Main; use Gtk.Main; #include <gtk/gtk.h> withwithGtk.Button;Gtk.Main; useuseGtk.Button;Gtk.Main; *HQHULFZLGJHW withwithGtk.Window;Gtk.Button; useuseGtk.Window;Gtk.Button; void main (int argc, 7\SHG:LGJHWwithwithGtk.Enums;Gtk.Window; useuseGtk.Enums;Gtk.Window; void main (charint *argv[])argc, with Gtk.Enums; use Gtk.Enums; { char *argv[]) procedure Hello is {GtkWidget *window; procedureWindow :Hello Gtk_Window; is GtkWidgetGtkWidget *button;*window;8QLTXHQDPHVSDFH ButtonWindow :8VHFODXVHV: Gtk_Button;Gtk_Window; GtkWidget *button; beginButton : Gtk_Button; gtk_init (&argc, &argv); beginInit; windowgtk_init = gtk_window_new(&argc, &argv); (GTK_WINDOW_TOPLEVEL); Gtk_NewInit; (Window, Window_Toplevel); gtk_container_set_border_widthwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL); Set_Border_WidthGtk_New (Window, (Window,Window_Toplevel); 10); gtk_container_set_border_width(GTK_CONTAINER (window), 10); Set_Border_Width (Window, 10); button(GTK_CONTAINER = gtk_button_new_with_label (window), 10); ("Hello World"); Gtk_New (Button, "Hello World"); gtk_container_addbutton = gtk_button_new_with_label (GTK_CONTAINER (window), ("Hello button);World"); AddGtk_New (Window, (Button, Button); "Hello World"); gtk_widget_show_allgtk_container_add (GTK_CONTAINER (window); (window), button); Show_AllAdd (Window,%XLOW (Window); Button);LQ22 gtk_maingtk_widget_show_all ();1RGLVSDWFKLQJ (window); Main;Show_All (Window); } gtk_main (); end Main;Hello; } end Hello; GUIGUI BuilderBuilder SupportSupport withwith GtkAdaGtkAda ááSupport built-in ááTakes advantage of object-oriented features. – Each widget generates its own code ááGenerated sources – easy to read sources (generates new composite widgets) – sources can be modified and regenerated GtkAdaGtkAda:: aa completecomplete GUIGUI SolutionSolution ááPortable ááNative ááEasy to use ááSafe ááObject Oriented ááComes with a GUI builder ááSame look-and-feel.