CtkToolItem

CtkToolItem — The base class of widgets that can be added to CtkToolShell

Functions

Properties

gboolean is-important Read / Write
gboolean visible-horizontal Read / Write
gboolean visible-vertical Read / Write

Signals

gboolean create-menu-proxy Run Last
void toolbar-reconfigured Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── CtkWidget
            ╰── CtkContainer
                ╰── CtkBin
                    ╰── CtkToolItem
                        ├── CtkToolButton
                        ╰── CtkSeparatorToolItem

Implemented Interfaces

CtkToolItem implements AtkImplementorIface, CtkBuildable and CtkActivatable.

Includes

#include <ctk/ctk.h>

Description

CtkToolItems are widgets that can appear on a toolbar. To create a toolbar item that contain something else than a button, use ctk_tool_item_new(). Use ctk_container_add() to add a child widget to the tool item.

For toolbar items that contain buttons, see the CtkToolButton, CtkToggleToolButton and CtkRadioToolButton classes.

See the CtkToolbar class for a description of the toolbar widget, and CtkToolShell for a description of the tool shell interface.

Functions

ctk_tool_item_new ()

CtkToolItem *
ctk_tool_item_new (void);

Creates a new CtkToolItem

Returns

the new CtkToolItem

Since: 2.4


ctk_tool_item_set_homogeneous ()

void
ctk_tool_item_set_homogeneous (CtkToolItem *tool_item,
                               gboolean homogeneous);

Sets whether tool_item is to be allocated the same size as other homogeneous items. The effect is that all homogeneous items will have the same width as the widest of the items.

Parameters

tool_item

a CtkToolItem

 

homogeneous

whether tool_item is the same size as other homogeneous items

 

Since: 2.4


ctk_tool_item_get_homogeneous ()

gboolean
ctk_tool_item_get_homogeneous (CtkToolItem *tool_item);

Returns whether tool_item is the same size as other homogeneous items. See ctk_tool_item_set_homogeneous().

Parameters

tool_item

a CtkToolItem

 

Returns

TRUE if the item is the same size as other homogeneous items.

Since: 2.4


ctk_tool_item_set_expand ()

void
ctk_tool_item_set_expand (CtkToolItem *tool_item,
                          gboolean expand);

Sets whether tool_item is allocated extra space when there is more room on the toolbar then needed for the items. The effect is that the item gets bigger when the toolbar gets bigger and smaller when the toolbar gets smaller.

Parameters

tool_item

a CtkToolItem

 

expand

Whether tool_item is allocated extra space

 

Since: 2.4


ctk_tool_item_get_expand ()

gboolean
ctk_tool_item_get_expand (CtkToolItem *tool_item);

Returns whether tool_item is allocated extra space. See ctk_tool_item_set_expand().

Parameters

tool_item

a CtkToolItem

 

Returns

TRUE if tool_item is allocated extra space.

Since: 2.4


ctk_tool_item_set_tooltip_text ()

void
ctk_tool_item_set_tooltip_text (CtkToolItem *tool_item,
                                const gchar *text);

Sets the text to be displayed as tooltip on the item. See ctk_widget_set_tooltip_text().

Parameters

tool_item

a CtkToolItem

 

text

text to be used as tooltip for tool_item

 

Since: 2.12


ctk_tool_item_set_tooltip_markup ()

void
ctk_tool_item_set_tooltip_markup (CtkToolItem *tool_item,
                                  const gchar *markup);

Sets the markup text to be displayed as tooltip on the item. See ctk_widget_set_tooltip_markup().

Parameters

tool_item

a CtkToolItem

 

markup

markup text to be used as tooltip for tool_item

 

Since: 2.12


ctk_tool_item_set_use_drag_window ()

void
ctk_tool_item_set_use_drag_window (CtkToolItem *tool_item,
                                   gboolean use_drag_window);

Sets whether tool_item has a drag window. When TRUE the toolitem can be used as a drag source through ctk_drag_source_set(). When tool_item has a drag window it will intercept all events, even those that would otherwise be sent to a child of tool_item .

Parameters

tool_item

a CtkToolItem

 

use_drag_window

