CtkInfoBar

CtkInfoBar — Report important messages to the user

Functions

Properties

CtkMessageType message-type Read / Write / Construct
gboolean revealed Read / Write
gboolean show-close-button Read / Write / Construct

Signals

void close Action
void response Run Last

Types and Values

struct CtkInfoBar

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── CtkWidget
            ╰── CtkContainer
                ╰── CtkBox
                    ╰── CtkInfoBar

Implemented Interfaces

CtkInfoBar implements AtkImplementorIface, CtkBuildable and CtkOrientable.

Includes

#include <ctk/ctk.h>

Description

CtkInfoBar is a widget that can be used to show messages to the user without showing a dialog. It is often temporarily shown at the top or bottom of a document. In contrast to CtkDialog, which has a action area at the bottom, CtkInfoBar has an action area at the side.

The API of CtkInfoBar is very similar to CtkDialog, allowing you to add buttons to the action area with ctk_info_bar_add_button() or ctk_info_bar_new_with_buttons(). The sensitivity of action widgets can be controlled with ctk_info_bar_set_response_sensitive(). To add widgets to the main content area of a CtkInfoBar, use ctk_info_bar_get_content_area() and add your widgets to the container.

Similar to CtkMessageDialog, the contents of a CtkInfoBar can by classified as error message, warning, informational message, etc, by using ctk_info_bar_set_message_type(). CTK+ may use the message type to determine how the message is displayed.

A simple example for using a CtkInfoBar:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
CtkWidget *widget, *message_label, *content_area;
CtkWidget *grid;
CtkInfoBar *bar;

// set up info bar
widget = ctk_info_bar_new ();
bar = CTK_INFO_BAR (widget);
grid = ctk_grid_new ();

ctk_widget_set_no_show_all (widget, TRUE);
message_label = ctk_label_new ("");
content_area = ctk_info_bar_get_content_area (bar);
ctk_container_add (CTK_CONTAINER (content_area),
                   message_label);
ctk_info_bar_add_button (bar,
                         _("_OK"),
                         CTK_RESPONSE_OK);
g_signal_connect (bar,
                  "response",
                  G_CALLBACK (ctk_widget_hide),
                  NULL);
ctk_grid_attach (CTK_GRID (grid),
                 widget,
                 0, 2, 1, 1);

// ...

// show an error message
ctk_label_set_text (CTK_LABEL (message_label), "An error occurred!");
ctk_info_bar_set_message_type (bar,
                               CTK_MESSAGE_ERROR);
ctk_widget_show (bar);

CtkInfoBar as CtkBuildable

The CtkInfoBar implementation of the CtkBuildable interface exposes the content area and action area as internal children with the names “content_area” and “action_area”.

CtkInfoBar supports a custom <action-widgets> element, which can contain multiple <action-widget> elements. The “response” attribute specifies a numeric response, and the content of the element is the id of widget (which should be a child of the dialogs action_area ).


CSS nodes

CtkInfoBar has a single CSS node with name infobar. The node may get one of the style classes .info, .warning, .error or .question, depending on the message type.

Functions

ctk_info_bar_new ()

CtkWidget *
ctk_info_bar_new (void);

Creates a new CtkInfoBar object.

Returns

a new CtkInfoBar object

Since: 2.18


ctk_info_bar_new_with_buttons ()

CtkWidget *
ctk_info_bar_new_with_buttons (const gchar *first_button_text,
                               ...);

Creates a new CtkInfoBar with buttons. Button text/response ID pairs should be listed, with a NULL pointer ending the list. Button text can be either a stock ID such as CTK_STOCK_OK, or some arbitrary text. A response ID can be any positive number, or one of the values in the CtkResponseType enumeration. If the user clicks one of these dialog buttons, CtkInfoBar will emit the “response” signal with the corresponding response ID.

Parameters

first_button_text

stock ID or text to go in first button, or NULL.

[allow-none]

...

response ID for first button, then additional buttons, ending with NULL

 

Returns

a new CtkInfoBar


ctk_info_bar_add_action_widget ()

void
ctk_info_bar_add_action_widget (CtkInfoBar *info_bar,
                                CtkWidget *child,
                                gint response_id);

Add an activatable widget to the action area of a CtkInfoBar, connecting a signal handler that will emit the “response” signal on the message area when the widget is activated. The widget is appended to the end of the message areas action area.

Parameters

info_bar

a CtkInfoBar

 

child

an activatable widget

 

response_id

response ID for child

 

Since: 2.18


ctk_info_bar_add_button ()

CtkWidget *
ctk_info_bar_add_button (CtkInfoBar *info_bar,
                         const gchar *button_text,
                         gint response_id);

Adds a button with the given text and sets things up so that clicking the button will emit the “response” signal with the given response_id. The button is appended to the end of the info bars's action area. The button widget is returned, but usually you don't need it.

Parameters

info_bar

a CtkInfoBar

 

button_text

text of button

 

response_id

response ID for the button

 

Returns

the CtkButton widget that was added.

[transfer none][type Ctk.Button]

Since: 2.18


ctk_info_bar_add_buttons ()

void
ctk_info_bar_add_buttons (CtkInfoBar *info_bar,
                          const gchar *first_button_text,
                          ...);

Adds more buttons, same as calling ctk_info_bar_add_button() repeatedly. The variable argument list should be NULL-terminated as with ctk_info_bar_new_with_buttons(). Each button must have both text and response ID.

Parameters

info_bar

a CtkInfoBar

 

first_button_text

