• GTK (GIMP Toolkit) Is a Library for Creating Graphical User Interfaces

• GTK (GIMP Toolkit) Is a Library for Creating Graphical User Interfaces

GTK+ • GTK (GIMP Toolkit) is a library for creating graphical user interfaces. • It is licensed using the LGPL license, – so you can develop open software, free software, or even commercial non-free software using GTK without having to spend anything for licenses or royalties. C interface to GTK • The GTK interface is in C • Using C++ with GTK – First, you can use only the C subset of C++ when interfacing with GTK and then use the C interface. – Second, you can use GTK and C++ together by declaring all callbacks as static functions in C++ classes, and again calling GTK using its C interface. GtkWidgets • Familiar GUI components like –Window –Menus –Frame – Buttons –Labels – Slider – Scrollbars – Dialogs – File selectors –Etc. Signal, event, and Callback • Widgets fires signals and events. • Client register callbacks for events and signals fired by widgets • Callbacks handle these signals by invoking domain processing Hello, world • gtk_init (&argc, &argv); – Initialize the GTK lib – Should be the first line before any other GTK related API call. • window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_show (window); – create and display a window – Default window w/o children sized to 200x200. • gtk_main (); – enters the GTK main processing loop – When control reaches this point, GTK will sleep waiting for X events (such as button or key presses), timeouts, or file IO notifications to occur. – In our simple example, however, events are ignored. HelloGTK • g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL); – delete_event Ù X – If delete_event returns FALSE, destroy signal issued. • g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (destroy), NULL); – Register callback “destroy” HelloGTKObject • Wrap all callbacks as static member functions of “controller” classes – Why static? Since callbacks must be registered prior to being called by the main loop – Static mf allows the registration to be done without object • Wrap widgets into “view” classes – Register callbacks in view constructors – To hide GtkWidget details.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    10 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us