[evolution-patches] Handle task: and date: uris from command line



This is evolution bug 

http://bugzilla.ximian.com/show_bug.cgi?id=70751

and gnome-panel bug 

http://bugzilla.gnome.org/show_bug.cgi?id=162305


In order to improve integration with gnome clock applet there should be
ability to open existing task properties dialog and open calendar control 
with the predefined date.

That is needed for implementing two features:

1. Doubleclick on clock date should open evolution calendar with the date
clicked

2. Double click on task row should open task properties.

To do this I think the easiest way is allow calendar and tasks component of
evolution handle "task:" and "date:" uris

So, the corresponding evolution:uri_schemas property should be added to
GNOME_Evolution_Calendar.server file and bonobo methods handleURI should be
implemented in calendar-control and tasks-control.

The patches to evolution and to gnome-panel are attached.
Index: calendar/gui/GNOME_Evolution_Calendar.server.in.in
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/GNOME_Evolution_Calendar.server.in.in,v
retrieving revision 1.15
diff -u -r1.15 GNOME_Evolution_Calendar.server.in.in
--- calendar/gui/GNOME_Evolution_Calendar.server.in.in	26 Aug 2004 16:16:53 -0000	1.15
+++ calendar/gui/GNOME_Evolution_Calendar.server.in.in	27 Dec 2004 08:56:57 -0000
@@ -48,6 +50,11 @@
 	<oaf_attribute name="evolution:button_label" type="string" _value="Calendars"/>
         <oaf_attribute name="evolution:button_icon" type="string" value="stock_calendar"/>
 	<oaf_attribute name="evolution:button_sort_order" type="string" value="-8"/>
+
+        <oaf_attribute name="evolution:uri_schemas" type="stringv">
+          <item value="date"/>
+        </oaf_attribute>
+
 </oaf_server>
 
 <oaf_server iid="OAFIID:GNOME_Evolution_Tasks_Component:@VERSION@"
@@ -67,6 +74,11 @@
 	<oaf_attribute name="evolution:button_label" type="string" _value="Tasks"/>
         <oaf_attribute name="evolution:button_icon" type="string" value="stock_todo"/>
 	<oaf_attribute name="evolution:button_sort_order" type="string" value="-8"/>
+
+        <oaf_attribute name="evolution:uri_schemas" type="stringv">
+          <item value="task"/>
+        </oaf_attribute>
+
 </oaf_server>
 
 <oaf_server iid="OAFIID:GNOME_Evolution_Calendar_CompEditorFactory:@VERSION@"
Index: calendar/gui/calendar-component.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-component.c,v
retrieving revision 1.192
diff -u -r1.192 calendar-component.c
--- calendar/gui/calendar-component.c	22 Dec 2004 07:37:25 -0000	1.192
+++ calendar/gui/calendar-component.c	27 Dec 2004 08:56:58 -0000
@@ -1303,6 +1306,45 @@
 		bonobo_exception_set (ev, ex_GNOME_Evolution_Component_Failed);
 }
 
+static void
+impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environment *ev)
+{
+	CalendarComponent *calendar_component = CALENDAR_COMPONENT (bonobo_object_from_servant (servant));
+	CalendarComponentView *component_view;
+	
+	GDate* uri_date;
+	struct icaltimetype tt = icaltime_null_time ();
+	time_t et;
+	GList *l;
+	
+	g_return_if_fail (calendar_component->priv);
+	g_return_if_fail (calendar_component->priv->views);
+	
+	for (l = calendar_component->priv->views; l->next != NULL; l = l->next);
+	
+	g_return_if_fail (l->data);
+	
+	component_view =  (CalendarComponentView *)(l->data);
+	
+	if (!strncmp (uri, "date:", strlen ("date:"))) {
+
+	        uri_date = g_date_new ();
+		g_date_set_parse (uri_date, uri + strlen ("date:"));
+		
+		if (g_date_valid (uri_date)) {
+
+			tt.year = g_date_year (uri_date);
+			tt.month = g_date_month (uri_date);
+			tt.day = g_date_day (uri_date);
+			et = icaltime_as_timet_with_zone (tt, gnome_calendar_get_timezone (component_view->calendar));
+	
+			gnome_calendar_goto (component_view->calendar, et);
+		}
+
+		g_date_free (uri_date);
+	} 
+}
+
 /* GObject methods.  */
 
 static void
