Matthew Barnes c29619
diff -ur evolution-2.7.3/filter/filter-datespec.c my-evolution-2.7.3/filter/filter-datespec.c
Matthew Barnes c29619
--- evolution-2.7.3/filter/filter-datespec.c	2005-08-09 17:29:27.000000000 -0600
Matthew Barnes c29619
+++ my-evolution-2.7.3/filter/filter-datespec.c	2006-06-28 20:51:01.000000000 -0600
Matthew Barnes c29619
@@ -61,8 +61,10 @@
Matthew Barnes c29619
 
Matthew Barnes c29619
 typedef struct _timespan {
Matthew Barnes c29619
 	guint32 seconds;
Matthew Barnes c29619
-	const char *singular;
Matthew Barnes c29619
-	const char *plural;
Matthew Barnes c29619
+	const char *past_singular;
Matthew Barnes c29619
+	const char *past_plural;
Matthew Barnes c29619
+	const char *future_singular;
Matthew Barnes c29619
+	const char *future_plural;
Matthew Barnes c29619
 	float max;
Matthew Barnes c29619
 } timespan;
Matthew Barnes c29619
 
Matthew Barnes c29619
@@ -75,13 +77,13 @@
Matthew Barnes c29619
 #define ngettext(a, b)  a, b
Matthew Barnes c29619
 
Matthew Barnes c29619
 static const timespan timespans[] = {
Matthew Barnes c29619
-	{ 1, ngettext("1 second ago", "%d seconds ago"), 59.0 },
Matthew Barnes c29619
-	{ 60, ngettext("1 minute ago", "%d minutes ago"), 59.0 },
Matthew Barnes c29619
-	{ 3600, ngettext("1 hour ago", "%d hours ago"), 23.0 },
Matthew Barnes c29619
-	{ 86400, ngettext("1 day ago", "%d days ago"), 31.0 },
Matthew Barnes c29619
-	{ 604800, ngettext("1 week ago", "%d weeks ago"), 52.0 },
Matthew Barnes c29619
-	{ 2419200, ngettext("1 month ago", "%d months ago"), 12.0 },
Matthew Barnes c29619
-	{ 31557600, ngettext("1 year ago", "%d years ago"), 1000.0 },
Matthew Barnes c29619
+	{ 1, ngettext("1 second ago", "%d seconds ago"), ngettext("1 second in the future", "%d seconds in the future"), 59.0 },
Matthew Barnes c29619
+	{ 60, ngettext("1 minute ago", "%d minutes ago"), ngettext("1 minute in the future", "%d minutes in the future"), 59.0 },
Matthew Barnes c29619
+	{ 3600, ngettext("1 hour ago", "%d hours ago"), ngettext("1 hour in the future", "%d hours in the future"), 23.0 },
Matthew Barnes c29619
+	{ 86400, ngettext("1 day ago", "%d days ago"), ngettext("1 day in the future", "%d days in the future"), 31.0 },
Matthew Barnes c29619
+	{ 604800, ngettext("1 week ago", "%d weeks ago"), ngettext("1 week in the future", "%d weeks in the future"), 52.0 },
Matthew Barnes c29619
+	{ 2419200, ngettext("1 month ago", "%d months ago"), ngettext("1 month in the future", "%d months in the future"), 12.0 },
Matthew Barnes c29619
+	{ 31557600, ngettext("1 year ago", "%d years ago"), ngettext("1 year in the future", "%d years in the future"), 1000.0 },
Matthew Barnes 5929c8
 };
Matthew Barnes 5929c8
 
Matthew Barnes 5929c8
 /* now we let the compiler see the real function call */
Matthew Barnes c29619
@@ -92,7 +94,7 @@
Matthew Barnes c29619
 
Matthew Barnes c29619
 struct _FilterDatespecPrivate {
Matthew Barnes c29619
 	GtkWidget *label_button;
Matthew Barnes c29619
-	GtkWidget *notebook_type, *option_type, *calendar_specify, *spin_relative, *option_relative;
Matthew Barnes c29619
+	GtkWidget *notebook_type, *option_type, *calendar_specify, *spin_relative, *option_relative, *option_past_future;
Matthew Barnes c29619
 	FilterDatespec_type type;
Matthew Barnes c29619
 	int span;
Matthew Barnes c29619
 };
Matthew Barnes c29619
@@ -264,7 +266,7 @@
Matthew Barnes c29619
 get_best_span (time_t val)
