Пример #1
0
static void
hide_dialog(GncGWENGui *gui)
{
    g_return_if_fail(gui);

    ENTER("gui=%p", gui);

    /* Hide the dialog */
    gtk_widget_hide(gui->dialog);

    /* Remember whether the dialog is to be closed when finished */
    gnc_gconf_set_bool(
        GCONF_SECTION_AQBANKING, KEY_CLOSE_ON_FINISH,
        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gui->close_checkbutton)),
        NULL);

    /* Remember size and position of the dialog */
    gnc_save_window_size(GCONF_SECTION_CONNECTION, GTK_WINDOW(gui->dialog));

    /* Do not serve as GUI anymore */
    gui->state = HIDDEN;
    unregister_callbacks(gui);

    LEAVE(" ");
}
static void
close_handler (gpointer user_data)
{
    CommoditiesDialog *cd = user_data;

    gnc_save_window_size(GCONF_SECTION, GTK_WINDOW(cd->dialog));

    gnc_gconf_set_bool(GCONF_SECTION, "include_iso", cd->show_currencies, NULL);

    gtk_widget_destroy(cd->dialog);
}
Пример #3
0
static void
get_input(GncGWENGui *gui, guint32 flags, const gchar *title, const gchar *text,
          gchar **input, gint min_len, gint max_len)
{
    GladeXML *xml;
    GtkWidget *dialog;
    GtkWidget *heading_label;
    GtkWidget *input_entry;
    GtkWidget *confirm_entry;
    GtkWidget *confirm_label;
    GtkWidget *remember_pin_checkbutton;
    const gchar *internal_input, *internal_confirmed;
    gboolean confirm = (flags & GWEN_GUI_INPUT_FLAGS_CONFIRM) != 0;
    gboolean hidden = (flags & GWEN_GUI_INPUT_FLAGS_SHOW) == 0;
    gboolean is_tan = (flags & GWEN_GUI_INPUT_FLAGS_TAN) != 0;
    gint retval;

    g_return_if_fail(input);
    g_return_if_fail(max_len >= min_len && max_len > 0);

    ENTER(" ");

    /* Set up dialog */
    xml = gnc_glade_xml_new("aqbanking.glade", "Password Dialog");
    dialog = glade_xml_get_widget(xml, "Password Dialog");
    g_object_set_data_full(G_OBJECT(dialog), "xml", xml, g_object_unref);

    heading_label = glade_xml_get_widget(xml, "heading_label");
    input_entry = glade_xml_get_widget(xml, "input_entry");
    confirm_entry = glade_xml_get_widget(xml, "confirm_entry");
    confirm_label = glade_xml_get_widget(xml, "confirm_label");
    remember_pin_checkbutton = glade_xml_get_widget(xml, "remember_pin");
    if (is_tan)
    {
        gtk_widget_hide(remember_pin_checkbutton);
    }
    else
    {
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(remember_pin_checkbutton),
                                     gui->cache_passwords);
    }

    if (gui->parent)
        gtk_window_set_transient_for(GTK_WINDOW(dialog),
                                     GTK_WINDOW(gui->parent));
    if (title)
        gtk_window_set_title(GTK_WINDOW(dialog), title);

    if (text)
    {
        gchar *raw_text = strip_html(g_strdup(text));
        gtk_label_set_text(GTK_LABEL(heading_label), raw_text);
        g_free(raw_text);
    }

    if (*input)
    {
        gtk_entry_set_text(GTK_ENTRY(input_entry), *input);
        erase_password(*input);
        *input = NULL;
    }

    if (confirm)
    {
        gtk_entry_set_activates_default(GTK_ENTRY(input_entry), FALSE);
        gtk_entry_set_activates_default(GTK_ENTRY(confirm_entry), TRUE);
        gtk_entry_set_max_length(GTK_ENTRY(input_entry), max_len);
        gtk_entry_set_max_length(GTK_ENTRY(confirm_entry), max_len);
    }
    else
    {
        gtk_entry_set_activates_default(GTK_ENTRY(input_entry), TRUE);
        gtk_entry_set_max_length(GTK_ENTRY(input_entry), max_len);
        gtk_widget_hide(confirm_entry);
        gtk_widget_hide(confirm_label);
    }
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);

    /* Ask the user until he enters a valid input or cancels */
    while (TRUE)
    {
        gboolean remember_pin;

        if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK)
            break;

        if (!is_tan)
        {
            /* Enable or disable the password cache */
            remember_pin = gtk_toggle_button_get_active(
                               GTK_TOGGLE_BUTTON(remember_pin_checkbutton));
            enable_password_cache(gui, remember_pin);
            gnc_gconf_set_bool(GCONF_SECTION_AQBANKING, KEY_REMEMBER_PIN,
                               remember_pin, NULL);
        }

        internal_input = gtk_entry_get_text(GTK_ENTRY(input_entry));
        if (strlen(internal_input) < min_len)
        {
            gboolean retval;
            gchar *msg = g_strdup_printf(
                             _("The PIN needs to be at least %d characters \n"
                               "long. Do you want to try again?"), min_len);
            retval = gnc_verify_dialog(gui->parent, TRUE, "%s", msg);
            g_free(msg);
            if (!retval)
                break;
            continue;
        }

        if (!confirm)
        {
            *input = g_strdup(internal_input);
            break;
        }

        internal_confirmed = gtk_entry_get_text(GTK_ENTRY(confirm_entry));
        if (strcmp(internal_input, internal_confirmed) == 0)
        {
            *input = g_strdup(internal_input);
            break;
        }
    }

    /* This trashes passwords in the entries' memory as well */
    gtk_widget_destroy(dialog);

    LEAVE("input %s", *input ? "non-NULL" : "NULL");
}