Beispiel #1
0
void
gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data)
{
    PricesDialog *pdb_dialog = data;
    GtkBuilder *builder;
    GtkWidget *dialog, *button, *date, *label, *box;
    gint result;
    gboolean delete_user, delete_last;

    ENTER(" ");
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "dialog-price.glade", "Deletion Date");

    dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Deletion Date"));

    box = GTK_WIDGET(gtk_builder_get_object (builder, "date_hbox"));
    date = gnc_date_edit_new (time (NULL), FALSE, FALSE);

    gtk_box_pack_start (GTK_BOX (box), date, TRUE, TRUE, 0);
    gtk_widget_show (date);
    gtk_entry_set_activates_default(GTK_ENTRY(GNC_DATE_EDIT(date)->date_entry), TRUE);
    label = GTK_WIDGET(gtk_builder_get_object (builder, "date_label"));
    gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date), label);

    gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, pdb_dialog);

    gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (pdb_dialog->dialog));

    result = gtk_dialog_run (GTK_DIALOG (dialog));
    if (result == GTK_RESPONSE_OK)
    {
        Timespec ts;

        DEBUG("deleting prices");
        ts.tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (date));
        ts.tv_nsec = 0;

        button = GTK_WIDGET(gtk_builder_get_object (builder, "delete_manual"));
        delete_user = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
        button = GTK_WIDGET(gtk_builder_get_object (builder, "delete_last"));
        delete_last = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));

        gnc_pricedb_remove_old_prices(pdb_dialog->price_db, ts,
                                      delete_user, delete_last);
    }

    gtk_widget_destroy(dialog);
    LEAVE(" ");
}
void
gnc_prices_dialog_remove_old_clicked (GtkWidget *widget, gpointer data)
{
    PricesDialog *pdb_dialog = data;
    GladeXML *xml;
    GtkWidget *dialog, *button, *date, *label;
    gint result;
    gboolean delete_user, delete_last;

    ENTER(" ");
    xml = gnc_glade_xml_new ("price.glade", "Deletion Date");
    dialog = glade_xml_get_widget (xml, "Deletion Date");
    date = glade_xml_get_widget (xml, "date");
    label = glade_xml_get_widget (xml, "date_label");
    gnc_date_make_mnemonic_target (GNC_DATE_EDIT(date), label);
    glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func, pdb_dialog);
    gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (pdb_dialog->dialog));

    result = gtk_dialog_run (GTK_DIALOG (dialog));
    if (result == GTK_RESPONSE_OK)
    {
        Timespec ts;

        DEBUG("deleting prices");
        ts.tv_sec = gnc_date_edit_get_date (GNC_DATE_EDIT (date));
        ts.tv_nsec = 0;

        button = glade_xml_get_widget (xml, "delete_manual");
        delete_user = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
        button = glade_xml_get_widget (xml, "delete_last");
        delete_last = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));

        gnc_pricedb_remove_old_prices(pdb_dialog->price_db, ts,
                                      delete_user, delete_last);
    }

    gtk_widget_destroy(dialog);
    LEAVE(" ");
}