4 expander_cb (GtkExpander *expander, GParamSpec *pspec, GtkWindow *dialog)
6 gtk_window_set_resizable (dialog, gtk_expander_get_expanded (expander));
10 do_not_expand (GtkWidget *child, gpointer data)
12 gtk_container_child_set (GTK_CONTAINER (gtk_widget_get_parent (child)), child,
13 "expand", FALSE, "fill", FALSE, NULL);
17 response_cb (GtkDialog *dialog, gint response_id)
23 main (int argc, char *argv[])
31 GtkTextBuffer *buffer;
33 gtk_init (&argc, &argv);
35 dialog = gtk_message_dialog_new_with_markup (NULL,
39 "<big><b>%s</b></big>",
40 "Something went wrong");
41 gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
42 "Here are some more details "
43 "but not the full story.");
45 area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog));
46 /* make the hbox expand */
47 box = gtk_widget_get_parent (area);
48 gtk_container_child_set (GTK_CONTAINER (gtk_widget_get_parent (box)), box,
49 "expand", TRUE, "fill", TRUE, NULL);
50 /* make the labels not expand */
51 gtk_container_foreach (GTK_CONTAINER (area), do_not_expand, NULL);
53 expander = gtk_expander_new ("Details:");
54 sw = gtk_scrolled_window_new (NULL, NULL);
55 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN);
56 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
58 GTK_POLICY_AUTOMATIC);
60 tv = gtk_text_view_new ();
61 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv));
62 gtk_text_view_set_editable (GTK_TEXT_VIEW (tv), FALSE);
63 gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (tv), GTK_WRAP_WORD);
64 gtk_text_buffer_set_text (GTK_TEXT_BUFFER (buffer),
65 "Finally, the full story with all details. "
66 "And all the inside information, including "
67 "error codes, etc etc. Pages of information, "
68 "you might have to scroll down to read it all, "
69 "or even resize the window - it works !\n"
70 "A second paragraph will contain even more "
71 "innuendo, just to make you scroll down or "
72 "resize the window. Do it already !", -1);
73 gtk_container_add (GTK_CONTAINER (sw), tv);
74 gtk_container_add (GTK_CONTAINER (expander), sw);
75 gtk_box_pack_end (GTK_BOX (area), expander, TRUE, TRUE, 0);
76 gtk_widget_show_all (expander);
77 g_signal_connect (expander, "notify::expanded",
78 G_CALLBACK (expander_cb), dialog);
80 g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
82 gtk_window_present (GTK_WINDOW (dialog));