Whether tool_item has a drag window.

 

Since: 2.4


ctk_tool_item_get_use_drag_window ()

gboolean
ctk_tool_item_get_use_drag_window (CtkToolItem *tool_item);

Returns whether tool_item has a drag window. See ctk_tool_item_set_use_drag_window().

Parameters

tool_item

a CtkToolItem

 

Returns

TRUE if tool_item uses a drag window.

Since: 2.4


ctk_tool_item_set_visible_horizontal ()

void
ctk_tool_item_set_visible_horizontal (CtkToolItem *tool_item,
                                      gboolean visible_horizontal);

Sets whether tool_item is visible when the toolbar is docked horizontally.

Parameters

tool_item

a CtkToolItem

 

visible_horizontal

Whether tool_item is visible when in horizontal mode

 

Since: 2.4


ctk_tool_item_get_visible_horizontal ()

gboolean
ctk_tool_item_get_visible_horizontal (CtkToolItem *tool_item);

Returns whether the tool_item is visible on toolbars that are docked horizontally.

Parameters

tool_item

a CtkToolItem

 

Returns

TRUE if tool_item is visible on toolbars that are docked horizontally.

Since: 2.4


ctk_tool_item_set_visible_vertical ()

void
ctk_tool_item_set_visible_vertical (CtkToolItem *tool_item,
                                    gboolean visible_vertical);

Sets whether tool_item is visible when the toolbar is docked vertically. Some tool items, such as text entries, are too wide to be useful on a vertically docked toolbar. If visible_vertical is FALSE tool_item will not appear on toolbars that are docked vertically.

Parameters

tool_item

a CtkToolItem

 

visible_vertical

whether tool_item is visible when the toolbar is in vertical mode

 

Since: 2.4


ctk_tool_item_get_visible_vertical ()

gboolean
ctk_tool_item_get_visible_vertical (CtkToolItem *tool_item);

Returns whether tool_item is visible when the toolbar is docked vertically. See ctk_tool_item_set_visible_vertical().

Parameters

tool_item

a CtkToolItem

 

Returns

Whether tool_item is visible when the toolbar is docked vertically

Since: 2.4


ctk_tool_item_set_is_important ()

void
ctk_tool_item_set_is_important (CtkToolItem *tool_item,
                                gboolean is_important);

Sets whether tool_item should be considered important. The CtkToolButton class uses this property to determine whether to show or hide its label when the toolbar style is CTK_TOOLBAR_BOTH_HORIZ. The result is that only tool buttons with the “is_important” property set have labels, an effect known as “priority text”

Parameters

tool_item

a CtkToolItem

 

is_important

whether the tool item should be considered important

 

Since: 2.4


ctk_tool_item_get_is_important ()

gboolean
ctk_tool_item_get_is_important (CtkToolItem *tool_item);

Returns whether tool_item is considered important. See ctk_tool_item_set_is_important()

Parameters

tool_item

a CtkToolItem

 

Returns

TRUE if tool_item is considered important.

Since: 2.4


ctk_tool_item_get_ellipsize_mode ()

PangoEllipsizeMode
ctk_tool_item_get_ellipsize_mode (CtkToolItem *tool_item);

Returns the ellipsize mode used for tool_item . Custom subclasses of CtkToolItem should call this function to find out how text should be ellipsized.

Parameters

tool_item

a CtkToolItem

 

Returns

a PangoEllipsizeMode indicating how text in tool_item should be ellipsized.

Since: 2.20


ctk_tool_item_get_icon_size ()

CtkIconSize
ctk_tool_item_get_icon_size (CtkToolItem *tool_item);

Returns the icon size used for tool_item . Custom subclasses of CtkToolItem should call this function to find out what size icons they should use.

Parameters

tool_item

a CtkToolItem

 

Returns

a CtkIconSize indicating the icon size used for tool_item .

[type int]

Since: 2.4


ctk_tool_item_get_orientation ()

CtkOrientation
ctk_tool_item_get_orientation (CtkToolItem *tool_item);

Returns the orientation used for tool_item . Custom subclasses of CtkToolItem should call this function to find out what size icons they should use.