button text or stock ID

 

...

response ID for first button, then more text-response_id pairs, ending with NULL

 

Since: 2.18


ctk_info_bar_set_response_sensitive ()

void
ctk_info_bar_set_response_sensitive (CtkInfoBar *info_bar,
                                     gint response_id,
                                     gboolean setting);

Calls ctk_widget_set_sensitive (widget, setting) for each widget in the info bars’s action area with the given response_id. A convenient way to sensitize/desensitize dialog buttons.

Parameters

info_bar

a CtkInfoBar

 

response_id

a response ID

 

setting

TRUE for sensitive

 

Since: 2.18


ctk_info_bar_set_default_response ()

void
ctk_info_bar_set_default_response (CtkInfoBar *info_bar,
                                   gint response_id);

Sets the last widget in the info bar’s action area with the given response_id as the default widget for the dialog. Pressing “Enter” normally activates the default widget.

Note that this function currently requires info_bar to be added to a widget hierarchy.

Parameters

info_bar

a CtkInfoBar

 

response_id

a response ID

 

Since: 2.18


ctk_info_bar_response ()

void
ctk_info_bar_response (CtkInfoBar *info_bar,
                       gint response_id);

Emits the “response” signal with the given response_id .

Parameters

info_bar

a CtkInfoBar

 

response_id

a response ID

 

Since: 2.18


ctk_info_bar_set_message_type ()

void
ctk_info_bar_set_message_type (CtkInfoBar *info_bar,
                               CtkMessageType message_type);

Sets the message type of the message area.

CTK+ uses this type to determine how the message is displayed.

Parameters

info_bar

a CtkInfoBar

 

message_type

a CtkMessageType

 

Since: 2.18


ctk_info_bar_get_message_type ()

CtkMessageType
ctk_info_bar_get_message_type (CtkInfoBar *info_bar);

Returns the message type of the message area.

Parameters

info_bar

a CtkInfoBar

 

Returns

the message type of the message area.

Since: 2.18


ctk_info_bar_get_action_area ()

CtkWidget *
ctk_info_bar_get_action_area (CtkInfoBar *info_bar);

Returns the action area of info_bar .

Parameters

info_bar

a CtkInfoBar

 

Returns

the action area.

[type Ctk.Box][transfer none]

Since: 2.18


ctk_info_bar_get_content_area ()

CtkWidget *
ctk_info_bar_get_content_area (CtkInfoBar *info_bar);

Returns the content area of info_bar .

Parameters

info_bar

a CtkInfoBar

 

Returns

the content area.

[type Ctk.Box][transfer none]

Since: 2.18


ctk_info_bar_get_show_close_button ()

gboolean
ctk_info_bar_get_show_close_button (CtkInfoBar *info_bar);

Returns whether the widget will display a standard close button.

Parameters

info_bar

a CtkInfoBar

 

Returns

TRUE if the widget displays standard close button

Since: 3.10


ctk_info_bar_set_show_close_button ()

void
ctk_info_bar_set_show_close_button (CtkInfoBar *info_bar,
                                    gboolean setting);

If true, a standard close button is shown. When clicked it emits the response CTK_RESPONSE_CLOSE.

Parameters

info_bar

a CtkInfoBar

 

setting

TRUE to include a close button

 

Since: 3.10


ctk_info_bar_get_revealed ()

gboolean
ctk_info_bar_get_revealed (CtkInfoBar *info_bar);

Parameters

info_bar

a CtkInfoBar

 

Returns

the current value of the CtkInfoBar:revealed property.

Since: 3.22.29


ctk_info_bar_set_revealed ()

void
ctk_info_bar_set_revealed (CtkInfoBar *info_bar,
                           gboolean revealed);

Sets the CtkInfoBar:revealed property to revealed . This will cause info_bar to show up with a slide-in transition.

Note that this property does not automatically show info_bar and thus won’t have any effect if it is invisible.

Parameters

info_bar

a CtkInfoBar

 

revealed

The new value of the property

 

Since: 3.22.29

Types and Values

struct CtkInfoBar

struct CtkInfoBar;

Property Details

The “message-type” property

  “message-type”             CtkMessageType

The type of the message.

The type may be used to determine the appearance of the info bar.

Owner: CtkInfoBar

Flags: Read / Write / Construct

Default value: CTK_MESSAGE_INFO

Since: 2.18


The “revealed” property

  “revealed”                 gboolean

Controls whether the action bar shows its contents or not.

Owner: CtkInfoBar

Flags: Read / Write

Default value: TRUE


The “show-close-button” property

  “show-close-button”        gboolean

Whether to include a standard close button.

Owner: CtkInfoBar

Flags: Read / Write / Construct

Default value: FALSE

Since: 3.10

Signal Details

The “close” signal

void
user_function (CtkInfoBar *ctkinfobar,
               gpointer    user_data)

The ::close signal is a keybinding signal which gets emitted when the user uses a keybinding to dismiss the info bar.

The default binding for this signal is the Escape key.

Parameters

user_data

user data set when the signal handler was connected.

 

Flags: Action

Since: 2.18


The “response” signal

void
user_function (CtkInfoBar *info_bar,
               int         response_id,
               gpointer    user_data)

Emitted when an action widget is clicked or the application programmer calls ctk_dialog_response(). The response_id depends on which action widget was clicked.

Parameters

info_bar

the object on which the signal is emitted

 

response_id

the response ID

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

Since: 2.18

See Also

CtkStatusbar, CtkMessageDialog