CtkToolbar

CtkToolbar — Create bars of buttons and other widgets

Functions

Properties

CtkIconSize icon-size Read / Write
gboolean icon-size-set Read / Write
gboolean show-arrow Read / Write
CtkToolbarStyle toolbar-style Read / Write

Signals

gboolean focus-home-or-end Action
void orientation-changed Run First
gboolean popup-context-menu Run Last
void style-changed Run First

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── CtkWidget
            ╰── CtkContainer
                ╰── CtkToolbar

Implemented Interfaces

CtkToolbar implements AtkImplementorIface, CtkBuildable, CtkToolShell and CtkOrientable.

Includes

#include <ctk/ctk.h>

Description

A toolbar is created with a call to ctk_toolbar_new().

A toolbar can contain instances of a subclass of CtkToolItem. To add a CtkToolItem to the a toolbar, use ctk_toolbar_insert(). To remove an item from the toolbar use ctk_container_remove(). To add a button to the toolbar, add an instance of CtkToolButton.

Toolbar items can be visually grouped by adding instances of CtkSeparatorToolItem to the toolbar. If the CtkToolbar child property “expand” is TRUE and the property “draw” is set to FALSE, the effect is to force all following items to the end of the toolbar.

By default, a toolbar can be shrunk, upon which it will add an arrow button to show an overflow menu offering access to any CtkToolItem child that has a proxy menu item. To disable this and request enough size for all children, call ctk_toolbar_set_show_arrow() to set “show-arrow” to FALSE.

Creating a context menu for the toolbar can be done by connecting to the “popup-context-menu” signal.

CSS nodes

CtkToolbar has a single CSS node with name toolbar.

Functions

ctk_toolbar_new ()

CtkWidget *
ctk_toolbar_new (void);

Creates a new toolbar.

Returns

the newly-created toolbar.


ctk_toolbar_insert ()

void
ctk_toolbar_insert (CtkToolbar *toolbar,
                    CtkToolItem *item,
                    gint pos);

Insert a CtkToolItem into the toolbar at position pos . If pos is 0 the item is prepended to the start of the toolbar. If pos is negative, the item is appended to the end of the toolbar.

Parameters

toolbar

a CtkToolbar

 

item

a CtkToolItem

 

pos

the position of the new item

 

Since: 2.4


ctk_toolbar_get_item_index ()

gint
ctk_toolbar_get_item_index (CtkToolbar *toolbar,
                            CtkToolItem *item);

Returns the position of item on the toolbar, starting from 0. It is an error if item is not a child of the toolbar.

Parameters

toolbar

a CtkToolbar

 

item

a CtkToolItem that is a child of toolbar

 

Returns

the position of item on the toolbar.

Since: 2.4


ctk_toolbar_get_n_items ()

gint
ctk_toolbar_get_n_items (CtkToolbar *toolbar);

Returns the number of items on the toolbar.

Parameters

toolbar

a CtkToolbar

 

Returns

the number of items on the toolbar

Since: 2.4


ctk_toolbar_get_nth_item ()

CtkToolItem *
ctk_toolbar_get_nth_item (CtkToolbar *toolbar,
                          gint n);

Returns the n 'th item on toolbar , or NULL if the toolbar does not contain an n 'th item.

Parameters

toolbar

a CtkToolbar

 

n

A position on the toolbar

 

Returns

The n 'th CtkToolItem on toolbar , or NULL if there isn’t an n 'th item.

[nullable][transfer none]

Since: 2.4


ctk_toolbar_get_drop_index ()

gint
ctk_toolbar_get_drop_index (CtkToolbar *toolbar,
                            gint x,
                            gint y);

Returns the position corresponding to the indicated point on toolbar . This is useful when dragging items to the toolbar: this function returns the position a new item should be inserted.

x and y are in toolbar coordinates.

Parameters

toolbar

a CtkToolbar

 

x

