26 #include <glib/gi18n.h> 28 #include "dialog-utils.h" 29 #include "gnc-amount-edit.h" 35 #include "gnc-autoclear.h" 36 #include "window-autoclear.h" 38 #define WINDOW_AUTOCLEAR_CM_CLASS "window-autoclear" 40 __attribute__((unused))
static QofLogModule log_module = GNC_MOD_GUI;
43 struct _AutoClearWindow
50 GNCAmountEdit *end_value;
52 GtkWidget *cancel_button;
53 GtkWidget *show_cleared_splits_button;
54 GtkLabel *status_label;
58 void gnc_autoclear_window_ok_cb (GtkWidget *widget,
59 AutoClearWindow *data);
60 void gnc_autoclear_window_cancel_cb (GtkWidget *widget,
61 AutoClearWindow *data);
70 gnc_ui_autoclear_window_raise(AutoClearWindow * autoClearData)
72 if (autoClearData == NULL)
75 if (autoClearData->window == NULL)
78 gtk_window_present(GTK_WINDOW(autoClearData->window));
82 gnc_autoclear_make_window_name(
Account *account)
88 title = g_strconcat(fullname,
" - ", _(
"Auto-clear"), NULL);
96 show_cleared_splits (GList *splits)
98 GNCLedgerDisplay *ledger;
100 Query *book_query, *guid_query;
102 book_query = qof_query_create_for (GNC_ID_SPLIT);
103 guid_query = qof_query_create_for (GNC_ID_SPLIT);
106 for (GList *iter = splits; iter; iter = iter->next)
109 xaccQueryAddGUIDMatch (guid_query, &guid, GNC_ID_SPLIT, QOF_QUERY_OR);
122 gnc_autoclear_window_ok_cb (GtkWidget *widget,
123 AutoClearWindow *data)
125 GList *toclear_list = NULL;
127 GError* error = NULL;
129 g_return_if_fail (widget && data);
132 if (gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT(data->end_value), &error))
134 toclear_value = gnc_amount_edit_get_amount(data->end_value);
136 if (gnc_reverse_balance(data->account))
142 gnc_autoclear_get_splits (data->account, toclear_value, INT64_MAX,
143 &toclear_list, &error, data->status_label);
146 if (error && error->message)
148 GtkWidget *entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT(data->end_value));
149 gtk_label_set_text (data->status_label, error->message);
151 gnc_amount_edit_set_amount (data->end_value, toclear_value);
152 gtk_widget_grab_focus (GTK_WIDGET(entry));
153 gnc_amount_edit_select_region (GNC_AMOUNT_EDIT(data->end_value), 0, -1);
154 g_error_free (error);
159 for (GList *node = toclear_list; node; node = node->next)
163 if (gtk_toggle_button_get_active
164 (GTK_TOGGLE_BUTTON (data->show_cleared_splits_button)))
165 show_cleared_splits (toclear_list);
167 g_list_free (toclear_list);
170 gtk_widget_destroy (data->window);
176 gnc_autoclear_window_cancel_cb (GtkWidget *widget,
177 AutoClearWindow *data)
180 gtk_widget_destroy(data->window);
184 static void clear_status_label_cb (GtkEditable *editable, AutoClearWindow *data)
186 gtk_label_set_text (data->status_label,
"");
199 autoClearWindow (GtkWidget *parent,
Account *account)
204 AutoClearWindow *data;
208 gnc_commodity *currency;
210 data = g_new0 (AutoClearWindow, 1);
211 data->account = account;
214 builder = gtk_builder_new();
215 gnc_builder_add_from_file (builder,
"window-autoclear.glade",
"auto_clear_start_dialog");
216 data->window = GTK_WIDGET(gtk_builder_get_object (builder,
"auto_clear_start_dialog"));
217 title = gnc_autoclear_make_window_name (account);
218 gtk_window_set_title(GTK_WINDOW(data->window), title);
222 gtk_widget_set_name (GTK_WIDGET(data->window),
"gnc-id-auto-clear");
224 data->show_cleared_splits_button =
225 GTK_WIDGET (gtk_builder_get_object (builder,
"show_cleared_splits_button"));
228 data->end_value = GNC_AMOUNT_EDIT(gnc_amount_edit_new());
231 print_info = gnc_commodity_print_info (currency, FALSE);
232 gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT(data->end_value), print_info);
233 gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT(data->end_value),
236 g_signal_connect(GTK_WIDGET(data->end_value),
"activate",
237 G_CALLBACK(gnc_autoclear_window_ok_cb), data);
239 box = GTK_BOX(gtk_builder_get_object (builder,
"end_value_box"));
240 gtk_box_pack_start(box, GTK_WIDGET(data->end_value), TRUE, TRUE, 0);
242 label = GTK_WIDGET(gtk_builder_get_object (builder,
"end_label"));
243 gnc_amount_edit_make_mnemonic_target (GNC_AMOUNT_EDIT(data->end_value), label);
247 if (gnc_reverse_balance(data->account))
249 gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (data->end_value), after);
250 gtk_widget_grab_focus(GTK_WIDGET(data->end_value));
251 gnc_amount_edit_select_region (GNC_AMOUNT_EDIT (data->end_value), 0, -1);
253 data->status_label = GTK_LABEL(gtk_builder_get_object (builder,
"status_label"));
255 g_signal_connect (GTK_WIDGET(data->end_value),
"changed",
256 G_CALLBACK(clear_status_label_cb), data);
259 gtk_window_set_transient_for (GTK_WINDOW (data->window), GTK_WINDOW (parent));
261 gtk_builder_connect_signals(builder, data);
262 g_object_unref(G_OBJECT(builder));
void gnc_ledger_display_refresh(GNCLedgerDisplay *ld)
redisplay/redraw only the indicated window.
int gnc_commodity_get_fraction(const gnc_commodity *cm)
Retrieve the fraction for the specified commodity.
The instance data structure for a content plugin.
int xaccAccountGetCommoditySCU(const Account *acc)
Return the SCU for the account.
gnc_numeric gnc_numeric_neg(gnc_numeric a)
Returns a newly created gnc_numeric that is the negative of the given gnc_numeric value...
void xaccSplitSetReconcile(Split *split, char recn)
Set the reconcile flag.
gnc_numeric xaccAccountGetClearedBalance(const Account *acc)
Get the current balance of the account, only including cleared transactions.
void gnc_main_window_open_page(GncMainWindow *window, GncPluginPage *page)
Display a data plugin page in a window.
Functions for adding content to a window.
GncPluginPage * gnc_plugin_page_register_new_ledger(GNCLedgerDisplay *ledger)
Create a new "register" plugin page, given a pointer to an already created ledger.
gchar * gnc_account_get_full_name(const Account *account)
The gnc_account_get_full_name routine returns the fully qualified name of the account using the given...
Functions providing a register page for the GnuCash UI.
gnc_numeric gnc_numeric_convert(gnc_numeric n, gint64 denom, gint how)
Change the denominator of a gnc_numeric value to the specified denominator under standard arguments '...
void qof_query_destroy(QofQuery *query)
Frees the resources associate with a Query object.
gnc_numeric gnc_numeric_error(GNCNumericErrorCode error_code)
Create a gnc_numeric object that signals the error condition noted by error_code, rather than a numbe...
void qof_query_set_book(QofQuery *query, QofBook *book)
Set the book to be searched.
Argument is not a valid number.
QofQuery * qof_query_merge(QofQuery *q1, QofQuery *q2, QofQueryOp op)
Combine two queries together using the Boolean set (logical) operator 'op'.
Gnome specific utility functions.
Additional event handling code.
#define xaccSplitGetGUID(X)
#define CREC
The Split has been cleared.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
gnc_commodity * xaccAccountGetCommodity(const Account *acc)
Get the account's commodity.
const GncGUID * guid_null(void)
Returns a GncGUID which is guaranteed to never reference any entity.
GNCLedgerDisplay * gnc_ledger_display_query(Query *query, SplitRegisterType type, SplitRegisterStyle style)
display a general ledger for an arbitrary query
GNCNumericErrorCode gnc_numeric_check(gnc_numeric a)
Check for error signal in value.
Use unbiased ("banker's") rounding.
The type used to store guids in C.
void main_window_update_page_name(GncPluginPage *page, const gchar *name_in)
Update the name of the page in the main window.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...