[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

	Hi, I've worked out how to create diff files.

Attached is the new patch file with the recommended
diff -ubBp options.

Whats the peer review process to get this added to
repository ?.

Cervisia is busted for me as its got the cvs diff hardcoded
to just the -u (I looked at its source code and CervisiaPart::slotMakePatch() has
cmdline += " diff -uR 2>/dev/null";
Cervisia is a great tool as a GUI but I'll raise a enhancement
report for its patch options and use the command line as you
mentioned until its fixed.


Anyway.. if here are my notes that I wrote for any new
developers...

cd planner
cvs diff -ubBp 1>../thenameofchangeset.diff 2>/dev/null

What those do are...
-u = unified patch format
-b and -B means ignore various whitspace
-p means include function name in changes (makes
easier to read)

For the next person to apply this against a clean
source (without these changes applied yet) they use,

cd planner
patch -p0 -u <../thenameofchangeset.diff

WARNING: the location of the diff file is
important and should be one directory up from
where you run the patch command else you will
get every hunk failing on you even though it
looks right.

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	11 Feb 2004 20:40:21 -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	11 Feb 2004 20:40:21 -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	11 Feb 2004 20:40:21 -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	11 Feb 2004 20:40:22 -0000
@@ -71,6 +71,13 @@ static GtkStockItem stock_items[] = {
 		0, /*keyval*/
 		GETTEXT_PACKAGE
 	},
+		{
+		"planner-stock-link-tasks",
+		N_("Link"),
+		0, /*GdkModifierType*/
+		0, /*keyval*/
+		GETTEXT_PACKAGE
+	},
 	{
 		"planner-stock-indent-task",
 		N_("Indent"),
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	11 Feb 2004 20:40:23 -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 = count_value + (count_value + 1);
+	}
+
 	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	11 Feb 2004 20:40:26 -0000
@@ -36,6 +36,7 @@
 #include <gtk/gtkstock.h>
 #include <gtk/gtkmessagedialog.h>
 #include <libgnome/gnome-i18n.h>
+#include <libgnomecanvas/gnome-canvas.h>
 #include "planner-format.h"
 #include "planner-marshal.h"
 #include "planner-cell-renderer-date.h"
@@ -143,6 +144,9 @@ static void        task_tree_popup_edit_
 static void        task_tree_popup_unlink_task_cb      (gpointer              callback_data,
 							guint                 action,
 							GtkWidget            *widget);
+static void        task_tree_popup_link_tasks_cb      (gpointer              callback_data,
+							guint                 action,
+							GtkWidget            *widget);
 static void        task_tree_block_selection_changed   (PlannerTaskTree      *tree);
 static void        task_tree_unblock_selection_changed (PlannerTaskTree      *tree);
 static void        task_tree_selection_changed_cb      (GtkTreeSelection     *selection,
@@ -179,6 +183,7 @@ enum {
 	POPUP_SUBTASK,
 	POPUP_REMOVE,
 	POPUP_UNLINK,
+	POPUP_LINK,
 	POPUP_EDIT
 };
 
@@ -200,6 +205,9 @@ static GtkItemFactoryEntry popup_menu_it
 	{ N_("/_Unlink task"),       NULL, GIF_CB (task_tree_popup_unlink_task_cb),
 	  POPUP_UNLINK,  "<Item>",   NULL
 	},
+	{ N_("/_Link tasks"),       NULL, GIF_CB (task_tree_popup_link_tasks_cb),
+	  POPUP_LINK,  "<Item>",   NULL
+	},
 	{ "/sep2",                   NULL, 0,
 	  POPUP_NONE,    "<Separator>"
 	},
@@ -517,6 +525,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);
@@ -605,6 +620,14 @@ task_tree_popup_unlink_task_cb (gpointer
 }
 
 static void
+task_tree_popup_link_tasks_cb (gpointer   callback_data,
+				guint      action,
+				GtkWidget *widget)
+{
+	planner_task_tree_link_tasks (callback_data, MRP_RELATION_FS);
+}
+
+static void
 task_tree_block_selection_changed (PlannerTaskTree *tree)
 {
 	GtkTreeSelection *selection;
@@ -751,6 +774,8 @@ task_tree_tree_view_button_press_event (
 			gtk_widget_set_sensitive (
 				gtk_item_factory_get_widget_by_action (factory, POPUP_UNLINK), TRUE);
 			gtk_widget_set_sensitive (
+				gtk_item_factory_get_widget_by_action (factory, POPUP_LINK), TRUE);
+			gtk_widget_set_sensitive (
 				gtk_item_factory_get_widget_by_action (factory, POPUP_EDIT), TRUE);
 			
 			gtk_tree_path_free (path);
@@ -764,6 +789,8 @@ task_tree_tree_view_button_press_event (
 			gtk_widget_set_sensitive (
 				gtk_item_factory_get_widget_by_action (factory, POPUP_UNLINK), FALSE);
 			gtk_widget_set_sensitive (
+				gtk_item_factory_get_widget_by_action (factory, POPUP_LINK), FALSE);
+			gtk_widget_set_sensitive (
 				gtk_item_factory_get_widget_by_action (factory, POPUP_EDIT), FALSE);
 		}
 		
@@ -2066,6 +2093,57 @@ planner_task_tree_unlink_task (PlannerTa
 		g_list_free (relations);
 	}
 	
+	g_list_free (list);
+}
+
+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;
+	}
+	/* The next step is simply to fool make (gcc) into not warning on premature use of task
+	*  Without assigning target_task to something gcc complains that it may be used before
+	*  it was assigned a value. Ergo assign it to something. Its because the if() logic in
+	* the for() loop is what upsets the compiler warning.
+	*/
+	l = list;
+	target_task = l->data;
+
+	for (l = list; l; l = l->next) {
+		if (count_value == 0) {
+			target_task = l->data; /* this is the 1st item. We can't link tasks yet */
+		}
+		if (count_value >= 1) {
+			task = target_task;  /* remember the previous item */
+			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 = count_value + 1; /* Step on the count of items. This is only used to detect 0,1 many */
+	}
 	g_list_free (list);
 }
 
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	11 Feb 2004 20:40:26 -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	11 Feb 2004 20:40:26 -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 = count_value + 1;
+	}
+
 	value = (list != NULL) ? "1" : "0";
+	link_value = (count_value >= 2) ? "1" : "0";
 
 	bonobo_ui_component_freeze (view->ui_component, NULL);
 
@@ -604,6 +627,11 @@ task_view_update_ui (PlannerView *view)
 	bonobo_ui_component_set_prop (view->ui_component, 
 				      "/commands/UnlinkTask",
 				      "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, 

PNG image



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