Specialize alertpanel icons
[claws.git] / src / alertpanel.c
index 8fd030f6e310f32c856f0bd835d26d39abbd9786..081073a9ed3185cc3a73e8f2d8420d2e58a2eff6 100644 (file)
@@ -39,7 +39,7 @@
 #define TITLE_HEIGHT           72
 #define MESSAGE_HEIGHT         62
 
-#define DEFAULT_TITLE_FONT     "Helvetica 16"
+#define DEFAULT_TITLE_FONT     "Sans Bold 12"
 
 static gboolean alertpanel_is_open = FALSE;
 static AlertValue value;
@@ -53,7 +53,8 @@ static void alertpanel_create         (const gchar    *title,
                                         const gchar    *button2_label,
                                         const gchar    *button3_label,
                                         gboolean        can_disable,
-                                        GtkWidget      *custom_widget);
+                                        GtkWidget      *custom_widget,
+                                        gint            alert_type);
 
 static void alertpanel_button_toggled  (GtkToggleButton        *button,
                                         gpointer                data);
@@ -78,7 +79,7 @@ AlertValue alertpanel(const gchar *title,
                alertpanel_is_open = TRUE;
 
        alertpanel_create(title, message, button1_label, button2_label,
-                         button3_label, FALSE, NULL);
+                         button3_label, FALSE, NULL, ALERT_QUESTION);
        alertpanel_show();
 
        debug_print("return value = %d\n", value);
@@ -97,32 +98,35 @@ AlertValue alertpanel_with_widget(const gchar *title,
        else
                alertpanel_is_open = TRUE;
        alertpanel_create(title, message, button1_label, button2_label, 
-                         button3_label, FALSE, widget);
+                         button3_label, FALSE, widget, ALERT_QUESTION);
        alertpanel_show();
 
        debug_print("return value = %d\n", value);
        return value;
 }
-void alertpanel_message(const gchar *title, const gchar *message)
+
+static void alertpanel_message(const gchar *title, const gchar *message, gint type)
 {
        if (alertpanel_is_open)
                return;
        else
                alertpanel_is_open = TRUE;
 
-       alertpanel_create(title, message, NULL, NULL, NULL, FALSE, NULL);
+       alertpanel_create(title, message, NULL, NULL, NULL, FALSE, NULL, type);
        alertpanel_show();
 }
 
 AlertValue alertpanel_message_with_disable(const gchar *title,
-                                          const gchar *message)
+                                          const gchar *message,
+                                          gint alert_type)
 {
        if (alertpanel_is_open)
                return 0;
        else
                alertpanel_is_open = TRUE;
 
-       alertpanel_create(title, message, NULL, NULL, NULL, TRUE, NULL);
+       alertpanel_create(title, message, NULL, NULL, NULL, TRUE, NULL,
+                         alert_type);
        alertpanel_show();
 
        return value;
@@ -138,7 +142,7 @@ void alertpanel_notice(const gchar *format, ...)
        va_end(args);
        strretchomp(buf);
 
-       alertpanel_message(_("Notice"), buf);
+       alertpanel_message(_("Notice"), buf, ALERT_NOTICE);
 }
 
 void alertpanel_warning(const gchar *format, ...)
@@ -151,7 +155,7 @@ void alertpanel_warning(const gchar *format, ...)
        va_end(args);
        strretchomp(buf);
 
-       alertpanel_message(_("Warning"), buf);
+       alertpanel_message(_("Warning"), buf, ALERT_WARNING);
 }
 
 void alertpanel_error(const gchar *format, ...)
@@ -164,7 +168,7 @@ void alertpanel_error(const gchar *format, ...)
        va_end(args);
        strretchomp(buf);
 
-       alertpanel_message(_("Error"), buf);
+       alertpanel_message(_("Error"), buf, ALERT_ERROR);
 }
 
 /*!
@@ -218,10 +222,12 @@ static void alertpanel_create(const gchar *title,
                              const gchar *button2_label,
                              const gchar *button3_label,
                              gboolean     can_disable,
-                             GtkWidget *custom_widget)
+                             GtkWidget   *custom_widget,
+                             gint         alert_type)
 {
        static PangoFontDescription *font_desc;
        GtkWidget *label;
+       GtkWidget *w_hbox;
        GtkWidget *hbox;
        GtkWidget *vbox;
        GtkWidget *spc_vbox;
@@ -231,8 +237,13 @@ static void alertpanel_create(const gchar *title,
        GtkWidget *button1;
        GtkWidget *button2;
        GtkWidget *button3;
+       GtkWidget *icon;
        const gchar *label2;
        const gchar *label3;
+       gchar *icon_desc[] = {  GTK_STOCK_DIALOG_INFO,
+                               GTK_STOCK_DIALOG_QUESTION,
+                               GTK_STOCK_DIALOG_WARNING,
+                               GTK_STOCK_DIALOG_ERROR };
 
        debug_print("Creating alert panel dialog...\n");
 
@@ -251,16 +262,22 @@ static void alertpanel_create(const gchar *title,
        gtk_widget_realize(dialog);
 
        /* for title label */
+       w_hbox = gtk_hbox_new(FALSE, 0);
+       
+       if (alert_type < 0 || alert_type > 3)
+               alert_type = 0;
+       icon = gtk_image_new_from_stock(icon_desc[alert_type],
+                                       GTK_ICON_SIZE_DIALOG); 
+       gtk_box_pack_start(GTK_BOX(w_hbox), icon, FALSE, FALSE, 16);
        hbox = gtk_hbox_new(FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(w_hbox), hbox, FALSE, FALSE, 2);
        gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
-                          hbox, TRUE, TRUE, 16);
+                          w_hbox, TRUE, TRUE, 16);
+
 
-       /* title label */
-       /* pixmapwid = create_pixmapwid(dialog, GNUstep_xpm); */
-       /* gtk_box_pack_start(GTK_BOX(hbox), pixmapwid, FALSE, FALSE, 16); */
        label = gtk_label_new(title);
-       gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 16);
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+       gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
        if (!font_desc) {
                gchar *fontstr = prefs_common.titlefont
                                        ? prefs_common.titlefont
@@ -270,6 +287,7 @@ static void alertpanel_create(const gchar *title,
        if (font_desc) {
                gtk_widget_modify_font (label, font_desc);
        }
+       gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 16);
 
        /* for message and button(s) */
        vbox = gtk_vbox_new(FALSE, 0);