Re: [Planner Dev] Worked out how to create diff files OK now - attached is the Link task button feature patch and notes on using cvs diff.




Richard,
	ah, thats why we do code reviews !.

Attached is new diff against CVS. Note that I have removed
the right-mouse on task option as it doesn't apply to linking
tasks because the focus is reset to just the one task even if
you had shift-selected a few tasks.

Also in testing I've noticed a performance issue. Its not
my code because all I do is call up the existing routine
to add the link and the performance issue is also noticed
from the task edit dialog too.

Bug number 134273 raised http://bugzilla.gnome.org/show_bug.cgi?id=134273

Looks deep inside how mrp-task.c, mrp-task-manager.c
and mrp-relation.c  all talk to each other. My link
button makes it easier to reproduce because the link
button makes it easy to add links !.

Rgds,
Lincoln.
? data/images/24_link_tasks.png
? dotnet/Makefile
? dotnet/Makefile.in
? dotnet/libplanner/Makefile
? dotnet/libplanner/Makefile.in
? dotnet/samples/Makefile
? dotnet/samples/Makefile.in
Index: data/images/Makefile.am
===================================================================
RCS file: /cvs/gnome/planner/data/images/Makefile.am,v
retrieving revision 1.2
diff -u -b -B -p -r1.2 Makefile.am
--- data/images/Makefile.am	23 Jan 2004 00:48:19 -0000	1.2
+++ data/images/Makefile.am	12 Feb 2004 22:50:20 -0000
@@ -10,6 +10,7 @@ images_DATA = \
 	24_insert_task.png		\
 	24_remove_task.png		\
 	24_unlink_task.png		\
+	24_link_tasks.png		\
 	24_indent_task.png		\
 	24_unindent_task.png		\
 	24_insert_resource.png		\
Index: data/ui/gantt-view.ui
===================================================================
RCS file: /cvs/gnome/planner/data/ui/gantt-view.ui,v
retrieving revision 1.1.1.1
diff -u -b -B -p -r1.1.1.1 gantt-view.ui
--- data/ui/gantt-view.ui	1 Dec 2003 17:36:55 -0000	1.1.1.1
+++ data/ui/gantt-view.ui	12 Feb 2004 22:50:20 -0000
@@ -4,7 +4,8 @@
     <cmd name="RemoveTask"          _label="_Remove Task"             pixtype="stock" pixname="planner-stock-remove-task" sensitive="0"/>
     <cmd name="InsertTasks"         _label="In_sert Tasks..."         pixtype="stock" pixname="planner-stock-insert-task"/>
     <cmd name="EditTask"            _label="_Edit Task Properties..." sensitive="0"/>
-    <cmd name="UnlinkTask"          _label="Un_link Task"              pixtype="stock" pixname="planner-stock-unlink-task"/>
+    <cmd name="UnlinkTask"          _label="_Unlink Task"              pixtype="stock" pixname="planner-stock-unlink-task"/>
+    <cmd name="LinkTasks"          _label="_Link Tasks"              pixtype="stock" pixname="planner-stock-link-tasks"/>
     <cmd name="ResetConstraint"     _label="Reset _Constraint" sensitive="0"/>
     <cmd name="ResetAllConstraints" _label="Reset _All Constraints"/>
     <cmd name="SelectAll"           _label="Select _All"              _tip="Select all tasks"/>
@@ -44,6 +45,7 @@
         <menuitem name="InsertTasks"         verb=""/>
 	<menuitem name="RemoveTask"          verb=""/>
         <menuitem name="UnlinkTask"          verb=""/>
+	<menuitem name="LinkTasks"          verb=""/>
         <separator/>
         <menuitem name="IndentTask"          verb=""/>
         <menuitem name="UnindentTask"        verb=""/>
@@ -63,6 +65,7 @@
     <toolitem name="InsertTask"   verb="" _label="Insert"/>
     <toolitem name="RemoveTask"   verb="" _label="Remove"/>
     <toolitem name="UnlinkTask"   verb="" _label="Unlink"/>
+        <toolitem name="LinkTasks"   verb="" _label="Link"/>
     <toolitem name="IndentTask"   verb="" _label="Indent"/>
     <toolitem name="UnindentTask" verb="" _label="Unindent"/>
     <separator/>
Index: data/ui/task-view.ui
===================================================================
RCS file: /cvs/gnome/planner/data/ui/task-view.ui,v
retrieving revision 1.2
diff -u -b -B -p -r1.2 task-view.ui
--- data/ui/task-view.ui	16 Dec 2003 15:50:21 -0000	1.2
+++ data/ui/task-view.ui	12 Feb 2004 22:50:20 -0000
@@ -4,7 +4,8 @@
     <cmd name="InsertTasks"         _label="In_sert Tasks..."           pixtype="stock" pixname="planner-stock-insert-task"/>
     <cmd name="RemoveTask"          _label="_Remove Task"               pixtype="stock" pixname="planner-stock-remove-task"    sensitive="0"/>
     <cmd name="EditTask"            _label="_Edit Task Properties..."                                                     sensitive="0"/>