Matthew Barnes c29619
 {
Matthew Barnes c29619
 	int i;
Matthew Barnes c29619
-	
Matthew Barnes c29619
+
Matthew Barnes c29619
 	for (i=N_TIMESPANS-1;i>=0;i--) {
Matthew Barnes c29619
 		if (val % timespans[i].seconds == 0)
Matthew Barnes c29619
 			return i;
Matthew Barnes c29619
@@ -302,8 +304,18 @@
Matthew Barnes c29619
 			
Matthew Barnes c29619
 			span = get_best_span(fds->value);
Matthew Barnes c29619
 			count = fds->value / timespans[span].seconds;
Matthew Barnes c29619
+			sprintf(buf, ngettext(timespans[span].past_singular, timespans[span].past_plural, count), count);
Matthew Barnes c29619
+		}
Matthew Barnes c29619
+		break;
Matthew Barnes c29619
+	case FDST_X_FUTURE:
Matthew Barnes c29619
+		if (fds->value == 0)
Matthew Barnes c29619
+			label = _("now");
Matthew Barnes c29619
+		else {
Matthew Barnes c29619
+			int span, count;
Matthew Barnes c29619
 			
Matthew Barnes c29619
-			sprintf(buf, ngettext(timespans[span].singular, timespans[span].plural, count), count);
Matthew Barnes c29619
+			span = get_best_span(fds->value);
Matthew Barnes c29619
+			count = fds->value / timespans[span].seconds;
Matthew Barnes c29619
+			sprintf(buf, ngettext(timespans[span].future_singular, timespans[span].future_plural, count), count);
Matthew Barnes c29619
 		}
Matthew Barnes c29619
 		break;
Matthew Barnes c29619
 	}
Matthew Barnes c29619
@@ -329,6 +341,7 @@
Matthew Barnes c29619
 		fds->value = mktime(&tm;;
Matthew Barnes c29619
 		/* what about timezone? */
Matthew Barnes c29619
 		break; }
Matthew Barnes c29619
+	case FDST_X_FUTURE:
Matthew Barnes c29619
 	case FDST_X_AGO: {
Matthew Barnes c29619
 		int val;
Matthew Barnes c29619
 		
Matthew Barnes c29619
@@ -349,6 +362,8 @@
Matthew Barnes c29619
 	struct _FilterDatespecPrivate *p = PRIV(fds);
Matthew Barnes c29619
 	
Matthew Barnes c29619
 	p->type = fds->type==FDST_UNKNOWN ? FDST_NOW : fds->type;
Matthew Barnes c29619
+
Matthew Barnes c29619
+	int note_type = fds->type==FDST_X_FUTURE ? FDST_X_AGO : fds->type; // FUTURE and AGO use the same notebook pages/etc.
Matthew Barnes c29619
 	
Matthew Barnes c29619
 	switch (p->type) {
Matthew Barnes c29619
 	case FDST_NOW:
Matthew Barnes c29619
@@ -368,11 +383,18 @@
Matthew Barnes c29619
 		p->span = get_best_span(fds->value);
Matthew Barnes c29619
 		gtk_spin_button_set_value((GtkSpinButton*)p->spin_relative, fds->value/timespans[p->span].seconds);
Matthew Barnes c29619
 		gtk_option_menu_set_history((GtkOptionMenu*)p->option_relative, p->span);
Matthew Barnes c29619
+		gtk_option_menu_set_history((GtkOptionMenu*)p->option_past_future, 0);
Matthew Barnes c29619
+		break;
Matthew Barnes c29619
+	case FDST_X_FUTURE:
Matthew Barnes c29619
+		p->span = get_best_span(fds->value);
Matthew Barnes c29619
+		gtk_spin_button_set_value((GtkSpinButton*)p->spin_relative, fds->value/timespans[p->span].seconds);
Matthew Barnes c29619
+		gtk_option_menu_set_history((GtkOptionMenu*)p->option_relative, p->span);
Matthew Barnes c29619
+		gtk_option_menu_set_history((GtkOptionMenu*)p->option_past_future, 1);
Matthew Barnes c29619
 		break;
Matthew Barnes c29619
 	}
Matthew Barnes c29619
 	
Matthew Barnes c29619
-	gtk_notebook_set_current_page ((GtkNotebook*) p->notebook_type, p->type);
Matthew Barnes c29619
-	gtk_option_menu_set_history ((GtkOptionMenu*) p->option_type, p->type);
Matthew Barnes c29619
+	gtk_notebook_set_current_page ((GtkNotebook*) p->notebook_type, note_type);
Matthew Barnes c29619
+	gtk_option_menu_set_history ((GtkOptionMenu*) p->option_type, note_type);
Matthew Barnes c29619
 }
Matthew Barnes c29619
 
Matthew Barnes c29619
 
Matthew Barnes c29619
@@ -397,6 +419,18 @@
Matthew Barnes c29619
 }
Matthew Barnes c29619
 