@@ -1375,6 +1417,7 @@
 	epv->createControls          = impl_createControls;
 	epv->_get_userCreatableItems = impl__get_userCreatableItems;
 	epv->requestCreateItem       = impl_requestCreateItem;
+	epv->handleURI               = impl_handleURI;
 
 	object_class->dispose  = impl_dispose;
 	object_class->finalize = impl_finalize;
Index: calendar/gui/comp-util.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/comp-util.c,v
retrieving revision 1.26
diff -u -r1.26 comp-util.c
--- calendar/gui/comp-util.c	16 Jul 2004 14:30:49 -0000	1.26
+++ calendar/gui/comp-util.c	27 Dec 2004 08:56:58 -0000
@@ -368,12 +368,5 @@
 		return NULL;
 	}
 
-	comp = e_cal_component_new ();
-	if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
-		g_object_unref (comp);
-		icalcomponent_free (icalcomp);
-		return NULL;
-	}
-
 	return comp;
 }
Index: calendar/gui/tasks-component.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/tasks-component.c,v
retrieving revision 1.82
diff -u -r1.82 tasks-component.c
--- calendar/gui/tasks-component.c	22 Dec 2004 07:37:25 -0000	1.82
+++ calendar/gui/tasks-component.c	27 Dec 2004 08:56:58 -0000
@@ -1020,6 +1037,46 @@
 	*corba_statusbar_control = CORBA_Object_duplicate (BONOBO_OBJREF (component_view->statusbar_control), ev);
 }
 
+static void
+impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environment *ev)
+{
+	TasksComponent *task_component = TASKS_COMPONENT (bonobo_object_from_servant (servant));
+
+    	ECal *ecal;
+	icalcomponent *icalcomp;
+	ECalComponent *comp;
+	TaskEditor *editor;
+	
+
+	if (!strncmp (uri, "task:", strlen("task:"))) {
+
+		ecal = setup_create_ecal (task_component, NULL);
+		if (!ecal) return;
+
+		editor = task_editor_new (ecal);
+                
+		comp = e_cal_component_new ();
+		e_cal_get_object (ecal, uri + strlen("task:"), NULL, &icalcomp, NULL);
+		
+		if (icalcomp == NULL) {
+			g_object_unref (comp);
+			return;
+		}
+
+		if (!e_cal_component_set_icalcomponent (comp, icalcomp)) {
+			g_object_unref (comp);
+			icalcomponent_free (icalcomp);
+			return;
+		}
+
+		comp_editor_edit_comp (COMP_EDITOR (editor), comp);
+		comp_editor_focus (COMP_EDITOR (editor));
+		e_comp_editor_registry_add (comp_editor_registry, COMP_EDITOR (editor), TRUE);
+	} 
+
+	return;
+}
+
 static GNOME_Evolution_CreatableItemTypeList *
 impl__get_userCreatableItems (PortableServer_Servant servant,
 			      CORBA_Environment *ev)
@@ -1154,6 +1211,7 @@
 	epv->createControls          = impl_createControls;
 	epv->_get_userCreatableItems = impl__get_userCreatableItems;
 	epv->requestCreateItem       = impl_requestCreateItem;
+	epv->handleURI               = impl_handleURI;
 
 	object_class->dispose = impl_dispose;
 	object_class->finalize = impl_finalize;
Index: shell/main.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/main.c,v
retrieving revision 1.164
diff -u -r1.164 main.c
--- shell/main.c	8 Dec 2004 01:58:27 -0000	1.164
+++ shell/main.c	27 Dec 2004 08:56:58 -0000
@@ -388,15 +377,13 @@
 		open_uris (corba_shell, uri_list);
 	} else {
 		CORBA_Environment ev;
-
 		CORBA_exception_init (&ev);
+
+		if (default_component_id != NULL)
+			GNOME_Evolution_Shell_createNewWindow (corba_shell, default_component_id, &ev);
+
 		if (uri_list != NULL)
 			open_uris (corba_shell, uri_list);
-		else
-			if (default_component_id == NULL)
-				GNOME_Evolution_Shell_createNewWindow (corba_shell, "", &ev);
-			else
-				GNOME_Evolution_Shell_createNewWindow (corba_shell, default_component_id, &ev);
 
 		CORBA_exception_free (&ev);
 	}
