static void button_clicked (GtkWidget *widget, gpointer data) { if (data) { const char *s; /* Okay button or enter used in text field. */ #ifdef ENABLE_ENHANCED /* FIXME: This is not compatible with assuan. We can't just print stuff on stdout. */ if (pinentry->enhanced) printf ("Options: %s\nTimeout: %d\n\n", gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (insure)) ? "insure" : "", gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (time_out))); #endif s = gtk_secure_entry_get_text (GTK_SECURE_ENTRY (entry)); if (!s) s = ""; passphrase_ok = 1; pinentry_setbufferlen (pinentry, strlen (s) + 1); if (pinentry->pin) strcpy (pinentry->pin, s); } gtk_main_quit (); }
static void button_clicked (GtkWidget *widget, gpointer data) { if (data) { /* Okay button hit or Enter used in the text field. */ const char *s; char *s_utf8; char *s_buffer; if (pinentry->enhanced) { printf("Options: %s\nTimeout: %d\n\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(insure)) ? "insure" : "", gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(time_out))); } pinentry->locale_err = 1; s = gtk_secure_entry_get_text (GTK_SECURE_ENTRY(entry)); if (!s) s = ""; s_buffer = secmem_malloc (strlen (s) + 1); if (s_buffer) { strcpy (s_buffer, s); s_utf8 = pinentry_local_to_utf8 (pinentry->lc_ctype, s_buffer, 1); secmem_free (s_buffer); if (s_utf8) { passphrase_ok = 1; pinentry_setbufferlen (pinentry, strlen (s_utf8) + 1); if (pinentry->pin) strcpy (pinentry->pin, s_utf8); secmem_free (s_utf8); pinentry->locale_err = 0; } } } gtk_main_quit (); }
/* Handler called for "changed". We use it to update the quality indicator. */ static void changed_text_handler (GtkWidget *widget) { char textbuf[50]; const char *s; int length; int percent; GdkColor color = { 0, 0, 0, 0}; got_input = TRUE; if (!qualitybar || !pinentry->quality_bar) return; s = gtk_secure_entry_get_text (GTK_SECURE_ENTRY (widget)); if (!s) s = ""; length = strlen (s); percent = length? pinentry_inq_quality (pinentry, s, length) : 0; if (!length) { strcpy(textbuf, QUALITYBAR_EMPTY_TEXT); color.red = 0xffff; } else if (percent < 0) { snprintf (textbuf, sizeof textbuf, "(%d%%)", -percent); color.red = 0xffff; percent = -percent; } else { snprintf (textbuf, sizeof textbuf, "%d%%", percent); color.green = 0xffff; } gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (qualitybar), (double)percent/100.0); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (qualitybar), textbuf); gtk_widget_modify_bg (qualitybar, GTK_STATE_PRELIGHT, &color); }