Callbacks¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- Gtk.AssistantPageFunc(current_page, *data)¶
- Parameters:
- Returns:
The next page number
- Return type:
Type of callback used to calculate the next page in a
GtkAssistant
.It’s called both for computing the next page when the user presses the “forward” button and for handling the behavior of the “last” button.
See [method`Gtk`.Assistant.set_forward_page_func].
- Gtk.CellAllocCallback(renderer, cell_area, cell_background, *data)¶
- Parameters:
renderer (
Gtk.CellRenderer
) – the cell renderer to operate oncell_area (
Gdk.Rectangle
) – the area allocated to renderer inside the rectangle provided toGtk.CellArea.foreach_alloc
().cell_background (
Gdk.Rectangle
) – the background area for renderer inside the background area provided toGtk.CellArea.foreach_alloc
().
- Returns:
True
to stop iterating over cells.- Return type:
The type of the callback functions used for iterating over the cell renderers and their allocated areas inside a
GtkCellArea
, seeGtk.CellArea.foreach_alloc
().
- Gtk.CellCallback(renderer, *data)¶
- Parameters:
renderer (
Gtk.CellRenderer
) – the cell renderer to operate on
- Returns:
True
to stop iterating over cells.- Return type:
The type of the callback functions used for iterating over the cell renderers of a
GtkCellArea
, seeGtk.CellArea.foreach
().
- Gtk.CellLayoutDataFunc(cell_layout, cell, tree_model, iter, *data)¶
- Parameters:
cell_layout (
Gtk.CellLayout
) – aGtkCellLayout
cell (
Gtk.CellRenderer
) – the cell renderer whose value is to be settree_model (
Gtk.TreeModel
) – the modeliter (
Gtk.TreeIter
) – aGtkTreeIter
indicating the row to set the value fordata (
object
orNone
) – user data passed toGtk.CellLayout.set_cell_data_func
()
A function which should set the value of cell_layout’s cell renderer(s) as appropriate.
- Gtk.CustomAllocateFunc(widget, width, height, baseline)¶
- Parameters:
widget (
Gtk.Widget
) – the widget to allocatewidth (
int
) – the new width of the widgetheight (
int
) – the new height of the widgetbaseline (
int
) – the new baseline of the widget, or -1
A function to be used by
GtkCustomLayout
to allocate a widget.
- Gtk.CustomFilterFunc(item, *user_data)¶
- Parameters:
item (
GObject.Object
) – The item to be matched
- Returns:
True
to keep the item around- Return type:
User function that is called to determine if the item should be matched.
If the filter matches the item, this function must return
True
. If the item should be filtered out,False
must be returned.
- Gtk.CustomMeasureFunc(widget, orientation, for_size)¶
- Parameters:
widget (
Gtk.Widget
) – the widget to be measuredorientation (
Gtk.Orientation
) – the direction to be measuredfor_size (
int
) – the size to be measured for
- Returns:
- minimum:
the measured minimum size of the widget
- natural:
the measured natural size of the widget
- minimum_baseline:
the measured minimum baseline of the widget
- natural_baseline:
the measured natural baseline of the widget
- Return type:
(minimum:
int
, natural:int
, minimum_baseline:int
, natural_baseline:int
)
A function to be used by
GtkCustomLayout
to measure a widget.
- Gtk.CustomRequestModeFunc(widget)¶
- Parameters:
widget (
Gtk.Widget
) – the widget to be queried- Returns:
the size request mode
- Return type:
Queries a widget for its preferred size request mode.
- Gtk.DrawingAreaDrawFunc(drawing_area, cr, width, height, *user_data)¶
- Parameters:
drawing_area (
Gtk.DrawingArea
) – theGtkDrawingArea
to redrawcr (
cairo.Context
) – the context to draw towidth (
int
) – the actual width of the contents. This value will be at least as wide asGtk.DrawingArea
:width
.height (
int
) – the actual height of the contents. This value will be at least as wide asGtk.DrawingArea
:height
.
Whenever drawing_area needs to redraw, this function will be called.
This function should exclusively redraw the contents of the drawing area and must not call any widget functions that cause changes.
- Gtk.EntryCompletionMatchFunc(completion, key, iter, *user_data)¶
- Parameters:
completion (
Gtk.EntryCompletion
) – theGtkEntryCompletion
key (
str
) – the string to match, normalized and case-foldediter (
Gtk.TreeIter
) – aGtkTreeIter
indicating the row to matchuser_data (
object
orNone
) – user data given toGtk.EntryCompletion.set_match_func
()
- Returns:
True
if iter should be displayed as a possible completion for key- Return type:
A function which decides whether the row indicated by iter matches a given key, and should be displayed as a possible completion for key.
Note that key is normalized and case-folded (see
GLib.utf8_normalize
() andGLib.utf8_casefold
()). If this is not appropriate, match functions have access to the unmodified key viagtk_editable_get_text (GTK_EDITABLE (gtk_entry_completion_get_entry ()))
.
- Gtk.ExpressionNotify(*user_data)¶
- Parameters:
user_data (
object
orNone
) – data passed toGtk.Expression.watch
()
Callback called by
Gtk.Expression.watch
() when the expression value changes.
- Gtk.FlowBoxCreateWidgetFunc(item, *user_data)¶
- Parameters:
item (
GObject.Object
) – the item from the model for which to create a widget foruser_data (
object
orNone
) – user data fromGtk.FlowBox.bind_model
()
- Returns:
a
GtkWidget
that represents item- Return type:
Called for flow boxes that are bound to a
GListModel
.This function is called for each item that gets added to the model.
- Gtk.FlowBoxFilterFunc(child, *user_data)¶
- Parameters:
child (
Gtk.FlowBoxChild
) – aGtkFlowBoxChild
that may be filtered
- Returns:
- Return type:
A function that will be called whenever a child changes or is added.
It lets you control if the child should be visible or not.
- Gtk.FlowBoxForeachFunc(box, child, *user_data)¶
- Parameters:
box (
Gtk.FlowBox
) – aGtkFlowBox
child (
Gtk.FlowBoxChild
) – aGtkFlowBoxChild
A function used by
Gtk.FlowBox.selected_foreach
().It will be called on every selected child of the box.
- Gtk.FlowBoxSortFunc(child1, child2, *user_data)¶
- Parameters:
child1 (
Gtk.FlowBoxChild
) – the first childchild2 (
Gtk.FlowBoxChild
) – the second child
- Returns:
< 0 if child1 should be before child2, 0 if they are equal, and > 0 otherwise
- Return type:
A function to compare two children to determine which should come first.
- Gtk.FontFilterFunc(family, face, *data)¶
- Parameters:
family (
Pango.FontFamily
) – aPangoFontFamily
face (
Pango.FontFace
) – aPangoFontFace
belonging to familydata (
object
orNone
) – user data passed toGtk.FontChooser.set_filter_func
()
- Returns:
True
if the font should be displayed- Return type:
The type of function that is used for deciding what fonts get shown in a
GtkFontChooser
.See [method`Gtk`.FontChooser.set_filter_func].
- Gtk.IconViewForeachFunc(icon_view, path, *data)¶
- Parameters:
icon_view (
Gtk.IconView
) – aGtkIconView
path (
Gtk.TreePath
) – TheGtkTreePath
of a selected row
A function used by
Gtk.IconView.selected_foreach
() to map all selected rows.It will be called on every selected row in the view.
- Gtk.ListBoxCreateWidgetFunc(item, *user_data)¶
- Parameters:
item (
GObject.Object
) – the item from the model for which to create a widget for
- Returns:
a
GtkWidget
that represents item- Return type:
Called for list boxes that are bound to a
GListModel
withGtk.ListBox.bind_model
() for each item that gets added to the model.If the widget returned is not a
Gtk.ListBoxRow
widget, then the widget will be inserted as the child of an intermediateGtk.ListBoxRow
.
- Gtk.ListBoxFilterFunc(row, *user_data)¶
- Parameters:
row (
Gtk.ListBoxRow
) – the row that may be filtered
- Returns:
- Return type:
Will be called whenever the row changes or is added and lets you control if the row should be visible or not.
- Gtk.ListBoxForeachFunc(box, row, *user_data)¶
- Parameters:
box (
Gtk.ListBox
) – aGtkListBox
row (
Gtk.ListBoxRow
) – aGtkListBoxRow
A function used by
Gtk.ListBox.selected_foreach
().It will be called on every selected child of the box.
- Gtk.ListBoxSortFunc(row1, row2, *user_data)¶
- Parameters:
row1 (
Gtk.ListBoxRow
) – the first rowrow2 (
Gtk.ListBoxRow
) – the second row
- Returns:
< 0 if row1 should be before row2, 0 if they are equal and > 0 otherwise
- Return type:
Compare two rows to determine which should be first.
- Gtk.ListBoxUpdateHeaderFunc(row, before, *user_data)¶
- Parameters:
row (
Gtk.ListBoxRow
) – the row to updatebefore (
Gtk.ListBoxRow
orNone
) – the row before row, orNone
if it is first
Whenever row changes or which row is before row changes this is called, which lets you update the header on row.
You may remove or set a new one via [method`Gtk`.ListBoxRow.set_header] or just change the state of the current header widget.
- Gtk.MapListModelMapFunc(item, *user_data)¶
- Parameters:
item (
GObject.Object
) – The item to map
- Returns:
The item to map to
- Return type:
User function that is called to map an item of the original model to an item expected by the map model.
The returned items must conform to the item type of the model they are used with.
- Gtk.MenuButtonCreatePopupFunc(menu_button, *user_data)¶
- Parameters:
menu_button (
Gtk.MenuButton
) – theGtkMenuButton
user_data (
object
orNone
) – User data passed toGtk.MenuButton.set_create_popup_func
()
User-provided callback function to create a popup for a
GtkMenuButton
on demand.This function is called when the popup of menu_button is shown, but none has been provided via [method`Gtk`.MenuButton.set_popover] or [method`Gtk`.MenuButton.set_menu_model].
- Gtk.PageSetupDoneFunc(page_setup, *data)¶
- Parameters:
page_setup (
Gtk.PageSetup
) – theGtkPageSetup
that has been passed toGtk.print_run_page_setup_dialog_async
()data (
object
orNone
) – user data that has been passed toGtk.print_run_page_setup_dialog_async
()
The type of function that is passed to
Gtk.print_run_page_setup_dialog_async
().This function will be called when the page setup dialog is dismissed, and also serves as destroy notify for data.
- Gtk.PrintJobCompleteFunc(print_job, user_data, error)¶
- Parameters:
print_job (
Gtk.PrintJob
) – theGtkPrintJob
user_data (
object
orNone
) – user data that has been passed toGtk.PrintJob.send
()error (
GLib.Error
) – aGError
that contains error information if the sending of the print job failed, otherwiseNone
The type of callback that is passed to
Gtk.PrintJob.send
().It is called when the print job has been completely sent.
- Gtk.PrintSettingsFunc(key, value, *user_data)¶
- Gtk.PrinterFunc(printer, *data)¶
- Parameters:
printer (
Gtk.Printer
) – aGtkPrinter
data (
object
orNone
) – user data passed toGtk.enumerate_printers
()
- Returns:
- Return type:
The type of function passed to
Gtk.enumerate_printers
().Note that you need to ref printer, if you want to keep a reference to it after the function has returned.
- Gtk.ScaleFormatValueFunc(scale, value, *user_data)¶
- Gtk.ShortcutFunc(widget, args, *user_data)¶
- Parameters:
widget (
Gtk.Widget
) – The widget passed to the activationargs (
GLib.Variant
orNone
) – The arguments passed to the activationuser_data (
object
orNone
) – The user data provided when activating the action
- Returns:
True
if the action was successful.- Return type:
Prototype for shortcuts based on user callbacks.
- Gtk.TextCharPredicate(ch, *user_data)¶
- Parameters:
- Returns:
True
if the predicate is satisfied, and the iteration should stop, andFalse
otherwise- Return type:
The predicate function used by
Gtk.TextIter.forward_find_char
() andGtk.TextIter.backward_find_char
().
- Gtk.TextTagTableForeach(tag, *data)¶
- Parameters:
tag (
Gtk.TextTag
) – theGtkTextTag
data (
object
orNone
) – data passed toGtk.TextTagTable.foreach
()
A function used with
Gtk.TextTagTable.foreach
(), to iterate over everyGtkTextTag
inside aGtkTextTagTable
.
- Gtk.TickCallback(widget, frame_clock, *user_data)¶
- Parameters:
widget (
Gtk.Widget
) – the widgetframe_clock (
Gdk.FrameClock
) – the frame clock for the widget (same as callingGtk.Widget.get_frame_clock
())user_data (
object
orNone
) – user data passed toGtk.Widget.add_tick_callback
().
- Returns:
GLib.SOURCE_CONTINUE
if the tick callback should continue to be called,GLib.SOURCE_REMOVE
if the tick callback should be removed.- Return type:
Callback type for adding a function to update animations. See
Gtk.Widget.add_tick_callback
().
- Gtk.TreeCellDataFunc(tree_column, cell, tree_model, iter, *data)¶
- Parameters:
tree_column (
Gtk.TreeViewColumn
) – AGtkTreeViewColumn
cell (
Gtk.CellRenderer
) – TheGtkCellRenderer
that is being rendered by tree_columntree_model (
Gtk.TreeModel
) – TheGtkTreeModel
being renderediter (
Gtk.TreeIter
) – AGtkTreeIter
of the current row rendered
A function to set the properties of a cell instead of just using the straight mapping between the cell and the model.
This function is useful for customizing the cell renderer. For example, a function might get an* integer from the tree_model, and render it to the “text” attribute of “cell” by converting it to its written equivalent.
See also:
Gtk.TreeViewColumn.set_cell_data_func
()
- Gtk.TreeIterCompareFunc(model, a, b, *user_data)¶
- Parameters:
model (
Gtk.TreeModel
) – TheGtkTreeModel
the comparison is withina (
Gtk.TreeIter
) – AGtkTreeIter
in modelb (
Gtk.TreeIter
) – AnotherGtkTreeIter
in modeluser_data (
object
orNone
) – Data passed when the compare func is assigned e.g. byGtk.TreeSortable.set_sort_func
()
- Returns:
a negative integer, zero or a positive integer depending on whether a sorts before, with or after b
- Return type:
A
Gtk.TreeIterCompareFunc
should return a negative integer, zero, or a positive integer if a sorts before b, a sorts with b, or a sorts after b respectively.If two iters compare as equal, their order in the sorted model is undefined. In order to ensure that the
GtkTreeSortable
behaves as expected, theGtk.TreeIterCompareFunc
must define a partial order on the model, i.e. it must be reflexive, antisymmetric and transitive.For example, if model is a product catalogue, then a compare function for the “price” column could be one which returns
price_of(@a) - price_of(@b)
.
- Gtk.TreeListModelCreateModelFunc(item, *user_data)¶
- Parameters:
item (
GObject.Object
) – The item that is being expandeduser_data (
object
orNone
) – User data passed when registering the function
- Returns:
The model tracking the children of item or
None
if item can never have children- Return type:
Prototype of the function called to create new child models when
Gtk.TreeListRow.set_expanded
() is called.This function can return
None
to indicate that item is guaranteed to be a leaf node and will never have children. If it does not have children but may get children later, it should return an empty model that is filled once children arrive.
- Gtk.TreeModelFilterModifyFunc(model, iter, column, *data)¶
- Parameters:
model (
Gtk.TreeModel
) – theGtkTreeModelFilter
iter (
Gtk.TreeIter
) – aGtkTreeIter
pointing to the row whose display values are determinedcolumn (
int
) – the column whose display value is determineddata (
object
orNone
) – user data given toGtk.TreeModelFilter.set_modify_func
()
- Returns:
A
GValue
which is already initialized for with the correct type for the column column.- Return type:
value:
GObject.Value
A function which calculates display values from raw values in the model. It must fill value with the display value for the column column in the row indicated by iter.
Since this function is called for each data access, it’s not a particularly efficient operation.
- Gtk.TreeModelFilterVisibleFunc(model, iter, *data)¶
- Parameters:
model (
Gtk.TreeModel
) – the child model of theGtkTreeModelFilter
iter (
Gtk.TreeIter
) – aGtkTreeIter
pointing to the row in model whose visibility is determineddata (
object
orNone
) – user data given toGtk.TreeModelFilter.set_visible_func
()
- Returns:
Whether the row indicated by iter is visible.
- Return type:
A function which decides whether the row indicated by iter is visible.
- Gtk.TreeModelForeachFunc(model, path, iter, *data)¶
- Parameters:
model (
Gtk.TreeModel
) – theGtkTreeModel
being iteratedpath (
Gtk.TreePath
) – the currentGtkTreePath
iter (
Gtk.TreeIter
) – the currentGtkTreeIter
data (
object
orNone
) – The user data passed toGtk.TreeModel.foreach
()
- Returns:
- Return type:
Type of the callback passed to
Gtk.TreeModel.foreach
() to iterate over the rows in a tree model.
- Gtk.TreeSelectionForeachFunc(model, path, iter, *data)¶
- Parameters:
model (
Gtk.TreeModel
) – TheGtkTreeModel
being viewedpath (
Gtk.TreePath
) – TheGtkTreePath
of a selected rowiter (
Gtk.TreeIter
) – AGtkTreeIter
pointing to a selected row
A function used by
Gtk.TreeSelection.selected_foreach
() to map all selected rows. It will be called on every selected row in the view.
- Gtk.TreeSelectionFunc(selection, model, path, path_currently_selected, *data)¶
- Parameters:
selection (
Gtk.TreeSelection
) – AGtkTreeSelection
model (
Gtk.TreeModel
) – AGtkTreeModel
being viewedpath (
Gtk.TreePath
) – TheGtkTreePath
of the row in questionpath_currently_selected (
bool
) –True
, if the path is currently selected
- Returns:
True
, if the selection state of the row can be toggled- Return type:
A function used by
Gtk.TreeSelection.set_select_function
() to filter whether or not a row may be selected. It is called whenever a row’s state might change.A return value of
True
indicates to selection that it is okay to change the selection.
- Gtk.TreeViewColumnDropFunc(tree_view, column, prev_column, next_column, *data)¶
- Parameters:
tree_view (
Gtk.TreeView
) – AGtkTreeView
column (
Gtk.TreeViewColumn
) – TheGtkTreeViewColumn
being draggedprev_column (
Gtk.TreeViewColumn
) – AGtkTreeViewColumn
on one side of columnnext_column (
Gtk.TreeViewColumn
) – AGtkTreeViewColumn
on the other side of column
- Returns:
True
, if column can be dropped in this spot- Return type:
Function type for determining whether column can be dropped in a particular spot (as determined by prev_column and next_column). In left to right locales, prev_column is on the left of the potential drop spot, and next_column is on the right. In right to left mode, this is reversed. This function should return
True
if the spot is a valid drop spot. Please note that returningTrue
does not actually indicate that the column drop was made, but is meant only to indicate a possible drop spot to the user.
- Gtk.TreeViewMappingFunc(tree_view, path, *user_data)¶
- Parameters:
tree_view (
Gtk.TreeView
) – AGtkTreeView
path (
Gtk.TreePath
) – The path that’s expanded
Function used for
Gtk.TreeView.map_expanded_rows
().
- Gtk.TreeViewRowSeparatorFunc(model, iter, *data)¶
- Parameters:
model (
Gtk.TreeModel
) – theGtkTreeModel
iter (
Gtk.TreeIter
) – aGtkTreeIter
pointing at a row in model
- Returns:
True
if the row is a separator- Return type:
Function type for determining whether the row pointed to by iter should be rendered as a separator. A common way to implement this is to have a boolean column in the model, whose values the
GtkTreeViewRowSeparatorFunc
returns.
- Gtk.TreeViewSearchEqualFunc(model, column, key, iter, *search_data)¶
- Parameters:
model (
Gtk.TreeModel
) – theGtkTreeModel
being searchedcolumn (
int
) – the search column set byGtk.TreeView.set_search_column
()key (
str
) – the key string to compare withiter (
Gtk.TreeIter
) – aGtkTreeIter
pointing the row of model that should be compared with key.search_data (
object
orNone
) – user data fromGtk.TreeView.set_search_equal_func
()
- Returns:
- Return type:
A function used for checking whether a row in model matches a search key string entered by the user. Note the return value is reversed from what you would normally expect, though it has some similarity to strcmp() returning 0 for equal strings.
- Gtk.WidgetActionActivateFunc(widget, action_name, parameter)¶
- Parameters:
widget (
Gtk.Widget
) – the widget to which the action belongsaction_name (
str
) – the action nameparameter (
GLib.Variant
orNone
) – parameter for activation
The type of the callback functions used for activating actions installed with
Gtk.WidgetClass.install_action
().The parameter must match the parameter_type of the action.