-    <cmd name="UnlinkTask"          _label="Un_link Task"               pixtype="stock" pixname="planner-stock-unlink-task"/>
+    <cmd name="UnlinkTask"          _label="_Unlink Task"               pixtype="stock" pixname="planner-stock-unlink-task"/>
+        <cmd name="LinkTasks"          _label="_Link Tasks"               pixtype="stock" pixname="planner-stock-link-tasks"/>
     <cmd name="SelectAll"           _label="Select _All"                 _tip="Select all tasks"/>
     <cmd name="ResetConstraint"     _label="Reset _Constraint"                                                            sensitive="0"/>
     <cmd name="ResetAllConstraints" _label="Reset _All Constraints"/>
@@ -37,6 +38,7 @@
         <menuitem name="InsertTasks"         verb=""/>
 	<menuitem name="RemoveTask"          verb=""/>
         <menuitem name="UnlinkTask"          verb=""/>
+	<menuitem name="LinkTasks"          verb=""/>
         <separator/>
         <menuitem name="IndentTask"          verb=""/>
         <menuitem name="UnindentTask"        verb=""/>
@@ -58,6 +60,7 @@
     <toolitem name="InsertTask"   verb="" _label="Insert"/>
     <toolitem name="RemoveTask"   verb="" _label="Remove"/>
     <toolitem name="UnlinkTask"   verb="" _label="Unlink"/>
+    <toolitem name="LinkTasks"   verb="" _label="Link"/>
     <toolitem name="IndentTask"   verb="" _label="Indent"/>
     <toolitem name="UnindentTask" verb="" _label="Unindent"/>
     <toolitem name="MoveTaskUp"	  verb="" _label="Move up"/>
Index: src/planner-application.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-application.c,v
retrieving revision 1.4
diff -u -b -B -p -r1.4 planner-application.c
--- src/planner-application.c	11 Dec 2003 10:52:46 -0000	1.4
+++ src/planner-application.c	12 Feb 2004 22:50:21 -0000
@@ -72,6 +72,13 @@ static GtkStockItem stock_items[] = {
 		GETTEXT_PACKAGE
 	},
 	{
+		"planner-stock-link-tasks",
+		N_("Link"),
+		0, /*GdkModifierType*/
+		0, /*keyval*/
+		GETTEXT_PACKAGE
+	},
+	{
 		"planner-stock-indent-task",
 		N_("Indent"),
 		0, /*GdkModifierType*/
Index: src/planner-gantt-view.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-gantt-view.c,v
retrieving revision 1.5
diff -u -b -B -p -r1.5 planner-gantt-view.c
--- src/planner-gantt-view.c	16 Dec 2003 22:07:08 -0000	1.5
+++ src/planner-gantt-view.c	12 Feb 2004 22:50:22 -0000
@@ -80,6 +80,9 @@ static void       gantt_view_select_all_
 static void       gantt_view_unlink_task_cb               (BonoboUIComponent            *component,
 							   gpointer                      data,
 							   const char                   *cname);
+static void       gantt_view_link_tasks_cb               (BonoboUIComponent            *component,
+							   gpointer                      data,
+							   const char                   *cname);
 static void       gantt_view_indent_task_cb               (BonoboUIComponent            *component,
 							   gpointer                      data,
 							   const char                   *cname);
@@ -156,6 +159,7 @@ static BonoboUIVerb verbs[] = {
 	BONOBO_UI_VERB ("EditTask",		gantt_view_edit_task_cb),
 	BONOBO_UI_VERB ("SelectAll",		gantt_view_select_all_cb),
 	BONOBO_UI_VERB ("UnlinkTask",		gantt_view_unlink_task_cb),
+	BONOBO_UI_VERB ("LinkTasks",		gantt_view_link_tasks_cb),
 	BONOBO_UI_VERB ("IndentTask",		gantt_view_indent_task_cb),
 	BONOBO_UI_VERB ("UnindentTask",		gantt_view_unindent_task_cb),
 	BONOBO_UI_VERB ("MoveTaskUp",           gantt_view_move_task_up_cb),
@@ -242,6 +246,13 @@ init (PlannerView *view, PlannerWindow *
 			      "planner-stock-unlink-task",
 			      icon_set);
 
+	pixbuf = gdk_pixbuf_new_from_file (IMAGEDIR "/24_link_tasks.png", NULL);
+	icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
+	g_object_unref (pixbuf);
+	gtk_icon_factory_add (icon_factory,
+			      "planner-stock-link-tasks",
+			      icon_set);
+
 	pixbuf = gdk_pixbuf_new_from_file (IMAGEDIR "/24_indent_task.png", NULL);
 	icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
 	g_object_unref (pixbuf);
@@ -654,6 +665,21 @@ gantt_view_unlink_task_cb (BonoboUICompo
 }
 
 static void
+gantt_view_link_tasks_cb (BonoboUIComponent *component,
+			   gpointer           data,
+			   const char        *cname)
+{
+	PlannerView *view;
+
+	view = PLANNER_VIEW (data);
+/* TODO: need to get a way of easily modifying the options to tweak the link relationships between the tasks
+*	from the most common option of FS i.e. finish to start. Maybe project-wide flag, maybe menu option
+*	or maybe click-modifiers i.e. Shift+click or Control+click.
+*/
+	planner_task_tree_link_tasks (PLANNER_TASK_TREE (view->priv->tree), MRP_RELATION_FS);
+}
+
+static void
 gantt_view_indent_task_cb (BonoboUIComponent *component, 
 			   gpointer           data, 
 			   const char        *cname)
@@ -929,6 +955,8 @@ gantt_view_update_ui (PlannerView *view)
 	GList      *list, *l;
 	gchar      *value;
 	gchar      *rel_value = "0";
+	gchar      *link_value = "0";
+	gint        count_value = 0;
 
 	g_return_if_fail (PLANNER_IS_VIEW (view));
 	
@@ -947,7 +975,13 @@ gantt_view_update_ui (PlannerView *view)
 		}
 	}
 	