Index: applets/clock/calendar-client.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/calendar-client.c,v
retrieving revision 1.10
diff -u -r1.10 calendar-client.c
--- applets/clock/calendar-client.c	31 Aug 2004 08:18:34 -0000	1.10
+++ applets/clock/calendar-client.c	27 Dec 2004 09:07:15 -0000
@@ -529,18 +529,6 @@
   return g_strdup (icalproperty_get_description (prop));
 }
 
-static char *
-get_ical_url (icalcomponent *ical)
-{
-  icalproperty *prop;
-
-  prop = icalcomponent_get_first_property (ical, ICAL_URL_PROPERTY);
-  if (!prop)
-    return NULL;
-
-  return g_strdup (icalproperty_get_url (prop));
-}
-
 static inline GTime
 get_ical_start_time (icalcomponent *ical,
                      icaltimezone  *default_zone)
@@ -832,7 +820,6 @@
     null_safe_strcmp (a->summary,      b->summary)      == 0 &&
     null_safe_strcmp (a->description,  b->description)  == 0 &&
     null_safe_strcmp (a->color_string, b->color_string) == 0 &&
-    null_safe_strcmp (a->url,          b->url)          == 0 &&
     a->start_time       == b->start_time                   &&
     a->due_time         == b->due_time                     &&
     a->percent_complete == b->percent_complete             &&
@@ -850,7 +837,6 @@
   task_copy->summary          = g_strdup (task->summary);
   task_copy->description      = g_strdup (task->description);
   task_copy->color_string     = g_strdup (task->color_string);
-  task_copy->url              = g_strdup (task->url);
   task_copy->start_time       = task->start_time;
   task_copy->due_time         = task->due_time;
   task_copy->percent_complete = task->percent_complete;
@@ -872,9 +858,6 @@
   g_free (task->color_string);
   task->color_string = NULL;
 
-  g_free (task->url);
-  task->url = NULL;
-
   task->percent_complete = 0;
 }
 
@@ -888,7 +871,6 @@
   task->summary          = get_ical_summary (ical);
   task->description      = get_ical_description (ical);
   task->color_string     = get_source_color (source->source);
-  task->url              = get_ical_url (ical);
   task->start_time       = get_ical_start_time (ical, default_zone);
   task->due_time         = get_ical_due_time (ical, default_zone);
   task->percent_complete = get_ical_percent_complete (ical);
@@ -1980,25 +1962,3 @@
   e_cal_modify_object (esource, ical, CALOBJ_MOD_ALL, NULL);
 }
 
-gboolean
-calendar_client_launch_editor (CalendarClient     *client,
-			       CalendarEventType   event_type,
-			       GdkScreen          *screen,
-			       GError            **error)
-{
-  char     *command_line;
-  gboolean  retval;
-
-  g_return_val_if_fail (CALENDAR_IS_CLIENT (client), FALSE);
-  g_return_val_if_fail (event_type == CALENDAR_EVENT_APPOINTMENT ||
-			event_type == CALENDAR_EVENT_TASK, FALSE);
-
-  command_line = g_strdup_printf ("evolution -c %s",
-				  event_type == CALENDAR_EVENT_APPOINTMENT ? "calendar" : "tasks");
-
-  retval = gdk_spawn_command_line_on_screen (screen, command_line, error);
-
-  g_free (command_line);
-
-  return retval;
-}
Index: applets/clock/calendar-client.h
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/calendar-client.h,v
retrieving revision 1.4
diff -u -r1.4 calendar-client.h
--- applets/clock/calendar-client.h	19 Jul 2004 19:11:14 -0000	1.4
+++ applets/clock/calendar-client.h	27 Dec 2004 09:07:15 -0000
@@ -27,7 +27,6 @@
 #define __CALENDAR_CLIENT_H__
 
 #include <glib-object.h>
-#include <gdk/gdk.h>
 
 G_BEGIN_DECLS
 
@@ -90,7 +89,6 @@
   char  *summary;
   char  *description;
   char  *color_string;