x coordinate of a point on the toolbar

 

y

y coordinate of a point on the toolbar

 

Returns

The position corresponding to the point (x , y ) on the toolbar.

Since: 2.4


ctk_toolbar_set_drop_highlight_item ()

void
ctk_toolbar_set_drop_highlight_item (CtkToolbar *toolbar,
                                     CtkToolItem *tool_item,
                                     gint index_);

Highlights toolbar to give an idea of what it would look like if item was added to toolbar at the position indicated by index_ . If item is NULL, highlighting is turned off. In that case index_ is ignored.

The tool_item passed to this function must not be part of any widget hierarchy. When an item is set as drop highlight item it can not added to any widget hierarchy or used as highlight item for another toolbar.

Parameters

toolbar

a CtkToolbar

 

tool_item

a CtkToolItem, or NULL to turn of highlighting.

[allow-none]

index_

a position on toolbar

 

Since: 2.4


ctk_toolbar_set_show_arrow ()

void
ctk_toolbar_set_show_arrow (CtkToolbar *toolbar,
                            gboolean show_arrow);

Sets whether to show an overflow menu when toolbar isn’t allocated enough size to show all of its items. If TRUE, items which can’t fit in toolbar , and which have a proxy menu item set by ctk_tool_item_set_proxy_menu_item() or “create-menu-proxy”, will be available in an overflow menu, which can be opened by an added arrow button. If FALSE, toolbar will request enough size to fit all of its child items without any overflow.

Parameters

toolbar

a CtkToolbar

 

show_arrow

Whether to show an overflow menu

 

Since: 2.4


ctk_toolbar_unset_icon_size ()

void
ctk_toolbar_unset_icon_size (CtkToolbar *toolbar);

Unsets toolbar icon size set with ctk_toolbar_set_icon_size(), so that user preferences will be used to determine the icon size.

Parameters

toolbar

a CtkToolbar

 

ctk_toolbar_get_show_arrow ()

gboolean
ctk_toolbar_get_show_arrow (CtkToolbar *toolbar);

Returns whether the toolbar has an overflow menu. See ctk_toolbar_set_show_arrow().

Parameters

toolbar

a CtkToolbar

 

Returns

TRUE if the toolbar has an overflow menu.

Since: 2.4


ctk_toolbar_get_style ()

CtkToolbarStyle
ctk_toolbar_get_style (CtkToolbar *toolbar);

Retrieves whether the toolbar has text, icons, or both . See ctk_toolbar_set_style().

Parameters

toolbar

a CtkToolbar

 

Returns

the current style of toolbar


ctk_toolbar_get_icon_size ()

CtkIconSize
ctk_toolbar_get_icon_size (CtkToolbar *toolbar);

Retrieves the icon size for the toolbar. See ctk_toolbar_set_icon_size().

Parameters

toolbar

a CtkToolbar

 

Returns

the current icon size for the icons on the toolbar.


ctk_toolbar_get_relief_style ()

CtkReliefStyle
ctk_toolbar_get_relief_style (CtkToolbar *toolbar);

Returns the relief style of buttons on toolbar . See ctk_button_set_relief().

Parameters

toolbar

a CtkToolbar

 

Returns

The relief style of buttons on toolbar .

Since: 2.4


ctk_toolbar_set_style ()

void
ctk_toolbar_set_style (CtkToolbar *toolbar,
                       CtkToolbarStyle style);

Alters the view of toolbar to display either icons only, text only, or both.

Parameters

toolbar

a CtkToolbar.

 

style

the new style for toolbar .

 

ctk_toolbar_set_icon_size ()

void
ctk_toolbar_set_icon_size (CtkToolbar *toolbar,
                           CtkIconSize icon_size);

This function sets the size of stock icons in the toolbar. You can call it both before you add the icons and after they’ve been added. The size you set will override user preferences for the default icon size.

This should only be used for special-purpose toolbars, normal application toolbars should respect the user preferences for the size of icons.