+
+	for (l = list; l; l = l->next) {
+		count_value++;
+	}
+
 	value = (list != NULL) ? "1" : "0";
+	link_value = (count_value >= 2) ? "1" : "0";
 
 	bonobo_ui_component_freeze (view->ui_component, NULL);
 
@@ -966,6 +1000,10 @@ gantt_view_update_ui (PlannerView *view)
 				      "sensitive", rel_value,
 				      NULL);
 
+      	bonobo_ui_component_set_prop (view->ui_component, 
+				      "/commands/LinkTasks",
+				      "sensitive", link_value, 
+				      NULL);
 
 	bonobo_ui_component_set_prop (view->ui_component, 
 				      "/commands/IndentTask",
Index: src/planner-task-tree.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-tree.c,v
retrieving revision 1.9
diff -u -b -B -p -r1.9 planner-task-tree.c
--- src/planner-task-tree.c	25 Jan 2004 12:11:22 -0000	1.9
+++ src/planner-task-tree.c	12 Feb 2004 22:50:25 -0000
@@ -517,6 +517,13 @@ task_tree_init (PlannerTaskTree *tree)
 			      "planner-stock-unlink-task",
 			      icon_set);
 
+	pixbuf = gdk_pixbuf_new_from_file (IMAGEDIR "/24_link_tasks.png", NULL);
+	icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
+	g_object_unref (pixbuf);
+	gtk_icon_factory_add (icon_factory,
+			      "planner-stock-link-tasks",
+			      icon_set);
+
 	pixbuf = gdk_pixbuf_new_from_file (IMAGEDIR "/24_indent_task.png", NULL);
 	icon_set = gtk_icon_set_new_from_pixbuf (pixbuf);
 	g_object_unref (pixbuf);
@@ -2070,6 +2077,48 @@ planner_task_tree_unlink_task (PlannerTa
 }
 
 void