Parameters

tool_item

a CtkToolItem

 

Returns

a CtkOrientation indicating the orientation used for tool_item

Since: 2.4


ctk_tool_item_get_toolbar_style ()

CtkToolbarStyle
ctk_tool_item_get_toolbar_style (CtkToolItem *tool_item);

Returns the toolbar style used for tool_item . Custom subclasses of CtkToolItem should call this function in the handler of the CtkToolItem::toolbar_reconfigured signal to find out in what style the toolbar is displayed and change themselves accordingly

Possibilities are:

Parameters

tool_item

a CtkToolItem

 

Returns

A CtkToolbarStyle indicating the toolbar style used for tool_item .

Since: 2.4


ctk_tool_item_get_relief_style ()

CtkReliefStyle
ctk_tool_item_get_relief_style (CtkToolItem *tool_item);

Returns the relief style of tool_item . See ctk_button_set_relief(). Custom subclasses of CtkToolItem should call this function in the handler of the “toolbar_reconfigured” signal to find out the relief style of buttons.

Parameters

tool_item

a CtkToolItem

 

Returns

a CtkReliefStyle indicating the relief style used for tool_item .

Since: 2.4


ctk_tool_item_get_text_alignment ()

gfloat
ctk_tool_item_get_text_alignment (CtkToolItem *tool_item);

Returns the text alignment used for tool_item . Custom subclasses of CtkToolItem should call this function to find out how text should be aligned.

Parameters

tool_item

a CtkToolItem:

 

Returns

a gfloat indicating the horizontal text alignment used for tool_item

Since: 2.20


ctk_tool_item_get_text_orientation ()

CtkOrientation
ctk_tool_item_get_text_orientation (CtkToolItem *tool_item);

Returns the text orientation used for tool_item . Custom subclasses of CtkToolItem should call this function to find out how text should be orientated.

Parameters

tool_item

a CtkToolItem

 

Returns

a CtkOrientation indicating the text orientation used for tool_item

Since: 2.20


ctk_tool_item_retrieve_proxy_menu_item ()

CtkWidget *
ctk_tool_item_retrieve_proxy_menu_item
                               (CtkToolItem *tool_item);

Returns the CtkMenuItem that was last set by ctk_tool_item_set_proxy_menu_item(), ie. the CtkMenuItem that is going to appear in the overflow menu.

Parameters

tool_item

a CtkToolItem

 

Returns

The CtkMenuItem that is going to appear in the overflow menu for tool_item .

[transfer none]

Since: 2.4


ctk_tool_item_get_proxy_menu_item ()

CtkWidget *
ctk_tool_item_get_proxy_menu_item (CtkToolItem *tool_item,
                                   const gchar *menu_item_id);

If menu_item_id matches the string passed to ctk_tool_item_set_proxy_menu_item() return the corresponding CtkMenuItem.

Custom subclasses of CtkToolItem should use this function to update their menu item when the CtkToolItem changes. That the menu_item_ids must match ensures that a CtkToolItem will not inadvertently change a menu item that they did not create.

Parameters

tool_item

a CtkToolItem

 

menu_item_id

a string used to identify the menu item

 

Returns

The CtkMenuItem passed to ctk_tool_item_set_proxy_menu_item(), if the menu_item_ids match.

[transfer none][nullable]

Since: 2.4


ctk_tool_item_set_proxy_menu_item ()

void
ctk_tool_item_set_proxy_menu_item (CtkToolItem *tool_item,
                                   const gchar *menu_item_id,
                                   CtkWidget *menu_item);

Sets the CtkMenuItem used in the toolbar overflow menu. The menu_item_id is used to identify the caller of this function and should also be used with ctk_tool_item_get_proxy_menu_item().

See also “create-menu-proxy”.

Parameters

tool_item

a CtkToolItem

 

menu_item_id

a string used to identify menu_item

 

menu_item

a CtkMenuItem to use in the overflow menu, or NULL.

[nullable]

Since: 2.4


ctk_tool_item_rebuild_menu ()

void
ctk_tool_item_rebuild_menu (CtkToolItem *tool_item);

