PyMaemo/UI tutorial/Additions to GTK+
Additions to GTK+
A Hildon application might use any Gtk widget but in some cases could be needed to adapt those widgets to get that they fit perfectly.
Hildon provides a set of convenience functions to do that. The next sections explains these addictions.
Hildon Size Types
Hildon defines the following sizes to be used as sizes for widgets such as buttons or entries in your Hildon application.
Const | Description |
---|---|
HILDON_SIZE_HALFSCREEN_WIDTH | set to 50% screen width |
HILDON_SIZE_FULLSCREEN_WIDTH | set to 100% screen width |
HILDON_SIZE_AUTO_HEIGHT | set to automatic height |
HILDON_SIZE_FINGER_HEIGHT | set to finger height |
HILDON_SIZE_THUMB_HEIGHT | set to thumb height |
HILDON_SIZE_AUTO | set to automatic width and automatic height |
Hildon widgets allows to set their sizes in their construction functions, but in case you want to set the size of a GTK+ widget, Hildon also provides functions to do that:
GtkButton(size) GtkToggleButton(size) GtkRadioButton(type_size, group) hildon_gtk_radio_button_new_from_widget(size, radio_group_member)
UI Modes
Hildon defines two modes in the UI that change the way user interacts with certain widgets. The main purpose of these modes is to enable direct manipulation of items, while still allowing user to select single or multiple items, when it is necessary. The following modes are supported:
Normal mode
- It is the default mode. In lists and grids, tapping on an item causes a direct action. In views, this direct action could open a new subview to perform a certain action with the item.
Edit mode
- Edit mode is used in views. The purpose of this mode is providing multiple selection functionality in list or grid and providing standard UI for editing single content item.
Hildon provides the following functions to set mode for a treeview or icon view:
GtkTreeView(mode) GtkTreeView(mode, model) hildon_gtk_tree_view_set_ui_mode(treeview, mode)
GtkIconView(mode) GtkIconView(mode, model) hildon_gtk_icon_view_set_ui_mode(iconview, mode)
The enum HildonUIMode defines the following flags:
HILDON_UI_MODE_NORMAL
HILDON_UI_MODE_EDIT
When you use a list or grid in edit mode inside a window you should use a hildon.EditToolbar
to control the edition and set the window to fullscreen, building an Edit subview. To know more about edit views you can check chapter toolbars. In that chapter you can check an example of HildonToolbar which uses the concepts explained above.