Add a message area widget

It is called GtkInfoBar. See bug 555344.
This commit is contained in:
Matthias Clasen
2009-06-05 14:56:08 -04:00
parent 4d7bbd058e
commit a85fac7145
12 changed files with 1596 additions and 97 deletions

View File

@ -8,6 +8,8 @@
#include "demo-common.h" #include "demo-common.h"
static GtkWidget *window = NULL; static GtkWidget *window = NULL;
static GtkWidget *infobar = NULL;
static GtkWidget *messagelabel = NULL;
static void static void
activate_action (GtkAction *action) activate_action (GtkAction *action)
@ -16,7 +18,7 @@ activate_action (GtkAction *action)
const gchar *typename = G_OBJECT_TYPE_NAME (action); const gchar *typename = G_OBJECT_TYPE_NAME (action);
GtkWidget *dialog; GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window), dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO, GTK_MESSAGE_INFO,
@ -29,7 +31,7 @@ activate_action (GtkAction *action)
"response", "response",
G_CALLBACK (gtk_widget_destroy), G_CALLBACK (gtk_widget_destroy),
NULL); NULL);
gtk_widget_show (dialog); gtk_widget_show (dialog);
} }
@ -41,37 +43,32 @@ activate_radio_action (GtkAction *action, GtkRadioAction *current)
gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current)); gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current));
gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current)); gint value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (current));
if (active) if (active)
{ {
GtkWidget *dialog; gchar *text;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_CLOSE,
"You activated radio action: \"%s\" of type \"%s\".\n"
"Current value: %d",
name, typename, value);
/* Close dialog on user response */ text = g_strdup_printf ("You activated radio action: \"%s\" of type \"%s\".\n"
g_signal_connect (dialog, "Current value: %d",
"response", name, typename, value);
G_CALLBACK (gtk_widget_destroy), gtk_label_set_text (GTK_LABEL (messagelabel), text);
NULL); gtk_info_bar_set_message_type (GTK_INFO_BAR (infobar), (GtkMessageType)value);
gtk_widget_show (infobar);
gtk_widget_show (dialog); g_free (text);
} }
} }
static void static void
activate_email (GtkAboutDialog *about, activate_email (GtkAboutDialog *about,
const gchar *link, const gchar *link,
gpointer data) gpointer data)
{ {
g_print ("send mail to %s\n", link); gchar *text;
text = g_strdup_printf ("send mail to %s", link);
g_print ("%s\n", text);
g_free (text);
} }
static void static void
activate_url (GtkAboutDialog *about, activate_url (GtkAboutDialog *about,
const gchar *link, const gchar *link,
gpointer data) gpointer data)
@ -147,12 +144,12 @@ about_cb (GtkAction *action,
g_object_unref (transparent); g_object_unref (transparent);
} }
typedef struct typedef struct
{ {
GtkAction action; GtkAction action;
} ToolMenuAction; } ToolMenuAction;
typedef struct typedef struct
{ {
GtkActionClass parent_class; GtkActionClass parent_class;
} ToolMenuActionClass; } ToolMenuActionClass;
@ -179,30 +176,30 @@ static GtkActionEntry entries[] = {
{ "HelpMenu", NULL, "_Help" }, /* name, stock id, label */ { "HelpMenu", NULL, "_Help" }, /* name, stock id, label */
{ "New", GTK_STOCK_NEW, /* name, stock id */ { "New", GTK_STOCK_NEW, /* name, stock id */
"_New", "<control>N", /* label, accelerator */ "_New", "<control>N", /* label, accelerator */
"Create a new file", /* tooltip */ "Create a new file", /* tooltip */
G_CALLBACK (activate_action) }, G_CALLBACK (activate_action) },
{ "File1", NULL, /* name, stock id */ { "File1", NULL, /* name, stock id */
"File1", NULL, /* label, accelerator */ "File1", NULL, /* label, accelerator */
"Open first file", /* tooltip */ "Open first file", /* tooltip */
G_CALLBACK (activate_action) }, G_CALLBACK (activate_action) },
{ "Save", GTK_STOCK_SAVE, /* name, stock id */ { "Save", GTK_STOCK_SAVE, /* name, stock id */
"_Save","<control>S", /* label, accelerator */ "_Save","<control>S", /* label, accelerator */
"Save current file", /* tooltip */ "Save current file", /* tooltip */
G_CALLBACK (activate_action) }, G_CALLBACK (activate_action) },
{ "SaveAs", GTK_STOCK_SAVE, /* name, stock id */ { "SaveAs", GTK_STOCK_SAVE, /* name, stock id */
"Save _As...", NULL, /* label, accelerator */ "Save _As...", NULL, /* label, accelerator */
"Save to a file", /* tooltip */ "Save to a file", /* tooltip */
G_CALLBACK (activate_action) }, G_CALLBACK (activate_action) },
{ "Quit", GTK_STOCK_QUIT, /* name, stock id */ { "Quit", GTK_STOCK_QUIT, /* name, stock id */
"_Quit", "<control>Q", /* label, accelerator */ "_Quit", "<control>Q", /* label, accelerator */
"Quit", /* tooltip */ "Quit", /* tooltip */
G_CALLBACK (activate_action) }, G_CALLBACK (activate_action) },
{ "About", NULL, /* name, stock id */ { "About", NULL, /* name, stock id */
"_About", "<control>A", /* label, accelerator */ "_About", "<control>A", /* label, accelerator */
"About", /* tooltip */ "About", /* tooltip */
G_CALLBACK (about_cb) }, G_CALLBACK (about_cb) },
{ "Logo", "demo-gtk-logo", /* name, stock id */ { "Logo", "demo-gtk-logo", /* name, stock id */
NULL, NULL, /* label, accelerator */ NULL, NULL, /* label, accelerator */
"GTK+", /* tooltip */ "GTK+", /* tooltip */
G_CALLBACK (activate_action) }, G_CALLBACK (activate_action) },
}; };
@ -211,9 +208,9 @@ static guint n_entries = G_N_ELEMENTS (entries);
static GtkToggleActionEntry toggle_entries[] = { static GtkToggleActionEntry toggle_entries[] = {
{ "Bold", GTK_STOCK_BOLD, /* name, stock id */ { "Bold", GTK_STOCK_BOLD, /* name, stock id */
"_Bold", "<control>B", /* label, accelerator */ "_Bold", "<control>B", /* label, accelerator */
"Bold", /* tooltip */ "Bold", /* tooltip */
G_CALLBACK (activate_action), G_CALLBACK (activate_action),
TRUE }, /* is_active */ TRUE }, /* is_active */
}; };
static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries); static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
@ -226,13 +223,13 @@ enum {
static GtkRadioActionEntry color_entries[] = { static GtkRadioActionEntry color_entries[] = {
{ "Red", NULL, /* name, stock id */ { "Red", NULL, /* name, stock id */
"_Red", "<control>R", /* label, accelerator */ "_Red", "<control>R", /* label, accelerator */
"Blood", COLOR_RED }, /* tooltip, value */ "Blood", COLOR_RED }, /* tooltip, value */
{ "Green", NULL, /* name, stock id */ { "Green", NULL, /* name, stock id */
"_Green", "<control>G", /* label, accelerator */ "_Green", "<control>G", /* label, accelerator */
"Grass", COLOR_GREEN }, /* tooltip, value */ "Grass", COLOR_GREEN }, /* tooltip, value */
{ "Blue", NULL, /* name, stock id */ { "Blue", NULL, /* name, stock id */
"_Blue", "<control>B", /* label, accelerator */ "_Blue", "<control>B", /* label, accelerator */
"Sky", COLOR_BLUE }, /* tooltip, value */ "Sky", COLOR_BLUE }, /* tooltip, value */
}; };
static guint n_color_entries = G_N_ELEMENTS (color_entries); static guint n_color_entries = G_N_ELEMENTS (color_entries);
@ -245,18 +242,18 @@ enum {
static GtkRadioActionEntry shape_entries[] = { static GtkRadioActionEntry shape_entries[] = {
{ "Square", NULL, /* name, stock id */ { "Square", NULL, /* name, stock id */
"_Square", "<control>S", /* label, accelerator */ "_Square", "<control>S", /* label, accelerator */
"Square", SHAPE_SQUARE }, /* tooltip, value */ "Square", SHAPE_SQUARE }, /* tooltip, value */
{ "Rectangle", NULL, /* name, stock id */ { "Rectangle", NULL, /* name, stock id */
"_Rectangle", "<control>R", /* label, accelerator */ "_Rectangle", "<control>R", /* label, accelerator */
"Rectangle", SHAPE_RECTANGLE }, /* tooltip, value */ "Rectangle", SHAPE_RECTANGLE }, /* tooltip, value */
{ "Oval", NULL, /* name, stock id */ { "Oval", NULL, /* name, stock id */
"_Oval", "<control>O", /* label, accelerator */ "_Oval", "<control>O", /* label, accelerator */
"Egg", SHAPE_OVAL }, /* tooltip, value */ "Egg", SHAPE_OVAL }, /* tooltip, value */
}; };
static guint n_shape_entries = G_N_ELEMENTS (shape_entries); static guint n_shape_entries = G_N_ELEMENTS (shape_entries);
static const gchar *ui_info = static const gchar *ui_info =
"<ui>" "<ui>"
" <menubar name='MenuBar'>" " <menubar name='MenuBar'>"
" <menu action='FileMenu'>" " <menu action='FileMenu'>"
@ -288,7 +285,7 @@ static const gchar *ui_info =
" <toolitem action='Open'>" " <toolitem action='Open'>"
" <menu action='OpenMenu'>" " <menu action='OpenMenu'>"
" <menuitem action='File1'/>" " <menuitem action='File1'/>"
" </menu>" " </menu>"
" </toolitem>" " </toolitem>"
" <toolitem action='Quit'/>" " <toolitem action='Quit'/>"
" <separator action='Sep1'/>" " <separator action='Sep1'/>"
@ -308,7 +305,7 @@ static void
register_stock_icons (void) register_stock_icons (void)
{ {
static gboolean registered = FALSE; static gboolean registered = FALSE;
if (!registered) if (!registered)
{ {
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
@ -320,12 +317,12 @@ register_stock_icons (void)
"_GTK!", "_GTK!",
0, 0, NULL } 0, 0, NULL }
}; };
registered = TRUE; registered = TRUE;
/* Register our stock items */ /* Register our stock items */
gtk_stock_add (items, G_N_ELEMENTS (items)); gtk_stock_add (items, G_N_ELEMENTS (items));
/* Add our custom icon factory to the list of defaults */ /* Add our custom icon factory to the list of defaults */
factory = gtk_icon_factory_new (); factory = gtk_icon_factory_new ();
gtk_icon_factory_add_default (factory); gtk_icon_factory_add_default (factory);
@ -350,7 +347,7 @@ register_stock_icons (void)
/* The gtk-logo-rgb icon has a white background, make it transparent */ /* The gtk-logo-rgb icon has a white background, make it transparent */
transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff); transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff);
icon_set = gtk_icon_set_new_from_pixbuf (transparent); icon_set = gtk_icon_set_new_from_pixbuf (transparent);
gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set); gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set);
gtk_icon_set_unref (icon_set); gtk_icon_set_unref (icon_set);
@ -359,7 +356,7 @@ register_stock_icons (void)
} }
else else
g_warning ("failed to load GTK logo for toolbar"); g_warning ("failed to load GTK logo for toolbar");
/* Drop our reference to the factory, GTK will hold a reference. */ /* Drop our reference to the factory, GTK will hold a reference. */
g_object_unref (factory); g_object_unref (factory);
} }
@ -373,9 +370,9 @@ update_statusbar (GtkTextBuffer *buffer,
gint row, col; gint row, col;
gint count; gint count;
GtkTextIter iter; GtkTextIter iter;
gtk_statusbar_pop (statusbar, 0); /* clear any previous message, gtk_statusbar_pop (statusbar, 0); /* clear any previous message,
* underflow is allowed * underflow is allowed
*/ */
count = gtk_text_buffer_get_char_count (buffer); count = gtk_text_buffer_get_char_count (buffer);
@ -409,21 +406,21 @@ update_resize_grip (GtkWidget *widget,
GdkEventWindowState *event, GdkEventWindowState *event,
GtkStatusbar *statusbar) GtkStatusbar *statusbar)
{ {
if (event->changed_mask & (GDK_WINDOW_STATE_MAXIMIZED | if (event->changed_mask & (GDK_WINDOW_STATE_MAXIMIZED |
GDK_WINDOW_STATE_FULLSCREEN)) GDK_WINDOW_STATE_FULLSCREEN))
{ {
gboolean maximized; gboolean maximized;
maximized = event->new_window_state & (GDK_WINDOW_STATE_MAXIMIZED | maximized = event->new_window_state & (GDK_WINDOW_STATE_MAXIMIZED |
GDK_WINDOW_STATE_FULLSCREEN); GDK_WINDOW_STATE_FULLSCREEN);
gtk_statusbar_set_has_resize_grip (statusbar, !maximized); gtk_statusbar_set_has_resize_grip (statusbar, !maximized);
} }
} }
GtkWidget * GtkWidget *
do_appwindow (GtkWidget *do_widget) do_appwindow (GtkWidget *do_widget)
{ {
if (!window) if (!window)
{ {
GtkWidget *table; GtkWidget *table;
@ -438,10 +435,10 @@ do_appwindow (GtkWidget *do_widget)
GError *error = NULL; GError *error = NULL;
register_stock_icons (); register_stock_icons ();
/* Create the toplevel window /* Create the toplevel window
*/ */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_screen (GTK_WINDOW (window), gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (do_widget)); gtk_widget_get_screen (do_widget));
@ -453,15 +450,15 @@ do_appwindow (GtkWidget *do_widget)
G_CALLBACK (gtk_widget_destroyed), G_CALLBACK (gtk_widget_destroyed),
&window); &window);
table = gtk_table_new (1, 4, FALSE); table = gtk_table_new (1, 5, FALSE);
gtk_container_add (GTK_CONTAINER (window), table); gtk_container_add (GTK_CONTAINER (window), table);
/* Create the menubar and toolbar /* Create the menubar and toolbar
*/ */
action_group = gtk_action_group_new ("AppWindowActions"); action_group = gtk_action_group_new ("AppWindowActions");
open_action = g_object_new (tool_menu_action_get_type (), open_action = g_object_new (tool_menu_action_get_type (),
"name", "Open", "name", "Open",
"label", "_Open", "label", "_Open",
"tooltip", "Open a file", "tooltip", "Open a file",
@ -469,30 +466,30 @@ do_appwindow (GtkWidget *do_widget)
NULL); NULL);
gtk_action_group_add_action (action_group, open_action); gtk_action_group_add_action (action_group, open_action);
g_object_unref (open_action); g_object_unref (open_action);
gtk_action_group_add_actions (action_group, gtk_action_group_add_actions (action_group,
entries, n_entries, entries, n_entries,
window); window);
gtk_action_group_add_toggle_actions (action_group, gtk_action_group_add_toggle_actions (action_group,
toggle_entries, n_toggle_entries, toggle_entries, n_toggle_entries,
NULL); NULL);
gtk_action_group_add_radio_actions (action_group, gtk_action_group_add_radio_actions (action_group,
color_entries, n_color_entries, color_entries, n_color_entries,
COLOR_RED, COLOR_RED,
G_CALLBACK (activate_radio_action), G_CALLBACK (activate_radio_action),
NULL); NULL);
gtk_action_group_add_radio_actions (action_group, gtk_action_group_add_radio_actions (action_group,
shape_entries, n_shape_entries, shape_entries, n_shape_entries,
SHAPE_SQUARE, SHAPE_SQUARE,
G_CALLBACK (activate_radio_action), G_CALLBACK (activate_radio_action),
NULL); NULL);
merge = gtk_ui_manager_new (); merge = gtk_ui_manager_new ();
g_object_set_data_full (G_OBJECT (window), "ui-manager", merge, g_object_set_data_full (G_OBJECT (window), "ui-manager", merge,
g_object_unref); g_object_unref);
gtk_ui_manager_insert_action_group (merge, action_group, 0); gtk_ui_manager_insert_action_group (merge, action_group, 0);
gtk_window_add_accel_group (GTK_WINDOW (window), gtk_window_add_accel_group (GTK_WINDOW (window),
gtk_ui_manager_get_accel_group (merge)); gtk_ui_manager_get_accel_group (merge));
if (!gtk_ui_manager_add_ui_from_string (merge, ui_info, -1, &error)) if (!gtk_ui_manager_add_ui_from_string (merge, ui_info, -1, &error))
{ {
g_message ("building menus failed: %s", error->message); g_message ("building menus failed: %s", error->message);
@ -502,7 +499,7 @@ do_appwindow (GtkWidget *do_widget)
bar = gtk_ui_manager_get_widget (merge, "/MenuBar"); bar = gtk_ui_manager_get_widget (merge, "/MenuBar");
gtk_widget_show (bar); gtk_widget_show (bar);
gtk_table_attach (GTK_TABLE (table), gtk_table_attach (GTK_TABLE (table),
bar, bar,
/* X direction */ /* Y direction */ /* X direction */ /* Y direction */
0, 1, 0, 1, 0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, 0, GTK_EXPAND | GTK_FILL, 0,
@ -511,7 +508,7 @@ do_appwindow (GtkWidget *do_widget)
bar = gtk_ui_manager_get_widget (merge, "/ToolBar"); bar = gtk_ui_manager_get_widget (merge, "/ToolBar");
gtk_widget_show (bar); gtk_widget_show (bar);
gtk_table_attach (GTK_TABLE (table), gtk_table_attach (GTK_TABLE (table),
bar, bar,
/* X direction */ /* Y direction */ /* X direction */ /* Y direction */
0, 1, 1, 2, 0, 1, 1, 2,
GTK_EXPAND | GTK_FILL, 0, GTK_EXPAND | GTK_FILL, 0,
@ -520,6 +517,25 @@ do_appwindow (GtkWidget *do_widget)
/* Create document /* Create document
*/ */
infobar = gtk_info_bar_new ();
gtk_widget_set_no_show_all (infobar, TRUE);
messagelabel = gtk_label_new ("");
gtk_widget_show (messagelabel);
gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (infobar))),
messagelabel,
TRUE, TRUE, 0);
gtk_info_bar_add_button (GTK_INFO_BAR (infobar),
GTK_STOCK_OK, GTK_RESPONSE_OK);
g_signal_connect (infobar, "response",
G_CALLBACK (gtk_widget_hide), NULL);
gtk_table_attach (GTK_TABLE (table),
infobar,
/* X direction */ /* Y direction */
0, 1, 2, 3,
GTK_EXPAND | GTK_FILL, 0,
0, 0);
sw = gtk_scrolled_window_new (NULL, NULL); sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
@ -528,20 +544,20 @@ do_appwindow (GtkWidget *do_widget)
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_IN); GTK_SHADOW_IN);
gtk_table_attach (GTK_TABLE (table), gtk_table_attach (GTK_TABLE (table),
sw, sw,
/* X direction */ /* Y direction */ /* X direction */ /* Y direction */
0, 1, 2, 3, 0, 1, 3, 4,
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
0, 0); 0, 0);
gtk_window_set_default_size (GTK_WINDOW (window), gtk_window_set_default_size (GTK_WINDOW (window),
200, 200); 200, 200);
contents = gtk_text_view_new (); contents = gtk_text_view_new ();
gtk_widget_grab_focus (contents); gtk_widget_grab_focus (contents);
gtk_container_add (GTK_CONTAINER (sw), gtk_container_add (GTK_CONTAINER (sw),
contents); contents);
@ -551,7 +567,7 @@ do_appwindow (GtkWidget *do_widget)
gtk_table_attach (GTK_TABLE (table), gtk_table_attach (GTK_TABLE (table),
statusbar, statusbar,
/* X direction */ /* Y direction */ /* X direction */ /* Y direction */
0, 1, 3, 4, 0, 1, 4, 5,
GTK_EXPAND | GTK_FILL, 0, GTK_EXPAND | GTK_FILL, 0,
0, 0); 0, 0);
@ -570,12 +586,12 @@ do_appwindow (GtkWidget *do_widget)
statusbar, statusbar,
0); 0);
g_signal_connect_object (window, g_signal_connect_object (window,
"window_state_event", "window_state_event",
G_CALLBACK (update_resize_grip), G_CALLBACK (update_resize_grip),
statusbar, statusbar,
0); 0);
update_statusbar (buffer, GTK_STATUSBAR (statusbar)); update_statusbar (buffer, GTK_STATUSBAR (statusbar));
} }
@ -584,9 +600,11 @@ do_appwindow (GtkWidget *do_widget)
gtk_widget_show_all (window); gtk_widget_show_all (window);
} }
else else
{ {
gtk_widget_destroy (window); gtk_widget_destroy (window);
window = NULL; window = NULL;
infobar = NULL;
messagelabel = NULL;
} }
return window; return window;