Matthew Barnes c29619
 static void
Matthew Barnes c29619
+set_option_past_future (GtkMenu *menu, FilterDatespec *fds)
Matthew Barnes c29619
+{
Matthew Barnes c29619
+	GtkWidget *w;
Matthew Barnes c29619
+	
Matthew Barnes c29619
+	w = gtk_menu_get_active (menu);
Matthew Barnes c29619
+	if(g_list_index (GTK_MENU_SHELL (menu)->children, w) == 0)
Matthew Barnes c29619
+		fds->type = fds->priv->type = FDST_X_AGO;
Matthew Barnes c29619
+	else
Matthew Barnes c29619
+		fds->type = fds->priv->type = FDST_X_FUTURE;
Matthew Barnes c29619
+}
Matthew Barnes c29619
+
Matthew Barnes c29619
+static void
Matthew Barnes c29619
 button_clicked (GtkButton *button, FilterDatespec *fds)
Matthew Barnes c29619
 {
Matthew Barnes c29619
 	struct _FilterDatespecPrivate *p = PRIV(fds);
Matthew Barnes c29619
@@ -424,6 +458,7 @@
Matthew Barnes c29619
 	p->calendar_specify = glade_xml_get_widget (gui, "calendar_specify");
Matthew Barnes c29619
 	p->spin_relative = glade_xml_get_widget (gui, "spin_relative");
Matthew Barnes c29619
 	p->option_relative = glade_xml_get_widget (gui, "option_relative");
Matthew Barnes c29619
+	p->option_past_future = glade_xml_get_widget (gui, "option_past_future");
Matthew Barnes c29619
 	
Matthew Barnes c29619
 	set_values (fds);
Matthew Barnes c29619
 	
Matthew Barnes c29619
@@ -431,6 +466,8 @@
Matthew Barnes c29619
 			  G_CALLBACK (set_option_type), fds);
Matthew Barnes c29619
 	g_signal_connect (GTK_OPTION_MENU (p->option_relative)->menu, "deactivate",
Matthew Barnes c29619
 			  G_CALLBACK (set_option_relative), fds);
Matthew Barnes c29619
+	g_signal_connect (GTK_OPTION_MENU (p->option_past_future)->menu, "deactivate",
Matthew Barnes c29619
+			  G_CALLBACK (set_option_past_future), fds);
Matthew Barnes c29619
 	
Matthew Barnes c29619
 	gtk_box_pack_start ((GtkBox *) dialog->vbox, toplevel, TRUE, TRUE, 3);
Matthew Barnes c29619
 	
Matthew Barnes c29619
@@ -486,5 +523,8 @@
Matthew Barnes c29619
 	case FDST_X_AGO:
Matthew Barnes c29619
 		g_string_append_printf (out, "(- (get-current-date) %d)", (int) fds->value);
Matthew Barnes c29619
 		break;
Matthew Barnes c29619
+	case FDST_X_FUTURE:
Matthew Barnes c29619
+		g_string_append_printf (out, "(+ (get-current-date) %d)", (int) fds->value);
Matthew Barnes c29619
+		break;
Matthew Barnes c29619
 	}
Matthew Barnes c29619
 }
Matthew Barnes c29619
diff -ur evolution-2.7.3/filter/filter-datespec.h my-evolution-2.7.3/filter/filter-datespec.h
Matthew Barnes c29619
--- evolution-2.7.3/filter/filter-datespec.h	2002-11-01 16:22:57.000000000 -0700
Matthew Barnes c29619
+++ my-evolution-2.7.3/filter/filter-datespec.h	2006-06-28 17:25:55.000000000 -0600
Matthew Barnes c29619
@@ -42,6 +42,7 @@
Matthew Barnes c29619
 	FDST_NOW,
Matthew Barnes c29619
 	FDST_SPECIFIED,
Matthew Barnes c29619
 	FDST_X_AGO,
Matthew Barnes c29619
+	FDST_X_FUTURE,
Matthew Barnes c29619
 } FilterDatespec_type;
Matthew Barnes c29619
 
Matthew Barnes c29619
 struct _FilterDatespec {
Matthew Barnes c29619
@@ -52,7 +53,7 @@
Matthew Barnes c29619
 	
Matthew Barnes c29619
 	/* either a timespan, an absolute time, or 0
Matthew Barnes c29619
 	 * depending on type -- the above mapping to
Matthew Barnes c29619
-	 * (X_AGO, SPECIFIED, NOW)
Matthew Barnes c29619
+	 * (X_FUTURE, X_AGO, SPECIFIED, NOW)
Matthew Barnes c29619
 	 */
Matthew Barnes c29619
 	
Matthew Barnes c29619
 	time_t value;