Basics of gtk_ilugc

1,137 views

Published on

Basics of GTK Programming in C Session by Karthik at Indian Linux Users Group, Chennai Monthly meet.
http://www.ilugc.in/content/ilugc-monthly-meet-december-11-th

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,137
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
61
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Basics of gtk_ilugc

  1. 1. Basic GTK+ & GUI Designing K. Karthikeyan CDAC, Chennai
  2. 2. Introduction● Linux Desktop Environments – GNOME, KDE – KDEs dependency on Qt drives towards GNOME● GIMP - GNU Image Manipulation Program – Peter Mattis, Spencer Kimball, to replace motif – GIMP Tool Kit(GTK) – Object Oriented and renamed as GTK+
  3. 3. GTK+Cross platform graphical tool kit, used by GNOMEapplications.Part of GNU project, LGPLWritten in C and Language Bindings for– C++ gtkmm– Python pygtk– PHP php-gtk etc.,Latest stable version gtk+ 2.22.0
  4. 4. GTK+ and Supporting Libraries Glib – General Purpose utility library, Provides Cross platform interfaces, Abstract Data types Gobject – Provides Data types, signals, Object oriented Interfaces GDK – Graphics Library for X window system GdkPixbuf – provides functions for client side image manipulation Pango – Font and layout rendering ATK – Accessibility Tool Kit
  5. 5. GTK+ Widget HierarchyGtkObject GtkWidget GtkContainer GtkBin GtkWindow
  6. 6. What we need..● GCC compiler● Editor● Gtk+ and its dependent packages – libgtk2.0-dev, libgtk2.0-0, libglib2.0-dev, ...● Pkg-config package● How to check ● $pkg-config - -cflags gtk+-2.0 ● $pkg-config - -libs gtk+-2.0
  7. 7. GTK+ hello world window/*hello.c */#include <gtk/gtk.h>int main(int argc, char *argv[ ]){GtkWidget *window;gtk_init (&argc, &argv); /* Initialization */window = gtk_window_new (GTK_WINDOW_TOPLEVEL);gtk_window_set_title(GTK_WINDOW(window),"Hello World");gtk_widget_show(window);gtk_main (); /* Main Event loop */return 0;}
  8. 8. How to compile & Run “hello.c”● To Compile “gcc -Wall program.c -o executable_name `pkg- config --cflags --libs gtk+-2.0` “ -Wall - Enable all types of compiler warnings● To Run ./executable_name
  9. 9. Hands on... :)
  10. 10. Signal Connection & Callback function● Connecting a signal with a function g_signal_connect(gpointer, “signal name”, callback_handler, gpointer);● Callback function format return_type callback_function(GtkWidget *, ... ,gpointer)
  11. 11. Basic Widgets and Initialization● Label - gtk_label_new()● Buttons - gtk_button_new() and more● Box - gtk_hbox_new(), gtk_vbox_new()● Pane - gtk_hpane_new(), gtk_vpane_new()● Table - gtk_table_new()● Expander - gtk_expander_new() and more● Notebooks- gtk_note_book_new()
  12. 12. Basic Widgets and Initialization● Stock_Buttons● Toggle Button – 1. Toggle Button 2. Radio button 3. Check button● Text Entry – 1. Text Entry 2. Spin button● Scale – 1. Horizontal scale 2. Vertical scale
  13. 13. Some Important functions● GtkWidget ● gtk_widget_set_size_request ● gtk_widget_grab_focus ● gtk_widget_set_sensitive ● gtk_widget_destroy● GtkWindow ● gtk_window_set_default_size ● gtk_window_move ● gtk_window_resizable
  14. 14. Resources & References● Books ● Foundations of GTK+ Development – by Andrew Krause ● The Offical GNOME 2 Developers Guide -by Matthias Warkus● IRC Channels ● Server --> irc.gnome.org ● Channels – #gtk+, #gnome-india, #gnome-love, #nosip ...● Websites library.gnome.org, en.wikipedia.org, ...
  15. 15. Thank You.... !karthikeyank@cdacchn.inkarthikk5phy@gmail.com To Tweet : @karthik2u

×