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.ActionEntrystructs.user_data (
objectorNone) – 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.Actionwith 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.MenuItemto 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.Imagewidgets inside that box are first destroyed. AGtk.Imagefor 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.Boxand 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.
Deprecated since version 5.9: Use
Gtk.ImageMenuIteminstead, even if deprecated. This function doesn’t place the icon at the right place.
- Parameters:
menu_item (
Gtk.MenuItem) – aGtk.MenuItem.long_description (
strorNone) – the long description, orNoneto 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:modalproperty is set toTrue.It is on purpose that the return type is
Gtk.ShortcutsWindow, notGtk.Widgetor something else, so in C when you declare the variable asGtk.ShortcutsWindowit’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.Actionname without theGio.ActionMapprefix; theGio.Actionmust be present in g_action_map.gtk_action_group (
Gtk.ActionGroup) – aGtk.ActionGroup.gtk_action_name (
str) – aGtk.Actionname present in gtk_action_group.
Utility function to be able to port an application gradually to
Gio.Action, whenGtk.UIManagerandGtk.Actionare still used. Porting toGio.Actionshould 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.ActionMapprefix) 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.Actioncan be bound to severalGtk.Action's (with different parameter values for theGio.Action), but the reverse is not true, oneGtk.Actioncannot be bound to severalGio.Action's.This function:
Calls
Gio.Action.activate() when theGtk.ActionGtk.Action::activatesignal is emitted.Binds the
Gio.ActionGio.Action:enabledproperty to theGtk.ActionGtk.Action:sensitiveproperty. The binding is done with theGObject.BindingFlags.BIDIRECTIONALandGObject.BindingFlags.SYNC_CREATEflags, the source is theGio.Actionand the target is theGtk.Action.
When using this function, you should set the callback to
Nonein 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.Actionname with theGio.ActionMapprefix; theGio.Actionmust be present in g_action_map.gtk_action_group (
Gtk.ActionGroup) – aGtk.ActionGroup.gtk_action_name (
str) – the name of theGtk.Actionto create and add to gtk_action_group.
Utility function to be able to port an application gradually to
Gio.ActionandAmtk.ActionInfo, whenGtk.UIManageris 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.Actionmust exist. WithAmtk.utils_create_gtk_action(), both theGio.ActionandAmtk.ActionInfomust exist (so typically you need to convert theGtk.ActionEntry's intoAmtk.ActionInfoEntry's).This function creates a
Gtk.Actionfrom aGio.Actionplus its correspondingAmtk.ActionInfo.The
Gtk.Actionis 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.Actionis 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.RecentChooserMenuare 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.