[gtk+] gtk3-demo: Improve the infobar demo
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gtk3-demo: Improve the infobar demo
- Date: Wed, 31 Jul 2013 17:05:20 +0000 (UTC)
commit a87648c1b6b8fc9faeed62fabf2fe02ee93a95f9
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jul 31 18:42:10 2013 +0200
gtk3-demo: Improve the infobar demo
Add buttons that allow to show and hide each info bar.
demos/gtk-demo/infobar.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/demos/gtk-demo/infobar.c b/demos/gtk-demo/infobar.c
index 22d9a07..2239bbe 100644
--- a/demos/gtk-demo/infobar.c
+++ b/demos/gtk-demo/infobar.c
@@ -15,6 +15,12 @@ on_bar_response (GtkInfoBar *info_bar,
{
GtkWidget *dialog;
+ if (response_id == GTK_RESPONSE_CLOSE)
+ {
+ gtk_widget_hide (info_bar);
+ return;
+ }
+
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
@@ -39,9 +45,13 @@ do_infobar (GtkWidget *do_widget)
GtkWidget *vbox;
GtkWidget *vbox2;
GtkWidget *label;
+ GtkWidget *actions;
+ GtkWidget *button;
if (!window)
{
+ actions = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (do_widget));
@@ -59,12 +69,20 @@ do_infobar (GtkWidget *do_widget)
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_INFO");
gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE,
0);
+ button = gtk_toggle_button_new_with_label ("Message");
+ g_object_bind_property (button, "active", bar, "visible", G_BINDING_BIDIRECTIONAL);
+ gtk_container_add (GTK_CONTAINER (actions), button);
+
bar = gtk_info_bar_new ();
gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0);
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_WARNING);
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_WARNING");
gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE,
0);
+ button = gtk_toggle_button_new_with_label ("Warning");
+ g_object_bind_property (button, "active", bar, "visible", G_BINDING_BIDIRECTIONAL);
+ gtk_container_add (GTK_CONTAINER (actions), button);
+
bar = gtk_info_bar_new_with_buttons (_("_OK"), GTK_RESPONSE_OK, NULL);
gtk_info_bar_set_show_close_button (GTK_INFO_BAR (bar), TRUE);
g_signal_connect (bar, "response", G_CALLBACK (on_bar_response), window);
@@ -73,18 +91,30 @@ do_infobar (GtkWidget *do_widget)
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_QUESTION");
gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE,
0);
+ button = gtk_toggle_button_new_with_label ("Question");
+ g_object_bind_property (button, "active", bar, "visible", G_BINDING_BIDIRECTIONAL);
+ gtk_container_add (GTK_CONTAINER (actions), button);
+
bar = gtk_info_bar_new ();
gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0);
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_ERROR);
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_ERROR");
gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE,
0);
+ button = gtk_toggle_button_new_with_label ("Error");
+ g_object_bind_property (button, "active", bar, "visible", G_BINDING_BIDIRECTIONAL);
+ gtk_container_add (GTK_CONTAINER (actions), button);
+
bar = gtk_info_bar_new ();
gtk_box_pack_start (GTK_BOX (vbox), bar, FALSE, FALSE, 0);
gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_OTHER);
label = gtk_label_new ("This is an info bar with message type GTK_MESSAGE_OTHER");
gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))), label, FALSE, FALSE,
0);
+ button = gtk_toggle_button_new_with_label ("Other");
+ g_object_bind_property (button, "active", bar, "visible", G_BINDING_BIDIRECTIONAL);
+ gtk_container_add (GTK_CONTAINER (actions), button);
+
frame = gtk_frame_new ("Info bars");
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 8);
@@ -95,6 +125,9 @@ do_infobar (GtkWidget *do_widget)
/* Standard message dialog */
label = gtk_label_new ("An example of different info bars");
gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (actions);
+ gtk_box_pack_start (GTK_BOX (vbox2), actions, FALSE, FALSE, 0);
}
if (!gtk_widget_get_visible (window))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]