Skip to content

Highlevel api

jtappin edited this page Apr 7, 2011 · 29 revisions

GtkFortran High Level API

Window

hl_gtk_window_new


function hl_gtk_window_new(title, destroy, delete_event, data_destroy, &
& data_delete_event, border, wsize, sensitive) result(win)

Higher-level interface to make a gtk_window

/n/n/n/n/n/n/n/n
Argument Type Required? Description \\
TITLE String optional Title for the window \\
DESTROY c\_funptr optional Callback for the "destroy" signal \\
DELETE\_EVENT c\_funptr optional Callback for the "delete-event" signal \\
DATA\_DESTROY c\_ptr optional Data to be passed to the destroy signal handler \\
DATA\_DELETE\_EVENT c\_ptr optional Data to be passed to the delete\_event signal handler \\
BORDER integer optional Size of the window border \\
WSIZE integer(2) optional Size of the window \\
SENSITIVE boolean optional Whether the widget should initially be sensitive or not.
### Buttons

hl_gtk_button_new


function hl_gtk_button_new(label, clicked, data, tooltip, sensitive) &
& result(but)

Higher-level button

/n/n/n/n/n
Argument Type Required? Description \\
LABEL string required The label on the button \\
CLICKED c\_funptr optional callback routine for the "clicked" signal \\
DATA c\_ptr optional Data to be passed to the clicked callback \\
TOOLTIP string optional tooltip to be displayed when the pointer is held over the button. \\
SENSITIVE boolean optional Whether the widget should initially be sensitive or not.
#### hl\_gtk\_check\_button\_new


function hl_gtk_check_button_new(label, toggled, data, tooltip, &
& initial_state, sensitive) result(but)

Higher level check box.

/n/n/n/n/n/n
Argument Type Required? Description \\
LABEL string required The label on the button. \\
TOGGLED c\_funptr optional Callback function for the "toggled" signal. \\
DATA c\_ptr optional Data to pass to/from the toggled callback. \\
TOOLTIP string optional A tooltip for the check\_button. \\
INITIAL\_STATE integer optional set the initial state of the check\_button. \\
SENSITIVE boolean optional Whether the widget should initially be sensitive or not.
#### hl\_gtk\_radio\_button\_new


function hl_gtk_radio_button_new(group, label, toggled, data, tooltip, &
& sensitive) result(but)

Radio button

/n/n/n/n/n/n
Argument Type Required? Description \\
GROUP c\_ptr required The group to which the button belongs. This is an INOUT argument so it must be a variable of type(c\_ptr). To start a new group (menu) initialize the variable to NULL, to add a new button use the value returned from the last call to hl\_gtk\_radio\_button\_new. This is the variable which you use to do things like setting the selection. \\
LABEL string required The label for the button. \\
TOGGLED c\_funptr optional call back to be executed when the button is toggled \\
DATA c\_ptr optional Data to pass to/from the "toggled" callback. \\
TOOLTIP string optional A tooltip for the radio button \\
SENSITIVE boolean optional Whether the widget should initially be sensitive or not.
#### hl\_gtk\_radio\_group\_set\_select


subroutine hl_gtk_radio_group_set_select(group, index)

Set the indexth button of a radio group

/n/n
Argument Type Required? Description \\
GROUP c\_ptr required The group of the last button added to the radio menu \\
INDEX integer required The index of the button to set (starting from the first as 0).
#### hl\_gtk\_radio\_group\_get\_select


function hl_gtk_radio_group_get_select(group) result(index)

Find the selected button in a radio group.

/n
Argument Type Required? Description \\
GROUP c\_ptr required The group of the last button added to the radio menu
### Text Entry

hl_gtk_entry_new


function hl_gtk_entry_new(len, editable, activate, data, tooltip, value, &
& sensitive) result(entry)

Higher level text entry box

/n/n/n/n/n/n/n
Argument Type Required? Description \\
LEN integer optional The maximum length of the entry field. \\
EDITABLE boolean optional whether the entry box can be edited by the user \\
ACTIVATE c\_funptr optional Callback function for the "activate" signal \\
DATA c\_ptr optional Data to be passed to the activate callback \\
TOOLTIP string optional tooltip to be displayed when the pointer is held over the button. \\
VALUE string optional An initial value for the entry box. \\
SENSITIVE boolean optional Whether the widget should initially be sensitive or not.
### List1

This is a single column list based on the GtkTreeView widget system.

hl_gtk_list1_new


function hl_gtk_list1_new(scroll, width, changed, data, multiple, &
& sensitive, tooltip, title, height) result(list)

A single column selectable list based on the GTK Tree View

