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.



ons 2004-02-11 klockan 22.23 skrev lincoln phipps openmutual net:
> Richard
> 
> 	Hi, I've worked out how to create diff files.
> 
> Attached is the new patch file with the recommended
> diff -ubBp options.

Thanks!

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

Usually one of the planner "regulars" read through the patch and
comments for a few rounds, until it's ready to go into CVS.

The patch looks great, I have just a few tiny comments, it would be nice
if you could take a look at them and send a new patch. I can commit it
to CVS for you.

Thanks again,
Richard


> 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);
> +	}

This looks wrong, I think you mean 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	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>

This shouldn't be necessary.

>  #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;

This could be done a bit more straightforward, something like:

target_task = list->data;
for (l = list-next; l = l->next) {

and remove the count_value check.

> +	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, 
> 
> ______________________________________________________________________
> _______________________________________________
> Planner-dev mailing list
> Planner-dev lists imendio com
> http://lists.imendio.com/mailman/listinfo/planner-dev




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