GtkInfoBar

GtkInfoBar — Report important messages to the user

Functions

Properties

GtkMessageType message-type Read / Write / Construct

Style Properties

Signals

void close Action
void response Run Last

Types and Values

struct GtkInfoBar

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkObject
            ╰── GtkWidget
                ╰── GtkContainer
                    ╰── GtkBox
                        ╰── GtkHBox
                            ╰── GtkInfoBar

Implemented Interfaces

GtkInfoBar implements AtkImplementorIface, GtkBuildable and GtkOrientable.

Includes

#include <gtk/gtk.h>

Description

GtkInfoBar 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 GtkDialog, which has a horizontal action area at the bottom, GtkInfoBar has a vertical action area at the side.

The API of GtkInfoBar is very similar to GtkDialog, allowing you to add buttons to the action area with gtk_info_bar_add_button() or gtk_info_bar_new_with_buttons(). The sensitivity of action widgets can be controlled with gtk_info_bar_set_response_sensitive(). To add widgets to the main content area of a GtkInfoBar, use gtk_info_bar_get_content_area() and add your widgets to the container.

Similar to GtkMessageDialog, the contents of a GtkInfoBar can by classified as error message, warning, informational message, etc, by using gtk_info_bar_set_message_type(). GTK+ uses the message type to determine the background color of the message area.

Example 6. Simple GtkInfoBar usage.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* set up info bar */
info_bar = gtk_info_bar_new ();
gtk_widget_set_no_show_all (info_bar, TRUE);
message_label = gtk_label_new ("");
gtk_widget_show (message_label);
content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar));
gtk_container_add (GTK_CONTAINER (content_area), message_label);
gtk_info_bar_add_button (GTK_INFO_BAR (info_bar),
                         GTK_STOCK_OK, GTK_RESPONSE_OK);
g_signal_connect (info_bar, "response",
                  G_CALLBACK (gtk_widget_hide), NULL);
gtk_table_attach (GTK_TABLE (table),
                  info_bar,
                  0, 1, 2, 3,
                  GTK_EXPAND | GTK_FILL,  0,
                  0,                      0);

/* ... */

/* show an error message */
gtk_label_set_text (GTK_LABEL (message_label), error_message);
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar),
                               GTK_MESSAGE_ERROR);
gtk_widget_show (info_bar);

GtkInfoBar as GtkBuildable

The GtkInfoBar implementation of the GtkBuildable interface exposes the content area and action area as internal children with the names "content_area" and "action_area".

GtkInfoBar 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).

Functions

gtk_info_bar_new ()

GtkWidget *
gtk_info_bar_new (void);

Creates a new GtkInfoBar object.

Returns

a new GtkInfoBar object

Since: 2.18


gtk_info_bar_new_with_buttons ()

GtkWidget *
gtk_info_bar_new_with_buttons (const gchar *first_button_text,
                               ...);

Creates a new GtkInfoBar 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 GTK_STOCK_OK, or some arbitrary text. A response ID can be any positive number, or one of the values in the GtkResponseType enumeration. If the user clicks one of these dialog buttons, GtkInfoBar 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 GtkInfoBar


gtk_info_bar_add_action_widget ()

void
gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
                                GtkWidget *child,
                                gint response_id);

Add an activatable widget to the action area of a GtkInfoBar, 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 GtkInfoBar

 

child

an activatable widget

 

response_id

response ID for child

 

Since: 2.18


gtk_info_bar_add_button ()

GtkWidget *
gtk_info_bar_add_button (GtkInfoBar *info_bar,
                         const gchar *button_text,
                         gint response_id);

Adds a button with the given text (or a stock button, if button_text is a stock ID) 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 GtkInfoBar

 

button_text

text of button, or stock ID

 

response_id

response ID for the button

 

Returns

the button widget that was added.

[transfer none]

Since: 2.18


gtk_info_bar_add_buttons ()

