[Planner Dev] Planner enhancement ** Link button patch against 0.11 CVS.



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


My first attempt at any GNOME coding - a cut+past job if
ever there was !. I'm using Cervisia to manage CVS and
do the diff but never used it before in anger so please
feedback if using it wrong. Also whats the copyright
release procedure  for Planner ?

The following patch adds a Link button to the menus and
GUI.

If you ctrl-click tasks in Task or Gantt view and then
click the Link button it puts a FS link between these.
Multiple items cause it to cascade links as it walks
through the task list.

I want to add shift-click and ctrl-click to modify the
MRP_RELATION_XX behaviour but don't know anything
about GNOME gui stuff to trap this message type.

Any hints on how I check for shift-click or crtl-click
would be helpful. But this works as it stands anyway.

Rgds,
Lincoln.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFAKP24Vo/F3CLIt9cRAg2+AJ4pmzVVTaChGq8DbbzzC8iHoJ0wfwCfXrly
5LMVe6KMXuaDUT3k2jTdRkM=
=2bBH
-----END PGP SIGNATURE-----

PNG image

? planner0.11.link.lcjp.diff
? planner0.11.link.lcjp2.diff
? data/images/.xvpics
? 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 -r1.2 Makefile.am
--- data/images/Makefile.am	23 Jan 2004 00:48:19 -0000	1.2
+++ data/images/Makefile.am	10 Feb 2004 15:43:48 -0000
@@ -10,6 +10,7 @@
 	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 -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	10 Feb 2004 15:43:48 -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 -r1.2 task-view.ui
--- data/ui/task-view.ui	16 Dec 2003 15:50:21 -0000	1.2
+++ data/ui/task-view.ui	10 Feb 2004 15:43:49 -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 -r1.4 planner-application.c
--- src/planner-application.c	11 Dec 2003 10:52:46 -0000	1.4
+++ src/planner-application.c	10 Feb 2004 15:43:49 -0000
@@ -71,6 +71,13 @@
 		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-model.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-gantt-model.c,v
retrieving revision 1.2
diff -u -r1.2 planner-gantt-model.c
--- src/planner-gantt-model.c	11 Dec 2003 10:52:46 -0000	1.2
+++ src/planner-gantt-model.c	10 Feb 2004 15:43:50 -0000
@@ -105,7 +105,7 @@
 		type = g_type_register_static (G_TYPE_OBJECT,
 					       "PlannerGanttModel",
 					       &info, 0);
-		
+
 		g_type_add_interface_static (type,
 					     GTK_TYPE_TREE_MODEL,
 					     &tree_model_info);
@@ -333,7 +333,7 @@
 gantt_model_unlink_subtree_cb (GNode *node, gpointer data)
 {
 	g_node_unlink (node);
-	
+
 	return FALSE;
 }
 
Index: src/planner-gantt-view.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-gantt-view.c,v
retrieving revision 1.5
diff -u -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	10 Feb 2004 15:43:51 -0000
@@ -80,6 +80,9 @@
 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 @@
 	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 @@
 			      "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);
@@ -642,8 +653,8 @@
 }
 
 static void
-gantt_view_unlink_task_cb (BonoboUIComponent *component, 
-			   gpointer           data, 
+gantt_view_unlink_task_cb (BonoboUIComponent *component,
+			   gpointer           data,
 			   const char        *cname)
 {
 	PlannerView *view;
@@ -654,6 +665,18 @@
 }
 
 static void
+gantt_view_link_tasks_cb (BonoboUIComponent *component,
+			   gpointer           data,
+			   const char        *cname)
+{
+	PlannerView *view;
+
+	view = PLANNER_VIEW (data);
+//TODO: need to get the shift-control-button/menu options to tweak the link relationships between the tasks
+	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,15 +952,17 @@
 	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));
-	
+
 	if (!view->activated) {
 		return;
 	}
-	
+
 	priv = view->priv;
-	
+
 	list = planner_task_tree_get_selected_tasks (PLANNER_TASK_TREE (priv->tree));
 
 	for (l = list; l; l = l->next) {
@@ -946,33 +971,43 @@
 			break;
 		}
 	}
-	
+
+
+	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);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/EditTask",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/RemoveTask",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	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, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/IndentTask",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/UnindentTask",
 				      "sensitive", value, 
 				      NULL);
Index: src/planner-task-tree.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-task-tree.c,v
retrieving revision 1.9
diff -u -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	10 Feb 2004 15:43:54 -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_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 @@
 	POPUP_SUBTASK,
 	POPUP_REMOVE,
 	POPUP_UNLINK,
+	POPUP_LINK,
 	POPUP_EDIT
 };
 
@@ -200,6 +205,9 @@
 	{ 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 @@
 			      "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,12 +620,20 @@
 }
 
 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;
