Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- Amtk.action_map_add_action_entries_check_dups(action_map, entries, user_data)¶
- Parameters:
action_map (
Gio.ActionMap
) – aGio.ActionMap
.entries ([
Gio.ActionEntry
]) – a pointer to the first item in an array ofGio.ActionEntry
structs.user_data (
object
orNone
) – the user data for signal connections.
A wrapper function for
Gio.ActionMap.add_action_entries
() that checks duplicates.This function first checks - for each entry - that the action_map doesn’t already contain a
Gio.Action
with the same name. A warning is printed if an old action will be dropped. In any case, it then callsGio.ActionMap.add_action_entries
() with the same arguments as passed to this function.This function also checks if there are duplicates in the entries array itself.
New in version 2.0.
- Amtk.finalize()¶
Free the resources allocated by Amtk. For example it unrefs the singleton objects.
It is not mandatory to call this function, it’s just to be friendlier to memory debugging tools. This function is meant to be called at the end of main(). It can be called several times.
New in version 3.0.
- Parameters:
item (
Gio.MenuItem
) – aGio.MenuItem
to append.
Like
Gio.Menu.append_item
() but with (transfer full) for the item parameter.New in version 5.0.
- Parameters:
Like
Gio.Menu.append_section
() but with (transfer full) and a different type for the section parameter, and callsGio.Menu.freeze
() on section.New in version 5.0.
- Amtk.init()¶
Initializes the Amtk library (e.g. for the internationalization).
This function can be called several times, but is meant to be called at the beginning of main(), before any other Amtk function call.
New in version 3.0.
- Parameters:
menu_item (
Gtk.MenuItem
) – aGtk.MenuItem
.- Returns:
the long description of menu_item, previously set with
Amtk.menu_item_set_long_description
().- Return type:
New in version 2.0.
- Parameters:
item (
Gtk.MenuItem
) – aGtk.MenuItem
.icon_name (
str
) – an icon name.
Sets an icon to a
Gtk.MenuItem
.If the child widget of item is already a
Gtk.Box
, allGtk.Image
widgets inside that box are first destroyed. AGtk.Image
for icon_name is then inserted to the box.If the child widget of item is not a
Gtk.Box
(it’s usually theGtk.AccelLabel
), it is replaced by a newGtk.Box
and the initial child widget is inserted to theGtk.Box
, alongside the icon.As a consequence, if you want to call functions on the
Gtk.AccelLabel
, it’s easier to do it before calling this function.New in version 2.0.
- Parameters:
menu_item (
Gtk.MenuItem
) – aGtk.MenuItem
.long_description (
str
orNone
) – the long description, orNone
to unset it.
Sets the long description of menu_item. A possible use-case is to display it in a
Gtk.Statusbar
, or as a tooltip.New in version 2.0.
- Amtk.shortcuts_group_new(title)¶
- Parameters:
title (
str
) – theGtk.ShortcutsGroup
:title
.- Returns:
a new
Gtk.ShortcutsGroup
.- Return type:
New in version 5.0.
- Amtk.shortcuts_section_new(title)¶
- Parameters:
title (
str
) – theGtk.ShortcutsSection
:title
.- Returns:
a new
Gtk.ShortcutsSection
.- Return type:
New in version 5.0.
- Amtk.shortcuts_window_new(parent)¶
- Parameters:
parent (
Gtk.Window
) – theGtk.Window
:transient-for
.- Returns:
a new
Gtk.ShortcutsWindow
.- Return type:
Creates a new
Gtk.ShortcutsWindow
. TheGtk.Window
:modal
property is set toTrue
.It is on purpose that the return type is
Gtk.ShortcutsWindow
, notGtk.Widget
or something else, so in C when you declare the variable asGtk.ShortcutsWindow
it’s easier to find it later (searching “GtkShortcuts” will return something in your codebase).New in version 5.0.
- Amtk.utils_bind_g_action_to_gtk_action(g_action_map, detailed_g_action_name_without_prefix, gtk_action_group, gtk_action_name)¶
- Parameters:
g_action_map (
Gio.ActionMap
) – aGio.ActionMap
.detailed_g_action_name_without_prefix (
str
) – a detailedGio.Action
name without theGio.ActionMap
prefix; theGio.Action
must be present in g_action_map.gtk_action_group (
Gtk.ActionGroup
) – aGtk.ActionGroup
.gtk_action_name (
str
) – aGtk.Action
name present in gtk_action_group.
Utility function to be able to port an application gradually to
Gio.Action
, whenGtk.UIManager
andGtk.Action
are still used. Porting toGio.Action
should be the first step.For detailed_g_action_name_without_prefix, see the
Gio.Action.parse_detailed_name
() function. The"app."
or"win."
prefix (or any otherGio.ActionMap
prefix) must not be included in detailed_g_action_name_without_prefix. For example a valid detailed_g_action_name_without_prefix is"open"
or"insert-command::foobar"
.The same
Gio.Action
can be bound to severalGtk.Action
's (with different parameter values for theGio.Action
), but the reverse is not true, oneGtk.Action
cannot be bound to severalGio.Action
's.This function:
Calls
Gio.Action.activate
() when theGtk.Action
Gtk.Action
::activate
signal is emitted.Binds the
Gio.Action
Gio.Action
:enabled
property to theGtk.Action
Gtk.Action
:sensitive
property. The binding is done with theGObject.BindingFlags.BIDIRECTIONAL
andGObject.BindingFlags.SYNC_CREATE
flags, the source is theGio.Action
and the target is theGtk.Action
.
When using this function, you should set the callback to
None
in the correspondingGtk.ActionEntry
.New in version 4.0.
- Amtk.utils_create_gtk_action(g_action_map, detailed_g_action_name_with_prefix, gtk_action_group, gtk_action_name)¶
- Parameters:
g_action_map (
Gio.ActionMap
) – aGio.ActionMap
.detailed_g_action_name_with_prefix (
str
) – a detailedGio.Action
name with theGio.ActionMap
prefix; theGio.Action
must be present in g_action_map.gtk_action_group (
Gtk.ActionGroup
) – aGtk.ActionGroup
.gtk_action_name (
str
) – the name of theGtk.Action
to create and add to gtk_action_group.
Utility function to be able to port an application gradually to
Gio.Action
andAmtk.ActionInfo
, whenGtk.UIManager
is still used. This function goes one step further compared toAmtk.utils_bind_g_action_to_gtk_action
(). WithAmtk.utils_bind_g_action_to_gtk_action
(), only theGio.Action
must exist. WithAmtk.utils_create_gtk_action
(), both theGio.Action
andAmtk.ActionInfo
must exist (so typically you need to convert theGtk.ActionEntry
's intoAmtk.ActionInfoEntry
's).This function creates a
Gtk.Action
from aGio.Action
plus its correspondingAmtk.ActionInfo
.The
Gtk.Action
is created with the information provided by theAmtk.ActionInfo
(retrieved withAmtk.ActionInfoCentralStore.lookup
() with detailed_g_action_name_with_prefix as argument). Only the first accelerator is taken into account.Once the
Gtk.Action
is created, it is added to the gtk_action_group, andAmtk.utils_bind_g_action_to_gtk_action
() is called.New in version 4.0.
- Parameters:
menubar (
Gtk.MenuBar
) – aGtk.MenuBar
.- Returns:
a new widget that contains menubar.
- Return type:
This function wraps menubar into a container, to allow the menubar to shrink below its minimum width.
A possible use-case: have two applications side-by-side on a single screen.
New in version 5.6.
- Parameters:
menu (
Gtk.RecentChooserMenu
) – aGtk.RecentChooserMenu
.item (
Gtk.MenuItem
) – aGtk.MenuItem
.
- Returns:
the URI of item. Free with
GLib.free
() when no longer needed.- Return type:
Gets the URI of item. item must be a child of menu. menu must be a
Gtk.RecentChooserMenu
.This function has been written because the value returned by
Gtk.RecentChooser.get_current_uri
() is not updated whenGtk.MenuItem
's of aGtk.RecentChooserMenu
are selected/deselected.New in version 2.0.
- Amtk.utils_remove_mnemonic(str)¶
- Parameters:
str (
str
) – a string.- Returns:
the new string with the mnemonics removed. Free with
GLib.free
() when no longer needed.- Return type:
Removes the mnemonics from str. Single underscores are removed, and two consecutive underscores are replaced by one underscore (see the documentation of
Gtk.Label.new_with_mnemonic
()).New in version 5.0.