/********************************************************************\
 * autoClearWindow                                                  *
 *   opens up the window to auto-clear an account                   *
 *                                                                  *
 * Args:   parent  - the parent of this window                      *
 *         account - the account to auto-clear                      *
 * Return: autoClearData - the instance of this AutoClearWindow     *
\********************************************************************/
AutoClearWindow *
autoClearWindow (GtkWidget *parent, Account *account)
{
    GtkBox *box;
    GtkLabel *label;
    GtkBuilder *builder;
    AutoClearWindow *data;
    char *title;

    data = g_new0 (AutoClearWindow, 1);
    data->account = account;

    /* Create the dialog box */
    builder = gtk_builder_new();
    gnc_builder_add_from_file (builder, "window-autoclear.glade", "auto_clear_start_dialog");
    data->window = GTK_WIDGET(gtk_builder_get_object (builder, "auto_clear_start_dialog"));
    title = gnc_autoclear_make_window_name (account);
    gtk_window_set_title(GTK_WINDOW(data->window), title);
    g_free (title);

    // Set the style context for this dialog so it can be easily manipulated with css
    gnc_widget_set_style_context (GTK_WIDGET(data->window), "GncAutoClearDialog");

    /* Add amount edit box */
    data->end_value = GNC_AMOUNT_EDIT(gnc_amount_edit_new());
    g_signal_connect(GTK_WIDGET(data->end_value), "activate",
                     G_CALLBACK(gnc_autoclear_window_ok_cb), data);

    box   = GTK_BOX(gtk_builder_get_object (builder, "end_value_box"));
    gtk_box_pack_start(box, GTK_WIDGET(data->end_value), TRUE, TRUE, 0);

    label = GTK_LABEL(gtk_builder_get_object (builder, "end_label"));
    gtk_label_set_mnemonic_widget(label, GTK_WIDGET(data->end_value));
    gtk_widget_grab_focus(GTK_WIDGET(data->end_value));

    data->status_label = GTK_LABEL(gtk_builder_get_object (builder, "status_label"));

    if (parent != NULL)
        gtk_window_set_transient_for (GTK_WINDOW (data->window), GTK_WINDOW (parent));

    gtk_builder_connect_signals(builder, data);
    g_object_unref(G_OBJECT(builder));

    return data;
}
Beispiel #2
0
/********************************************************************\
 * autoClearWindow                                                  *
 *   opens up the window to auto-clear an account                   *
 *                                                                  *
 * Args:   parent  - the parent of this window                      *
 *         account - the account to auto-clear                      *
 * Return: autoClearData - the instance of this AutoClearWindow     *
\********************************************************************/
AutoClearWindow *
autoClearWindow (GtkWidget *parent, Account *account)
{
    GtkWidget *dialog, *box, *label, *end_value;
    GladeXML *xml;
    AutoClearWindow *data;
    char *title;

    data = g_new0 (AutoClearWindow, 1);
    data->account = account;

    /* Create the dialog box */
    xml = gnc_glade_xml_new ("autoclear.glade", "Auto-clear Start Dialog");
    dialog = glade_xml_get_widget (xml, "Auto-clear Start Dialog");
    title = gnc_autoclear_make_window_name (account);
    gtk_window_set_title(GTK_WINDOW(dialog), title);
    g_free (title);

    /* Add amount edit box */
    end_value = gnc_amount_edit_new();
    data->end_value = GNC_AMOUNT_EDIT(end_value);
    box = glade_xml_get_widget(xml, "end_value_box");
    gtk_box_pack_start(GTK_BOX(box), end_value, TRUE, TRUE, 0);
    label = glade_xml_get_widget(xml, "end_label");
    gtk_label_set_mnemonic_widget(GTK_LABEL(label), end_value);
    gtk_widget_grab_focus(GTK_WIDGET(end_value));

    data->window = GTK_WIDGET(dialog);

    if (parent != NULL)
        gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
    data->ok_button = glade_xml_get_widget(xml, "ok_button");
    data->cancel_button = glade_xml_get_widget(xml, "cancel_button");
    data->status_label = GTK_LABEL(glade_xml_get_widget(xml, "status_label"));

    g_signal_connect(data->ok_button, "clicked",
                     G_CALLBACK(gnc_autoclear_window_ok_cb), data);
    g_signal_connect(data->end_value, "activate",
                     G_CALLBACK(gnc_autoclear_window_ok_cb), data);
    g_signal_connect(data->cancel_button, "clicked",
                     G_CALLBACK(gnc_autoclear_window_cancel_cb), data);

    return data;
}