Parameters

toolbar

A CtkToolbar

 

icon_size

The CtkIconSize that stock icons in the toolbar shall have.

 

ctk_toolbar_unset_style ()

void
ctk_toolbar_unset_style (CtkToolbar *toolbar);

Unsets a toolbar style set with ctk_toolbar_set_style(), so that user preferences will be used to determine the toolbar style.

Parameters

toolbar

a CtkToolbar

 

Types and Values

struct CtkToolbar

struct CtkToolbar;

enum CtkToolbarSpaceStyle

Whether spacers are vertical lines or just blank.

Members

CTK_TOOLBAR_SPACE_EMPTY

Use blank spacers.

 

CTK_TOOLBAR_SPACE_LINE

Use vertical lines for spacers.

 

Property Details

The “icon-size” property

  “icon-size”                CtkIconSize

The size of the icons in a toolbar is normally determined by the toolbar-icon-size setting. When this property is set, it overrides the setting.

This should only be used for special-purpose toolbars, normal application toolbars should respect the user preferences for the size of icons.

Owner: CtkToolbar

Flags: Read / Write

Default value: CTK_ICON_SIZE_LARGE_TOOLBAR

Since: 2.10


The “icon-size-set” property

  “icon-size-set”            gboolean

Is TRUE if the icon-size property has been set.

Owner: CtkToolbar

Flags: Read / Write

Default value: FALSE

Since: 2.10


The “show-arrow” property

  “show-arrow”               gboolean

If an arrow should be shown if the toolbar doesn't fit.

Owner: CtkToolbar

Flags: Read / Write

Default value: TRUE


The “toolbar-style” property

  “toolbar-style”            CtkToolbarStyle

How to draw the toolbar.

Owner: CtkToolbar

Flags: Read / Write

Default value: CTK_TOOLBAR_BOTH_HORIZ

Signal Details

The “focus-home-or-end” signal

gboolean
user_function (CtkToolbar *toolbar,
               gboolean    focus_home,
               gpointer    user_data)

A keybinding signal used internally by CTK+. This signal can't be used in application code

Parameters

toolbar

the CtkToolbar which emitted the signal

 

focus_home

TRUE if the first item should be focused

 

user_data

user data set when the signal handler was connected.

 

Returns

TRUE if the signal was handled, FALSE if not

Flags: Action


The “orientation-changed” signal

void
user_function (CtkToolbar    *toolbar,
               CtkOrientation orientation,
               gpointer       user_data)

Emitted when the orientation of the toolbar changes.

Parameters

toolbar

the object which emitted the signal

 

orientation

the new CtkOrientation of the toolbar

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First


The “popup-context-menu” signal

gboolean
user_function (CtkToolbar *toolbar,
               int         x,
               int         y,
               int         button,
               gpointer    user_data)

Emitted when the user right-clicks the toolbar or uses the keybinding to display a popup menu.

Application developers should handle this signal if they want to display a context menu on the toolbar. The context-menu should appear at the coordinates given by x and y . The mouse button number is given by the button parameter. If the menu was popped up using the keybaord, button is -1.

Parameters

toolbar

the CtkToolbar which emitted the signal

 

x

the x coordinate of the point where the menu should appear

 

y

the y coordinate of the point where the menu should appear

 

button

the mouse button the user pressed, or -1

 

user_data

user data set when the signal handler was connected.

 

Returns

return TRUE if the signal was handled, FALSE if not

Flags: Run Last


The “style-changed” signal

void
user_function (CtkToolbar     *toolbar,
               CtkToolbarStyle style,
               gpointer        user_data)

Emitted when the style of the toolbar changes.

Parameters

toolbar

The CtkToolbar which emitted the signal

 

style

the new CtkToolbarStyle of the toolbar

 

user_data

user data set when the signal handler was connected.

 

Flags: Run First

See Also

CtkToolItem