View File

@ -159,6 +159,7 @@ that is, GUI components such as #GtkButton or #GtkTextView.
<xi:include href="xml/gtklabel.xml" /> <xi:include href="xml/gtklabel.xml" />
<xi:include href="xml/gtkprogressbar.xml" /> <xi:include href="xml/gtkprogressbar.xml" />
<xi:include href="xml/gtkstatusbar.xml" /> <xi:include href="xml/gtkstatusbar.xml" />
<xi:include href="xml/gtkinfobar.xml" />
<xi:include href="xml/gtkstatusicon.xml" /> <xi:include href="xml/gtkstatusicon.xml" />
</chapter> </chapter>

View File

@ -2588,6 +2588,35 @@ GTK_MESSAGE_DIALOG_GET_CLASS
gtk_message_dialog_get_type gtk_message_dialog_get_type
</SECTION> </SECTION>
<SECTION>
<FILE>gtkinfobar</FILE>
<TITLE>GtkInfoBar</TITLE>
GtkInfoBar
gtk_info_bar_new
gtk_info_bar_new_with_buttons
gtk_info_bar_set_contents
gtk_info_bar_add_action_widget
gtk_info_bar_add_button
gtk_info_bar_add_buttons
gtk_info_bar_set_response_sensitive
gtk_info_bar_set_default_response
gtk_info_bar_response
gtk_info_bar_set_message_type
gtk_info_bar_get_message_type
<SUBSECTION Standard>
GTK_TYPE_INFO_BAR
GTK_INFO_BAR
GTK_INFO_BAR_CLASS
GTK_IS_INFO_BAR
GTK_IS_INFO_BAR_CLASS
GTK_INFO_BAR_GET_CLASS
<SUBSECTION Private>
gtk_info_bar_get_type
GtkMessageAreaPrivate
</SECTION>
<SECTION> <SECTION>
<FILE>gtkmisc</FILE> <FILE>gtkmisc</FILE>
<TITLE>GtkMisc</TITLE> <TITLE>GtkMisc</TITLE>