/n/n/n/n/n/n/n/n/n
Argument Type Required? Description \\
SCROLL c\_ptr required The scroll box containing the list (used for packing etc.) \\
WIDTH integer optional The width of the displayed column. \\
CHANGED c\_funptr optional Callback function for the "changed" signal to the associated selection object. \\
DATA c\_ptr optional Data to be passed to/from the callback. \\
MULTIPLE boolean optional Whether multiple selections are allowed. \\
SENSITIVE boolean optional Whether the widget is intially sensitive. \\
TOOLTIP string optional Tooltip for the widget \\
TITLE string optional Title for the visible column. \\
HEIGHT integer optional The height of the display (this is actually the height of the scroll box).
#### hl\_gtk\_list1\_ins


subroutine hl_gtk_list1_ins(list, text, row)

Insert a row into a list

/n/n/n
Argument Type Required? Description \\
LIST c\_ptr required The list to insert to. \\
TEXT string required The text to insert. \\
ROW integer optional The row at which to insert the text (omit to append)
#### hl\_gtk\_list1\_rem


subroutine hl_gtk_list1_rem(list, row)

Remove a row or clear a list

/n/n
Argument Type Required? Description \\
LIST c\_ptr required The list to modify \\
ROW integer optional The row to remove, if absent clear the list
#### hl\_gtk\_list1\_get\_selections


function hl_gtk_list1_get_selections(list, indices, selection) result(count)

Get the indices of the selected rows

/n/n/n
Argument Type Required? Description \\
LIST c\_ptr required The list whose selections are to be found. \\
INDICES integer optional An allocatable array to return the list of selections. (If count = 0 it will not be allocated). If this argument is not given, then the number of selected rows is returned. \\
SELECTION c\_ptr optional A selection. If this is given then LIST is ignored. This is most often used in the callback routine for the changed signal when that needs to find which element(s) are selected.

Returns the number of selections.

Pulldown Menu

hl_gtk_menu_new


function hl_gtk_menu_new(orientation) result(menu)

Menu initializer (mainly for consistency)

/n
Argument Type Required? Description \\
ORIENTATION integer optional Whether to lay out the top level horizontaly or vertically.
#### hl\_gtk\_menu\_submenu\_new


function hl_gtk_menu_submenu_new(menu, label, tooltip, pos) result(submenu)

Make a submenu node

/n/n/n/n
Argument Type Required? Description \\
MENU c\_ptr required The parent of the submenu \\
LABEL string required The label of the submenu \\
TOOLTIP string optional A tooltip for the submenu. \\
POS integer optional The position at which to insert the item (omit to append)
#### hl\_gtk\_menu\_item\_new


function hl_gtk_menu_item_new(menu, label, activate, data, tooltip, pos) &
& result(item)

Make a menu item or separator

/n/n/n/n/n/n
Argument Type Required? Description \\
MENU c\_ptr required The parent menu. \\
LABEL string optional The label for the menu, if absent then insert a separator. \\
ACTIVATE c\_funptr optional The callback function for the activate signal \\
DATA c\_ptr optional Data to pass to the callback. \\
TOOLTIP string optional A tooltip for the menu item. \\
POS integer optional The position at which to insert the item (omit to append)
### Progress Bar

hl_gtk_progress_bar_new


function hl_gtk_progress_bar_new(orientation, step) result(bar)

Intializer for a progress bar

/n/n
Argument Type Required? Description \\
ORIENTATION integer optional The orientation of the bar. \\
STEP double optional The fractional step to advance when pulsing the bar
#### hl\_gtk\_progress\_bar\_set\_f


subroutine hl_gtk_progress_bar_set_f(bar, val, string, text)

Set the value of a progress bar (fraction or pulse)

/n/n/n/n
Argument Type Required? Description \\
BAR c\_ptr required The bar to set \\
VAL double optional The value to set. If absent, the bar is pulsed \\
STRING boolean optional Whether to put a string on the bar. \\
TEXT string optional Text to put in the bar, (overrides STRING)

This routine is normally accessed via the generic interface hl_gtk_progress_bar

hl_gtk_progress_bar_set_ii


subroutine hl_gtk_progress_bar_set_ii(bar, val, maxv, string, text)

Set the value of a progress bar (n of m)

/n/n/n/n/n
Argument Type Required? Description \\
BAR c\_ptr required The bar to set \\
VAL int required The value to set. \\
MAXV int required The maximum value for the bar \\
STRING boolean optional Whether to put a string on the bar. \\
TEXT string optional Text to put in the bar, (overrides STRING)

This routine is normally accessed via the generic interface hl_gtk_progress_bar

Dialogue

The message dialogue provided is here because, the built-in message dialogue GtkMessageDialog cannot be created without calling variadic functions which are not compatible with Fortran, therefore this is based around the plain GtkDialog family.

hl_gtk_message_dialog_show


function hl_gtk_message_dialog_show(message, button_set, title) &
& result(resp)

A DIY version of the message dialogue, needed because both creators for the built in one are variadic and so not callable from Fortran.

/n/n/n
Argument Type Required? Description \\
MESSAGE string(n) required The message to display. Since this is a string array, the CNULL terminations are provided internally \\
BUTTON\_SET integer required The set of buttons to display \\
TITLE string optional Title for the window.

The return value is the response code, not the widget.

Clone this wiki locally