-  char  *url;
   GTime  start_time;
   GTime  due_time;
   guint  percent_complete;
@@ -139,10 +137,6 @@
 							  char               *task_uid,
 							  gboolean            task_completed,
 							  guint               percent_complete);
-gboolean        calendar_client_launch_editor            (CalendarClient     *client,
-							  CalendarEventType   event_type,
-							  GdkScreen          *screen,
-							  GError            **error);
 
 void calendar_event_free (CalendarEvent *event);
 
Index: applets/clock/clock.c
===================================================================
RCS file: /cvs/gnome/gnome-panel/applets/clock/clock.c,v
retrieving revision 1.161
diff -u -r1.161 clock.c
--- applets/clock/clock.c	28 Nov 2004 15:37:51 -0000	1.161
+++ applets/clock/clock.c	27 Dec 2004 09:07:16 -0000
@@ -58,7 +58,6 @@
 #include <gconf/gconf-client.h>
 #include <libgnomeui/gnome-help.h>
 #include <libgnome/gnome-init.h>
-#include <libgnomeui/gnome-url.h>
 
 #ifdef HAVE_LIBECAL
 #include "calendar-client.h"
@@ -548,7 +547,6 @@
         TASK_COLUMN_COMPLETED_TIME,
         TASK_COLUMN_OVERDUE_ATTR,
         TASK_COLUMN_COLOR,
-        TASK_COLUMN_URL,
         N_TASK_COLUMNS
 };
 
@@ -628,7 +626,6 @@
                                     TASK_COLUMN_COMPLETED,             task->percent_complete == 100,
                                     TASK_COLUMN_COMPLETED_TIME,        task->completed_time,
                                     TASK_COLUMN_COLOR,                 task->color_string,
-                                    TASK_COLUMN_URL,                   task->url,
                                     -1);
 
                 g_free (percent_complete_text);
@@ -810,16 +807,19 @@
                    ClockData         *cd)
 {
         GtkTreeIter iter;
-        char       *uri;
+	gchar       *command_line;
+	gchar       *uid;
 
         gtk_tree_model_get_iter (GTK_TREE_MODEL (cd->tasks_model), &iter, path);
         gtk_tree_model_get (GTK_TREE_MODEL (cd->tasks_model), &iter,
-                            TASK_COLUMN_URL, &uri, -1);
+                            TASK_COLUMN_UID, &uid, -1);
 
-        if (uri)
-                gnome_url_show_on_screen (uri,
-					  gtk_widget_get_screen (cd->applet),
-					  NULL);
+	command_line = g_strdup_printf ("evolution task:%s", uid);
+
+	gdk_spawn_command_line_on_screen (gtk_widget_get_screen (cd->calendar), command_line, NULL);
+
+	g_free (command_line);
+	g_free (uid);
 
         return TRUE;
 }
@@ -911,7 +911,6 @@
                         G_TYPE_LONG,           /* completed time          */
                         PANGO_TYPE_ATTR_LIST,  /* summary text attributes */
                         G_TYPE_STRING,         /* color                   */
-                        G_TYPE_STRING          /* url                     */
                 };
 
                 cd->tasks_model = gtk_list_store_newv (N_TASK_COLUMNS, column_types);
@@ -1137,14 +1136,23 @@
 
 static void
 calendar_day_activated (ClockData *cd)
-{
-        /* FIXME: should be able to launch the editor for
-         *        the specific day
-         */
-        calendar_client_launch_editor (cd->client,
-                                       CALENDAR_EVENT_APPOINTMENT,
-                                       gtk_widget_get_screen (cd->calendar),
-                                       NULL);
+{  
+   guint day; 
+   guint year;
+   guint month;
+   
+   GDate *date;
+   gchar command_line[40];
+      
+   gtk_calendar_get_date (GTK_CALENDAR(cd->calendar), &year, &month, &day);
+   date = g_date_new ();
+   g_date_set_dmy (date, day, month, year);
+
+   g_date_strftime (command_line, sizeof (command_line), "evolution -c calendar date:%x", date);
+   gdk_spawn_command_line_on_screen (gtk_widget_get_screen (cd->calendar), command_line, NULL);
+   g_date_free (date);
+   
+   return;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]