Dbusmenu.Menuitem¶
- Subclasses:
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
This is a unique indentifier for the menu item. |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when the submenu for this item is about to be shown |
|
Signaled when the child menuitem has been added to the parent. |
|
Signaled when the child menuitem has had its location in the list change. |
|
Signaled when the child menuitem has been requested to be removed from the parent. |
|
Emitted when an event is passed through. |
|
Emitted on the objects on the server side when they are signaled on the client side. |
|
Emitted everytime a property on a menuitem is either updated or added. |
|
Emitted when the initial request for properties is complete on the item. |
|
Signaled when the application would like the visualization of this menu item shown to the user. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Parent object |
|
priv |
r |
Private data |
Class Details¶
- class Dbusmenu.Menuitem(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
This is the
GObject.Object
based object that represents a menu item. It gets created the same on both the client and the server side and libdbusmenu-glib does the work of making this object model appear on both sides of DBus. Simple really, though through updates and people coming on and off the bus it can lead to lots of fun complex scenarios.- classmethod new()¶
- Returns:
A newly allocated
Dbusmenu.Menuitem
.- Return type:
Create a new
Dbusmenu.Menuitem
with all default values.
- classmethod new_with_id(id)¶
- Parameters:
id (
int
) – ID to use for this menuitem- Returns:
A newly allocated
Dbusmenu.Menuitem
.- Return type:
This creates a blank
Dbusmenu.Menuitem
with a specific ID.
- child_add_position(child, position)¶
- Parameters:
child (
Dbusmenu.Menuitem
) – TheDbusmenu.Menuitem
to make a child of self.position (
int
) – Where in self object’s list of chidren child should be placed.
- Returns:
Whether child was added successfully.
- Return type:
Puts child in the list of children for self at the location specified in position. If there is not enough entires available then child will be placed at the end of the list.
- child_append(child)¶
- Parameters:
child (
Dbusmenu.Menuitem
) – The #DbusmenMenuitem that will be a child- Returns:
Whether the child has been added successfully.
- Return type:
This function adds child to the list of children on self at the end of that list.
- child_delete(child)¶
- Parameters:
child (
Dbusmenu.Menuitem
) – The childDbusmenu.Menuitem
that you want to no longer be a child of self.- Returns:
If we were able to delete child.
- Return type:
This function removes child from the children list of self. It does not call
GObject.Object.unref
on child.
- child_find(id)¶
- Parameters:
id (
int
) – The ID of the child that we’re looking for.- Returns:
The menu item with the ID id or
None
if it can’t be found.- Return type:
Search the children of self to find one with the ID of id. If it doesn’t exist then we return
None
.
- child_prepend(child)¶
- Parameters:
child (
Dbusmenu.Menuitem
) – The #DbusmenMenuitem that will be a child- Returns:
Whether the child has been added successfully.
- Return type:
This function adds child to the list of children on self at the beginning of that list.
- child_reorder(child, position)¶
- Parameters:
child (
Dbusmenu.Menuitem
) – TheDbusmenu.Menuitem
that is a child needing to be movedposition (
int
) – The position in the list to place it in
- Returns:
Whether the move was successful.
- Return type:
This function moves a child on the list of children. It is for a child that is already in the list, but simply needs a new location.
- find_id(id)¶
- Parameters:
id (
int
) – ID of theDbusmenu.Menuitem
to search for- Returns:
The
Dbusmenu.Menuitem
with the ID of id orNone
if there isn’t such a menu item in the tree represented by self.- Return type:
This function searchs the whole tree of children that are attached to self. This could be quite a few nodes, all the way down the tree. It is a depth first search.
- foreach(func, data)¶
- Parameters:
This calls the function func on this menu item and all of the children of this item. And their children. And their children. And… you get the point. It will get called on the whole tree.
- get_children()¶
- Returns:
A
GLib.List
of pointers toDbusmenu.Menuitem
objects.- Return type:
Returns simply the list of children that this menu item has. The list is valid until another child related function is called, where it might be changed.
- get_parent()¶
- Returns:
The parent of this menu item
- Return type:
This function looks up the parent of self
- get_position(parent)¶
- Parameters:
parent (
Dbusmenu.Menuitem
) – TheDbusmenu.Menuitem
who’s children contain self- Returns:
The position of self in the children of parent.
- Return type:
This function returns the position of the menu item self in the children of parent. It will return zero if the menu item can’t be found.
- get_position_realized(parent)¶
- Parameters:
parent (
Dbusmenu.Menuitem
) – TheDbusmenu.Menuitem
who’s children contain self- Returns:
The position of self in the realized children of parent.
- Return type:
This function is very similar to
Dbusmenu.Menuitem.get_position
except that it only counts in the children that have been realized.
- get_root()¶
-
This function returns the internal value of whether this is a root node or not.
- handle_event(name, variant, timestamp)¶
- Parameters:
name (
str
) – The name of the signalvariant (
GLib.Variant
) – A value that could be set for the eventtimestamp (
int
) – The timestamp of when the event happened
This function is called to create an event. It is likely to be overrided by subclasses. The default menu item will respond to the activate signal and do:
Emits the
Dbusmenu.Menuitem
::item-activate
signal on this menu item. Called by server objects when they get the appropriate DBus signals from the client.If you subclass this function you should really think about calling the parent function unless you have a good reason not to.
- properties_copy()¶
- Returns:
A brand new
GLib.HashTable
that contains all of theroperties that are on thisDbusmenu.Menuitem
self.- Return type:
This function takes the properties of a
Dbusmenu.Menuitem
and puts them into aGLib.HashTable
that is referenced by the key of a string and has the value of a string. The hash table may not have any entries if there aren’t any or there is an error in processing. It is the caller’s responsibility to destroy the createdGLib.HashTable
.
- properties_list()¶
-
This functiong gets a list of the names of all the properties that are set on this menu item. This data on the list is owned by the menuitem but the list is not and should be freed using g_list_free() when the calling function is done with it.
- property_exist(property)¶
- Parameters:
property (
str
) – The property to look for.- Returns:
A boolean checking to see if the property is available
- Return type:
Checkes to see if a particular property exists on self and returns
True
if so.
- property_get(property)¶
- Parameters:
property (
str
) – The property to grab.- Returns:
A string with the value of the property that shouldn’t be free’d. Or
None
if the property is not set or is not a string.- Return type:
Look up a property on self and return the value of it if it exits.
None
will be returned if the property doesn’t exist.
- property_get_bool(property)¶
- Parameters:
property (
str
) – The property to grab.- Returns:
The value of the property or
False
.- Return type:
Look up a property on self and return the value of it if it exits. Returns
False
if the property doesn’t exist.
- property_get_byte_array(property)¶
- Parameters:
property (
str
) – The property to grab.- Returns:
A byte array with the value of the property that shouldn’t be free’d. Or
None
if the property is not set or is not a byte array.- Return type:
Look up a property on self and return the value of it if it exits.
None
will be returned if the property doesn’t exist.
- property_get_int(property)¶
- Parameters:
property (
str
) – The property to grab.- Returns:
The value of the property or zero.
- Return type:
Look up a property on self and return the value of it if it exits. Returns zero if the property doesn’t exist.
- property_get_variant(property)¶
- Parameters:
property (
str
) – The property to grab.- Returns:
A
GLib.Variant
for the property.- Return type:
Look up a property on self and return the value of it if it exits.
None
will be returned if the property doesn’t exist.
- property_remove(property)¶
- Parameters:
property (
str
) – The property to look for.
Removes a property from the menuitem.
- property_set(property, value)¶
- Parameters:
- Returns:
A boolean representing if the property value was set.
- Return type:
Takes the pair of property and value and places them as a property on self. If a property already exists by that name, then the value is set to the new value. If not, the property is added. If the value is changed or the property was previously unset then the signal
Dbusmenu.Menuitem
::prop-changed
will be emitted by this function.
- property_set_bool(property, value)¶
- Parameters:
- Returns:
A boolean representing if the property value was set.
- Return type:
Takes a boolean value and sets it on property as a property on self. If a property already exists by that name, then the value is set to the new value. If not, the property is added. If the value is changed or the property was previously unset then the signal
Dbusmenu.Menuitem
::prop-changed
will be emitted by this function.
- property_set_byte_array(property, value, nelements)¶
- Parameters:
- Returns:
A boolean representing if the property value was set.
- Return type:
Takes a byte array value and sets it on property as a property on self. If a property already exists by that name, then the value is set to the new value. If not, the property is added. If the value is changed or the property was previously unset then the signal
Dbusmenu.Menuitem
::prop-changed
will be emitted by this function.
- property_set_int(property, value)¶
- Parameters:
- Returns:
A boolean representing if the property value was set.
- Return type:
Takes a boolean value and sets it on property as a property on self. If a property already exists by that name, then the value is set to the new value. If not, the property is added. If the value is changed or the property was previously unset then the signal
Dbusmenu.Menuitem
::prop-changed
will be emitted by this function.
- property_set_variant(property, value)¶
- Parameters:
property (
str
) – Name of the property to set.value (
GLib.Variant
) – The value of the property.
- Returns:
A boolean representing if the property value was set.
- Return type:
Takes the pair of property and value and places them as a property on self. If a property already exists by that name, then the value is set to the new value. If not, the property is added. If the value is changed or the property was previously unset then the signal
Dbusmenu.Menuitem
::prop-changed
will be emitted by this function.
- send_about_to_show(cb, cb_data)¶
- Parameters:
This function is used to send the even that the submenu of this item is about to be shown. Callers to this event should delay showing the menu until their callback is called if possible.
- set_parent(parent)¶
- Parameters:
parent (
Dbusmenu.Menuitem
) – The new parentDbusmenu.Menuitem
- Returns:
Whether the parent was set successfully
- Return type:
Sets the parent of self to parent. If self already has a parent, then this call will fail. The parent will be set automatically when using the usual methods to add a child menuitem, so this function should not normally be called directly
- set_root(root)¶
- Parameters:
root (
bool
) – Whether self is a root node or not
This function sets the internal value of whether this is a root node or not.
- show_to_user(timestamp)¶
- Parameters:
timestamp (
int
) – The time that the user requested it to be shown
Signals that this menu item should be shown to the user. If this is server side the server will then take it and send it over the bus.
- take_children()¶
- Returns:
A
GLib.List
of pointers toDbusmenu.Menuitem
objects.- Return type:
While the name sounds devious that’s exactly what this function does. It takes the list of children from the self and clears the internal list. The calling function is now in charge of the ref’s on the children it has taken. A lot of responsibility involved in taking children.
- unparent()¶
- Returns:
Whether the menu item was unparented successfully
- Return type:
Unparents the menu item self. If self doesn’t have a parent, then this call will fail. The menuitem will be unparented automatically when using the usual methods to delete a child menuitem, so this function should not normally be called directly
- do_child_removed() virtual¶
- do_handle_event(name, variant, timestamp) virtual¶
- Parameters:
name (
str
) – The name of the signalvariant (
GLib.Variant
) – A value that could be set for the eventtimestamp (
int
) – The timestamp of when the event happened
This function is called to create an event. It is likely to be overrided by subclasses. The default menu item will respond to the activate signal and do:
Emits the
Dbusmenu.Menuitem
::item-activate
signal on this menu item. Called by server objects when they get the appropriate DBus signals from the client.If you subclass this function you should really think about calling the parent function unless you have a good reason not to.
Signal Details¶
- Dbusmenu.Menuitem.signals.about_to_show(menuitem)¶
- Signal Name:
about-to-show
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signal- Return type:
Emitted when the submenu for this item is about to be shown
- Dbusmenu.Menuitem.signals.child_added(menuitem, arg1, arg2)¶
- Signal Name:
child-added
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signalarg1 (
GObject.Object
) – TheDbusmenu.Menuitem
which is the child.arg2 (
int
) – The position that the child is being added in.
Signaled when the child menuitem has been added to the parent.
- Dbusmenu.Menuitem.signals.child_moved(menuitem, arg1, arg2, arg3)¶
- Signal Name:
child-moved
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signalarg1 (
GObject.Object
) – TheDbusmenu.Menuitem
which is the child.arg2 (
int
) – The position that the child is being moved to.arg3 (
int
) – The position that the child is was in.
Signaled when the child menuitem has had its location in the list change.
- Dbusmenu.Menuitem.signals.child_removed(menuitem, arg1)¶
- Signal Name:
child-removed
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signalarg1 (
GObject.Object
) – TheDbusmenu.Menuitem
which was the child.
Signaled when the child menuitem has been requested to be removed from the parent. This signal is called when it has been removed from the list but not yet had
GObject.Object.unref
called on it.
- Dbusmenu.Menuitem.signals.event(menuitem, arg1, arg2, arg3)¶
- Signal Name:
event
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signalarg1 (
str
) – Name of the eventarg2 (
GLib.Variant
) – Information passed along with the eventarg3 (
int
) – X11 timestamp of when the event happened
- Return type:
Emitted when an event is passed through. The event is signalled after handle_event is called.
- Dbusmenu.Menuitem.signals.item_activated(menuitem, arg1)¶
- Signal Name:
item-activated
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signalarg1 (
int
) – The timestamp of when it was activated
Emitted on the objects on the server side when they are signaled on the client side.
- Dbusmenu.Menuitem.signals.property_changed(menuitem, arg1, arg2)¶
- Signal Name:
property-changed
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signalarg1 (
str
) – The name of the property that changedarg2 (
GLib.Variant
) – The new value of the property
Emitted everytime a property on a menuitem is either updated or added.
- Dbusmenu.Menuitem.signals.realized(menuitem)¶
- Signal Name:
realized
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signal
Emitted when the initial request for properties is complete on the item. If there is a type handler configured for the “type” parameter that will be executed before this is signaled.
- Dbusmenu.Menuitem.signals.show_to_user(menuitem, arg1)¶
- Signal Name:
show-to-user
- Flags:
- Parameters:
menuitem (
Dbusmenu.Menuitem
) – The object which received the signalarg1 (
int
) – Timestamp the event happened at
Signaled when the application would like the visualization of this menu item shown to the user. This usually requires going over the bus to get it done.
Property Details¶
- Dbusmenu.Menuitem.props.id¶
- Name:
id
- Type:
- Default Value:
-1
- Flags:
This is a unique indentifier for the menu item.