0.9.5claws24
[claws.git] / src / alertpanel.c
index cdaefc305e00a575ad36d16fc9405fa86fb4effd..d456ea4ef352a5a09aea82afd79114aa5f90536a 100644 (file)
 #include <gdk/gdkkeysyms.h>
 
 #include "intl.h"
+#include "mainwindow.h"
 #include "alertpanel.h"
 #include "manage_window.h"
 #include "utils.h"
 #include "gtkutils.h"
 #include "inc.h"
+#include "logwindow.h"
 
 #define TITLE_FONT     "-*-helvetica-medium-r-normal--17-*-*-*-*-*-*-*," \
                        "-*-*-medium-r-normal--16-*-*-*-*-*-*-*,*"
@@ -165,6 +167,32 @@ void alertpanel_error(const gchar *format, ...)
        alertpanel_message(_("Error"), buf);
 }
 
+/*!
+ *\brief       display an error with a View Log button
+ *
+ */
+void alertpanel_error_log(const gchar *format, ...)
+{
+       va_list args;
+       int val;
+       MainWindow *mainwin;
+       gchar buf[256];
+
+       va_start(args, format);
+       g_vsnprintf(buf, sizeof(buf), format, args);
+       va_end(args);
+       strretchomp(buf);
+
+       mainwin = mainwindow_get_mainwindow();
+       
+       if (mainwin && mainwin->logwin) {
+               val = alertpanel(_("Error"), buf, _("OK"), _("View log"), NULL);
+               if (val == G_ALERTALTERNATE)
+                       log_window_show(mainwin->logwin);
+       } else
+               alertpanel_error(buf);
+}
+
 static void alertpanel_show(void)
 {
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
@@ -236,7 +264,7 @@ static void alertpanel_create(const gchar *title,
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
        style = gtk_style_copy(gtk_widget_get_style(label));
        if (!titlefont)
-               titlefont = gdk_fontset_load(TITLE_FONT);
+               titlefont = gtkut_font_load(TITLE_FONT);
        if (titlefont)
                style->font = titlefont;
        gtk_widget_set_style(label, style);
@@ -260,9 +288,16 @@ static void alertpanel_create(const gchar *title,
        /* message label */
        label = gtk_label_new(message);
        gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 24);
-       gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
        gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
 
+       /* Claws: custom widget */
+       if (custom_widget) {
+               GtkWidget *custom_hbox = gtk_hbox_new(FALSE, 0);
+               gtk_box_pack_start(GTK_BOX(msg_vbox), custom_hbox, FALSE,
+                                  FALSE, 0);
+               gtk_box_pack_start(GTK_BOX(custom_hbox), custom_widget, FALSE,
+                                  FALSE, 24);
+       }
        if (can_disable) {
                hbox = gtk_hbox_new(FALSE, 0);
                gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);