View File

@ -81,6 +81,7 @@ gtk_image_menu_item_get_type
gtk_im_context_get_type gtk_im_context_get_type
gtk_im_context_simple_get_type gtk_im_context_simple_get_type
gtk_im_multicontext_get_type gtk_im_multicontext_get_type
gtk_info_bar_get_type
gtk_input_dialog_get_type gtk_input_dialog_get_type
gtk_invisible_get_type gtk_invisible_get_type
gtk_item_factory_get_type gtk_item_factory_get_type

View File

@ -230,6 +230,7 @@ gtk_public_h_sources = \
gtkimcontextsimple.h \ gtkimcontextsimple.h \
gtkimmodule.h \ gtkimmodule.h \
gtkimmulticontext.h \ gtkimmulticontext.h \
gtkinfobar.h \
gtkinputdialog.h \ gtkinputdialog.h \
gtkinvisible.h \ gtkinvisible.h \
gtkitem.h \ gtkitem.h \
@ -486,6 +487,7 @@ gtk_base_c_sources = \
gtkimcontextsimple.c \ gtkimcontextsimple.c \
gtkimmodule.c \ gtkimmodule.c \
gtkimmulticontext.c \ gtkimmulticontext.c \
gtkinfobar.c \
gtkinputdialog.c \ gtkinputdialog.c \
gtkinvisible.c \ gtkinvisible.c \
gtkitem.c \ gtkitem.c \

