diff --git a/auth-dialog/main.c b/auth-dialog/main.c index 30e0366..9f4288e 100644 --- a/auth-dialog/main.c +++ b/auth-dialog/main.c @@ -151,6 +151,26 @@ static void ssl_box_add_error(auth_ui_data *ui_data, const char *msg) gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 0); } +static void ssl_box_add_notice(auth_ui_data *ui_data, const char *msg) +{ + GtkWidget *hbox, *text, *image; + int width; + + hbox = gtk_hbox_new(FALSE, 8); + gtk_box_pack_start(GTK_BOX(ui_data->ssl_box), hbox, FALSE, FALSE, 0); + + image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_DIALOG); + gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); + + text = gtk_label_new(msg); + gtk_label_set_line_wrap(GTK_LABEL(text), TRUE); + gtk_window_get_size(GTK_WINDOW(ui_data->dialog), &width, NULL); + /* FIXME: this is not very nice -- can't make the window thinner after this */ + gtk_widget_set_size_request(text, width - 100, -1); + gtk_box_pack_start(GTK_BOX(hbox), text, FALSE, FALSE, 0); +} + static void ssl_box_add_info(auth_ui_data *ui_data, const char *msg) { GtkWidget *text; @@ -166,6 +186,7 @@ static void ssl_box_add_info(auth_ui_data *ui_data, const char *msg) static void ssl_box_clear(auth_ui_data *ui_data) { + printf("ssl_box_clear\n"); gtk_widget_hide(ui_data->no_form_label); gtk_widget_hide(ui_data->getting_form_label); gtk_container_foreach(GTK_CONTAINER(ui_data->ssl_box), @@ -972,6 +993,19 @@ static gboolean write_progress_real(char *message) return FALSE; } +/* NOTE: write_progress_real() will free the given string */ +static gboolean write_notice_real(char *message) +{ + auth_ui_data *ui_data = _ui_data; /* FIXME global */ + + g_return_val_if_fail(message, FALSE); + printf("add notice %s\n", message); + ssl_box_add_notice(ui_data, message); + g_free(message); + + return FALSE; +} + /* runs in worker thread */ static void write_progress(struct openconnect_info *info, int level, const char *fmt, ...) { @@ -992,6 +1026,7 @@ static void write_progress(struct openconnect_info *info, int level, const char } if (level <= PRG_ERR) { + g_idle_add((GSourceFunc)write_notice_real, g_strdup(msg)); last_message = msg; return; }