2010-06-24 04:35:24 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
static void
|
|
|
|
expander_cb (GtkExpander *expander, GParamSpec *pspec, GtkWindow *dialog)
|
|
|
|
{
|
|
|
|
gtk_window_set_resizable (dialog, gtk_expander_get_expanded (expander));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2020-02-10 03:24:47 +00:00
|
|
|
response_cb (GtkDialog *dialog, gint response_id, gpointer data)
|
2010-06-24 04:35:24 +00:00
|
|
|
{
|
2020-02-10 03:24:47 +00:00
|
|
|
gboolean *done = data;
|
|
|
|
|
|
|
|
*done = TRUE;
|
|
|
|
|
|
|
|
g_main_context_wakeup (NULL);
|
2010-06-24 04:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *area;
|
|
|
|
GtkWidget *expander;
|
|
|
|
GtkWidget *sw;
|
|
|
|
GtkWidget *tv;
|
|
|
|
GtkTextBuffer *buffer;
|
2020-02-10 03:24:47 +00:00
|
|
|
gboolean done = FALSE;
|
2010-06-24 04:35:24 +00:00
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2010-06-24 04:35:24 +00:00
|
|
|
|
|
|
|
dialog = gtk_message_dialog_new_with_markup (NULL,
|
|
|
|
0,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_CLOSE,
|
|
|
|
"<big><b>%s</b></big>",
|
|
|
|
"Something went wrong");
|
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
|
|
|
"Here are some more details "
|
|
|
|
"but not the full story.");
|
|
|
|
|
|
|
|
area = gtk_message_dialog_get_message_area (GTK_MESSAGE_DIALOG (dialog));
|
|
|
|
|
|
|
|
expander = gtk_expander_new ("Details:");
|
|
|
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
2020-04-17 03:25:06 +00:00
|
|
|
gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE);
|
2010-06-24 04:35:24 +00:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
|
|
GTK_POLICY_NEVER,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
tv = gtk_text_view_new ();
|
|
|
|
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tv));
|
|
|
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (tv), FALSE);
|
|
|
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (tv), GTK_WRAP_WORD);
|
|
|
|
gtk_text_buffer_set_text (GTK_TEXT_BUFFER (buffer),
|
|
|
|
"Finally, the full story with all details. "
|
|
|
|
"And all the inside information, including "
|
|
|
|
"error codes, etc etc. Pages of information, "
|
|
|
|
"you might have to scroll down to read it all, "
|
|
|
|
"or even resize the window - it works !\n"
|
|
|
|
"A second paragraph will contain even more "
|
|
|
|
"innuendo, just to make you scroll down or "
|
|
|
|
"resize the window. Do it already !", -1);
|
2020-05-02 04:51:20 +00:00
|
|
|
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), tv);
|
2020-05-07 04:05:51 +00:00
|
|
|
gtk_expander_set_child (GTK_EXPANDER (expander), sw);
|
2017-04-21 16:59:59 +00:00
|
|
|
gtk_widget_set_hexpand (expander, TRUE);
|
|
|
|
gtk_widget_set_vexpand (expander, TRUE);
|
2020-05-09 12:26:52 +00:00
|
|
|
gtk_box_append (GTK_BOX (area), expander);
|
2010-06-24 04:35:24 +00:00
|
|
|
g_signal_connect (expander, "notify::expanded",
|
|
|
|
G_CALLBACK (expander_cb), dialog);
|
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), &done);
|
2010-06-24 04:35:24 +00:00
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
|
|
|
|
2020-02-10 03:24:47 +00:00
|
|
|
while (!done)
|
|
|
|
g_main_context_iteration (NULL, TRUE);
|
2010-06-24 04:35:24 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|