| Previous | Up | Next |
Glade builds the code to create the windows and boxes and popups you design into interface.c. As mentioned before, don't alter this file, Glade rewrites it every time you build the source code. There is really no reason to alter it, frankly. All the window, etc creation functions are named create_windowname() using whatever name you gave to the window. All the elements you put into the window, in containers etc, are created with this function.
To refer to the elements within a window use either lookup_widget() (a function supplied in support.c), gtk_widget_get_toplevel(), or a key scheme with gtk_object_set_data() and gtk_object_get_data(). If this doesn't make much sense right now, read on, especially the example near the end of this tutorial.
In callbacks.c you attach the handlers you designated in the properties window of Glade to actual backend code. 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 help 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 Glade widgets which are so self explantory (ie vertical and horizonal seperators), that they weren't included here.
| Gtk+ Basic | |||
|---|---|---|---|
| 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 Box | A multi-line, scrollbarred text box | Gtk functions for text boxes include gtk_editable_get_chars(), gtk_text_thaw(), gtk_text_freeze(), gtk_text_insert() and others. Signals are all those used with text, changed, activate, delete_text, insert_text, etc 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. | |
| List | creates a list, each element in the list can be manipulated | Common signals here are select_child, selection_changed, unselect_child. Functions include gtk_list_insert_items(), gtk_list_append_items(), gtk_list_remove_items(), gtk_list_select_item(), etc. | |
| Tree | creates a 'tree' of data, each element can be manipulated | Signals are the same as used for the list widget, as all as all the common 'widget' signals. Functions include gtk_tree_insert(), gtk_tree_remove_items(), gtk_tree_append(), etc. | |
| Columned List | A multiple column list | This widget allows lists in columns (ie a file selection list which shows ownership and creation data as well as filename). You will need to specify the select mode in the properties window. This mode indicates whether only one or many items can be selected at once from the window (default is single). GtkCList has many signals and is a complicated widget. Please see the Gtk+ Reference Manual in the help listing for more details. | |
| Columned Tree | a multiple columned tree | Not having used this widget myself, I can't tell you more than to look in the Gtk+ Reference Manual, and other sources in the help listing. | |
| 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)). | |
| Progress Bar | A bar that shows the progress of some event | This bar can be set to show either activity (ie a bar just moving back and forth), or a percentage of the completion of something. If you use the percentage mode, you'll have to update the bar with gtk_progress_set_percentage() or gtk_progress_set_value(). | |
| 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. | |
| Pixmap | shows an icon or pixmap | This icon or pixmap is not changeable by the application. | |
| Drawing Area | A place to create custom widgets | Use this area to create custom widgets. | |
| 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. | |
| 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. |
| Previous | Up | Next |