[Planner Dev] Giving some live to the Resource Usage View. Patch included.
- From: Alvaro del Castillo <acs barrapunto com>
- To: Planner-Dev <planner-dev lists imendio com>
- Subject: [Planner Dev] Giving some live to the Resource Usage View. Patch included.
- Date: Mon, 03 Apr 2006 21:03:31 +0200
Hi guys!
I am using Planner in my daily work and I have found some problems so I
feel it is time to return to hacking in Planner a bit at least for
solving some of these issues.
The first one is the alignment between the TreeView and the Gantt chart
in the Gannt view and in Resource View. fmoraes has a patch working for
the Gantt view as you can read in bugzilla:
http://bugzilla.gnome.org/show_bug.cgi?id=128983
but it needs some work in order to do it correctly as Richard point out.
I have asked Francisco to solve the alignment also in the resource usage
view so we will remove the problem for the two views.
Other problem I have is that more and more I work with the resource
usage view in order to optimice how you assign people to tasks. As we
don't have a mature algorithm in order to do resource levelling right
now the manager has to play a bit with this view to solve the assignment
issues (over and sub assignments resources). Currently the canvas graph
hasn't any interactivity in contrast to the Gantt canvas graph. I have
started to add some interactivity. With the patch in this email you can:
- Select a task in the usage resource graph and the task will be
selected in the Tree View (very useful now that the alignment between
canvas and tree isn't ok).
- Right click on a task to have the task edit dialog.
I have attached the patch to this email. It has some corrections on code
style for resource usage code also. As always I have tried to follow
existing code as much as possible, mainly from the Gantt canvas view.
Any testing will be very welcomed. To test it as usual:
1. Check out current CVS
2. Save the patch in the planner CVS directory.
3. Patch the planner code:
sid delito:~/devel/planner$ patch -p0 < resource-usage-canvas.patch
patching file src/planner-usage-chart.c
patching file src/planner-usage-chart.h
patching file src/planner-usage-model.c
patching file src/planner-usage-model.h
patching file src/planner-usage-row.c
patching file src/planner-usage-tree.h
patching file src/planner-usage-view.c
4. Compile and install the patched version:
sid delito:~/devel/planner$ ./autogen.sh
Now type `make' to compile Planner
sid delito:~/devel/planner$ make
...
delito:/home/sid/devel/planner# make install
5. Test the patch:
Launch the installed patched Planner:
sid delito:~$ /usr/local/bin/planner
Create two resources, a task and assign the two new resources to the new
task.
Then go to the Resource usage View and left click over the task in the
Canvas graph. The task you have clicked should be selected in the Tree
View.
Then go to the Resource usage View and right click over the task in the
Canvas graph. The task editor should be opened for the the task you have
clicked.
If Kurt and Richard find the patch useful and in good shape I will
commit it to the CVS.
Cheers
-- Alvaro
Index: src/planner-usage-chart.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-usage-chart.c,v
retrieving revision 1.1
diff -r1.1 planner-usage-chart.c
76,77c76,77
< GtkWidget *header;
< GnomeCanvas *canvas;
---
> GtkWidget *header;
> GnomeCanvas *canvas;
79,80c79,80
< GtkAdjustment *hadjustment;
< GtkAdjustment *vadjustment;
---
> GtkAdjustment *hadjustment;
> GtkAdjustment *vadjustment;
82,95c82,96
< GtkTreeModel *model;
< TreeNode *tree;
<
< GnomeCanvasItem *background;
< gdouble zoom;
< gint row_height;
< gdouble height;
<
< mrptime project_start;
< mrptime last_time;
<
< gboolean height_changed;
< guint reflow_idle_id;
< GList *signal_ids;
---
> GtkTreeModel *model;
> TreeNode *tree;
> PlannerUsageTree *view;
>
> GnomeCanvasItem *background;
> gdouble zoom;
> gint row_height;
> gdouble height;
>
> mrptime project_start;
> mrptime last_time;
>
> gboolean height_changed;
> guint reflow_idle_id;
> GList *signal_ids;
111,112c112,113
< static void usage_chart_class_init (PlannerUsageChartClass *klass);
< static void usage_chart_init (PlannerUsageChart *chart);
---
> static void usage_chart_class_init (PlannerUsageChartClass *klass);
> static void usage_chart_init (PlannerUsageChart *chart);
115,117c116,118
< guint prop_id,
< const GValue *value,
< GParamSpec *spec);
---
> guint prop_id,
> const GValue *value,
> GParamSpec *spec);
119,123c120,124
< guint prop_id,
< GValue *value,
< GParamSpec *spec);
< static void usage_chart_set_zoom (PlannerUsageChart *chart,
< gdouble level);
---
> guint prop_id,
> GValue *value,
> GParamSpec *spec);
> static void usage_chart_set_zoom (PlannerUsageChart *chart,
> gdouble level);
126c127
< GtkStyle *prev_style);
---
> GtkStyle *prev_style);
131,142c132,143
< GtkAllocation *allocation);
< static void usage_chart_set_adjustments (PlannerUsageChart *chart,
< GtkAdjustment *hadj,
< GtkAdjustment *vadj);
< static void usage_chart_reflow_now (PlannerUsageChart *chart);
< static void usage_chart_reflow (PlannerUsageChart *chart,
< gboolean height_changed);
< static gdouble usage_chart_reflow_do (PlannerUsageChart *chart,
< TreeNode *root,
< gdouble start_y);
< static gboolean usage_chart_reflow_idle (PlannerUsageChart *chart);
< static gint usage_chart_get_width (PlannerUsageChart *chart);
---
> GtkAllocation *allocation);
> static void usage_chart_set_adjustments (PlannerUsageChart *chart,
> GtkAdjustment *hadj,
> GtkAdjustment *vadj);
> static void usage_chart_reflow_now (PlannerUsageChart *chart);
> static void usage_chart_reflow (PlannerUsageChart *chart,
> gboolean height_changed);
> static gdouble usage_chart_reflow_do (PlannerUsageChart *chart,
> TreeNode *root,
> gdouble start_y);
> static gboolean usage_chart_reflow_idle (PlannerUsageChart *chart);
> static gint usage_chart_get_width (PlannerUsageChart *chart);
145,146c146,147
< static void usage_chart_remove_children (PlannerUsageChart *chart,
< TreeNode *node);
---
> static void usage_chart_remove_children (PlannerUsageChart *chart,
> TreeNode *node);
148,167c149,168
< TreeFunc func,
< gpointer data);
< static void scale_func (TreeNode *node,
< gpointer data);
< static void usage_chart_set_scroll_region (PlannerUsageChart *chart,
< gdouble x1,
< gdouble y1,
< gdouble x2,
< gdouble y2);
< static void usage_chart_build_tree (PlannerUsageChart *chart);
< static TreeNode *usage_chart_insert_resource (PlannerUsageChart *chart,
< GtkTreePath *path,
< MrpResource *resource);
< static TreeNode *usage_chart_insert_assignment (PlannerUsageChart *chart,
< GtkTreePath *path,
< MrpAssignment *assign);
< static TreeNode *usage_chart_insert_row (PlannerUsageChart *chart,
< GtkTreePath *path,
< MrpResource *resource,
< MrpAssignment *assign);
---
> TreeFunc func,
> gpointer data);
> static void scale_func (TreeNode *node,
> gpointer data);
> static void usage_chart_set_scroll_region (PlannerUsageChart *chart,
> gdouble x1,
> gdouble y1,
> gdouble x2,
> gdouble y2);
> static void usage_chart_build_tree (PlannerUsageChart *chart);
> static TreeNode *usage_chart_insert_resource (PlannerUsageChart *chart,
> GtkTreePath *path,
> MrpResource *resource);
> static TreeNode *usage_chart_insert_assignment (PlannerUsageChart *chart,
> GtkTreePath *path,
> MrpAssignment *assign);
> static TreeNode *usage_chart_insert_row (PlannerUsageChart *chart,
> GtkTreePath *path,
> MrpResource *resource,
> MrpAssignment *assign);
169,175c170,176
< GtkTreePath *path,
< TreeNode *new_node);
< static void usage_chart_add_signal (PlannerUsageChart *chart,
< gpointer instance,
< gulong sig_id,
< char *sig_name);
< static void usage_chart_disconnect_signals (PlannerUsageChart *chart);
---
> GtkTreePath *path,
> TreeNode *new_node);
> static void usage_chart_add_signal (PlannerUsageChart *chart,
> gpointer instance,
> gulong sig_id,
> char *sig_name);
> static void usage_chart_disconnect_signals (PlannerUsageChart *chart);
177,178c178,179
< GParamSpec *spec,
< PlannerUsageChart *chart);
---
> GParamSpec *spec,
> PlannerUsageChart *chart);
180,184c181,185
< GParamSpec *spec,
< PlannerUsageChart *chart);
< static void show_hide_descendants (TreeNode *node,
< gboolean show);
< static void collapse_descendants (TreeNode *node);
---
> GParamSpec *spec,
> PlannerUsageChart *chart);
> static void show_hide_descendants (TreeNode *node,
> gboolean show);
> static void collapse_descendants (TreeNode *node);
186c187
< GtkTreePath *path);
---
> GtkTreePath *path);
188,190c189,191
< GtkTreePath *path,
< GtkTreeIter *iter,
< gpointer data);
---
> GtkTreePath *path,
> GtkTreeIter *iter,
> gpointer data);
192,194c193,195
< GtkTreePath *path,
< GtkTreeIter *iter,
< gpointer data);
---
> GtkTreePath *path,
> GtkTreeIter *iter,
> gpointer data);
196,197c197,198
< GtkTreePath *path,
< gpointer data);
---
> GtkTreePath *path,
> gpointer data);
464c465
< gchar *message)
---
> gchar *message)
1047a1049,1057
> GtkTreeModel *
> planner_usage_chart_get_model (PlannerUsageChart *chart)
> {
> g_return_val_if_fail (PLANNER_IS_USAGE_CHART (chart), NULL);
>
> return chart->priv->model;
> }
>
>
1534a1545,1560
> PlannerUsageTree *
> planner_usage_chart_get_view (PlannerUsageChart *chart)
> {
> g_return_val_if_fail (PLANNER_IS_USAGE_CHART (chart), NULL);
>
> return chart->priv->view;
> }
>
> void
> planner_usage_chart_set_view (PlannerUsageChart *chart,
> PlannerUsageTree *view)
> {
> g_return_if_fail (PLANNER_IS_USAGE_TREE (view));
>
> chart->priv->view = view;
> }
Index: src/planner-usage-chart.h
===================================================================
RCS file: /cvs/gnome/planner/src/planner-usage-chart.h,v
retrieving revision 1.1
diff -r1.1 planner-usage-chart.h
29a30
> #include "planner-usage-tree.h"
38c39
< typedef struct _PlannerUsageChart PlannerUsageChart;
---
> typedef struct _PlannerUsageChart PlannerUsageChart;
40c41
< typedef struct _PlannerUsageChartPriv PlannerUsageChartPriv;
---
> typedef struct _PlannerUsageChartPriv PlannerUsageChartPriv;
43c44
< GtkVBox parent_class;
---
> GtkVBox parent_class;
57c58
< GtkWidget * planner_usage_chart_new_with_model (GtkTreeModel *model);
---
> GtkWidget * planner_usage_chart_new_with_model (GtkTreeModel *model);
60c61,65
< GtkTreeModel *model);
---
> GtkTreeModel *model);
> PlannerUsageTree *
> planner_usage_chart_get_view (PlannerUsageChart *chart);
> void planner_usage_chart_set_view (PlannerUsageChart *chart,
> PlannerUsageTree *view);
62c67
< GtkTreePath *path);
---
> GtkTreePath *path);
64c69
< GtkTreePath *path);
---
> GtkTreePath *path);
70,71c75,76
< gboolean *in,
< gboolean *out);
---
> gboolean *in,
> gboolean *out);
75c80
< gchar *message);
---
> gchar *message);
77c82
< void planner_usage_chart_setup_root_task (PlannerUsageChart *chart);
---
> void planner_usage_chart_setup_root_task (PlannerUsageChart *chart);
Index: src/planner-usage-model.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-usage-model.c,v
retrieving revision 1.1
diff -r1.1 planner-usage-model.c
130d129
<
206c205
< return NUM_COLS;
---
> return USAGE_NUM_COLS;
319c318
<
---
>
320a320,323
>
> return usage_model_get_path_from_node (PLANNER_USAGE_MODEL (model),
> node);
> }
321a325,335
> GtkTreePath *
> planner_usage_model_get_path_from_assignment (PlannerUsageModel *model,
> MrpAssignment *assignment)
> {
> GNode *node;
>
> g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
> g_return_val_if_fail (MRP_IS_ASSIGNMENT (assignment), NULL);
>
> node = g_hash_table_lookup (model->priv->assign2node, assignment);
>
323c337
< node);
---
> node);
Index: src/planner-usage-model.h
===================================================================
RCS file: /cvs/gnome/planner/src/planner-usage-model.h,v
retrieving revision 1.1
diff -r1.1 planner-usage-model.h
56c56
< NUM_COLS
---
> USAGE_NUM_COLS
60c60
< PlannerUsageModel *planner_usage_model_new (MrpProject *project);
---
> PlannerUsageModel *planner_usage_model_new (MrpProject *project);
62c62,65
< MrpResource *resource);
---
> MrpResource *resource);
> GtkTreePath * planner_usage_model_get_path_from_assignment
> (PlannerUsageModel *model,
> MrpAssignment *assignment);
65c68
< GtkTreeIter *iter);
---
> GtkTreeIter *iter);
67c70
< GtkTreeIter *iter);
---
> GtkTreeIter *iter);
69c72
< GtkTreeIter *iter);
---
> GtkTreeIter *iter);
71c74
< GtkTreeIter *iter);
---
> GtkTreeIter *iter);
73c76
< GtkTreePath *path);
---
> GtkTreePath *path);
75c78
< GtkTreePath *path);
---
> GtkTreePath *path);
77c80
< GtkTreePath *path);
---
> GtkTreePath *path);
79c82
< GtkTreePath *Path);
---
> GtkTreePath *Path);
Index: src/planner-usage-row.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-usage-row.c,v
retrieving revision 1.1
diff -r1.1 planner-usage-row.c
41a42,44
> #include "planner-usage-chart.h"
> #include "planner-usage-model.h"
> #include "planner-task-tree.h"
91a95
> /* acs: in Usage Gantt rows are tasks */
93a98
> MrpTask *task;
146a152,153
> static gboolean usage_row_event (GnomeCanvasItem *item,
> GdkEvent *event);
227a235,236
> item_class->event = usage_row_event;
>
600a610,615
> if (priv->task != NULL) {
> g_object_unref (priv->task);
> }
>
> priv->task = g_object_ref (task);
>
623c638
<
---
>
1559a1575,1637
> }
>
> static gboolean
> usage_row_event (GnomeCanvasItem *item, GdkEvent *event)
> {
> PlannerUsageRow *row;
> PlannerUsageRowPriv *priv;
> PlannerUsageChart *chart;
> GtkTreePath *path;
> GtkTreeSelection *selection;
> PlannerUsageTree *tree;
> GtkTreeView *tree_view;
> GtkTreeIter iter;
> GtkWidget *canvas_widget;
>
> row = PLANNER_USAGE_ROW (item);
> priv = row->priv;
> canvas_widget = GTK_WIDGET (item->canvas);
>
> switch (event->type) {
> case GDK_BUTTON_PRESS:
> if (priv->assignment == NULL) {
> break;
> }
> chart = g_object_get_data (G_OBJECT (item->canvas), "chart");
> tree = planner_usage_chart_get_view (chart);
> path = planner_usage_model_get_path_from_assignment
> (PLANNER_USAGE_MODEL (planner_usage_chart_get_model (chart)),
> priv->assignment);
>
> tree_view = GTK_TREE_VIEW (tree);
>
> selection = gtk_tree_view_get_selection (tree_view);
>
> gtk_tree_model_get_iter (gtk_tree_view_get_model (tree_view),
> &iter, path);
>
> if (!gtk_tree_selection_iter_is_selected (selection, &iter)) {
> gtk_tree_selection_unselect_all (selection);
> gtk_tree_selection_select_path (selection, path);
> }
>
> if (event->button.button == 3) {
> planner_usage_tree_edit_task (tree);
> }
> break;
>
> case GDK_2BUTTON_PRESS:
> if (event->button.button == 3) {
> g_print ("Second mouse button pressed\n");
> }
>
> default:
> break;
> }
>
>
>
> if (TRUE) {
> return TRUE;
> }
>
> return FALSE;
Index: src/planner-usage-tree.h
===================================================================
RCS file: /cvs/gnome/planner/src/planner-usage-tree.h,v
retrieving revision 1.1
diff -r1.1 planner-usage-tree.h
29a30
> #include "planner-task-dialog.h"
52,61c53,61
< GtkWidget *planner_usage_tree_new (PlannerWindow *window,
< PlannerUsageModel *model);
< void planner_usage_tree_set_model (PlannerUsageTree *tree,
< PlannerUsageModel *model);
< void planner_usage_tree_edit_task (PlannerUsageTree *tree);
< void planner_usage_tree_edit_resource (PlannerUsageTree *tree);
< GList * planner_usage_tree_get_selected_items (PlannerUsageTree *tree);
< void planner_usage_tree_expand_all (PlannerUsageTree *tree);
< void planner_usage_tree_collapse_all (PlannerUsageTree *tree);
<
---
> GtkWidget *planner_usage_tree_new (PlannerWindow *window,
> PlannerUsageModel *model);
> void planner_usage_tree_set_model (PlannerUsageTree *tree,
> PlannerUsageModel *model);
> void planner_usage_tree_edit_task (PlannerUsageTree *tree);
> void planner_usage_tree_edit_resource (PlannerUsageTree *tree);
> GList * planner_usage_tree_get_selected_items (PlannerUsageTree *tree);
> void planner_usage_tree_expand_all (PlannerUsageTree *tree);
> void planner_usage_tree_collapse_all (PlannerUsageTree *tree);
Index: src/planner-usage-view.c
===================================================================
RCS file: /cvs/gnome/planner/src/planner-usage-view.c,v
retrieving revision 1.4
diff -r1.4 planner-usage-view.c
407a408,411
>
> planner_usage_chart_set_view (PLANNER_USAGE_CHART (priv->chart),
> PLANNER_USAGE_TREE (priv->tree));
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]