| Previous | Next |
What follows is a listing of the more commonly used widgets, and some of the gtk functions that are used with their elements. None of these have any of the function parameters listed, and not all the functions for each widget are listed. For these please refer to the pages linked to in the library section of this tutorial.
Note that the following is NOT an exhaustive list of widgets. There are widgets available with different libraries that aren't included in Glade. There are also a few Gtk+ widgets which are so self explantory (ie vertical and horizonal separators), that they weren't included here.
| Gtk+ Basic Widgets | |||
|---|---|---|---|
| Image | Name | Purpose | Functions and Considerations |
| Window | Basic Gtk Window | No specific functions coder needs to take care of, but if this is the main window you do need to attach a gtk_exit() to the delete_event signal (ie when they click the x in the top righthand corner). | |
| Dialog WIndow | creates a basic dialog box/window | There are no specific functions for this. You'll have to add the buttons to the buttonbar and whatever else you want. | |
| File Selection Dialog | creates a standardized file selection dialog window | The internal workings are handled by the widget. You'll need to connect signals to the buttons (ie the clicked signal), as well as grab the selection. | |
| Color Selection Dialog | A dialog window for selecting colors | This creates a standardized color selection dialog box/window. You'll have to make all the buttons work, and grab the selection with gtk_color_selection_get_color(). | |
| Font Selection Dialog | A dialog window for selecting fonts | This is a standardized dialog box/window, for selecting fonts. You'll need to grab the selection and set up the buttons, as usual. Use gtk_get_font_selection_dialog_get_font() for this. There are other functions for getting the font's name and so on. See the GTK+ Reference Manual listed in the help section of this tutorial. | |
| Menu Bar | Creates a Menu Bar | You will have to create handlers for all the activate signals for the dropdown menus. There is a menu editor in Glade to help you do this, and see the menu editor section of this tutorial for a guide. | |
| Toolbar | Creates a Tool Bar | You will have to attach handlers to the buttons (clicked signal usually). Also you'll have to supply icons (or use the standard ones) and names for the buttons. Do this in the properties window for each button. | |
| Label | creates a label widget | There are generally no signals here. This allows you to put labels into your creations. | |
| Text Entry | allows entry of a single line of text | use gtk_entry_set_text(), gtk_editable_get_chars(), gtk_entry_set_editable() and other functions to manipulate the text in this single line box. These are commonly used upon activate and changed signals. With the changed signal, set a flag, and grab the entry data later (ie when an ok button is clicked). | |
| ComboBox | creates a text entry box with dropdown entries | Use this box, or the Gnome entry, to create dropdown lists of entries. Gnome entry manages this list for you, with ComboBox you'll have to manage it yourself. Use the text entry functions with this, as well as specific combobox ones: gtk_combo_set_value_in_list() etc. | |
| Text View | A multi-line text editor | This widget has changed substantially from Gtk+ 1.*. To use it you create a GtkTextBuffer, which is the text being edited, and show it in the GtkTextView. In a very simple application you get the buffer with gtk_text_view_get_buffer(), and set it with gtk_text_view_set_buffer(). The buffer itself emits signals, such as changed, insert_text etc. The view also emits signals such as copy_clipboard, move_focus, etc. | |
| Button | A basic button | With this, and all buttons, the signal most commonly used is the clicked signal, although you can also use enter, leave, pressed, released, etc. There are no particular functions to use to get data here, but often times you will want the button to eventually destroy its parent window. Use gtk_widget_destroy() for this. | |
| Toggle Button | A basic toggle button | This button is meant for use with variables/entities that have two states, on/off, 0/1 etc. It has a special signal, toggled, as well as all the normal button signals. | |
| Check Button | A check button (toggle with a label) | This is a toggle button, so again it has two states (on/off etc). This button also has a label, making it a labeled toggle button. You can use the toggled signal with it. | |
| Radio Button | A radio toggle button | This is a special kind of check button. Radio buttons are grouped together, and when one is picked all the others turn 'off', or are deselected. This allows the coder to let the user select one from a list of however many items. The signal here is toggled, of course. In the Properties window you will have to set the 'group' of the radio button, as well as its label. | |
| Option Menu | creates a menu from which a user can choose one option | Common signals are clicked, enter, leave, pressed, etc. Functions include gtk_option_menu_get_menu(), gtk_option_menu_set_menu(), etc. There is an example of how to link a handler to this widget later in this tutorial. | |
| Spin Button | A button that increments a counter | This is a useful way to get numbers from a user, numbers that are within a set range, and are always numeric (if you set the numeric value to TRUE in the properties window). You can also set the range, the increment, and the start value. The changed and activate signals can be used to retrieve the data within the spinbutton entry. Use gtk_spin_button_get_value_as_float(), or gtk_spin_button_get_value_as_int(), for example. (Remember to set a flag with the changed signal and retrieve the data later (ie when an ok button is clicked)). | |
| Status Bar | A place to put status messages | This bar is usually found at the bottom of a window, and is a place that indicates program actions. For instance, if the user clicks on a button to save a file, you can write 'File Saved' here. Use the gtk_statusbar_push(), gtk_statusbar_pop() functions, among others, with this. | |
| List or Tree View | a widget for displaying both trees and lists | This is a new widget for Gtk+ 2.0, replacing the ctree, clist, list and tree widgets that were previously used. It is a bit complicated in theory, but simple in practice. See the API for more information, but basically you create a list or tree model, and view it in the list/tree view. | |
| Gtk Image | shows an image | This is a no window widget, it doesn't receive events, it is simply for displaying an image/animation/whatever. | |
| Drawing Area | A place to create custom widgets | Use this widget to create custom widgets, to draw things (like graphs), etc. | |
| Gtk Containers | |||
| Handle Box | creates a container box which can be moved by the handle | No signals here, they are handled internally with the container box. The box is one of those 'rip away' boxes which you can use to create menus that the user can move around the screen as she wishes. | |
| Horizontal Box | creates a series of boxes to put widgets | This a container, you can associate signals if you wish, but they aren't needed. No, I don't know why it's called a horizontal box when it's aligned vertically, except that numerically it runs horizontally (ie a line of numbers, one for each box). | |
| Vertical Box | creates a series of boxes to put widgets | This is a container, you can associate signals if you wish, but they aren't needed. | |
| Table Box | creates a series of boxes in a table format | This is a container, you can associate signals if you wish, but they aren't needed. | |
| Gtk Fixed | allows you to fix the position of widgets within the container | This container shouldn't really be used. It's comfortable for those coming from a VB background, but it prevents you from learning how to properly use containers in Gtk+. Avoid it if at all possible. | |
| Horizontal ButtonBox | a horizontally laid out button box | This box is meant to contain buttons. | |
| Vertical ButtonBox | a vertically laid out button box | This box is meant to contain buttons. | |
| Horizontal Pane | creates a 'pane' that the user can grab to enlarge or shrink elements in a window | This is a container, you can associate signals if you wish, but they aren't needed. The resizing elements are internal. | |
| Vertical Pane | crealtes a 'pane' that the user can grab to enlarge or shrink elements in a window | This a container, you can associate signals if you wish, but they aren't needed. The resizing elements are internal. | |
| Notebook | This creates a series of 'file folder' boxes, where if the user clicks on a tab, it can change the page layout | This is a series of containers, you can associate signals if you wish, but they aren't needed. One thing you will want to do is either label the tabs, or if you wish to use this widget to create an easy 'changing' layout, decide not to show the tabs. | |
| Frame | This creates a frame, which can be labeled | This is a container, you can associate signals if you wish, but they aren't needed. Remember to label the frame, if that is what you want. | |
| Scrolled Window | A scrolled window widget | This is a container, you can associated signals if you wish, the scrolling should be taken care of automatically. | |
| Gtk Viewport | creates a viewport | The writer is not experience with this widget. See the API. |
| Previous | Next |