? cut-n-paste/Makefile
? cut-n-paste/Makefile.in
? cut-n-paste/eggmarshalers.c
? cut-n-paste/eggmarshalers.h
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/ChangeLog,v
retrieving revision 1.587
diff -p -u -r1.587 ChangeLog
--- ChangeLog	18 May 2005 16:17:21 -0000	1.587
+++ ChangeLog	19 May 2005 22:09:14 -0000
@@ -1,3 +1,14 @@
+2005-05-19  William Jon McCann  <mccann@jhu.edu>
+
+	* clock.c (compare_priority, handle_tasks_changed) 
+	(create_task_list): 
+	* calendar-client.[ch] (get_ical_priority, calendar_task_equal) 
+	(calendar_task_copy, calendar_task_init): 
+	Sort task list by priority.
+
+	Based on patch by Carlos Garcia Campos <carlosgc@gnome.org>
+	Fixes #166450.
+	
 ==================== 2.11.1 ====================
 
 ==================== 2.10.0 ====================
Index: calendar-client.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/calendar-client.c,v
retrieving revision 1.10
diff -p -u -r1.10 calendar-client.c
--- calendar-client.c	31 Aug 2004 08:18:34 -0000	1.10
+++ calendar-client.c	19 May 2005 22:09:14 -0000
@@ -635,6 +635,18 @@ get_ical_completed_time (icalcomponent *
                                  default_zone);
 }
 
+static int
+get_ical_priority (icalcomponent *ical)
+{
+  icalproperty *prop;
+
+  prop = icalcomponent_get_first_property (ical, ICAL_PRIORITY_PROPERTY);
+    if (!prop)
+      return -1;
+
+  return icalproperty_get_priority (prop);
+}
+
 static char *
 get_source_color (ECal *esource)
 {
@@ -836,7 +848,8 @@ calendar_task_equal (CalendarTask *a,
     a->start_time       == b->start_time                   &&
     a->due_time         == b->due_time                     &&
     a->percent_complete == b->percent_complete             &&
-    a->completed_time   == b->completed_time;
+    a->completed_time   == b->completed_time               &&
+    a->priority         == b->priority;
 }
 
 static void
@@ -855,6 +868,7 @@ calendar_task_copy (CalendarTask *task,
   task_copy->due_time         = task->due_time;
   task_copy->percent_complete = task->percent_complete;
   task_copy->completed_time   = task->completed_time;
+  task_copy->priority         = task->priority;
 }
 
 static void
@@ -893,6 +907,7 @@ calendar_task_init (CalendarTask        
   task->due_time         = get_ical_due_time (ical, default_zone);
   task->percent_complete = get_ical_percent_complete (ical);
   task->completed_time   = get_ical_completed_time (ical, default_zone);
+  task->priority         = get_ical_priority (ical);
 }
 
 void
Index: calendar-client.h
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/calendar-client.h,v
retrieving revision 1.4
diff -p -u -r1.4 calendar-client.h
--- calendar-client.h	19 Jul 2004 19:11:14 -0000	1.4
+++ calendar-client.h	19 May 2005 22:09:14 -0000
@@ -95,6 +95,7 @@ typedef struct
   GTime  due_time;
   guint  percent_complete;
   GTime  completed_time;
+  int    priority;
 } CalendarTask;
 
 typedef struct
Index: clock.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.c,v
retrieving revision 1.165
diff -p -u -r1.165 clock.c
--- clock.c	26 Feb 2005 14:41:48 -0000	1.165
+++ clock.c	19 May 2005 22:09:14 -0000
@@ -546,6 +546,7 @@ enum {
         TASK_COLUMN_OVERDUE_ATTR,
         TASK_COLUMN_COLOR,
         TASK_COLUMN_URL,
+        TASK_COLUMN_PRIORITY,
         N_TASK_COLUMNS
 };
 
@@ -626,6 +627,7 @@ handle_tasks_changed (ClockData *cd)
                                     TASK_COLUMN_COMPLETED_TIME,        task->completed_time,
                                     TASK_COLUMN_COLOR,                 task->color_string,
                                     TASK_COLUMN_URL,                   task->url,
+                                    TASK_COLUMN_PRIORITY,              task->priority,
                                     -1);
 
                 g_free (percent_complete_text);
@@ -873,6 +875,33 @@ appointment_pixbuf_cell_data_func (GtkTr
                                              APPOINTMENT_COLUMN_COLOR);
 }
 
+static int
+compare_priority  (GtkTreeModel *model,
+                   GtkTreeIter  *a,
+                   GtkTreeIter  *b,
+                   gpointer      user_data)
+{
+        int priority_a;
+        int priority_b;
+
+        gtk_tree_model_get (model, a, TASK_COLUMN_PRIORITY, &priority_a, -1);
+        gtk_tree_model_get (model, b, TASK_COLUMN_PRIORITY, &priority_b, -1);
+
+	/* We change undefined priorities so they appear after 'Low'. */
+	if (priority_a <= 0)
+		priority_a = 10;
+	if (priority_b <= 0)
+		priority_b = 10;
+
+	/* We'll just use the ordering of the priority values. */
+	if (priority_a < priority_b)
+		return -1;
+	else if (priority_a > priority_b)
+		return 1;
+	else
+		return 0;
+}
+
 static GtkWidget *
 create_task_list (ClockData  *cd,
                   GtkWidget **tree_view,
@@ -908,11 +937,21 @@ create_task_list (ClockData  *cd,
                         G_TYPE_LONG,           /* completed time          */
                         PANGO_TYPE_ATTR_LIST,  /* summary text attributes */
                         G_TYPE_STRING,         /* color                   */
-                        G_TYPE_STRING          /* url                     */
+                        G_TYPE_STRING,         /* url                     */
+                        G_TYPE_INT             /* priority                */
                 };
 
                 cd->tasks_model = gtk_list_store_newv (N_TASK_COLUMNS, column_types);
 
+                gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (cd->tasks_model),
+                                                 TASK_COLUMN_PRIORITY,
+                                                 compare_priority,
+                                                 NULL, NULL);
+
+                gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (cd->tasks_model),
+                                                      TASK_COLUMN_PRIORITY,
+                                                      GTK_SORT_ASCENDING);
+
                 cd->tasks_filter = GTK_TREE_MODEL_FILTER (
                         gtk_tree_model_filter_new (GTK_TREE_MODEL (cd->tasks_model),
                                                    NULL));
@@ -929,8 +968,6 @@ create_task_list (ClockData  *cd,
                          cd,
                          NULL);
         }
-
-        /* FIXME: implement sorting */
 
         *tree_view = view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (cd->tasks_filter));
         gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE);
