2005-11-18 [cleroy] 1.9.100cvs17
[claws.git] / src / gtk / inputdialog.c
index 5a329c9688545173238e2fd547793516bc276145..3ba93fdd73ad0f86c308df449092a06b41352517 100644 (file)
@@ -14,7 +14,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -64,8 +64,9 @@ static GtkWidget *msg_label;
 static GtkWidget *entry;
 static GtkWidget *combo;
 static GtkWidget *ok_button;
+static GtkWidget *icon_q, *icon_p;
 
-static void input_dialog_create        (void);
+static void input_dialog_create        (gboolean is_password);
 static gchar *input_dialog_open        (const gchar    *title,
                                 const gchar    *message,
                                 const gchar    *default_string);
@@ -93,11 +94,14 @@ gchar *input_dialog(const gchar *title, const gchar *message,
        if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
 
        if (!dialog)
-               input_dialog_create();
+               input_dialog_create(FALSE);
 
        type = INPUT_DIALOG_NORMAL;
        gtk_widget_hide(combo);
        gtk_widget_show(entry);
+
+       gtk_widget_show(icon_q);
+       gtk_widget_hide(icon_p);
        gtk_entry_set_visibility(GTK_ENTRY(entry), TRUE);
 
        return input_dialog_open(title, message, default_string);
@@ -109,11 +113,14 @@ gchar *input_dialog_with_invisible(const gchar *title, const gchar *message,
        if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
 
        if (!dialog)
-               input_dialog_create();
+               input_dialog_create(TRUE);
 
        type = INPUT_DIALOG_INVISIBLE;
        gtk_widget_hide(combo);
        gtk_widget_show(entry);
+
+       gtk_widget_hide(icon_q);
+       gtk_widget_show(icon_p);
        gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
 
        return input_dialog_open(title, message, default_string);
@@ -126,12 +133,15 @@ gchar *input_dialog_combo(const gchar *title, const gchar *message,
        if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
 
        if (!dialog)
-               input_dialog_create();
+               input_dialog_create(FALSE);
 
        type = INPUT_DIALOG_COMBO;
        gtk_widget_hide(entry);
        gtk_widget_show(combo);
 
+       gtk_widget_show(icon_q);
+       gtk_widget_hide(icon_p);
+
        if (!list) {
                GList empty_list;
 
@@ -160,7 +170,7 @@ gchar *input_dialog_query_password(const gchar *server, const gchar *user)
        return pass;
 }
 
-static void input_dialog_create(void)
+static void input_dialog_create(gboolean is_password)
 {
        static PangoFontDescription *font_desc;
        GtkWidget *w_hbox;
@@ -168,7 +178,6 @@ static void input_dialog_create(void)
        GtkWidget *vbox;
        GtkWidget *cancel_button;
        GtkWidget *confirm_area;
-       GtkWidget *icon;
 
        dialog = gtk_dialog_new();
 
@@ -192,10 +201,14 @@ static void input_dialog_create(void)
        /* for title label */
        w_hbox = gtk_hbox_new(FALSE, 0);
        
-       icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
-                                       GTK_ICON_SIZE_DIALOG); 
-       gtk_misc_set_alignment (GTK_MISC (icon), 0.5, 0.0);
-       gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+       icon_q = gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
+                               GTK_ICON_SIZE_DIALOG); 
+       gtk_misc_set_alignment (GTK_MISC (icon_q), 0.5, 0.0);
+       gtk_box_pack_start (GTK_BOX (hbox), icon_q, FALSE, FALSE, 0);
+       icon_p = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION,
+                               GTK_ICON_SIZE_DIALOG); 
+       gtk_misc_set_alignment (GTK_MISC (icon_p), 0.5, 0.0);
+       gtk_box_pack_start (GTK_BOX (hbox), icon_p, FALSE, FALSE, 0);
        
        vbox = gtk_vbox_new (FALSE, 12);
        gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
@@ -250,6 +263,11 @@ static void input_dialog_create(void)
 
        gtk_widget_show_all(GTK_DIALOG(dialog)->vbox);
        
+       if (is_password)
+               gtk_widget_hide(icon_q);
+       else
+               gtk_widget_hide(icon_p);
+
        gtk_widget_grab_default(ok_button);
 
        g_signal_connect(G_OBJECT(ok_button), "clicked",
@@ -266,10 +284,11 @@ static gchar *input_dialog_open(const gchar *title, const gchar *message,
        if (dialog && GTK_WIDGET_VISIBLE(dialog)) return NULL;
 
        if (!dialog)
-               input_dialog_create();
+               input_dialog_create(FALSE);
 
        input_dialog_set(title, message, default_string);
        gtk_widget_show(dialog);
+
        gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
        manage_window_set_transient(GTK_WINDOW(dialog));