2006-08-14 [cleroy] 2.4.0cvs50
[claws.git] / src / gtk / gtkutils.c
index 288ae4569efb110e956dcdaf0fbd642c8ee025cb..10f539626d480d04f3818b9b97525b148590b265 100644 (file)
@@ -60,6 +60,7 @@
 #include "prefs_common.h"
 #include "manage_window.h"
 #include "base64.h"
+#include "manual.h"
 
 gboolean gtkut_get_font_size(GtkWidget *widget,
                             gint *width, gint *height)
@@ -104,6 +105,36 @@ void gtkut_convert_int_to_gdk_color(gint rgbvalue, GdkColor *color)
        color->blue  = (int) (((gdouble) (rgbvalue & 0x0000ff)        / 255.0) * 65535.0);
 }
 
+void gtkut_stock_button_add_help(GtkWidget *bbox, GtkWidget **help_btn)
+{
+       g_return_if_fail(bbox != NULL);
+
+       *help_btn = gtk_button_new_from_stock(GTK_STOCK_HELP);
+
+       GTK_WIDGET_SET_FLAGS(*help_btn, GTK_CAN_DEFAULT);
+       gtk_box_pack_end(GTK_BOX (bbox), *help_btn, TRUE, TRUE, 0);
+       gtk_button_box_set_child_secondary(GTK_BUTTON_BOX (bbox),
+                       *help_btn, TRUE);
+       gtk_widget_set_sensitive(*help_btn,
+                       manual_available(MANUAL_MANUAL_LOCAL));
+       gtk_widget_show(*help_btn);
+}
+
+void gtkut_stock_button_set_create_with_help(GtkWidget **bbox,
+               GtkWidget **help_button,
+               GtkWidget **button1, const gchar *label1,
+               GtkWidget **button2, const gchar *label2,
+               GtkWidget **button3, const gchar *label3)
+{
+       g_return_if_fail(bbox != NULL);
+       g_return_if_fail(button1 != NULL);
+
+       gtkut_stock_button_set_create(bbox, button1, label1,
+                       button2, label2, button3, label3);
+
+       gtkut_stock_button_add_help(*bbox, help_button);
+}
+
 void gtkut_stock_button_set_create(GtkWidget **bbox,
                                   GtkWidget **button1, const gchar *label1,
                                   GtkWidget **button2, const gchar *label2,
@@ -759,16 +790,17 @@ void gtkut_widget_init(void)
 
 void gtkut_widget_set_app_icon(GtkWidget *widget)
 {
-#include "pixmaps/sylpheed.xpm"        
-       static GdkPixmap *sylpheedxpm;
-       static GdkBitmap *sylpheedxpmmask;
+#include "pixmaps/sylpheed-claws.xpm"
+       static GdkPixmap *sylpheedclawsxpm;
+       static GdkBitmap *sylpheedclawsxpmmask;
        
        g_return_if_fail(widget != NULL);
        g_return_if_fail(widget->window != NULL);
-       if (!sylpheedxpm) {
-               PIXMAP_CREATE(widget, sylpheedxpm, sylpheedxpmmask, sylpheed_xpm);
+       if (!sylpheedclawsxpm) {
+               PIXMAP_CREATE(widget, sylpheedclawsxpm, sylpheedclawsxpmmask,
+                             sylpheed_claws_xpm);
        }               
-       gdk_window_set_icon(widget->window, NULL, sylpheedxpm, sylpheedxpmmask);
+       gdk_window_set_icon(widget->window, NULL, sylpheedclawsxpm, sylpheedclawsxpmmask);
 }
 
 void gtkut_widget_set_composer_icon(GtkWidget *widget)
@@ -800,9 +832,12 @@ GtkWidget *label_window_create(const gchar *str)
 
        label = gtk_label_new(str);
        gtk_container_add(GTK_CONTAINER(window), label);
+       gtk_label_set_line_wrap(label, TRUE);
        gtk_widget_show(label);
 
        gtk_widget_show_now(window);
+       
+       GTK_EVENTS_FLUSH();
 
        return window;
 }
@@ -1147,6 +1182,9 @@ GtkWidget *face_get_from_header(const gchar *o_face)
        GdkPixbufLoader *loader = gdk_pixbuf_loader_new ();
        GtkWidget *image;
        
+       if (o_face == NULL || strlen(o_face) == 0)
+               return NULL;
+
        strncpy2(face, o_face, sizeof(face));
 
        unfold_line(face); /* strip all whitespace and linebreaks */
@@ -1281,7 +1319,7 @@ GtkWidget *gtkut_get_link_btn(GtkWidget *window, const gchar *url, const gchar *
        return btn;
 }
 
-GtkWidget *gtkut_sc_combobox_create(GtkWidget *eventbox)
+GtkWidget *gtkut_sc_combobox_create(GtkWidget *eventbox, gboolean focus_on_click)
 {
        GtkWidget *combobox;
        GtkListStore *menu;
@@ -1299,8 +1337,8 @@ GtkWidget *gtkut_sc_combobox_create(GtkWidget *eventbox)
 
        if( eventbox != NULL )
                gtk_container_add(GTK_CONTAINER(eventbox), combobox);
-
-       gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(combobox), FALSE);
-
+#if GTK_CHECK_VERSION(2,6,0)
+       gtk_combo_box_set_focus_on_click(GTK_COMBO_BOX(combobox), focus_on_click);
+#endif
        return combobox;
 }