aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-11-02 06:11:23 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-11-02 06:11:23 +0800
commit57f02847d87a5adb7b443ef06d8bca945f0cae38 (patch)
tree8ad5b2c6dd06d7ae5a947bc87be966ec604147d8
parent02978e3e44d1f47589ff8a80d386f5e4a836dfbd (diff)
downloadgsoc2013-evolution-57f02847d87a5adb7b443ef06d8bca945f0cae38.tar
gsoc2013-evolution-57f02847d87a5adb7b443ef06d8bca945f0cae38.tar.gz
gsoc2013-evolution-57f02847d87a5adb7b443ef06d8bca945f0cae38.tar.bz2
gsoc2013-evolution-57f02847d87a5adb7b443ef06d8bca945f0cae38.tar.lz
gsoc2013-evolution-57f02847d87a5adb7b443ef06d8bca945f0cae38.tar.xz
gsoc2013-evolution-57f02847d87a5adb7b443ef06d8bca945f0cae38.tar.zst
gsoc2013-evolution-57f02847d87a5adb7b443ef06d8bca945f0cae38.zip
Check to make sure the user has entered a valid date.
2000-11-01 Jeffrey Stedfast <fejj@helixcode.com> * filter-datespec.c (validate): Check to make sure the user has entered a valid date. svn path=/trunk/; revision=6324
-rw-r--r--filter/ChangeLog5
-rw-r--r--filter/filter-datespec.c407
2 files changed, 223 insertions, 189 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 72b07bc94e..1b232056ba 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,8 @@
+2000-11-01 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * filter-datespec.c (validate): Check to make sure the user has
+ entered a valid date.
+
2000-10-31 Jeffrey Stedfast <fejj@helixcode.com>
* filtertypes.xml: Updated to allow the user to select "sounds
diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c
index 526c3400f7..db98efd1ef 100644
--- a/filter/filter-datespec.c
+++ b/filter/filter-datespec.c
@@ -28,15 +28,17 @@
#define d(x)
-static void xml_create(FilterElement *fe, xmlNodePtr node);
-static xmlNodePtr xml_encode(FilterElement *fe);
-static int xml_decode(FilterElement *fe, xmlNodePtr node);
-static GtkWidget *get_widget(FilterElement *fe);
-static void build_code(FilterElement *fe, GString *out, struct _FilterPart *fds);
-static void format_sexp(FilterElement *, GString *);
-static void filter_datespec_class_init (FilterDatespecClass *class);
-static void filter_datespec_init (FilterDatespec *gspaper);
-static void filter_datespec_finalise (GtkObject *obj);
+static gboolean validate (FilterElement *fe, gpointer data);
+static void xml_create (FilterElement *fe, xmlNodePtr node);
+static xmlNodePtr xml_encode (FilterElement *fe);
+static int xml_decode (FilterElement *fe, xmlNodePtr node);
+static GtkWidget *get_widget (FilterElement *fe);
+static void build_code (FilterElement *fe, GString *out, struct _FilterPart *fds);
+static void format_sexp (FilterElement *, GString *);
+
+static void filter_datespec_class_init (FilterDatespecClass *class);
+static void filter_datespec_init (FilterDatespec *gspaper);
+static void filter_datespec_finalise (GtkObject *obj);
static void make_span_editor (FilterDatespec *fds);
static void adj_value_changed (GtkAdjustment *adj, gpointer user_data);
@@ -49,8 +51,7 @@ static void cal_day_selected_double_click (GtkCalendar *cal, gpointer user_data)
#define PRIV(x) (((FilterDatespec *)(x))->priv)
-typedef struct _timespan
-{
+typedef struct _timespan {
guint32 seconds;
const gchar *singular;
const gchar *plural;
@@ -96,15 +97,15 @@ filter_datespec_get_type (void)
if (!type) {
GtkTypeInfo type_info = {
"FilterDatespec",
- sizeof(FilterDatespec),
- sizeof(FilterDatespecClass),
- (GtkClassInitFunc)filter_datespec_class_init,
- (GtkObjectInitFunc)filter_datespec_init,
- (GtkArgSetFunc)NULL,
- (GtkArgGetFunc)NULL
+ sizeof (FilterDatespec),
+ sizeof (FilterDatespecClass),
+ (GtkClassInitFunc) filter_datespec_class_init,
+ (GtkObjectInitFunc) filter_datespec_init,
+ (GtkArgSetFunc) NULL,
+ (GtkArgGetFunc) NULL
};
- type = gtk_type_unique(filter_element_get_type (), &type_info);
+ type = gtk_type_unique (filter_element_get_type (), &type_info);
}
return type;
@@ -117,11 +118,12 @@ filter_datespec_class_init (FilterDatespecClass *class)
FilterElementClass *filter_element = (FilterElementClass *)class;
object_class = (GtkObjectClass *)class;
- parent_class = gtk_type_class(filter_element_get_type ());
-
+ parent_class = gtk_type_class (filter_element_get_type ());
+
object_class->finalize = filter_datespec_finalise;
-
+
/* override methods */
+ filter_element->validate = validate;
filter_element->xml_create = xml_create;
filter_element->xml_encode = xml_encode;
filter_element->xml_decode = xml_decode;
@@ -133,22 +135,22 @@ filter_datespec_class_init (FilterDatespecClass *class)
static void
filter_datespec_init (FilterDatespec *o)
{
- o->priv = g_malloc0(sizeof(*o->priv));
+ o->priv = g_malloc0 (sizeof (*o->priv));
o->type = FDST_UNKNOWN;
PRIV(o)->selected_type = FDST_UNKNOWN;
- PRIV(o)->spinbuttons = g_new (GtkWidget *, N_TIMESPANS );
+ PRIV(o)->spinbuttons = g_new (GtkWidget *, N_TIMESPANS);
}
static void
filter_datespec_finalise(GtkObject *obj)
{
FilterDatespec *o = (FilterDatespec *)obj;
-
+
if (o->priv) {
g_free (PRIV(o)->spinbuttons);
g_free (o->priv);
}
-
+
((GtkObjectClass *)(parent_class))->finalize(obj);
}
@@ -160,56 +162,81 @@ filter_datespec_finalise(GtkObject *obj)
* Return value: A new #FilterDatespec object.
**/
FilterDatespec *
-filter_datespec_new(void)
+filter_datespec_new (void)
{
- FilterDatespec *o = (FilterDatespec *)gtk_type_new(filter_datespec_get_type ());
+ FilterDatespec *o = (FilterDatespec *)gtk_type_new (filter_datespec_get_type ());
return o;
}
-static void xml_create(FilterElement *fe, xmlNodePtr node)
+static gboolean
+validate (FilterElement *fe, gpointer data)
+{
+ FilterDatespec *fds = (FilterDatespec *) fe;
+ gboolean valid = TRUE;
+
+ if (fds->value < 0) {
+ GtkWidget *gd;
+
+ valid = FALSE;
+
+ if (fds->type == FDST_UNKNOWN)
+ gd = gnome_ok_dialog (_("Oops. You have forgotten to choose a date."));
+ else
+ gd = gnome_ok_dialog (_("Oops. You have chosen an invalid date."));
+
+ gnome_dialog_run_and_close (GNOME_DIALOG (gd));
+ }
+
+ return valid;
+}
+
+static void
+xml_create (FilterElement *fe, xmlNodePtr node)
{
/* parent implementation */
((FilterElementClass *)(parent_class))->xml_create(fe, node);
}
-static xmlNodePtr xml_encode(FilterElement *fe)
+static xmlNodePtr
+xml_encode (FilterElement *fe)
{
xmlNodePtr value, work;
FilterDatespec *fds = (FilterDatespec *)fe;
gchar str[32];
-
- d(printf("Encoding datespec as xml\n"));
-
- value = xmlNewNode(NULL, "value");
- xmlSetProp(value, "name", fe->name);
- xmlSetProp(value, "type", "datespec");
-
- work = xmlNewChild(value, NULL, "datespec", NULL);
+
+ d(printf ("Encoding datespec as xml\n"));
+
+ value = xmlNewNode (NULL, "value");
+ xmlSetProp (value, "name", fe->name);
+ xmlSetProp (value, "type", "datespec");
+
+ work = xmlNewChild (value, NULL, "datespec", NULL);
sprintf (str, "%d", fds->type);
- xmlSetProp(work, "type", str);
+ xmlSetProp (work, "type", str);
sprintf (str, "%d", (int)fds->value);
- xmlSetProp(work, "value", str);
-
+ xmlSetProp (work, "value", str);
+
return value;
}
-static int xml_decode(FilterElement *fe, xmlNodePtr node)
+static int
+xml_decode (FilterElement *fe, xmlNodePtr node)
{
FilterDatespec *fds = (FilterDatespec *)fe;
xmlNodePtr n;
gchar *val;
-
- d(printf("Decoding datespec from xml %p\n", fe));
-
- fe->name = xmlGetProp(node, "name");
-
+
+ d(printf ("Decoding datespec from xml %p\n", fe));
+
+ fe->name = xmlGetProp (node, "name");
+
n = node->childs;
while (n) {
- if (!strcmp(n->name, "datespec")) {
- val = xmlGetProp(n, "type");
+ if (!strcmp (n->name, "datespec")) {
+ val = xmlGetProp (n, "type");
fds->type = atoi (val);
g_free (val);
- val = xmlGetProp(n, "value");
+ val = xmlGetProp (n, "value");
fds->value = atoi (val);
g_free (val);
break;
@@ -219,101 +246,103 @@ static int xml_decode(FilterElement *fe, xmlNodePtr node)
return 0;
}
-static void activate_now(GtkMenuItem *item, FilterDatespec *fds)
+static void
+activate_now (GtkMenuItem *item, FilterDatespec *fds)
{
- if (PRIV(fds)->cur_extra_widget) {
+ if (PRIV (fds)->cur_extra_widget) {
gtk_container_remove (GTK_CONTAINER (PRIV(fds)->gd->vbox),
- PRIV(fds)->cur_extra_widget);
+ PRIV (fds)->cur_extra_widget);
PRIV (fds)->cur_extra_widget = NULL;
}
-
-
- gtk_label_set_text (GTK_LABEL (PRIV(fds)->descriptive_label),
+
+ gtk_label_set_text (GTK_LABEL (PRIV (fds)->descriptive_label),
_("The message's date will be compared against\n"
"whatever the time is when the filter is run\n"
"or vfolder is opened."));
-
- PRIV(fds)->selected_type = FDST_NOW;
+
+ PRIV (fds)->selected_type = FDST_NOW;
}
-static void activate_specified(GtkMenuItem *item, FilterDatespec *fds)
+static void
+activate_specified (GtkMenuItem *item, FilterDatespec *fds)
{
struct tm *seltime;
-
+
/* Remove other widget if it exists */
-
- if (PRIV(fds)->cur_extra_widget) {
- gtk_container_remove (GTK_CONTAINER (PRIV(fds)->gd->vbox),
- PRIV(fds)->cur_extra_widget);
+
+ if (PRIV (fds)->cur_extra_widget) {
+ gtk_container_remove (GTK_CONTAINER (PRIV (fds)->gd->vbox),
+ PRIV (fds)->cur_extra_widget);
PRIV (fds)->cur_extra_widget = NULL;
}
-
+
/* Set description */
-
- gtk_label_set_text (GTK_LABEL (PRIV(fds)->descriptive_label),
+
+ gtk_label_set_text (GTK_LABEL (PRIV (fds)->descriptive_label),
_("The message's date will be compared against\n"
"the time that you specify here."));
-
+
/* Reset if going from one type to another */
- if (PRIV(fds)->selected_type != FDST_SPECIFIED)
+ if (PRIV (fds)->selected_type != FDST_SPECIFIED)
fds->value = 0;
-
- PRIV(fds)->selected_type = FDST_SPECIFIED;
-
+
+ PRIV (fds)->selected_type = FDST_SPECIFIED;
+
/* Set the calendar's time */
-
+
if (fds->value > 0) {
/* gmtime? */
seltime = localtime (&(fds->value));
-
- gtk_calendar_select_month (GTK_CALENDAR (PRIV(fds)->date_chooser),
+
+ gtk_calendar_select_month (GTK_CALENDAR (PRIV (fds)->date_chooser),
seltime->tm_mon,
seltime->tm_year + 1900);
- gtk_calendar_select_day (GTK_CALENDAR (PRIV(fds)->date_chooser),
+ gtk_calendar_select_day (GTK_CALENDAR (PRIV (fds)->date_chooser),
seltime->tm_mday);
/* free seltime?? */
}
-
- gtk_box_pack_start (GTK_BOX (PRIV(fds)->gd->vbox),
- PRIV(fds)->date_chooser,
+
+ gtk_box_pack_start (GTK_BOX (PRIV (fds)->gd->vbox),
+ PRIV (fds)->date_chooser,
TRUE, TRUE, 3);
- gtk_widget_show (PRIV(fds)->date_chooser);
- PRIV(fds)->cur_extra_widget = PRIV(fds)->date_chooser;
+ gtk_widget_show (PRIV (fds)->date_chooser);
+ PRIV (fds)->cur_extra_widget = PRIV (fds)->date_chooser;
}
-static void activate_x_ago(GtkMenuItem *item, FilterDatespec *fds)
+static void
+activate_x_ago (GtkMenuItem *item, FilterDatespec *fds)
{
- if (PRIV(fds)->cur_extra_widget) {
- gtk_container_remove (GTK_CONTAINER (PRIV(fds)->gd->vbox),
- PRIV(fds)->cur_extra_widget);
+ if (PRIV (fds)->cur_extra_widget) {
+ gtk_container_remove (GTK_CONTAINER (PRIV (fds)->gd->vbox),
+ PRIV (fds)->cur_extra_widget);
PRIV (fds)->cur_extra_widget = NULL;
}
-
- gtk_label_set_text (GTK_LABEL (PRIV(fds)->descriptive_label),
+
+ gtk_label_set_text (GTK_LABEL (PRIV (fds)->descriptive_label),
_("The message's date will be compared against\n"
"a time relative to when the filter is run;\n"
"\"a week ago\", for example."));
-
+
/* Reset if going from one type to another */
- if (PRIV(fds)->selected_type != FDST_X_AGO)
+ if (PRIV (fds)->selected_type != FDST_X_AGO)
fds->value = 0;
-
- PRIV(fds)->selected_type = FDST_X_AGO;
-
+
+ PRIV (fds)->selected_type = FDST_X_AGO;
+
if (fds->value > 0)
set_adjustments (fds);
-
- gtk_box_pack_start (GTK_BOX (PRIV(fds)->gd->vbox),
- PRIV(fds)->span_chooser,
+
+ gtk_box_pack_start (GTK_BOX (PRIV (fds)->gd->vbox),
+ PRIV (fds)->span_chooser,
TRUE, TRUE, 3);
- gtk_widget_show (PRIV(fds)->span_chooser);
- PRIV(fds)->cur_extra_widget = PRIV(fds)->span_chooser;
-
+ gtk_widget_show (PRIV (fds)->span_chooser);
+ PRIV (fds)->cur_extra_widget = PRIV (fds)->span_chooser;
}
typedef void (*my_menu_callback) (GtkMenuItem *, FilterDatespec *);
-static void button_clicked(GtkButton *button, FilterDatespec *fds)
+static void
+button_clicked (GtkButton *button, FilterDatespec *fds)
{
GnomeDialog *gd;
GtkWidget *box;
@@ -323,72 +352,72 @@ static void button_clicked(GtkButton *button, FilterDatespec *fds)
GtkWidget *sep;
int i;
gchar *desc;
-
+
/* keep in sync with FilterDatespec_type! */
const char *items[] = { N_("the current time"), N_("a time you specify"),
N_("a time relative to the current time"), NULL };
const my_menu_callback callbacks[]
= { activate_now, activate_specified, activate_x_ago };
-
- PRIV(fds)->descriptive_label = gtk_label_new("");
- PRIV(fds)->cur_extra_widget = NULL;
- PRIV(fds)->double_click = FALSE;
-
+
+ PRIV (fds)->descriptive_label = gtk_label_new("");
+ PRIV (fds)->cur_extra_widget = NULL;
+ PRIV (fds)->double_click = FALSE;
+
/* The calendar */
-
- PRIV(fds)->date_chooser = gtk_calendar_new ();
- gtk_object_ref (GTK_OBJECT (PRIV(fds)->date_chooser));
- gtk_signal_connect (GTK_OBJECT (PRIV(fds)->date_chooser), "day_selected",
+
+ PRIV (fds)->date_chooser = gtk_calendar_new ();
+ gtk_object_ref (GTK_OBJECT (PRIV (fds)->date_chooser));
+ gtk_signal_connect (GTK_OBJECT (PRIV (fds)->date_chooser), "day_selected",
cal_day_selected, fds);
- gtk_signal_connect (GTK_OBJECT (PRIV(fds)->date_chooser), "day_selected_double_click",
+ gtk_signal_connect (GTK_OBJECT (PRIV (fds)->date_chooser), "day_selected_double_click",
cal_day_selected_double_click, fds);
-
+
/* The span editor thingie */
-
+
make_span_editor (fds);
- gtk_object_ref (GTK_OBJECT (PRIV(fds)->span_chooser));
-
+ gtk_object_ref (GTK_OBJECT (PRIV (fds)->span_chooser));
+
/* The dialog */
-
+
gd = (GnomeDialog *) gnome_dialog_new ("Select a time to compare against",
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
- PRIV(fds)->gd = gd;
-
+ PRIV (fds)->gd = gd;
+
/* The menu */
-
+
menu = gtk_menu_new ();
for (i = 0; items[i]; i++) {
GtkWidget *item;
-
+
item = gtk_menu_item_new_with_label (gettext (items[i]));
gtk_signal_connect (GTK_OBJECT (item), "activate",
callbacks[i], fds);
gtk_menu_append (GTK_MENU (menu), item);
gtk_widget_show (item);
}
-
+
gtk_widget_show (menu);
-
+
/* The selector */
-
+
selectomatic = gtk_option_menu_new();
gtk_option_menu_set_menu (GTK_OPTION_MENU (selectomatic), GTK_WIDGET (menu));
if (fds->type != FDST_UNKNOWN)
/* Keep in sync with FilterDatespec_type! */
gtk_option_menu_set_history (GTK_OPTION_MENU (selectomatic), fds->type);
-
+
gtk_widget_show ((GtkWidget *)selectomatic);
-
+
/* The label */
-
+
label = gtk_label_new (_("Compare against"));
gtk_widget_show (label);
-
+
/* The hbox */
-
+
box = gtk_hbox_new (FALSE, 3);
gtk_box_pack_start (GTK_BOX (box), label,
TRUE, TRUE, 2);
@@ -396,38 +425,38 @@ static void button_clicked(GtkButton *button, FilterDatespec *fds)
TRUE, TRUE, 2);
gtk_widget_show (box);
gtk_box_pack_start ((GtkBox *)gd->vbox, (GtkWidget *)box, TRUE, TRUE, 3);
-
+
/* The separator */
-
+
sep = gtk_hseparator_new ();
gtk_widget_show (sep);
gtk_box_pack_start (GTK_BOX (gd->vbox), sep, TRUE, TRUE, 3);
-
+
/* The descriptive label */
-
- gtk_box_pack_start (GTK_BOX (gd->vbox), PRIV(fds)->descriptive_label, TRUE, TRUE, 3);
- gtk_misc_set_alignment (GTK_MISC (PRIV(fds)->descriptive_label), 0.5, 0.5);
- gtk_widget_show (PRIV(fds)->descriptive_label);
-
+
+ gtk_box_pack_start (GTK_BOX (gd->vbox), PRIV (fds)->descriptive_label, TRUE, TRUE, 3);
+ gtk_misc_set_alignment (GTK_MISC (PRIV (fds)->descriptive_label), 0.5, 0.5);
+ gtk_widget_show (PRIV (fds)->descriptive_label);
+
/* Set up the current view */
-
+
if (fds->type == FDST_UNKNOWN)
fds->type = FDST_NOW;
(callbacks[fds->type]) (NULL, fds);
-
+
/* go go gadget gnomedialog! */
-
+
switch (gnome_dialog_run_and_close(gd)) {
case -1: /*wm close*/
- if (PRIV(fds)->double_click == FALSE)
+ if (PRIV (fds)->double_click == FALSE)
break;
/* else fall */
case 0:
- fds->type = PRIV(fds)->selected_type;
-
- PRIV(fds)->descriptive_label = NULL;
-
+ fds->type = PRIV (fds)->selected_type;
+
+ PRIV (fds)->descriptive_label = NULL;
+
desc = describe_button (fds);
gtk_label_set_text (GTK_LABEL (GTK_BIN (button)->child), desc);
g_free (desc);
@@ -436,44 +465,44 @@ static void button_clicked(GtkButton *button, FilterDatespec *fds)
/* cancel */
break;
}
-
- gtk_widget_destroy (PRIV(fds)->date_chooser);
- gtk_widget_destroy (PRIV(fds)->span_chooser);
+
+ gtk_widget_destroy (PRIV (fds)->date_chooser);
+ gtk_widget_destroy (PRIV (fds)->span_chooser);
}
static GtkWidget *
-get_widget(FilterElement *fe)
+get_widget (FilterElement *fe)
{
FilterDatespec *fds = (FilterDatespec *)fe;
GtkWidget *button;
GtkWidget *label;
gchar *desc;
-
+
desc = describe_button (fds);
label = gtk_label_new (desc);
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
g_free (desc);
-
+
button = gtk_button_new();
gtk_container_add (GTK_CONTAINER (button), label);
- gtk_signal_connect(GTK_OBJECT (button), "clicked", button_clicked, fds);
-
- gtk_widget_show(button);
- gtk_widget_show(label);
+ gtk_signal_connect (GTK_OBJECT (button), "clicked", button_clicked, fds);
+
+ gtk_widget_show (button);
+ gtk_widget_show (label);
return button;
}
static void
-build_code(FilterElement *fe, GString *out, struct _FilterPart *fp)
+build_code (FilterElement *fe, GString *out, struct _FilterPart *fp)
{
return;
}
static void
-format_sexp(FilterElement *fe, GString *out)
+format_sexp (FilterElement *fe, GString *out)
{
FilterDatespec *fds = (FilterDatespec *)fe;
-
+
switch (fds->type) {
case FDST_UNKNOWN:
g_warning ("user hasn't selected a datespec yet!");
@@ -496,17 +525,17 @@ stringify_agoness (FilterDatespec *fds)
time_t val;
GString *str;
gchar *ret;
-
+
str = g_string_new("");
val = fds->value;
-
+
if (val == 0) {
g_string_append (str, _("now"));
} else {
int where;
-
+
where = 0;
-
+
while (val) {
int count;
@@ -529,10 +558,10 @@ stringify_agoness (FilterDatespec *fds)
where++;
}
-
+
g_string_append (str, " ago");
}
-
+
ret = str->str;
g_string_free (str, FALSE);
return ret;
@@ -545,48 +574,48 @@ make_span_editor (FilterDatespec *fds)
int chunk;
int delta;
GtkWidget *table;
-
- /*PRIV(fds)->span_chooser = gtk_vbox_new (TRUE, 3);*/
+
+ /*PRIV (fds)->span_chooser = gtk_vbox_new (TRUE, 3);*/
table = gtk_table_new (N_TIMECHUNKS, MAX_CHUNK * 2, FALSE);
-
+
i = 0;
-
+
for (chunk = 0; chunk < N_TIMECHUNKS; chunk++ ) {
/*GtkWidget *hbox;*/
/*hbox = gtk_hbox_new (FALSE, 1);*/
- /*gtk_box_pack_start (GTK_BOX (PRIV(fds)->span_chooser),
+ /*gtk_box_pack_start (GTK_BOX (PRIV (fds)->span_chooser),
* hbox, TRUE, TRUE, 1);
*/
- /*gtk_table_attach (GTK_TABLE (PRIV(fds)->span_chooser),
+ /*gtk_table_attach (GTK_TABLE (PRIV (fds)->span_chooser),
* hbox,
* 0, 1, chunk, chunk + 1,
* 0, GTK_EXPAND | GTK_FILL,
* 3, 3);
*gtk_widget_show (hbox);
*/
-
+
for (delta = 0; delta < timechunks[chunk]; delta++, i++ ) {
gchar *text;
GtkObject *adj;
GtkWidget *sb;
GtkWidget *label;
-
+
adj = gtk_adjustment_new (0.0, 0.0,
timespans[i].max,
1.0, 10.0, 0.0);
sb = gtk_spin_button_new (GTK_ADJUSTMENT (adj),
0, 0);
-
+
/*gtk_box_pack_start (GTK_BOX (hbox), sb, FALSE, FALSE, 1);*/
gtk_table_attach (GTK_TABLE (table), sb,
delta * 2, delta * 2 + 1,
chunk, chunk + 1,
0, GTK_EXPAND | GTK_FILL,
2, 4);
- PRIV(fds)->spinbuttons[i] = sb;
-
+ PRIV (fds)->spinbuttons[i] = sb;
+
gtk_widget_show (GTK_WIDGET (sb));
if (delta + 1 < timechunks[chunk])
@@ -596,7 +625,7 @@ make_span_editor (FilterDatespec *fds)
label = gtk_label_new (text);
g_free (text);
-
+
/*gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 3);*/
gtk_table_attach (GTK_TABLE (table), label,
delta * 2 + 1, (delta + 1) * 2,
@@ -604,13 +633,13 @@ make_span_editor (FilterDatespec *fds)
0, GTK_EXPAND | GTK_FILL,
2, 4);
gtk_widget_show (label);
-
+
gtk_signal_connect (adj, "value_changed",
adj_value_changed, fds);
}
}
-
- PRIV(fds)->span_chooser = table;
+
+ PRIV (fds)->span_chooser = table;
}
static void
@@ -618,12 +647,12 @@ adj_value_changed (GtkAdjustment *adj, gpointer user_data)
{
FilterDatespec *fds = (FilterDatespec *) user_data;
int i;
-
+
fds->value = 0;
-
+
for (i = 0; i < N_TIMESPANS; i++)
fds->value += timespans[i].seconds *
- (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (PRIV(fds)->spinbuttons[i])));
+ (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (PRIV (fds)->spinbuttons[i])));
}
static void
@@ -631,10 +660,10 @@ set_adjustments (FilterDatespec *fds)
{
time_t val;
int where;
-
+
val = fds->value;
where = 0;
-
+
while (val) {
int count;
@@ -645,7 +674,7 @@ set_adjustments (FilterDatespec *fds)
val -= timespans[where].seconds;
}
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (PRIV(fds)->spinbuttons[where]),
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (PRIV (fds)->spinbuttons[where]),
(gfloat) count);
where++;
}
@@ -655,7 +684,7 @@ static gchar *
describe_button (FilterDatespec *fds)
{
gchar *desc = NULL;
-
+
switch (fds->type) {
case FDST_UNKNOWN:
desc = g_strdup (_("<click here to select a date>"));
@@ -670,7 +699,7 @@ describe_button (FilterDatespec *fds)
desc = stringify_agoness (fds);
break;
}
-
+
return desc;
}
@@ -679,7 +708,7 @@ cal_day_selected (GtkCalendar *cal, gpointer user_data)
{
FilterDatespec *fds = (FilterDatespec *)user_data;
struct tm seltime;
-
+
seltime.tm_sec = 0;
seltime.tm_min = 0;
seltime.tm_hour = 0;
@@ -687,7 +716,7 @@ cal_day_selected (GtkCalendar *cal, gpointer user_data)
seltime.tm_mon = cal->month;
seltime.tm_year = cal->year - 1900;
seltime.tm_isdst = -1;
-
+
fds->value = mktime (&seltime);
}
@@ -695,8 +724,8 @@ static void
cal_day_selected_double_click (GtkCalendar *cal, gpointer user_data)
{
FilterDatespec *fds = (FilterDatespec *)user_data;
-
+
cal_day_selected (cal, user_data);
- PRIV(fds)->double_click = TRUE;
- gnome_dialog_close (PRIV(fds)->gd);
+ PRIV (fds)->double_click = TRUE;
+ gnome_dialog_close (PRIV (fds)->gd);
}