2
* dialog-daterange.c --
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License as
6
* published by the Free Software Foundation; either version 2 of
7
* the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, contact:
17
* Free Software Foundation Voice: +1-617-542-5942
18
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
19
* Boston, MA 02110-1301, USA gnu@gnu.org
24
* @file dialog-daterange.c
25
* @brief Dialog for date range entry
26
* @author Copyright (C) 2002 Christian Stimming <stimming@tuhh.de>
27
* @author Copyright (C) 2008 Andreas Koehler <andi5.py@gmx.net>
32
#include "dialog-daterange.h"
33
#include "dialog-utils.h"
34
#include "gnc-date-edit.h"
36
/* This static indicates the debugging module that this .o belongs to. */
37
static QofLogModule log_module = G_LOG_DOMAIN;
39
typedef struct _DaterangeInfo DaterangeInfo;
41
void ddr_toggled_cb(GtkToggleButton *button, gpointer user_data);
45
GtkWidget *enter_from_button;
46
GtkWidget *enter_to_button;
47
GtkWidget *from_dateedit;
48
GtkWidget *to_dateedit;
52
gnc_ab_enter_daterange(GtkWidget *parent,
55
gboolean *last_retv_date,
56
gboolean *first_possible_date,
62
GtkWidget *heading_label;
63
GtkWidget *first_button;
64
GtkWidget *last_retrieval_button;
65
GtkWidget *now_button;
69
xml = gnc_glade_xml_new("aqbanking.glade", "Date Range Dialog");
71
dialog = glade_xml_get_widget(xml, "Date Range Dialog");
72
g_object_set_data_full(G_OBJECT(dialog), "xml", xml, g_object_unref);
73
glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
77
gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));
79
heading_label = glade_xml_get_widget(xml, "heading_label");
80
first_button = glade_xml_get_widget(xml, "first_button");
81
last_retrieval_button = glade_xml_get_widget(xml, "last_retrieval_button");
82
info.enter_from_button = glade_xml_get_widget(xml, "enter_from_button");
83
now_button = glade_xml_get_widget(xml, "now_button");
84
info.enter_to_button = glade_xml_get_widget(xml, "enter_to_button");
86
info.from_dateedit = gnc_date_edit_new_ts(*from_date, FALSE, FALSE);
87
gtk_container_add(GTK_CONTAINER(glade_xml_get_widget(xml, "enter_from_box")),
89
gtk_widget_show(info.from_dateedit);
91
info.to_dateedit = gnc_date_edit_new_ts(*to_date, FALSE, FALSE);
92
gtk_container_add(GTK_CONTAINER(glade_xml_get_widget(xml, "enter_to_box")),
94
gtk_widget_show(info.to_dateedit);
96
if (*last_retv_date) {
97
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(last_retrieval_button),
100
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(first_button), TRUE);
101
gtk_widget_set_sensitive(last_retrieval_button, FALSE);
104
gtk_widget_set_sensitive(info.from_dateedit, FALSE);
105
gtk_widget_set_sensitive(info.to_dateedit, FALSE);
107
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
110
gtk_label_set_text(GTK_LABEL(heading_label), heading);
112
gtk_widget_show(dialog);
114
result = gtk_dialog_run(GTK_DIALOG(dialog));
115
gtk_widget_hide(dialog);
117
if (result == GTK_RESPONSE_OK) {
118
*from_date = gnc_date_edit_get_date_ts(
119
GNC_DATE_EDIT(info.from_dateedit));
120
*last_retv_date = gtk_toggle_button_get_active(
121
GTK_TOGGLE_BUTTON(last_retrieval_button));
122
*first_possible_date = gtk_toggle_button_get_active(
123
GTK_TOGGLE_BUTTON(first_button));
124
*to_date = gnc_date_edit_get_date_ts(
125
GNC_DATE_EDIT(info.to_dateedit));
126
*to_now = gtk_toggle_button_get_active(
127
GTK_TOGGLE_BUTTON(now_button));
130
gtk_widget_destroy(dialog);
132
return result == GTK_RESPONSE_OK;
136
ddr_toggled_cb(GtkToggleButton *button, gpointer user_data)
138
DaterangeInfo *info = user_data;
140
g_return_if_fail(info);
142
gtk_widget_set_sensitive(info->from_dateedit,
143
gtk_toggle_button_get_active(
144
GTK_TOGGLE_BUTTON(info->enter_from_button)));
145
gtk_widget_set_sensitive(info->to_dateedit,
146
gtk_toggle_button_get_active(
147
GTK_TOGGLE_BUTTON(info->enter_to_button)));