Commit 3c7c0daf authored by Kurt Maute's avatar Kurt Maute

Add %Complete column to task view.


svn path=/trunk/; revision=889
parent 9541f4e6
2008-02-27 Kurt Maute <kurt@maute.us>
* src/planner-task-tree.c
* src/planner-gantt-model.c
* src/planner-gantt-model.h
* src/planner-task-view.c:
Patch to add % complete column to task view. Original patch by Robert
Mibus, enhanced by me to allow edit of the % complete column in task
view. Bug # 379975
2008-02-15 Maurice van der Pot <griffon26@kfk4ever.com>
* src/planner-task-tree.c: (planner_task_tree_indent_task),
......
......@@ -652,6 +652,8 @@ gantt_model_get_column_type (GtkTreeModel *tree_model,
return MRP_TYPE_TASK;
case COL_COST:
return G_TYPE_LONG;
case COL_COMPLETE:
return G_TYPE_INT;
default:
return G_TYPE_INVALID;
}
......@@ -890,6 +892,12 @@ gantt_model_get_value (GtkTreeModel *tree_model,
break;
case COL_COMPLETE:
g_value_init (value, G_TYPE_INT);
g_value_set_int (value, mrp_task_get_percent_complete (task));
break;
default:
g_warning ("Bad column %d requested", column);
}
......
......@@ -60,6 +60,7 @@ enum {
COL_TASK,
COL_COST,
COL_ASSIGNED_TO,
COL_COMPLETE,
NUM_COLS
};
......
......@@ -126,6 +126,11 @@ static void task_tree_cost_data_func (GtkTreeViewColumn *tr
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data);
static void task_tree_complete_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data);
static void task_tree_assigned_to_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
......@@ -1533,6 +1538,31 @@ task_tree_cost_data_func (GtkTreeViewColumn *tree_column,
g_free (str);
}
static void
task_tree_complete_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
GtkTreeModel *tree_model,
GtkTreeIter *iter,
gpointer data)
{
gchar *str;
gint complete;
gtk_tree_model_get (tree_model,
iter,
COL_COMPLETE, &complete,
-1);
str = planner_format_int (complete);
g_object_set (cell,
"text", str,
NULL);
g_free (str);
}
static void
task_tree_assigned_to_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
......@@ -1710,6 +1740,46 @@ task_tree_name_edited (GtkCellRendererText *cell,
gtk_tree_path_free (path);
}
static void
task_tree_complete_edited (GtkCellRendererText *cell,
gchar *path_string,
gchar *new_text,
gpointer data)
{
PlannerTaskTree *tree = data;
GtkTreeView *view = data;
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeIter iter;
MrpTask *task;
GValue value = { 0 };
gint complete;
model = gtk_tree_view_get_model (view);
path = gtk_tree_path_new_from_string (path_string);
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter,
COL_TASK, &task,
-1);
complete = atoi(new_text);
if (mrp_task_get_percent_complete (MRP_TASK (task)) != complete) {
g_value_init (&value, G_TYPE_INT);
g_value_set_int (&value, complete);
task_cmd_edit_property (tree->priv->main_window,
PLANNER_TASK_TREE (view),
task,
"percent_complete",
&value);
g_value_unset (&value);
}
gtk_tree_path_free (path);
}
static void
task_tree_start_edited (GtkCellRendererText *cell,
gchar *path_string,
......@@ -2444,6 +2514,32 @@ task_tree_add_column (PlannerTaskTree *tree,
g_object_set_data (G_OBJECT (col), "id", "cost");
break;
case COL_COMPLETE:
cell = gtk_cell_renderer_text_new ();
g_object_set (cell, "editable", TRUE, NULL);
col = gtk_tree_view_column_new_with_attributes (title,
cell,
NULL);
gtk_tree_view_column_set_resizable (col, TRUE);
gtk_tree_view_column_set_min_width (col, 70);
gtk_tree_view_column_set_cell_data_func (col,
cell,
task_tree_complete_data_func,
GTK_TREE_VIEW (tree),
NULL);
g_object_set_data (G_OBJECT (col),
"data-func", task_tree_complete_data_func);
g_object_set_data (G_OBJECT (col), "id", "complete");
g_signal_connect (cell,
"edited",
G_CALLBACK (task_tree_complete_edited),
GTK_TREE_VIEW (tree));
break;
case COL_ASSIGNED_TO:
cell = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes (title,
......
......@@ -341,6 +341,7 @@ task_view_get_widget (PlannerView *view)
COL_SLACK, _("Slack"),
COL_COST, _("Cost"),
COL_ASSIGNED_TO, _("Assigned to"),
COL_COMPLETE, _("% Complete"),
-1);
g_object_unref (model);
......@@ -814,6 +815,7 @@ task_view_load_columns (PlannerView *view)
strcmp (id, "duration") == 0 ||
strcmp (id, "slack") == 0 ||
strcmp (id, "cost") == 0 ||
strcmp (id, "complete") == 0 ||
strcmp (id, "assigned-to")) {
gtk_tree_view_column_set_visible (column, TRUE);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment