Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/rhythmbox/ChangeLog,v
retrieving revision 1.1480
diff -u -r1.1480 ChangeLog
--- ChangeLog	15 Dec 2005 12:28:20 -0000	1.1480
+++ ChangeLog	16 Dec 2005 12:54:02 -0000
@@ -1,3 +1,11 @@
+2005-12-16  Alex Lancaster  <alexl@users.sourceforge.net>
+
+	* widgets/rb-query-creator-properties.c:
+	(property_options, year_property_type)
+	(yearCriteriaSetWidgetData, yearCriteriaGetWidgetData): New widget
+	that supports automatic playlists including year as a criteria.
+	Performs the internal Julian to year conversion.  Closes #321341.
+
 2005-12-15  William Jon McCann  <mccann@jhu.edu>
 
 	* shell/rb-shell.c (rb_shell_sync_fullscreen) 
Index: widgets/rb-query-creator-properties.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/widgets/rb-query-creator-properties.c,v
retrieving revision 1.4
diff -u -r1.4 rb-query-creator-properties.c
--- widgets/rb-query-creator-properties.c	5 Nov 2005 05:03:19 -0000	1.4
+++ widgets/rb-query-creator-properties.c	16 Dec 2005 12:54:06 -0000
@@ -31,6 +31,7 @@
 const RBQueryCreatorPropertyType escaped_string_property_type;
 const RBQueryCreatorPropertyType rating_property_type;
 const RBQueryCreatorPropertyType integer_property_type;
+const RBQueryCreatorPropertyType year_property_type;
 const RBQueryCreatorPropertyType duration_property_type;
 const RBQueryCreatorPropertyType relative_time_property_type;
 
@@ -45,6 +46,8 @@
 static GtkWidget * integerCriteriaCreateWidget (gboolean *constrain);
 static void integerCriteriaSetWidgetData (GtkWidget *widget, GValue *val);
 static void integerCriteriaGetWidgetData (GtkWidget *widget, GValue *val);
+static void yearCriteriaSetWidgetData (GtkWidget *widget, GValue *val);
+static void yearCriteriaGetWidgetData (GtkWidget *widget, GValue *val);
 static GtkWidget * durationCriteriaCreateWidget (gboolean *constrain);
 static void durationCriteriaSetWidgetData (GtkWidget *widget, GValue *val);
 static void durationCriteriaGetWidgetData (GtkWidget *widget, GValue *val);
@@ -62,6 +65,7 @@
 	{ N_("Artist"), RHYTHMDB_PROP_ARTIST, RHYTHMDB_PROP_ARTIST_FOLDED, &string_property_type },
 	{ N_("Album"), RHYTHMDB_PROP_ALBUM, RHYTHMDB_PROP_ALBUM_FOLDED, &string_property_type },
 	{ N_("Genre"), RHYTHMDB_PROP_GENRE, RHYTHMDB_PROP_GENRE_FOLDED, &string_property_type },
+	{ N_("Year"), RHYTHMDB_PROP_DATE, RHYTHMDB_PROP_DATE, &year_property_type },
 	{ N_("Rating"), RHYTHMDB_PROP_RATING, RHYTHMDB_PROP_RATING, &rating_property_type },
 	{ N_("Path"), RHYTHMDB_PROP_LOCATION, RHYTHMDB_PROP_LOCATION, &escaped_string_property_type },
 
@@ -162,6 +166,16 @@
 	integerCriteriaGetWidgetData
 };
 
+const RBQueryCreatorPropertyType year_property_type =
+{
+	G_N_ELEMENTS (numeric_criteria_options),
+	numeric_criteria_options,
+	integerCriteriaCreateWidget,
+	yearCriteriaSetWidgetData,
+	yearCriteriaGetWidgetData
+};
+
+
 const RBQueryCreatorPropertyType duration_property_type =
 {
 	G_N_ELEMENTS (numeric_criteria_options),
@@ -328,6 +342,39 @@
 	g_value_init (val, G_TYPE_ULONG);
 	g_value_set_ulong (val, (gulong)num);
 }
+
+/* Implementation for Year properties, using a single GtkSpinButton. */
+
+static void
+yearCriteriaSetWidgetData (GtkWidget *widget, GValue *val)
+{
+	GDate *date = NULL;
+	gulong num = g_value_get_ulong (val);
+	g_assert (num <= G_MAXINT);
+
+	/* Create a date structure to get year from */
+	date = g_date_new();
+	g_date_set_julian (date, num);
+	
+	gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), (gint)g_date_get_year(date));
+	g_date_free(date);
+}
+
+static void
+yearCriteriaGetWidgetData (GtkWidget *widget, GValue *val)
+{
+	GDate *date = NULL;
+	gint num = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
+	g_assert (num >= 0);
+
+	/* New date structure, use year set in widget */
+	date = g_date_new_dmy (1, G_DATE_JANUARY, num);
+
+	g_value_init (val, G_TYPE_ULONG);
+	g_value_set_ulong (val, (gulong) g_date_get_julian (date) );
+	g_date_free(date);
+}
+
 
 
 /*