Calling this function signals to the toolbar that the overflow menu item for tool_item has changed. If the overflow menu is visible when this function it called, the menu will be rebuilt.

The function must be called when the tool item changes what it will do in response to the “create-menu-proxy” signal.

Parameters

tool_item

a CtkToolItem

 

Since: 2.6


ctk_tool_item_toolbar_reconfigured ()

void
ctk_tool_item_toolbar_reconfigured (CtkToolItem *tool_item);

Emits the signal “toolbar_reconfigured” on tool_item . CtkToolbar and other CtkToolShell implementations use this function to notify children, when some aspect of their configuration changes.

Parameters

tool_item

a CtkToolItem

 

Since: 2.14


ctk_tool_item_get_text_size_group ()

CtkSizeGroup *
ctk_tool_item_get_text_size_group (CtkToolItem *tool_item);

Returns the size group used for labels in tool_item . Custom subclasses of CtkToolItem should call this function and use the size group for labels.

Parameters

tool_item

a CtkToolItem

 

Returns

a CtkSizeGroup.

[transfer none]

Since: 2.20

Types and Values

struct CtkToolItem

struct CtkToolItem;

The CtkToolItem struct contains only private data. It should only be accessed through the functions described below.


struct CtkToolItemClass

struct CtkToolItemClass {
  CtkBinClass parent_class;

  /* signals */
  gboolean   (* create_menu_proxy)    (CtkToolItem *tool_item);
  void       (* toolbar_reconfigured) (CtkToolItem *tool_item);
};

Members

create_menu_proxy ()

Signal emitted when the toolbar needs information from tool_item about whether the item should appear in the toolbar overflow menu.

 

toolbar_reconfigured ()

Signal emitted when some property of the toolbar that the item is a child of changes.

 

Property Details

The “is-important” property

  “is-important”             gboolean

Whether the toolbar item is considered important. When TRUE, toolbar buttons show text in CTK_TOOLBAR_BOTH_HORIZ mode.

Owner: CtkToolItem

Flags: Read / Write

Default value: FALSE


The “visible-horizontal” property

  “visible-horizontal”       gboolean

Whether the toolbar item is visible when the toolbar is in a horizontal orientation.

Owner: CtkToolItem

Flags: Read / Write

Default value: TRUE


The “visible-vertical” property

  “visible-vertical”         gboolean

Whether the toolbar item is visible when the toolbar is in a vertical orientation.

Owner: CtkToolItem

Flags: Read / Write

Default value: TRUE

Signal Details

The “create-menu-proxy” signal

gboolean
user_function (CtkToolItem *tool_item,
               gpointer     user_data)

This signal is emitted when the toolbar needs information from tool_item about whether the item should appear in the toolbar overflow menu. In response the tool item should either

  • call ctk_tool_item_set_proxy_menu_item() with a NULL pointer and return TRUE to indicate that the item should not appear in the overflow menu

  • call ctk_tool_item_set_proxy_menu_item() with a new menu item and return TRUE, or

  • return FALSE to indicate that the signal was not handled by the item. This means that the item will not appear in the overflow menu unless a later handler installs a menu item.

The toolbar may cache the result of this signal. When the tool item changes how it will respond to this signal it must call ctk_tool_item_rebuild_menu() to invalidate the cache and ensure that the toolbar rebuilds its overflow menu.

Parameters

tool_item

the object the signal was emitted on

 

user_data

user data set when the signal handler was connected.

 

Returns

TRUE if the signal was handled, FALSE if not

Flags: Run Last


The “toolbar-reconfigured” signal

void
user_function (CtkToolItem *tool_item,
               gpointer     user_data)

This signal is emitted when some property of the toolbar that the item is a child of changes. For custom subclasses of CtkToolItem, the default handler of this signal use the functions

  • ctk_tool_shell_get_orientation()

  • ctk_tool_shell_get_style()

  • ctk_tool_shell_get_icon_size()

  • ctk_tool_shell_get_relief_style() to find out what the toolbar should look like and change themselves accordingly.

Parameters

tool_item

the object the signal was emitted on

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

See Also

CtkToolbar, CtkToolButton, CtkSeparatorToolItem