View File

@ -110,6 +110,7 @@
#include <gtk/gtkimcontext.h> #include <gtk/gtkimcontext.h>
#include <gtk/gtkimcontextsimple.h> #include <gtk/gtkimcontextsimple.h>
#include <gtk/gtkimmulticontext.h> #include <gtk/gtkimmulticontext.h>
#include <gtk/gtkinfobar.h>
#include <gtk/gtkinputdialog.h> #include <gtk/gtkinputdialog.h>
#include <gtk/gtkinvisible.h> #include <gtk/gtkinvisible.h>
#include <gtk/gtkitem.h> #include <gtk/gtkitem.h>

View File

@ -5155,6 +5155,23 @@ gtk_win32_embed_widget_get_type G_GNUC_CONST
#endif #endif
#endif #endif
#if IN_HEADER(__GTK_INFO_BAR_H__)
#if IN_FILE(__GTK_INFO_BAR_C__)
gtk_info_bar_get_type G_GNUC_CONST
gtk_info_bar_new
gtk_info_bar_new_with_buttons
gtk_info_bar_get_action_area
gtk_info_bar_get_content_area
gtk_info_bar_add_action_widget
gtk_info_bar_add_button
gtk_info_bar_add_buttons
gtk_info_bar_set_response_sensitive
gtk_info_bar_set_default_response
gtk_info_bar_set_message_type
gtk_info_bar_get_message_type
#endif
#endif
#ifdef INCLUDE_VARIABLES #ifdef INCLUDE_VARIABLES
gtk_binary_age gtk_binary_age
gtk_interface_age gtk_interface_age

