aboutsummaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
Diffstat (limited to 'filter')
-rw-r--r--filter/ChangeLog8
-rw-r--r--filter/filter-datespec.c654
-rw-r--r--filter/filter-datespec.h7
-rw-r--r--filter/filter.glade294
4 files changed, 485 insertions, 478 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog
index 72e57bd460..1c24bc393b 100644
--- a/filter/ChangeLog
+++ b/filter/ChangeLog
@@ -1,3 +1,11 @@
+2002-08-02 Not Zed <NotZed@Ximian.com>
+
+ * filter.glade: Added a datespec editor window.
+
+ * filter-datespec.c (button_clicked): Rewritten to use glade.
+ Simplified all the code around it as a result, etc, and fixed bug
+ #21798.
+
2002-08-01 Peter Williams <peterw@ximian.com>
* filter-datespec.c (activate_specified): If the value was unset,
diff --git a/filter/filter-datespec.c b/filter/filter-datespec.c
index ae0683e0f2..698e95325d 100644
--- a/filter/filter-datespec.c
+++ b/filter/filter-datespec.c
@@ -26,19 +26,18 @@
#include <math.h>
#include <glib.h>
#include <gtk/gtkcalendar.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkhseparator.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkoptionmenu.h>
#include <gtk/gtkspinbutton.h>
-#include <gtk/gtktable.h>
+#include <gtk/gtknotebook.h>
#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-dialog-util.h>
#include <libgnomeui/gnome-stock.h>
+#include <glade/glade.h>
#include "filter-datespec.h"
#include "e-util/e-sexp.h"
@@ -58,16 +57,6 @@ 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);
-static void omenu_item_activated (GtkMenuItem *item, gpointer user_data);
-static gchar *describe_button (FilterDatespec *fds);
-static gchar *stringify_agoness (FilterDatespec *fds);
-static void set_adjustments (FilterDatespec *fds);
-
-static void cal_day_selected (GtkCalendar *cal, gpointer user_data);
-static void cal_day_selected_double_click (GtkCalendar *cal, gpointer user_data);
-
#define PRIV(x) (((FilterDatespec *)(x))->priv)
typedef struct _timespan {
@@ -78,28 +67,23 @@ typedef struct _timespan {
} timespan;
static const timespan timespans[] = {
- { 31557600, N_("year"), N_("years"), 1000.0 },
- { 2419200, N_("month"), N_("months"), 12.0 },
- { 604800, N_("week"), N_("weeks"), 52.0 },
- { 86400, N_("day"), N_("days"), 31.0 },
- { 3600, N_("hour"), N_("hours"), 23.0 },
+ { 1, N_("second"), N_("seconds"), 59.0 },
{ 60, N_("minute"), N_("minutes"), 59.0 },
- { 1, N_("second"), N_("seconds"), 59.0 }
+ { 3600, N_("hour"), N_("hours"), 23.0 },
+ { 86400, N_("day"), N_("days"), 31.0 },
+ { 604800, N_("week"), N_("weeks"), 52.0 },
+ { 2419200, N_("month"), N_("months"), 12.0 },
+ { 31557600, N_("year"), N_("years"), 1000.0 },
};
#define DAY_INDEX 3
#define N_TIMESPANS (sizeof (timespans) / sizeof (timespans[0]))
struct _FilterDatespecPrivate {
- GnomeDialog *gd;
- GtkWidget *descriptive_label;
- GtkWidget *cur_extra_widget;
- FilterDatespec_type selected_type;
-
- GtkWidget *date_chooser;
- GtkWidget *span_chooser;
- GtkWidget *omenu, *spinbutton, *recent_item;
- gboolean double_click;
+ GtkWidget *label_button;
+ GtkWidget *notebook_type, *option_type, *calendar_specify, *spin_relative, *option_relative;
+ FilterDatespec_type type;
+ int span;
};
static FilterElementClass *parent_class;
@@ -153,7 +137,6 @@ filter_datespec_init (FilterDatespec *o)
{
o->priv = g_malloc0 (sizeof (*o->priv));
o->type = FDST_UNKNOWN;
- PRIV(o)->selected_type = FDST_UNKNOWN;
}
static void
@@ -161,8 +144,7 @@ filter_datespec_finalise(GtkObject *obj)
{
FilterDatespec *o = (FilterDatespec *)obj;
- if (o->priv)
- g_free (o->priv);
+ g_free (o->priv);
((GtkObjectClass *)(parent_class))->finalize(obj);
}
@@ -185,18 +167,11 @@ static gboolean
validate (FilterElement *fe)
{
FilterDatespec *fds = (FilterDatespec *) fe;
- gboolean valid = TRUE;
+ gboolean valid;
- if (fds->value <= 0) {
- GtkWidget *gd;
-
- valid = FALSE;
-
- if (fds->type == FDST_UNKNOWN)
- gd = gnome_ok_dialog (_("You have forgotten to choose a date."));
- else
- gd = gnome_ok_dialog (_("You have chosen an invalid date."));
-
+ valid = fds->type != FDST_UNKNOWN;
+ if (!valid) {
+ GtkWidget *gd = gnome_ok_dialog (_("You have forgotten to choose a date."));
gnome_dialog_run_and_close (GNOME_DIALOG (gd));
}
@@ -270,229 +245,188 @@ xml_decode (FilterElement *fe, xmlNodePtr node)
return 0;
}
-static void
-activate_now (GtkMenuItem *item, FilterDatespec *fds)
+static int get_best_span(time_t val)
{
- 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;
+ int i;
+
+ for (i=N_TIMESPANS-1;i>=0;i--) {
+ if (val % timespans[i].seconds == 0)
+ return i;
}
-
- 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;
+
+ return 0;
}
+/* sets button label */
static void
-activate_specified (GtkMenuItem *item, FilterDatespec *fds)
+set_button(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);
- PRIV (fds)->cur_extra_widget = NULL;
+ char buf[128];
+ char *label = buf;
+
+ switch (fds->type) {
+ case FDST_UNKNOWN:
+ label = _("<click here to select a date>");
+ break;
+ case FDST_NOW:
+ label = _("now");
+ break;
+ case FDST_SPECIFIED: {
+ struct tm tm;
+
+ localtime_r(&fds->value, &tm);
+ /* strftime for date filter display, only needs to show a day date (i.e. no time) */
+ strftime(buf, sizeof(buf), _("%d-%b-%Y"), &tm);
+ break; }
+ case FDST_X_AGO:
+ if (fds->value == 0)
+ label = _("now");
+ else {
+ int span, count;
+
+ span = get_best_span(fds->value);
+ count = fds->value / timespans[span].seconds;
+
+ if (count == 1)
+ /* 1 (minute|day|...) ago (singular time ago) */
+ sprintf(buf, _("%d %s ago"), count, timespans[span].singular);
+ else
+ /* N (minutes|days|...) ago (plural time ago) */
+ sprintf(buf, _("%d %s ago"), count, timespans[span].plural);
+ }
+ break;
}
-
- /* Set description */
-
- 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)
- fds->value = 0;
-
- PRIV (fds)->selected_type = FDST_SPECIFIED;
-
- /* Set the calendar's time */
- if (fds->value < 1)
- fds->value = time (NULL);
+ gtk_label_set_text((GtkLabel *)fds->priv->label_button, label);
+}
- /* gmtime? */
- seltime = localtime (&(fds->value));
-
- 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),
- seltime->tm_mday);
-
- 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;
+static void
+get_values(FilterDatespec *fds)
+{
+ struct _FilterDatespecPrivate *p = PRIV(fds);
+
+ switch(fds->priv->type) {
+ case FDST_SPECIFIED: {
+ guint year, month, day;
+ struct tm tm;
+
+ gtk_calendar_get_date((GtkCalendar *)p->calendar_specify, &year, &month, &day);
+ memset(&tm, 0, sizeof(tm));
+ tm.tm_mday = day;
+ tm.tm_year = year - 1900;
+ tm.tm_mon = month;
+ fds->value = mktime(&tm);
+ /* what about timezone? */
+ break; }
+ case FDST_X_AGO: {
+ int val;
+
+ val = gtk_spin_button_get_value_as_int((GtkSpinButton *)p->spin_relative);
+ fds->value = timespans[p->span].seconds * val;
+ break; }
+ case FDST_NOW:
+ default:
+ break;
+ }
+
+ fds->type = p->type;
}
static void
-activate_x_ago (GtkMenuItem *item, FilterDatespec *fds)
+set_values(FilterDatespec *fds)
{
- 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;
+ struct _FilterDatespecPrivate *p = PRIV(fds);
+
+ p->type = fds->type==FDST_UNKNOWN ? FDST_NOW : fds->type;
+
+ switch (p->type) {
+ case FDST_NOW:
+ case FDST_UNKNOWN:
+ /* noop */
+ break;
+ case FDST_SPECIFIED: {
+ struct tm tm;
+
+ localtime_r(&fds->value, &tm);
+ gtk_calendar_select_month((GtkCalendar*)p->calendar_specify, tm.tm_mon, tm.tm_year + 1900);
+ gtk_calendar_select_day((GtkCalendar*)p->calendar_specify, tm.tm_mday);
+ break; }
+ case FDST_X_AGO:
+ p->span = get_best_span(fds->value);
+ gtk_spin_button_set_value((GtkSpinButton*)p->spin_relative, fds->value/timespans[p->span].seconds);
+ gtk_option_menu_set_history((GtkOptionMenu*)p->option_relative, p->span);
+ break;
}
-
- 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)
- fds->value = 0;
-
- 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,
- TRUE, TRUE, 3);
- gtk_widget_show (PRIV (fds)->span_chooser);
- PRIV (fds)->cur_extra_widget = PRIV (fds)->span_chooser;
+ gtk_notebook_set_page((GtkNotebook*)p->notebook_type, p->type);
+ gtk_option_menu_set_history((GtkOptionMenu*)p->option_type, p->type);
}
-typedef void (*my_menu_callback) (GtkMenuItem *, FilterDatespec *);
+
+static void
+set_option_type(GtkMenu *menu, FilterDatespec *fds)
+{
+ GtkWidget *w;
+
+ /* ugh, no other way to 'get_history' */
+ w = gtk_menu_get_active(menu);
+ fds->priv->type = g_list_index(GTK_MENU_SHELL(menu)->children, w);
+ gtk_notebook_set_page((GtkNotebook*)fds->priv->notebook_type, fds->priv->type);
+}
+
+static void
+set_option_relative(GtkMenu *menu, FilterDatespec *fds)
+{
+ GtkWidget *w;
+
+ w = gtk_menu_get_active(menu);
+ fds->priv->span = g_list_index(GTK_MENU_SHELL(menu)->children, w);
+}
+
+static void
+dialogue_clicked(GnomeDialog *gd, int button, FilterDatespec *fds)
+{
+ if (button != 0)
+ return;
+
+ get_values(fds);
+ set_button(fds);
+}
static void
button_clicked (GtkButton *button, FilterDatespec *fds)
{
GnomeDialog *gd;
- GtkWidget *box;
- GtkWidget *label;
- GtkWidget *menu;
- GtkWidget *selectomatic;
- 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;
-
- /* 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",
- cal_day_selected, fds);
- 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));
-
- /* The dialog */
-
+ struct _FilterDatespecPrivate *p = PRIV(fds);
+ GtkWidget *w, *x;
+ GladeXML *gui;
+
+ gui = glade_xml_new(FILTER_GLADEDIR "/filter.glade", "filter_datespec");
+ w = glade_xml_get_widget(gui, "filter_datespec");
+
gd = (GnomeDialog *) gnome_dialog_new (_("Select a time to compare against"),
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL,
NULL);
- 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);
- gtk_box_pack_start (GTK_BOX (box), selectomatic,
- 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);
-
- /* Set up the current view */
-
- if (fds->type == FDST_UNKNOWN)
- fds->type = FDST_NOW;
- PRIV (fds)->selected_type = fds->type;
- (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)
- break;
- /* else fall */
- case 0:
- 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);
- /* falllllll */
- case 1:
- /* cancel */
- break;
- }
-
- gtk_widget_destroy (PRIV (fds)->date_chooser);
- gtk_widget_destroy (PRIV (fds)->span_chooser);
+ p->notebook_type = glade_xml_get_widget(gui, "notebook_type");
+ p->option_type = glade_xml_get_widget(gui, "option_type");
+ p->calendar_specify = glade_xml_get_widget(gui, "calendar_specify");
+ p->spin_relative = glade_xml_get_widget(gui, "spin_relative");
+ p->option_relative = glade_xml_get_widget(gui, "option_relative");
+
+ set_values(fds);
+
+ gtk_signal_connect((GtkObject *)GTK_OPTION_MENU(p->option_type)->menu, "deactivate", set_option_type, fds);
+ gtk_signal_connect((GtkObject *)GTK_OPTION_MENU(p->option_relative)->menu, "deactivate", set_option_relative, fds);
+
+ gtk_box_pack_start ((GtkBox *)gd->vbox, w, TRUE, TRUE, 3);
+
+ gtk_signal_connect((GtkObject *)gd, "clicked", dialogue_clicked, fds);
+
+ gnome_dialog_run_and_close(gd);
+
+ return;
}
static GtkWidget *
@@ -500,20 +434,17 @@ 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);
+ fds->priv->label_button = gtk_label_new ("");
+ gtk_misc_set_alignment (GTK_MISC (fds->priv->label_button), 0.5, 0.5);
+ set_button(fds);
button = gtk_button_new();
- gtk_container_add (GTK_CONTAINER (button), label);
+ gtk_container_add (GTK_CONTAINER (button), fds->priv->label_button);
gtk_signal_connect (GTK_OBJECT (button), "clicked", button_clicked, fds);
gtk_widget_show (button);
- gtk_widget_show (label);
+ gtk_widget_show (fds->priv->label_button);
return button;
}
@@ -543,234 +474,3 @@ format_sexp (FilterElement *fe, GString *out)
break;
}
}
-
-static gchar *
-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;
-
- count = 0;
-
- while (timespans[where].seconds <= val) {
- count++;
- val -= timespans[where].seconds;
- }
-
- if (count != 0 ) {
- if (count > 1)
- g_string_sprintfa (str, "%d %s", (int) count, gettext (timespans[where].plural));
- else
- g_string_sprintfa (str, "%d %s", (int) count, gettext (timespans[where].singular));
-
- if (val)
- g_string_append (str, ", ");
- }
-
- where++;
- }
-
- g_string_append (str, _(" ago"));
- }
-
- ret = str->str;
- g_string_free (str, FALSE);
- return ret;
-}
-
-static void
-make_span_editor (FilterDatespec *fds)
-{
- int i;
- GtkObject *adj;
- GtkWidget *hbox, *menu, *om, *sb, *label;
-
- /*PRIV (fds)->span_chooser = gtk_vbox_new (TRUE, 3);*/
-
- hbox = gtk_hbox_new (TRUE, 3);
-
- adj = gtk_adjustment_new (0.0, 0.0,
- /*timespans[i].max*/100000.0,
- 1.0, 10.0, 0.0);
- sb = gtk_spin_button_new (GTK_ADJUSTMENT (adj), 0, 0);
- gtk_widget_show (GTK_WIDGET (sb));
- gtk_box_pack_start (GTK_BOX (hbox), sb, TRUE, TRUE, 0);
-
- menu = gtk_menu_new ();
- for (i = 0; i < N_TIMESPANS; i++) {
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (gettext (timespans[i].plural));
- gtk_object_set_data (GTK_OBJECT (item), "timespan", (gpointer) &(timespans[i]));
- gtk_signal_connect (GTK_OBJECT (item), "activate", omenu_item_activated, fds);
- gtk_widget_show (item);
- gtk_menu_prepend (GTK_MENU (menu), item);
-
- if (i == DAY_INDEX)
- PRIV (fds)->recent_item = item;
- }
-
- om = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (om), DAY_INDEX);
- gtk_widget_show (om);
- gtk_box_pack_start (GTK_BOX (hbox), om, FALSE, TRUE, 0);
-
- label = gtk_label_new (_("ago"));
- gtk_widget_show (label);
- gtk_misc_set_padding (GTK_MISC (label), 3, 0);
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
-
- gtk_widget_show (hbox);
-
- PRIV (fds)->span_chooser = hbox;
- PRIV (fds)->omenu = om;
- PRIV (fds)->spinbutton = sb;
-
- /* if we do this earlier, we get the signal before the private
- * members have been set up. */
- gtk_signal_connect (adj, "value_changed",
- adj_value_changed, fds);
-}
-
-static void
-omenu_item_activated (GtkMenuItem *item, gpointer user_data)
-{
- FilterDatespec *fds = (FilterDatespec *) user_data;
- GtkOptionMenu *om;
- timespan *old_ts, *new_ts;
- int cur_val;
- gfloat new_val;
-
- if (!PRIV (fds)->recent_item) {
- PRIV (fds)->recent_item = GTK_WIDGET (item);
- return;
- }
-
- om = GTK_OPTION_MENU (PRIV (fds)->omenu);
- old_ts = gtk_object_get_data (GTK_OBJECT (PRIV (fds)->recent_item), "timespan");
- new_ts = gtk_object_get_data (GTK_OBJECT (item), "timespan");
-
- cur_val = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton));
-
- /*if (old_ts->seconds > new_ts->seconds)*/
- new_val = ceil (cur_val * old_ts->seconds / new_ts->seconds);
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton), new_val);
- PRIV (fds)->recent_item = GTK_WIDGET (item);
-}
-
-static void
-adj_value_changed (GtkAdjustment *adj, gpointer user_data)
-{
- FilterDatespec *fds = (FilterDatespec *) user_data;
- GtkOptionMenu *om;
- timespan *ts;
-
- om = GTK_OPTION_MENU (PRIV (fds)->omenu);
-
- if (om->menu_item == NULL) /* this has happened to me... dunno what it means */
- return;
-
- ts = gtk_object_get_data (GTK_OBJECT (om->menu_item), "timespan");
- fds->value = ts->seconds *
- (gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton)));
-}
-
-static void
-set_adjustments (FilterDatespec *fds)
-{
- time_t val;
- int i;
-
- val = fds->value;
-
- for (i = 0; i < N_TIMESPANS; i++) {
- if (val % timespans[i].seconds == 0) {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (PRIV (fds)->spinbutton),
- (gfloat) val / timespans[i].seconds);
- break;
- }
- }
-
- gtk_option_menu_set_history (GTK_OPTION_MENU (PRIV (fds)->omenu),
- N_TIMESPANS - (i + 1));
-}
-
-static gchar *
-format_time (time_t time)
-{
- struct tm *as_tm;
- char buf[128];
-
- /* no idea if this format is the 'correct' one */
-
- as_tm = localtime (&time);
- strftime (buf, 128, _("%b %d %l:%M %p"), as_tm);
- return g_strdup (buf);
-}
-
-static gchar *
-describe_button (FilterDatespec *fds)
-{
- gchar *desc = NULL;
-
- switch (fds->type) {
- case FDST_UNKNOWN:
- desc = g_strdup (_("<click here to select a date>"));
- break;
- case FDST_NOW:
- desc = g_strdup (_("now"));
- break;
- case FDST_SPECIFIED:
- desc = format_time (fds->value);
- break;
- case FDST_X_AGO:
- desc = stringify_agoness (fds);
- break;
- }
-
- return desc;
-}
-
-static void
-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;
- seltime.tm_mday = cal->selected_day;
- seltime.tm_mon = cal->month;
- seltime.tm_year = cal->year - 1900;
- seltime.tm_isdst = -1;
-
- fds->value = mktime (&seltime);
-}
-
-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);
-}
-
diff --git a/filter/filter-datespec.h b/filter/filter-datespec.h
index a606cc1d2f..5d20380a47 100644
--- a/filter/filter-datespec.h
+++ b/filter/filter-datespec.h
@@ -31,7 +31,12 @@
typedef struct _FilterDatespec FilterDatespec;
typedef struct _FilterDatespecClass FilterDatespecClass;
-typedef enum _FilterDatespec_type { FDST_NOW, FDST_SPECIFIED, FDST_X_AGO, FDST_UNKNOWN } FilterDatespec_type;
+typedef enum _FilterDatespec_type {
+ FDST_UNKNOWN = -1,
+ FDST_NOW,
+ FDST_SPECIFIED,
+ FDST_X_AGO,
+} FilterDatespec_type;
struct _FilterDatespec {
FilterElement parent;
diff --git a/filter/filter.glade b/filter/filter.glade
index 7325381317..a38c91974f 100644
--- a/filter/filter.glade
+++ b/filter/filter.glade
@@ -735,4 +735,298 @@ with all local and active remote folders
</widget>
</widget>
+<widget>
+ <class>GtkWindow</class>
+ <name>filter_datespec_win</name>
+ <title>window1</title>
+ <type>GTK_WINDOW_TOPLEVEL</type>
+ <position>GTK_WIN_POS_NONE</position>
+ <modal>False</modal>
+ <allow_shrink>False</allow_shrink>
+ <allow_grow>True</allow_grow>
+ <auto_shrink>False</auto_shrink>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>filter_datespec</name>
+ <homogeneous>False</homogeneous>
+ <spacing>3</spacing>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox5</name>
+ <border_width>4</border_width>
+ <homogeneous>False</homogeneous>
+ <spacing>3</spacing>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label4</name>
+ <label>Compare against</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkOptionMenu</class>
+ <name>option_type</name>
+ <can_focus>True</can_focus>
+ <items>the current time
+the time you specify
+a time relative to the current time
+</items>
+ <initial_choice>0</initial_choice>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkHSeparator</class>
+ <name>hseparator1</name>
+ <child>
+ <padding>1</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkNotebook</class>
+ <name>notebook_type</name>
+ <show_tabs>False</show_tabs>
+ <show_border>False</show_border>
+ <tab_pos>GTK_POS_TOP</tab_pos>
+ <scrollable>False</scrollable>
+ <tab_hborder>2</tab_hborder>
+ <tab_vborder>2</tab_vborder>
+ <popup_enable>False</popup_enable>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox9</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label5</name>
+ <label>The message's date will be compared against
+the current time when filtering occurs.</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>Notebook:tab</child_name>
+ <name>label1</name>
+ <label>label1</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox7</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label6</name>
+ <label>The message's date will be compared against
+12:00am of the date specified.</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkCalendar</class>
+ <name>calendar_specify</name>
+ <can_focus>True</can_focus>
+ <show_heading>True</show_heading>
+ <show_day_names>True</show_day_names>
+ <no_month_change>False</no_month_change>
+ <show_week_numbers>False</show_week_numbers>
+ <week_start_monday>False</week_start_monday>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>Notebook:tab</child_name>
+ <name>label2</name>
+ <label>label2</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+
+ <widget>
+ <class>GtkVBox</class>
+ <name>vbox8</name>
+ <homogeneous>False</homogeneous>
+ <spacing>0</spacing>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label7</name>
+ <label>The message's date will be compared against
+a time relative to when filtering occurs.</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkHBox</class>
+ <name>hbox6</name>
+ <homogeneous>True</homogeneous>
+ <spacing>0</spacing>
+ <child>
+ <padding>2</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ </child>
+
+ <widget>
+ <class>GtkSpinButton</class>
+ <name>spin_relative</name>
+ <can_focus>True</can_focus>
+ <climb_rate>1</climb_rate>
+ <digits>0</digits>
+ <numeric>False</numeric>
+ <update_policy>GTK_UPDATE_ALWAYS</update_policy>
+ <snap>False</snap>
+ <wrap>False</wrap>
+ <value>1</value>
+ <lower>0</lower>
+ <upper>1000</upper>
+ <step>1</step>
+ <page>10</page>
+ <page_size>10</page_size>
+ <child>
+ <padding>0</padding>
+ <expand>True</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkOptionMenu</class>
+ <name>option_relative</name>
+ <can_focus>True</can_focus>
+ <items>seconds
+minutes
+hours
+days
+weeks
+months
+years
+</items>
+ <initial_choice>3</initial_choice>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>False</fill>
+ </child>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <name>label8</name>
+ <label>ago</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>7.45058e-09</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ <child>
+ <padding>0</padding>
+ <expand>False</expand>
+ <fill>True</fill>
+ </child>
+ </widget>
+ </widget>
+ </widget>
+
+ <widget>
+ <class>GtkLabel</class>
+ <child_name>Notebook:tab</child_name>
+ <name>label3</name>
+ <label>label3</label>
+ <justify>GTK_JUSTIFY_CENTER</justify>
+ <wrap>False</wrap>
+ <xalign>0.5</xalign>
+ <yalign>0.5</yalign>
+ <xpad>0</xpad>
+ <ypad>0</ypad>
+ </widget>
+ </widget>
+ </widget>
+</widget>
+
</GTK-Interface>