26 #include <glib/gi18n.h>
28 #include "dialog-utils.h"
30 #include "gnc-gui-query.h"
33 #include "gnc-date-edit.h"
34 #include "gnc-account-sel.h"
36 #include "business-gnome-utils.h"
37 #include "dialog-date-close.h"
44 GtkWidget *acct_combo;
45 GtkWidget *memo_entry;
46 GtkWidget *question_check;
50 GList * acct_commodities;
58 void gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data);
62 gnc_dialog_date_close_ok_cb (GtkWidget *widget, gpointer user_data)
70 acc = gnc_account_sel_get_account( GNC_ACCOUNT_SEL(ddc->acct_combo) );
74 gnc_error_dialog (ddc->dialog,
"%s",
75 _(
"No Account selected. Please try again."));
81 gnc_error_dialog (ddc->dialog,
"%s",
82 _(
"Placeholder account selected. Please try again."));
90 *(ddc->ts2) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->post_date));
95 *(ddc->ts) = gncBillTermComputeDueDate (ddc->terms, *(ddc->ts2));
97 *(ddc->ts) = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (ddc->date));
100 if (ddc->memo_entry && ddc->memo)
101 *(ddc->memo) = gtk_editable_get_chars (GTK_EDITABLE (ddc->memo_entry),
103 if (ddc->question_check)
104 ddc->answer = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ddc->question_check));
114 gnc_account_sel_set_acct_filters( gas, ddc->acct_types, ddc->acct_commodities );
115 gnc_account_sel_set_new_account_ability( gas, TRUE );
116 gnc_account_sel_set_new_account_modal( gas, TRUE );
117 gnc_account_sel_set_account( gas, ddc->acct, set_default_acct );
121 gnc_dialog_date_close_parented (GtkWidget *parent,
const char *message,
122 const char *label_message,
123 gboolean ok_is_default,
133 if (!message || !label_message || !ts)
139 builder = gtk_builder_new();
140 gnc_builder_add_from_file (builder,
"dialog-date-close.glade",
"Date Close Dialog");
141 ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"Date Close Dialog"));
143 date_box = GTK_WIDGET(gtk_builder_get_object (builder,
"date_box"));
144 ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
145 gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0);
146 gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ts);
149 gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent));
152 label = GTK_LABEL (gtk_builder_get_object (builder,
"msg_label"));
153 gtk_label_set_text (label, message);
154 label = GTK_LABEL (gtk_builder_get_object (builder,
"label"));
155 gtk_label_set_text (label, label_message);
158 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ddc);
160 gtk_widget_show_all (ddc->dialog);
163 while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK)
170 g_object_unref(G_OBJECT(builder));
172 gtk_widget_destroy(ddc->dialog);
173 retval = ddc->retval;
174 g_list_free (ddc->acct_types);
181 post_date_changed_cb (
GNCDateEdit *gde, gpointer d)
187 post_date = gnc_date_edit_get_date_ts (gde);
188 due_date = gncBillTermComputeDueDate (ddc->terms, post_date);
189 gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), due_date);
193 gnc_dialog_dates_acct_question_parented (GtkWidget *parent,
const char *message,
194 const char *ddue_label_message,
195 const char *post_label_message,
196 const char *acct_label_message,
197 const char *question_check_message,
198 gboolean ok_is_default,
199 gboolean set_default_acct,
200 GList * acct_types, GList * acct_commodities,
204 char **memo,
Account **acct, gboolean *answer)
213 if (!message || !ddue_label_message || !post_label_message ||
214 !acct_label_message || !acct_types || !book || !ddue || !post || !acct)
216 if (question_check_message && !answer)
223 ddc->acct_types = acct_types;
224 ddc->acct_commodities = acct_commodities;
229 builder = gtk_builder_new();
230 gnc_builder_add_from_file (builder,
"dialog-date-close.glade",
"Date Account Dialog");
231 ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"Date Account Dialog"));
232 ddc->memo_entry = GTK_WIDGET(gtk_builder_get_object (builder,
"memo_entry"));
234 acct_box = GTK_WIDGET(gtk_builder_get_object (builder,
"acct_hbox"));
235 ddc->acct_combo = gnc_account_sel_new();
236 gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0);
238 date_box = GTK_WIDGET(gtk_builder_get_object (builder,
"date_hbox"));
239 ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
240 gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0);
242 date_box = GTK_WIDGET(gtk_builder_get_object (builder,
"post_date_box"));
243 ddc->post_date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
244 gtk_box_pack_start (GTK_BOX(date_box), ddc->post_date, TRUE, TRUE, 0);
246 ddc->question_check = GTK_WIDGET(gtk_builder_get_object (builder,
"question_check"));
249 gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent));
253 label = GTK_LABEL (gtk_builder_get_object (builder,
"top_msg_label"));
254 gtk_label_set_text (label, message);
255 label = GTK_LABEL (gtk_builder_get_object (builder,
"date_label"));
256 gtk_label_set_text (label, ddue_label_message);
257 label = GTK_LABEL (gtk_builder_get_object (builder,
"postdate_label"));
258 gtk_label_set_text (label, post_label_message);
259 label = GTK_LABEL (gtk_builder_get_object (builder,
"acct_label"));
260 gtk_label_set_text (label, acct_label_message);
262 if (question_check_message)
264 gtk_label_set_text(GTK_LABEL(GTK_BIN(ddc->question_check)->child), question_check_message);
265 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ddc->question_check), *answer);
269 gtk_widget_hide(ddc->question_check);
270 gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object (builder,
"hide1")));
275 gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->post_date), *post);
280 g_signal_connect (G_OBJECT (ddc->post_date),
"date_changed",
281 G_CALLBACK (post_date_changed_cb), ddc);
282 gtk_widget_set_sensitive (ddc->date, FALSE);
283 post_date_changed_cb (GNC_DATE_EDIT (ddc->post_date), ddc);
286 gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *ddue);
289 fill_in_acct_info (ddc, set_default_acct);
292 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ddc);
294 gtk_widget_show_all (ddc->dialog);
297 gnc_date_grab_focus (GNC_DATE_EDIT (ddc->post_date));
300 while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK)
307 g_object_unref(G_OBJECT(builder));
309 gtk_widget_destroy(ddc->dialog);
310 retval = ddc->retval;
312 if (question_check_message)
313 *answer = ddc->answer;
320 gnc_dialog_date_acct_parented (GtkWidget *parent,
const char *message,
321 const char *date_label_message,
322 const char *acct_label_message,
323 gboolean ok_is_default,
324 GList * acct_types,
QofBook *book,
335 if (!message || !date_label_message || !acct_label_message ||
336 !acct_types || !book || !date || !acct)
342 ddc->acct_types = acct_types;
345 builder = gtk_builder_new();
346 gnc_builder_add_from_file (builder,
"dialog-date-close.glade",
"Date Account Dialog");
347 ddc->dialog = GTK_WIDGET(gtk_builder_get_object (builder,
"Date Account Dialog"));
349 acct_box = GTK_WIDGET(gtk_builder_get_object (builder,
"acct_hbox"));
350 ddc->acct_combo = gnc_account_sel_new();
352 gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct, FALSE);
353 gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0);
355 date_box = GTK_WIDGET(gtk_builder_get_object (builder,
"date_hbox"));
356 ddc->date = gnc_date_edit_new (time(NULL), FALSE, FALSE);
357 gtk_box_pack_start (GTK_BOX(date_box), ddc->date, TRUE, TRUE, 0);
360 gtk_window_set_transient_for (GTK_WINDOW(ddc->dialog), GTK_WINDOW(parent));
364 label = GTK_LABEL (gtk_builder_get_object (builder,
"top_msg_label"));
365 gtk_label_set_text (label, message);
366 label = GTK_LABEL (gtk_builder_get_object (builder,
"date_label"));
367 gtk_label_set_text (label, date_label_message);
368 label = GTK_LABEL (gtk_builder_get_object (builder,
"acct_label"));
369 gtk_label_set_text (label, acct_label_message);
372 gnc_date_edit_set_time_ts (GNC_DATE_EDIT (ddc->date), *date);
375 fill_in_acct_info (ddc, FALSE);
378 gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, ddc);
380 gtk_widget_show_all (ddc->dialog);
382 gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder,
"postdate_label")));
383 gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder,
"post_date_box")));
384 gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder,
"memo_entry")));
385 gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder,
"memo_label")));
388 while (gtk_dialog_run (GTK_DIALOG (ddc->dialog)) == GTK_RESPONSE_OK)
395 g_object_unref(G_OBJECT(builder));
397 gtk_widget_destroy(ddc->dialog);
398 retval = ddc->retval;
utility functions for the GnuCash UI
Use a 64-bit unsigned int timespec.
gboolean xaccAccountGetPlaceholder(const Account *acc)