-	
+
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));
-	
+
 	g_signal_handlers_block_by_func (selection,
 					 task_tree_selection_changed_cb,
 					 tree);
@@ -751,6 +774,8 @@
 			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 @@
 			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);
 		}
 		
@@ -2036,7 +2063,7 @@
 	MrpRelation *relation;
 
 	/* FIXME: undo */
-	
+
 	list = planner_task_tree_get_selected_tasks (tree);
 	if (list == NULL) {
 		return;
@@ -2048,24 +2075,75 @@
 		relations = g_list_copy (mrp_task_get_predecessor_relations (task));
 		for (r = relations; r; r = r->next) {
 			relation = r->data;
-			
+
 			mrp_task_remove_predecessor (
 				task, mrp_relation_get_predecessor (relation));
 		}
 
 		g_list_free (relations);
-		
+
 		relations = g_list_copy (mrp_task_get_successor_relations (task));
 		for (r = relations; r; r = r->next) {
 			relation = r->data;
-			
+
 			mrp_task_remove_predecessor (
 				mrp_relation_get_successor (relation), task);
 		}
 
 		g_list_free (relations);
 	}
-	
+
+	g_list_free (list);
+}
+
+void
+planner_task_tree_link_tasks (PlannerTaskTree *tree, MrpRelationType relationship)
+{
+	MrpTask     *task;
+	MrpTask     *target_task;   // use same name as has been used before
+	GList       *list, *l;
+	//GList       *relations, *r;
+	//MrpRelation *relation;
+	gint        count_value = 0;  // used so that we only start linking once we have 2 or more tasks
+
+	/* FIXME: undo */
+
+	list = planner_task_tree_get_selected_tasks (tree);
+	if (list == NULL) {
+		return;
+	}
+	// Setup initial task item to fool make into not warning on premature use of task
+	l = list;
+	target_task = l->data;
+
+	for (l = list; l; l = l->next) {
+		if (count_value == 0) { target_task = l->data; }
+		if (count_value >= 1) {
+			task = target_task;  // remember the 0th item
+			target_task = l->data; //we now have two items - link them up !!
+			GError *error = NULL;
+				if (!mrp_task_add_predecessor (target_task,
+							       task,
+							       relationship,
+							       0,
+							       &error)) {
+					GtkWidget *dialog;
+
+				//	gnome_canvas_item_ungrab (item, event->button.time);
+
+					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.
+	}
 	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 -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	10 Feb 2004 15:43:54 -0000
@@ -66,6 +66,7 @@
 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 -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	10 Feb 2004 15:43:55 -0000
@@ -86,6 +86,9 @@
 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 @@
 	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),
@@ -371,8 +375,8 @@
 }
 
 static void
-task_view_unlink_task_cb (BonoboUIComponent *component, 
-			  gpointer           data, 
+task_view_unlink_task_cb (BonoboUIComponent *component,
+			  gpointer           data,
 			  const char        *cname)
 {
 	PlannerView *view;
@@ -383,6 +387,18 @@
 }
 
 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)
@@ -548,7 +564,7 @@
 	g_return_val_if_fail (PLANNER_IS_VIEW (view), 0);
 
 	g_assert (view->priv->print_sheet);
-	
+
 	return planner_table_print_sheet_get_n_pages (view->priv->print_sheet);
 }
 
@@ -559,7 +575,7 @@
 	g_return_if_fail (PLANNER_IS_VIEW (view));
 
 	g_assert (view->priv->print_sheet);
-	
+
 	planner_table_print_sheet_free (view->priv->print_sheet);
 	view->priv->print_sheet = NULL;
 }
@@ -571,11 +587,13 @@
 	GList      *list, *l;
 	gchar      *value;
 	gchar      *rel_value = "0";
-	
+	gchar	   *link_value = "0";
+	gint	    count_value = 0;
+
 	if (!view->activated) {
 		return;
 	}
-	
+
 	priv = view->priv;
 
 	list = planner_task_tree_get_selected_tasks (PLANNER_TASK_TREE (priv->tree));
@@ -587,48 +605,58 @@
 		}
 	}
 
+	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);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/EditTask",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/RemoveTask",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/UnlinkTask",
-				      "sensitive", rel_value, 
+				      "sensitive", rel_value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+      	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, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/UnindentTask",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/MoveTaskUp",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
-	
-	bonobo_ui_component_set_prop (view->ui_component, 
+
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/MoveTaskDown",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
-	bonobo_ui_component_set_prop (view->ui_component, 
+	bonobo_ui_component_set_prop (view->ui_component,
 				      "/commands/ResetConstraint",
-				      "sensitive", value, 
+				      "sensitive", value,
 				      NULL);
 
 	bonobo_ui_component_thaw (view->ui_component, NULL);
@@ -636,4 +664,4 @@
 	g_list_free (list);
 }
 
-	
+


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