+planner_task_tree_link_tasks (PlannerTaskTree *tree, MrpRelationType relationship)
+{
+	MrpTask     *task;
+	MrpTask     *target_task;
+	GList       *list, *l;
+	gint        count_value = 0;
+
+	/* FIXME: undo */
+
+	list = planner_task_tree_get_selected_tasks (tree);
+	if (list == NULL) {
+		return;
+	}
+	target_task = list->data; /* this is the 1st Item but we won't link tasks until we have more */
+
+	for (l = list; l; l = l->next) {
+		if (count_value >= 1) {
+			task = target_task;  /* remember the previous task */
+			target_task = l->data; /* now have two items - link them up !! */
+			GError *error = NULL;
+				if (!mrp_task_add_predecessor (target_task,
+							       task,
+							       relationship,
+							       0,
+							       &error)) {
+					GtkWidget *dialog;
+					dialog = gtk_message_dialog_new (NULL,
+									 GTK_DIALOG_DESTROY_WITH_PARENT,
+									 GTK_MESSAGE_ERROR,
+									 GTK_BUTTONS_OK,
+									 "%s", error->message);
+					gtk_dialog_run (GTK_DIALOG (dialog));
+					gtk_widget_destroy (dialog);
+					g_error_free (error);
+				}
+		}
+	count_value++; /* Step on the count of items. This is used so that we detect 0,1 many */
+	}
+	g_list_free (list);
+}
+
+void
 planner_task_tree_indent_task (PlannerTaskTree *tree)
 {
 	PlannerGanttModel *model;
Index: src/planner-task-tree.h
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-tree.h,v
retrieving revision 1.3
diff -u -b -B -p -r1.3 planner-task-tree.h
--- src/planner-task-tree.h	16 Dec 2003 15:50:22 -0000	1.3
+++ src/planner-task-tree.h	12 Feb 2004 22:50:25 -0000
@@ -66,6 +66,7 @@ void       planner_task_tree_edit_task  
 void       planner_task_tree_insert_tasks           (PlannerTaskTree   *tree);
 void       planner_task_tree_select_all             (PlannerTaskTree   *tree);
 void       planner_task_tree_unlink_task            (PlannerTaskTree   *tree);
+void       planner_task_tree_link_tasks             (PlannerTaskTree   *tree, MrpRelationType relationship);
 void       planner_task_tree_indent_task            (PlannerTaskTree   *tree);
 void       planner_task_tree_unindent_task          (PlannerTaskTree   *tree);
 void       planner_task_tree_reset_constraint       (PlannerTaskTree   *tree);
Index: src/planner-task-view.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-view.c,v
retrieving revision 1.4
diff -u -b -B -p -r1.4 planner-task-view.c
--- src/planner-task-view.c	16 Dec 2003 22:07:08 -0000	1.4
+++ src/planner-task-view.c	12 Feb 2004 22:50:25 -0000
@@ -86,6 +86,9 @@ static void   task_view_select_all_cb   
 static void   task_view_unlink_task_cb           (BonoboUIComponent            *component,
 						  gpointer                      data,
 						  const char                   *cname);
+static void   task_view_link_tasks_cb           (BonoboUIComponent            *component,
+						  gpointer                      data,
+						  const char                   *cname);
 static void   task_view_indent_task_cb           (BonoboUIComponent            *component,
 						  gpointer                      data,
 						  const char                   *cname);
@@ -133,6 +136,7 @@ static BonoboUIVerb verbs[] = {
 	BONOBO_UI_VERB ("EditTask",		task_view_edit_task_cb),
 	BONOBO_UI_VERB ("SelectAll",		task_view_select_all_cb),
 	BONOBO_UI_VERB ("UnlinkTask",		task_view_unlink_task_cb),
+	BONOBO_UI_VERB ("LinkTasks",		task_view_link_tasks_cb),
 	BONOBO_UI_VERB ("IndentTask",		task_view_indent_task_cb),
 	BONOBO_UI_VERB ("UnindentTask",		task_view_unindent_task_cb),
 	BONOBO_UI_VERB ("MoveTaskUp",		task_view_move_task_up_cb),
@@ -383,6 +387,18 @@ task_view_unlink_task_cb (BonoboUICompon
 }
 
 static void
+task_view_link_tasks_cb (BonoboUIComponent *component,
+			  gpointer           data,
+			  const char        *cname)
+{
+	PlannerView *view;
+
+	view = PLANNER_VIEW (data);
+
+	planner_task_tree_link_tasks (PLANNER_TASK_TREE (view->priv->tree), MRP_RELATION_FS);
+}
+
+static void
 task_view_indent_task_cb (BonoboUIComponent *component, 
 			  gpointer           data, 
 			  const char        *cname)
@@ -571,6 +587,8 @@ task_view_update_ui (PlannerView *view)
 	GList      *list, *l;
 	gchar      *value;
 	gchar      *rel_value = "0";
+	gchar	   *link_value = "0";
+	gint	    count_value = 0;
 	
 	if (!view->activated) {
 		return;
@@ -587,7 +605,12 @@ task_view_update_ui (PlannerView *view)
 		}
 	}
 
+	for (l = list; l; l = l->next) {
+			count_value++;
+	}
+
 	value = (list != NULL) ? "1" : "0";
+	link_value = (count_value >= 2) ? "1" : "0";
 
 	bonobo_ui_component_freeze (view->ui_component, NULL);
 
@@ -607,6 +630,11 @@ task_view_update_ui (PlannerView *view)
 				      NULL);
 
 	bonobo_ui_component_set_prop (view->ui_component, 
+				      "/commands/LinkTasks",
+				      "sensitive", link_value, 
+				      NULL);
+
+	bonobo_ui_component_set_prop (view->ui_component, 
 				      "/commands/IndentTask",
 				      "sensitive", value, 
 				      NULL);

PNG image



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