void
gtk_info_bar_add_buttons (GtkInfoBar *info_bar,
                          const gchar *first_button_text,
                          ...);

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

Parameters

info_bar

a GtkInfoBar

 

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


gtk_info_bar_set_response_sensitive ()

void
gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
                                     gint response_id,
                                     gboolean setting);

Calls gtk_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 GtkInfoBar

 

response_id

a response ID

 

setting

TRUE for sensitive

 

Since: 2.18


gtk_info_bar_set_default_response ()

void
gtk_info_bar_set_default_response (GtkInfoBar *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 GtkInfoBar

 

response_id

a response ID

 

Since: 2.18


gtk_info_bar_response ()

void
gtk_info_bar_response (GtkInfoBar *info_bar,
                       gint response_id);

Emits the 'response' signal with the given response_id .

Parameters

info_bar

a GtkInfoBar

 

response_id

a response ID

 

Since: 2.18


gtk_info_bar_set_message_type ()

void
gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
                               GtkMessageType message_type);

Sets the message type of the message area. GTK+ uses this type to determine what color to use when drawing the message area.

Parameters

info_bar

a GtkInfoBar

 

message_type

a GtkMessageType

 

Since: 2.18


gtk_info_bar_get_message_type ()

GtkMessageType
gtk_info_bar_get_message_type (GtkInfoBar *info_bar);

Returns the message type of the message area.

Parameters

info_bar

a GtkInfoBar

 

Returns

the message type of the message area.

Since: 2.18


gtk_info_bar_get_action_area ()

GtkWidget *
gtk_info_bar_get_action_area (GtkInfoBar *info_bar);

Returns the action area of info_bar .

Parameters

info_bar

a GtkInfoBar

 

Returns

the action area.

[transfer none]

Since: 2.18


gtk_info_bar_get_content_area ()

GtkWidget *
gtk_info_bar_get_content_area (GtkInfoBar *info_bar);

Returns the content area of info_bar .

Parameters

info_bar

a GtkInfoBar

 

Returns

the content area.

[transfer none]

Since: 2.18

Types and Values

struct GtkInfoBar

struct GtkInfoBar;

Property Details

The “message-type” property

  “message-type”             GtkMessageType

The type of the message.

The type is used to determine the colors to use in the info bar. The following symbolic color names can by used to customize these colors: "info_fg_color", "info_bg_color", "warning_fg_color", "warning_bg_color", "question_fg_color", "question_bg_color", "error_fg_color", "error_bg_color". "other_fg_color", "other_bg_color".

If the type is GTK_MESSAGE_OTHER, no info bar is painted but the colors are still set.

Owner: GtkInfoBar

Flags: Read / Write / Construct

Default value: GTK_MESSAGE_INFO

Since: 2.18

Style Property Details

The “action-area-border” style property

  “action-area-border”       int

Width of the border around the action area of the info bar.

Owner: GtkInfoBar

Flags: Read

Allowed values: >= 0

Default value: 5

Since: 2.18


The “button-spacing” style property

  “button-spacing”           int

Spacing between buttons in the action area of the info bar.

Owner: GtkInfoBar

Flags: Read

Allowed values: >= 0

Default value: 6

Since: 2.18


The “content-area-border” style property

  “content-area-border”      int

The width of the border around the content content area of the info bar.

Owner: GtkInfoBar

Flags: Read

Allowed values: >= 0

Default value: 8

Since: 2.18


The “content-area-spacing” style property

  “content-area-spacing”     int

The default spacing used between elements of the content area of the info bar.

Owner: GtkInfoBar

Flags: Read

Allowed values: >= 0

Default value: 16

Since: 2.18

Signal Details

The “close” signal

void
user_function (GtkInfoBar *infobar,
               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 (GtkInfoBar *info_bar,
               int         response_id,
               gpointer    user_data)

Emitted when an action widget is clicked or the application programmer calls gtk_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

GtkStatusbar, GtkMessageDialog