View File

@ -206,6 +206,15 @@ typedef enum
GTK_MENU_DIR_PREV GTK_MENU_DIR_PREV
} GtkMenuDirectionType; } GtkMenuDirectionType;
typedef enum
{
GTK_MESSAGE_INFO,
GTK_MESSAGE_WARNING,
GTK_MESSAGE_QUESTION,
GTK_MESSAGE_ERROR,
GTK_MESSAGE_OTHER
} GtkMessageType;
typedef enum typedef enum
{ {
GTK_PIXELS, GTK_PIXELS,

1262
gtk/gtkinfobar.c Normal file

File diff suppressed because it is too large Load Diff

116
gtk/gtkinfobar.h Normal file
View File

@ -0,0 +1,116 @@
/*
* gtkinfobar.h
* This file is part of GTK+
*
* Copyright (C) 2005 - Paolo Maggi
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* Modified by the gedit Team, 2005. See the gedit AUTHORS file for a
* list of people on the gedit Team.
* See the gedit ChangeLog files for a list of changes.
*
* Modified by the GTK+ Team, 2008-2009.
*/
#ifndef __GTK_INFO_BAR_H__
#define __GTK_INFO_BAR_H__
#include <gtk/gtkhbox.h>
#include <gtk/gtkenums.h>
G_BEGIN_DECLS
/*
* Type checking and casting macros
*/
#define GTK_TYPE_INFO_BAR (gtk_info_bar_get_type())
#define GTK_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_INFO_BAR, GtkInfoBar))
#define GTK_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_INFO_BAR, GtkInfoBarClass))
#define GTK_IS_INFO_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_INFO_BAR))
#define GTK_IS_INFO_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_INFO_BAR))
#define GTK_INFO_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_INFO_BAR, GtkInfoBarClass))
typedef struct _GtkInfoBarPrivate GtkInfoBarPrivate;
typedef struct _GtkInfoBarClass GtkInfoBarClass;
typedef struct _GtkInfoBar GtkInfoBar;
struct _GtkInfoBar
{
GtkHBox parent;
/*< private > */
GtkInfoBarPrivate *priv;
};
struct _GtkInfoBarClass
{
GtkHBoxClass parent_class;
/* Signals */
void (* response) (GtkInfoBar *info_bar, gint response_id);
/* Keybinding signals */
void (* close) (GtkInfoBar *info_bar);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
void (*_gtk_reserved5) (void);
void (*_gtk_reserved6) (void);
};
GType gtk_info_bar_get_type (void) G_GNUC_CONST;
GtkWidget *gtk_info_bar_new (void);
GtkWidget *gtk_info_bar_new_with_buttons (const gchar *first_button_text,
...);
GtkWidget *gtk_info_bar_get_action_area (GtkInfoBar *info_bar);
GtkWidget *gtk_info_bar_get_content_area (GtkInfoBar *info_bar);
void gtk_info_bar_add_action_widget (GtkInfoBar *info_bar,
GtkWidget *child,
gint response_id);
GtkWidget *gtk_info_bar_add_button (GtkInfoBar *info_bar,
const gchar *button_text,
gint response_id);
void gtk_info_bar_add_buttons (GtkInfoBar *info_bar,
const gchar *first_button_text,
...);
void gtk_info_bar_set_response_sensitive (GtkInfoBar *info_bar,
gint response_id,
gboolean setting);
void gtk_info_bar_set_default_response (GtkInfoBar *info_bar,
gint response_id);
/* Emit response signal */
void gtk_info_bar_response (GtkInfoBar *info_bar,
gint response_id);
void gtk_info_bar_set_message_type (GtkInfoBar *info_bar,
GtkMessageType message_type);
GtkMessageType gtk_info_bar_get_message_type (GtkInfoBar *info_bar);
G_END_DECLS
#endif /* __GTK_INFO_BAR_H__ */

View File

@ -32,18 +32,10 @@
#define __GTK_MESSAGE_DIALOG_H__ #define __GTK_MESSAGE_DIALOG_H__
#include <gtk/gtkdialog.h> #include <gtk/gtkdialog.h>
#include <gtk/gtkenums.h>
G_BEGIN_DECLS G_BEGIN_DECLS
typedef enum
{
GTK_MESSAGE_INFO,
GTK_MESSAGE_WARNING,
GTK_MESSAGE_QUESTION,
GTK_MESSAGE_ERROR,
GTK_MESSAGE_OTHER
} GtkMessageType;
typedef enum typedef enum
{ {
GTK_BUTTONS_NONE, GTK_BUTTONS_NONE,

View File

@ -2483,6 +2483,56 @@ test_file (const gchar *filename)
builder = NULL; builder = NULL;
} }
static void
test_message_area (void)
{
GtkBuilder *builder;
GError *error;
GObject *obj, *obj1;
const gchar buffer[] =
"<interface>"
" <object class=\"GtkInfoBar\" id=\"infobar1\">"
" <child internal-child=\"content_area\">"
" <object class=\"GtkHBox\" id=\"contentarea1\">"
" <child>"
" <object class=\"GtkLabel\" id=\"content\">"
" <property name=\"label\" translatable=\"yes\">Message</property>"
" </object>"
" </child>"
" </object>"
" </child>"
" <child internal-child=\"action_area\">"
" <object class=\"GtkVButtonBox\" id=\"actionarea1\">"
" <child>"
" <object class=\"GtkButton\" id=\"button_ok\">"
" <property name=\"label\">gtk-ok</property>"
" <property name=\"use-stock\">yes</property>"
" </object>"
" </child>"
" </object>"
" </child>"
" <action-widgets>"
" <action-widget response=\"1\">button_ok</action-widget>"
" </action-widgets>"
" </object>"
"</interface>";
error = NULL;
builder = builder_new_from_string (buffer, -1, &error);
g_assert (error == NULL);
obj = gtk_builder_get_object (builder, "infobar1");
g_assert (GTK_IS_INFO_BAR (obj));
obj1 = gtk_builder_get_object (builder, "content");
g_assert (GTK_IS_LABEL (obj1));
g_assert (gtk_widget_get_parent (gtk_widget_get_parent (obj1)) == obj);
obj1 = gtk_builder_get_object (builder, "button_ok");
g_assert (GTK_IS_BUTTON (obj1));
g_assert (gtk_widget_get_parent (gtk_widget_get_parent (obj1)) == obj);
g_object_unref (builder);
}
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
@ -2525,6 +2575,7 @@ main (int argc, char **argv)
g_test_add_func ("/Builder/Requires", test_requires); g_test_add_func ("/Builder/Requires", test_requires);
g_test_add_func ("/Builder/AddObjects", test_add_objects); g_test_add_func ("/Builder/AddObjects", test_add_objects);
g_test_add_func ("/Builder/Menus", test_menus); g_test_add_func ("/Builder/Menus", test_menus);
g_test_add_func ("/Builder/MessageArea", test_message_area);
return g_test_run(); return g_test_run();
} }