[planner] Indentation fixes (spaces replaced with tabs)
- From: Maurice van der Pot <mvdpot src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [planner] Indentation fixes (spaces replaced with tabs)
- Date: Tue, 24 Nov 2009 20:04:14 +0000 (UTC)
commit c9ee812aed89973ca48e206cbb20f17a4268a7e5
Author: Maurice van der Pot <griffon26 kfk4ever com>
Date: Sat Nov 7 00:12:15 2009 +0100
Indentation fixes (spaces replaced with tabs)
src/planner-usage-chart.c | 1633 +++++++++++++++++++++++----------------------
src/planner-usage-model.c | 1110 +++++++++++++++---------------
2 files changed, 1372 insertions(+), 1371 deletions(-)
---
diff --git a/src/planner-usage-chart.c b/src/planner-usage-chart.c
index cd90403..8458c74 100644
--- a/src/planner-usage-chart.c
+++ b/src/planner-usage-chart.c
@@ -58,54 +58,54 @@ typedef struct _TreeNode TreeNode;
typedef void (*TreeFunc) (TreeNode *node, gpointer data);
struct _TreeNode {
- MrpResource *resource;
- MrpAssignment *assignment;
- GnomeCanvasItem *item;
- TreeNode *parent;
- TreeNode **children;
- guint num_children;
- guint expanded:1;
+ MrpResource *resource;
+ MrpAssignment *assignment;
+ GnomeCanvasItem *item;
+ TreeNode *parent;
+ TreeNode **children;
+ guint num_children;
+ guint expanded:1;
};
typedef struct {
- gulong id;
- gpointer instance;
+ gulong id;
+ gpointer instance;
} ConnectData;
struct _PlannerUsageChartPriv {
- GtkWidget *header;
- GnomeCanvas *canvas;
+ GtkWidget *header;
+ GnomeCanvas *canvas;
- GtkAdjustment *hadjustment;
- GtkAdjustment *vadjustment;
+ GtkAdjustment *hadjustment;
+ GtkAdjustment *vadjustment;
- GtkTreeModel *model;
- TreeNode *tree;
+ GtkTreeModel *model;
+ TreeNode *tree;
PlannerUsageTree *view;
- GnomeCanvasItem *background;
- gdouble zoom;
- gint row_height;
- gdouble height;
+ GnomeCanvasItem *background;
+ gdouble zoom;
+ gint row_height;
+ gdouble height;
- mrptime project_start;
- mrptime last_time;
+ mrptime project_start;
+ mrptime last_time;
- gboolean height_changed;
- guint reflow_idle_id;
- GList *signal_ids;
+ gboolean height_changed;
+ guint reflow_idle_id;
+ GList *signal_ids;
};
enum {
- PROP_0,
- PROP_HEADER_HEIGHT,
- PROP_ROW_HEIGHT,
- PROP_MODEL
+ PROP_0,
+ PROP_HEADER_HEIGHT,
+ PROP_ROW_HEIGHT,
+ PROP_MODEL
};
enum {
- STATUS_UPDATED,
- LAST_SIGNAL
+ STATUS_UPDATED,
+ LAST_SIGNAL
};
@@ -204,221 +204,221 @@ static GtkVBoxClass *parent_class = NULL;
GType
planner_usage_chart_get_type (void)
{
- static GType type = 0;
-
- if (!type) {
- static const GTypeInfo info = {
- sizeof (PlannerUsageChartClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) usage_chart_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (PlannerUsageChart),
- 0, /* n_preallocs */
- (GInstanceInitFunc) usage_chart_init
- };
- type = g_type_register_static (GTK_TYPE_VBOX,
- "PlannerUsageChart", &info,
- 0);
- }
- return type;
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (PlannerUsageChartClass),
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) usage_chart_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PlannerUsageChart),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) usage_chart_init
+ };
+ type = g_type_register_static (GTK_TYPE_VBOX,
+ "PlannerUsageChart", &info,
+ 0);
+ }
+ return type;
}
static void
usage_chart_class_init (PlannerUsageChartClass * class)
{
- GObjectClass *o_class;
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
- GtkContainerClass *container_class;
-
- parent_class = g_type_class_peek_parent (class);
-
- o_class = (GObjectClass *) class;
- object_class = (GtkObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
- container_class = (GtkContainerClass *) class;
-
- o_class->set_property = usage_chart_set_property;
- o_class->get_property = usage_chart_get_property;
- o_class->finalize = usage_chart_finalize;
-
- object_class->destroy = usage_chart_destroy;
-
- widget_class->style_set = usage_chart_style_set;
- widget_class->realize = usage_chart_realize;
- widget_class->map = usage_chart_map;
- widget_class->unrealize = usage_chart_unrealize;
- widget_class->size_allocate = usage_chart_size_allocate;
-
- class->set_scroll_adjustments = usage_chart_set_adjustments;
-
- widget_class->set_scroll_adjustments_signal =
- g_signal_new ("set_scroll_adjustments",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (PlannerUsageChartClass,
- set_scroll_adjustments), NULL,
- NULL, planner_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT,
- GTK_TYPE_ADJUSTMENT);
-
- signals[STATUS_UPDATED] =
- g_signal_new ("status_updated",
- G_TYPE_FROM_CLASS (class),
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- planner_marshal_VOID__POINTER,
- G_TYPE_NONE, 1, G_TYPE_POINTER);
- /* Properties. */
-
- g_object_class_install_property (o_class,
- PROP_MODEL,
- g_param_spec_object ("model",
- NULL,
- NULL,
- GTK_TYPE_TREE_MODEL,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (o_class,
- PROP_HEADER_HEIGHT,
- g_param_spec_int ("header-height",
- NULL,
- NULL,
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (o_class,
- PROP_ROW_HEIGHT,
- g_param_spec_int ("row-height",
- NULL,
- NULL,
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE));
+ GObjectClass *o_class;
+ GtkObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+ GtkContainerClass *container_class;
+
+ parent_class = g_type_class_peek_parent (class);
+
+ o_class = (GObjectClass *) class;
+ object_class = (GtkObjectClass *) class;
+ widget_class = (GtkWidgetClass *) class;
+ container_class = (GtkContainerClass *) class;
+
+ o_class->set_property = usage_chart_set_property;
+ o_class->get_property = usage_chart_get_property;
+ o_class->finalize = usage_chart_finalize;
+
+ object_class->destroy = usage_chart_destroy;
+
+ widget_class->style_set = usage_chart_style_set;
+ widget_class->realize = usage_chart_realize;
+ widget_class->map = usage_chart_map;
+ widget_class->unrealize = usage_chart_unrealize;
+ widget_class->size_allocate = usage_chart_size_allocate;
+
+ class->set_scroll_adjustments = usage_chart_set_adjustments;
+
+ widget_class->set_scroll_adjustments_signal =
+ g_signal_new ("set_scroll_adjustments",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PlannerUsageChartClass,
+ set_scroll_adjustments), NULL,
+ NULL, planner_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT,
+ GTK_TYPE_ADJUSTMENT);
+
+ signals[STATUS_UPDATED] =
+ g_signal_new ("status_updated",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ planner_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+ /* Properties. */
+
+ g_object_class_install_property (o_class,
+ PROP_MODEL,
+ g_param_spec_object ("model",
+ NULL,
+ NULL,
+ GTK_TYPE_TREE_MODEL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (o_class,
+ PROP_HEADER_HEIGHT,
+ g_param_spec_int ("header-height",
+ NULL,
+ NULL,
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (o_class,
+ PROP_ROW_HEIGHT,
+ g_param_spec_int ("row-height",
+ NULL,
+ NULL,
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
}
static void
usage_chart_init (PlannerUsageChart * chart)
{
- PlannerUsageChartPriv *priv;
+ PlannerUsageChartPriv *priv;
- gtk_widget_set_redraw_on_allocate (GTK_WIDGET (chart), FALSE);
+ gtk_widget_set_redraw_on_allocate (GTK_WIDGET (chart), FALSE);
- priv = g_new0 (PlannerUsageChartPriv, 1);
- chart->priv = priv;
+ priv = g_new0 (PlannerUsageChartPriv, 1);
+ chart->priv = priv;
- priv->tree = usage_chart_tree_node_new ();
+ priv->tree = usage_chart_tree_node_new ();
- priv->zoom = DEFAULT_ZOOM_LEVEL;
+ priv->zoom = DEFAULT_ZOOM_LEVEL;
- priv->height_changed = FALSE;
- priv->reflow_idle_id = 0;
+ priv->height_changed = FALSE;
+ priv->reflow_idle_id = 0;
- gtk_box_set_homogeneous (GTK_BOX (chart), FALSE);
- gtk_box_set_spacing (GTK_BOX (chart), 0);
+ gtk_box_set_homogeneous (GTK_BOX (chart), FALSE);
+ gtk_box_set_spacing (GTK_BOX (chart), 0);
- priv->header = g_object_new (PLANNER_TYPE_GANTT_HEADER,
- "scale", SCALE (priv->zoom),
- "zoom", priv->zoom, NULL);
+ priv->header = g_object_new (PLANNER_TYPE_GANTT_HEADER,
+ "scale", SCALE (priv->zoom),
+ "zoom", priv->zoom, NULL);
- gtk_box_pack_start (GTK_BOX (chart), GTK_WIDGET (priv->header), FALSE,
- TRUE,
- 0);
+ gtk_box_pack_start (GTK_BOX (chart), GTK_WIDGET (priv->header), FALSE,
+ TRUE,
+ 0);
- priv->canvas = GNOME_CANVAS (gnome_canvas_new ());
- priv->canvas->close_enough = 5;
- gnome_canvas_set_center_scroll_region (priv->canvas, FALSE);
+ priv->canvas = GNOME_CANVAS (gnome_canvas_new ());
+ priv->canvas->close_enough = 5;
+ gnome_canvas_set_center_scroll_region (priv->canvas, FALSE);
- /* Easiest way to get access to the chart from the canvas items. */
- g_object_set_data (G_OBJECT (priv->canvas), "chart", chart);
- gtk_box_pack_start (GTK_BOX (chart),
- GTK_WIDGET (priv->canvas), TRUE, TRUE, 0);
+ /* Easiest way to get access to the chart from the canvas items. */
+ g_object_set_data (G_OBJECT (priv->canvas), "chart", chart);
+ gtk_box_pack_start (GTK_BOX (chart),
+ GTK_WIDGET (priv->canvas), TRUE, TRUE, 0);
- priv->row_height = -1;
- priv->height = -1;
- priv->project_start = MRP_TIME_INVALID;
- priv->last_time = MRP_TIME_INVALID;
- priv->background =
- gnome_canvas_item_new (gnome_canvas_root (priv->canvas),
- PLANNER_TYPE_GANTT_BACKGROUND, "scale",
- SCALE (priv->zoom), "zoom", priv->zoom,
- NULL);
+ priv->row_height = -1;
+ priv->height = -1;
+ priv->project_start = MRP_TIME_INVALID;
+ priv->last_time = MRP_TIME_INVALID;
+ priv->background =
+ gnome_canvas_item_new (gnome_canvas_root (priv->canvas),
+ PLANNER_TYPE_GANTT_BACKGROUND, "scale",
+ SCALE (priv->zoom), "zoom", priv->zoom,
+ NULL);
}
static TreeNode *
usage_chart_tree_node_new (void)
{
- TreeNode *node;
- node = g_new0 (TreeNode, 1);
- node->expanded = TRUE;
- return node;
+ TreeNode *node;
+ node = g_new0 (TreeNode, 1);
+ node->expanded = TRUE;
+ return node;
}
static void
usage_chart_set_property (GObject * object,
- guint prop_id,
- const GValue * value, GParamSpec * spec)
+ guint prop_id,
+ const GValue * value, GParamSpec * spec)
{
- PlannerUsageChart *chart;
-
- chart = PLANNER_USAGE_CHART (object);
-
- switch (prop_id) {
- case PROP_MODEL:
- planner_usage_chart_set_model (chart,
- g_value_get_object (value));
- break;
- case PROP_HEADER_HEIGHT:
- g_object_set (chart->priv->header, "height",
- g_value_get_int (value), NULL);
- break;
- case PROP_ROW_HEIGHT:
- chart->priv->row_height = g_value_get_int (value);
- usage_chart_reflow (chart, TRUE);
- break;
- default:
- break;
- }
+ PlannerUsageChart *chart;
+
+ chart = PLANNER_USAGE_CHART (object);
+
+ switch (prop_id) {
+ case PROP_MODEL:
+ planner_usage_chart_set_model (chart,
+ g_value_get_object (value));
+ break;
+ case PROP_HEADER_HEIGHT:
+ g_object_set (chart->priv->header, "height",
+ g_value_get_int (value), NULL);
+ break;
+ case PROP_ROW_HEIGHT:
+ chart->priv->row_height = g_value_get_int (value);
+ usage_chart_reflow (chart, TRUE);
+ break;
+ default:
+ break;
+ }
}
static void
usage_chart_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * spec)
+ guint prop_id, GValue * value, GParamSpec * spec)
{
- PlannerUsageChart *chart;
-
- chart = PLANNER_USAGE_CHART (object);
-
- switch (prop_id) {
- case PROP_MODEL:
- g_value_set_object (value, G_OBJECT (chart->priv->model));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
- break;
- }
+ PlannerUsageChart *chart;
+
+ chart = PLANNER_USAGE_CHART (object);
+
+ switch (prop_id) {
+ case PROP_MODEL:
+ g_value_set_object (value, G_OBJECT (chart->priv->model));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
+ break;
+ }
}
static void
usage_chart_set_zoom (PlannerUsageChart * chart, gdouble level)
{
- PlannerUsageChartPriv *priv;
+ PlannerUsageChartPriv *priv;
- priv = chart->priv;
- priv->zoom = level;
+ priv = chart->priv;
+ priv->zoom = level;
- usage_chart_tree_traverse (priv->tree, scale_func, chart);
+ usage_chart_tree_traverse (priv->tree, scale_func, chart);
g_object_set (priv->header,
- "scale", SCALE (priv->zoom),
+ "scale", SCALE (priv->zoom),
"zoom", priv->zoom,
NULL);
gnome_canvas_item_set (GNOME_CANVAS_ITEM (priv->background),
- "scale", SCALE (priv->zoom),
- "zoom", priv->zoom,
+ "scale", SCALE (priv->zoom),
+ "zoom", priv->zoom,
NULL);
usage_chart_reflow_now (chart);
@@ -427,17 +427,17 @@ usage_chart_set_zoom (PlannerUsageChart * chart, gdouble level)
static mrptime
usage_chart_get_center (PlannerUsageChart * chart)
{
- PlannerUsageChartPriv *priv;
- gint x1, width, x;
+ PlannerUsageChartPriv *priv;
+ gint x1, width, x;
- priv = chart->priv;
+ priv = chart->priv;
- gnome_canvas_get_scroll_offsets (priv->canvas, &x1, NULL);
+ gnome_canvas_get_scroll_offsets (priv->canvas, &x1, NULL);
- width = GTK_WIDGET (priv->canvas)->allocation.width;
+ width = GTK_WIDGET (priv->canvas)->allocation.width;
x = x1 + width / 2 - PADDING;
- x += floor (priv->project_start * SCALE (priv->zoom) + 0.5);
+ x += floor (priv->project_start * SCALE (priv->zoom) + 0.5);
return floor (x / SCALE (priv->zoom) + 0.5);
}
@@ -445,228 +445,229 @@ usage_chart_get_center (PlannerUsageChart * chart)
static void
usage_chart_set_center (PlannerUsageChart *chart, mrptime t)
{
- PlannerUsageChartPriv *priv;
- gint x1, width, x;
+ PlannerUsageChartPriv *priv;
+ gint x1, width, x;
- priv = chart->priv;
+ priv = chart->priv;
- x = floor (t * SCALE (priv->zoom) + 0.5);
+ x = floor (t * SCALE (priv->zoom) + 0.5);
width = GTK_WIDGET (priv->canvas)->allocation.width;
- x1 = x - width / 2 + PADDING;
- x1 -= floor (priv->project_start * SCALE (priv->zoom) + 0.5);
+ x1 = x - width / 2 + PADDING;
+ x1 -= floor (priv->project_start * SCALE (priv->zoom) + 0.5);
gnome_canvas_scroll_to (priv->canvas, x1, 0);
}
void
planner_usage_chart_status_updated (PlannerUsageChart *chart,
- gchar *message)
+ gchar *message)
{
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
- g_signal_emit (chart, signals[STATUS_UPDATED], 0, message);
+ g_signal_emit (chart, signals[STATUS_UPDATED], 0, message);
}
void
planner_usage_chart_zoom_in (PlannerUsageChart *chart)
{
- PlannerUsageChartPriv *priv;
- mrptime mt;
+ PlannerUsageChartPriv *priv;
+ mrptime mt;
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
priv = chart->priv;
mt = usage_chart_get_center (chart);
- usage_chart_set_zoom (chart, priv->zoom + 1);
- usage_chart_set_center (chart, mt);
+ usage_chart_set_zoom (chart, priv->zoom + 1);
+ usage_chart_set_center (chart, mt);
}
void
planner_usage_chart_zoom_out (PlannerUsageChart *chart)
{
- PlannerUsageChartPriv *priv;
- mrptime mt;
+ PlannerUsageChartPriv *priv;
+ mrptime mt;
g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
priv = chart->priv;
mt = usage_chart_get_center (chart);
- usage_chart_set_zoom (chart, priv->zoom - 1);
- usage_chart_set_center (chart, mt);
+ usage_chart_set_zoom (chart, priv->zoom - 1);
+ usage_chart_set_center (chart, mt);
}
void
planner_usage_chart_can_zoom (PlannerUsageChart *chart,
- gboolean *in,
+ gboolean *in,
gboolean *out)
{
- PlannerUsageChartPriv *priv;
+ PlannerUsageChartPriv *priv;
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
priv = chart->priv;
- if (in) {
- *in = (priv->zoom < ZOOM_IN_LIMIT);
- }
- if (out) {
- *out = (priv->zoom > ZOOM_OUT_LIMIT);
- }
+ if (in) {
+ *in = (priv->zoom < ZOOM_IN_LIMIT);
+ }
+ if (out) {
+ *out = (priv->zoom > ZOOM_OUT_LIMIT);
+ }
}
void
planner_usage_chart_zoom_to_fit (PlannerUsageChart *chart)
{
- PlannerUsageChartPriv *priv;
- gdouble t;
- gdouble zoom;
- gdouble alloc;
+ PlannerUsageChartPriv *priv;
+ gdouble t;
+ gdouble zoom;
+ gdouble alloc;
g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
priv = chart->priv;
t = usage_chart_get_width (chart);
- if (t == -1) {
- return;
+ if (t == -1) {
+ return;
}
- alloc = GTK_WIDGET (chart)->allocation.width - PADDING * 2;
+ alloc = GTK_WIDGET (chart)->allocation.width - PADDING * 2;
- zoom = planner_scale_clamp_zoom (ZOOM (alloc / t));
- usage_chart_set_zoom (chart, zoom);
+ zoom = planner_scale_clamp_zoom (ZOOM (alloc / t));
+ usage_chart_set_zoom (chart, zoom);
}
gdouble
planner_usage_chart_get_zoom (PlannerUsageChart *chart)
{
- g_return_val_if_fail (PLANNER_IS_USAGE_CHART (chart), 0);
+ g_return_val_if_fail (PLANNER_IS_USAGE_CHART (chart), 0);
- return chart->priv->zoom;
+ return chart->priv->zoom;
}
static gint
usage_chart_get_width (PlannerUsageChart *chart)
{
if (chart->priv->project_start == MRP_TIME_INVALID ||
- chart->priv->last_time == MRP_TIME_INVALID) {
- return -1;
- }
+ chart->priv->last_time == MRP_TIME_INVALID) {
+ return -1;
+ }
- return chart->priv->last_time - chart->priv->project_start;
+ return chart->priv->last_time - chart->priv->project_start;
}
static void
usage_chart_finalize (GObject *object)
{
- PlannerUsageChart *chart;
+ PlannerUsageChart *chart;
- chart = PLANNER_USAGE_CHART (object);
+ chart = PLANNER_USAGE_CHART (object);
- g_free (chart->priv);
+ g_free (chart->priv);
- if (G_OBJECT_CLASS (parent_class)->finalize) {
- (*G_OBJECT_CLASS (parent_class)->finalize) (object);
- }
+ if (G_OBJECT_CLASS (parent_class)->finalize) {
+ (*G_OBJECT_CLASS (parent_class)->finalize) (object);
+ }
}
static void
usage_chart_destroy (GtkObject *object)
{
- PlannerUsageChart *chart;
+ PlannerUsageChart *chart;
- chart = PLANNER_USAGE_CHART (object);
+ chart = PLANNER_USAGE_CHART (object);
- if (chart->priv->model != NULL) {
- g_object_unref (chart->priv->model);
- chart->priv->model = NULL;
- }
+ if (chart->priv->model != NULL) {
+ g_object_unref (chart->priv->model);
+ chart->priv->model = NULL;
+ }
- if (GTK_OBJECT_CLASS (parent_class)->destroy) {
- (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
- }
+ if (GTK_OBJECT_CLASS (parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+ }
}
static void
usage_chart_style_set (GtkWidget *widget, GtkStyle *prev_style)
{
- PlannerUsageChart *chart;
- PlannerUsageChartPriv *priv;
- GtkWidget *canvas;
- PangoContext *context;
- PangoFontMetrics *metrics;
-
- if (GTK_WIDGET_CLASS (parent_class)->style_set) {
- GTK_WIDGET_CLASS (parent_class)->style_set (widget,
- prev_style);
- }
+ PlannerUsageChart *chart;
+ PlannerUsageChartPriv *priv;
+ GtkWidget *canvas;
+ PangoContext *context;
+ PangoFontMetrics *metrics;
+
+ if (GTK_WIDGET_CLASS (parent_class)->style_set) {
+ GTK_WIDGET_CLASS (parent_class)->style_set (widget,
+ prev_style);
+ }
- chart = PLANNER_USAGE_CHART (widget);
- priv = chart->priv;
+ chart = PLANNER_USAGE_CHART (widget);
+ priv = chart->priv;
- canvas = GTK_WIDGET (priv->canvas);
+ canvas = GTK_WIDGET (priv->canvas);
context = gtk_widget_get_pango_context (canvas);
- metrics = pango_context_get_metrics (context,
- canvas->style->font_desc, NULL);
- f = 0.2 * pango_font_metrics_get_approximate_char_width (metrics) /
- PANGO_SCALE;
+ metrics = pango_context_get_metrics (context,
+ canvas->style->font_desc, NULL);
+ f = 0.2 * pango_font_metrics_get_approximate_char_width (metrics) /
+ PANGO_SCALE;
+ pango_font_metrics_unref(metrics);
}
static void
usage_chart_realize (GtkWidget *widget)
{
- PlannerUsageChart *chart;
- PlannerUsageChartPriv *priv;
- GtkWidget *canvas;
- GtkStyle *style;
- GdkColormap *colormap;
+ PlannerUsageChart *chart;
+ PlannerUsageChartPriv *priv;
+ GtkWidget *canvas;
+ GtkStyle *style;
+ GdkColormap *colormap;
- chart = PLANNER_USAGE_CHART (widget);
- priv = chart->priv;
+ chart = PLANNER_USAGE_CHART (widget);
+ priv = chart->priv;
- canvas = GTK_WIDGET (priv->canvas);
+ canvas = GTK_WIDGET (priv->canvas);
if (GTK_WIDGET_CLASS (parent_class)->realize) {
- GTK_WIDGET_CLASS (parent_class)->realize (widget);
- }
+ GTK_WIDGET_CLASS (parent_class)->realize (widget);
+ }
/* Set the background to white. */
- style = gtk_style_copy (canvas->style);
- colormap = gtk_widget_get_colormap (canvas);
- gdk_color_white (colormap, &style->bg[GTK_STATE_NORMAL]);
- gtk_widget_set_style (canvas, style);
- gtk_style_unref (style);
+ style = gtk_style_copy (canvas->style);
+ colormap = gtk_widget_get_colormap (canvas);
+ gdk_color_white (colormap, &style->bg[GTK_STATE_NORMAL]);
+ gtk_widget_set_style (canvas, style);
+ gtk_style_unref (style);
- usage_chart_set_zoom (chart, priv->zoom);
+ usage_chart_set_zoom (chart, priv->zoom);
}
static void
usage_chart_unrealize (GtkWidget *widget)
{
- PlannerUsageChart *chart;
+ PlannerUsageChart *chart;
- chart = PLANNER_USAGE_CHART (widget);
+ chart = PLANNER_USAGE_CHART (widget);
if (GTK_WIDGET_CLASS (parent_class)->unrealize) {
- GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
- }
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
+ }
}
static void
usage_chart_map (GtkWidget * widget)
{
- PlannerUsageChart *chart;
+ PlannerUsageChart *chart;
- chart = PLANNER_USAGE_CHART (widget);
+ chart = PLANNER_USAGE_CHART (widget);
- if (GTK_WIDGET_CLASS (parent_class)->map) {
- GTK_WIDGET_CLASS (parent_class)->map (widget);
- }
+ if (GTK_WIDGET_CLASS (parent_class)->map) {
+ GTK_WIDGET_CLASS (parent_class)->map (widget);
+ }
/* FIXME: Workaround for problem when changing the project length from
* other views. Need to fix this for real.
@@ -674,185 +675,185 @@ usage_chart_map (GtkWidget * widget)
usage_chart_set_zoom (chart, chart->priv->zoom);
chart->priv->height_changed = TRUE;
- usage_chart_reflow_now (chart);
+ usage_chart_reflow_now (chart);
}
static void
usage_chart_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
PlannerUsageChart *chart;
- gboolean height_changed;
+ gboolean height_changed;
- height_changed = widget->allocation.height != allocation->height;
+ height_changed = widget->allocation.height != allocation->height;
- GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
+ GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
chart = PLANNER_USAGE_CHART (widget);
- if (GTK_WIDGET_MAPPED (chart)) {
- usage_chart_reflow_now (chart);
- }
+ if (GTK_WIDGET_MAPPED (chart)) {
+ usage_chart_reflow_now (chart);
+ }
}
static void
usage_chart_set_adjustments (PlannerUsageChart *chart,
- GtkAdjustment *hadj,
+ GtkAdjustment *hadj,
GtkAdjustment *vadj)
{
- PlannerUsageChartPriv *priv;
-
- gboolean need_adjust = FALSE;
-
- g_return_if_fail (hadj == NULL || GTK_IS_ADJUSTMENT (hadj));
- g_return_if_fail (vadj == NULL || GTK_IS_ADJUSTMENT (vadj));
-
- priv = chart->priv;
-
- if (hadj == NULL) {
- hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
- }
- if (vadj == NULL) {
- vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
- }
- if (priv->hadjustment && (priv->hadjustment != hadj)) {
- g_object_unref (priv->hadjustment);
- }
- if (priv->vadjustment && (priv->vadjustment != hadj)) {
- g_object_unref (priv->vadjustment);
- }
-
- if (priv->hadjustment != hadj) {
- priv->hadjustment = hadj;
- g_object_ref (priv->hadjustment);
- gtk_object_sink (GTK_OBJECT (priv->hadjustment));
- gtk_widget_set_scroll_adjustments (priv->header, hadj, NULL);
- need_adjust = TRUE;
- }
- if (priv->vadjustment != vadj) {
- priv->vadjustment = vadj;
- g_object_ref (priv->vadjustment);
- gtk_object_sink (GTK_OBJECT (priv->vadjustment));
- need_adjust = TRUE;
- }
-
- if (need_adjust) {
- gtk_widget_set_scroll_adjustments (GTK_WIDGET (priv->canvas),
- hadj, vadj);
- }
+ PlannerUsageChartPriv *priv;
+
+ gboolean need_adjust = FALSE;
+
+ g_return_if_fail (hadj == NULL || GTK_IS_ADJUSTMENT (hadj));
+ g_return_if_fail (vadj == NULL || GTK_IS_ADJUSTMENT (vadj));
+
+ priv = chart->priv;
+
+ if (hadj == NULL) {
+ hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ }
+ if (vadj == NULL) {
+ vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+ }
+ if (priv->hadjustment && (priv->hadjustment != hadj)) {
+ g_object_unref (priv->hadjustment);
+ }
+ if (priv->vadjustment && (priv->vadjustment != hadj)) {
+ g_object_unref (priv->vadjustment);
+ }
+
+ if (priv->hadjustment != hadj) {
+ priv->hadjustment = hadj;
+ g_object_ref (priv->hadjustment);
+ gtk_object_sink (GTK_OBJECT (priv->hadjustment));
+ gtk_widget_set_scroll_adjustments (priv->header, hadj, NULL);
+ need_adjust = TRUE;
+ }
+ if (priv->vadjustment != vadj) {
+ priv->vadjustment = vadj;
+ g_object_ref (priv->vadjustment);
+ gtk_object_sink (GTK_OBJECT (priv->vadjustment));
+ need_adjust = TRUE;
+ }
+
+ if (need_adjust) {
+ gtk_widget_set_scroll_adjustments (GTK_WIDGET (priv->canvas),
+ hadj, vadj);
+ }
}
static gboolean
node_is_visible (TreeNode *node)
{
- g_return_val_if_fail (node->parent != NULL, FALSE);
+ g_return_val_if_fail (node->parent != NULL, FALSE);
- while (node->parent) {
- if (!node->parent->expanded) {
- return FALSE;
- }
- node = node->parent;
- }
+ while (node->parent) {
+ if (!node->parent->expanded) {
+ return FALSE;
+ }
+ node = node->parent;
+ }
- return TRUE;
+ return TRUE;
}
static gdouble
usage_chart_reflow_do (PlannerUsageChart *chart,
TreeNode *root,
- gdouble start_y)
+ gdouble start_y)
{
- gdouble row_y;
- TreeNode *node;
- guint i;
- gint row_height;
-
- if (root->children == NULL) {
- return start_y;
- }
-
- node = root->children[0];
- row_y = start_y;
-
- row_height = chart->priv->row_height;
- if (row_height == -1) {
- row_height = 23;
- }
- for (i = 0; i < root->num_children; i++) {
- node = root->children[i];
- if (node_is_visible (node)) {
- g_object_set (node->item,
- "y", row_y,
- "height", (double) row_height, NULL);
- row_y += row_height;
-
- if (node->children != NULL) {
- row_y += usage_chart_reflow_do (chart, node,
- row_y);
- }
- }
- }
-
- return row_y - start_y;
+ gdouble row_y;
+ TreeNode *node;
+ guint i;
+ gint row_height;
+
+ if (root->children == NULL) {
+ return start_y;
+ }
+
+ node = root->children[0];
+ row_y = start_y;
+
+ row_height = chart->priv->row_height;
+ if (row_height == -1) {
+ row_height = 23;
+ }
+ for (i = 0; i < root->num_children; i++) {
+ node = root->children[i];
+ if (node_is_visible (node)) {
+ g_object_set (node->item,
+ "y", row_y,
+ "height", (double) row_height, NULL);
+ row_y += row_height;
+
+ if (node->children != NULL) {
+ row_y += usage_chart_reflow_do (chart, node,
+ row_y);
+ }
+ }
+ }
+
+ return row_y - start_y;
}
static gboolean
usage_chart_reflow_idle (PlannerUsageChart *chart)
{
- PlannerUsageChartPriv *priv;
- mrptime t1, t2;
- gdouble x1, y1, x2, y2;
- gdouble height, width;
- gdouble bx1, bx2;
- GtkAllocation allocation;
+ PlannerUsageChartPriv *priv;
+ mrptime t1, t2;
+ gdouble x1, y1, x2, y2;
+ gdouble height, width;
+ gdouble bx1, bx2;
+ GtkAllocation allocation;
- priv = chart->priv;
+ priv = chart->priv;
- if (priv->height_changed || priv->height == -1) {
- height = usage_chart_reflow_do (chart, priv->tree, 0);
- priv->height = height;
- } else {
- height = priv->height;
- }
+ if (priv->height_changed || priv->height == -1) {
+ height = usage_chart_reflow_do (chart, priv->tree, 0);
+ priv->height = height;
+ } else {
+ height = priv->height;
+ }
- allocation = GTK_WIDGET (priv->canvas)->allocation;
+ allocation = GTK_WIDGET (priv->canvas)->allocation;
- t1 = priv->project_start;
- t2 = priv->last_time;
+ t1 = priv->project_start;
+ t2 = priv->last_time;
- x1 = t1 * SCALE (priv->zoom) - PADDING;
- x2 = t2 * SCALE (priv->zoom) + PADDING;
+ x1 = t1 * SCALE (priv->zoom) - PADDING;
+ x2 = t2 * SCALE (priv->zoom) + PADDING;
- y2 = height;
- y1 = 0;
+ y2 = height;
+ y1 = 0;
- width = MAX (x2 - x1, allocation.width - 1.0);
- height = MAX (y2 - y1, allocation.height - 1.0);
+ width = MAX (x2 - x1, allocation.width - 1.0);
+ height = MAX (y2 - y1, allocation.height - 1.0);
- gnome_canvas_item_get_bounds (priv->canvas->root,
- &bx1, NULL,
+ gnome_canvas_item_get_bounds (priv->canvas->root,
+ &bx1, NULL,
&bx2, NULL);
- bx2 += PADDING;
+ bx2 += PADDING;
- width = MAX (width, bx2 - bx1);
+ width = MAX (width, bx2 - bx1);
- x2 = x1 + width;
+ x2 = x1 + width;
- usage_chart_set_scroll_region (chart,
+ usage_chart_set_scroll_region (chart,
x1,
y1,
x2,
y1 + height);
- if (x1 > -1 && x2 > -1) {
- g_object_set (priv->header,
+ if (x1 > -1 && x2 > -1) {
+ g_object_set (priv->header,
"x1", x1,
"x2", x2,
NULL);
- }
+ }
- priv->height_changed = FALSE;
- priv->reflow_idle_id = 0;
+ priv->height_changed = FALSE;
+ priv->reflow_idle_id = 0;
return FALSE;
}
@@ -860,190 +861,190 @@ usage_chart_reflow_idle (PlannerUsageChart *chart)
static void
usage_chart_reflow_now (PlannerUsageChart *chart)
{
- if (!GTK_WIDGET_MAPPED (chart)) {
- return;
- }
+ if (!GTK_WIDGET_MAPPED (chart)) {
+ return;
+ }
- usage_chart_reflow_idle (chart);
+ usage_chart_reflow_idle (chart);
}
static void
usage_chart_reflow (PlannerUsageChart *chart, gboolean height_changed)
{
- if (!GTK_WIDGET_MAPPED (chart)) {
- return;
- }
+ if (!GTK_WIDGET_MAPPED (chart)) {
+ return;
+ }
- chart->priv->height_changed |= height_changed;
- if (chart->priv->reflow_idle_id != 0) {
- return;
- }
+ chart->priv->height_changed |= height_changed;
+ if (chart->priv->reflow_idle_id != 0) {
+ return;
+ }
chart->priv->reflow_idle_id =
- g_idle_add ((GSourceFunc) usage_chart_reflow_idle, chart);
+ g_idle_add ((GSourceFunc) usage_chart_reflow_idle, chart);
}
static void
usage_chart_tree_traverse (TreeNode *node, TreeFunc func, gpointer data)
{
- gint i;
- TreeNode *child;
+ gint i;
+ TreeNode *child;
- for (i = 0; i < node->num_children; i++) {
- child = node->children[i];
- usage_chart_tree_traverse (child, func, data);
- }
+ for (i = 0; i < node->num_children; i++) {
+ child = node->children[i];
+ usage_chart_tree_traverse (child, func, data);
+ }
- func (node, data);
+ func (node, data);
}
static void
scale_func (TreeNode *node, gpointer data)
{
- PlannerUsageChart *chart;
- PlannerUsageChartPriv *priv;
+ PlannerUsageChart *chart;
+ PlannerUsageChartPriv *priv;
- chart = PLANNER_USAGE_CHART (data);
- priv = chart->priv;
+ chart = PLANNER_USAGE_CHART (data);
+ priv = chart->priv;
- if (node->item) {
- gnome_canvas_item_set (GNOME_CANVAS_ITEM (node->item),
- "scale", SCALE (priv->zoom),
- "zoom", priv->zoom,
+ if (node->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM (node->item),
+ "scale", SCALE (priv->zoom),
+ "zoom", priv->zoom,
NULL);
- }
+ }
}
static void
usage_chart_set_scroll_region (PlannerUsageChart *chart,
- gdouble x1,
- gdouble y1,
+ gdouble x1,
+ gdouble y1,
gdouble x2,
gdouble y2)
{
- GnomeCanvas *canvas;
- gdouble ox1, oy1, ox2, oy2;
+ GnomeCanvas *canvas;
+ gdouble ox1, oy1, ox2, oy2;
- canvas = chart->priv->canvas;
+ canvas = chart->priv->canvas;
gnome_canvas_get_scroll_region (canvas, &ox1, &oy1, &ox2, &oy2);
if (ox1 == x1 && oy1 == y1 && ox2 == x2 && oy2 == y2) {
- return;
- }
+ return;
+ }
- gnome_canvas_set_scroll_region (canvas, x1, y1, x2, y2);
+ gnome_canvas_set_scroll_region (canvas, x1, y1, x2, y2);
}
GtkWidget *
planner_usage_chart_new (void)
{
- return planner_usage_chart_new_with_model (NULL);
+ return planner_usage_chart_new_with_model (NULL);
}
GtkWidget *
planner_usage_chart_new_with_model (GtkTreeModel *model)
{
- PlannerUsageChart *chart;
+ PlannerUsageChart *chart;
- chart = PLANNER_USAGE_CHART (gtk_type_new
- (planner_usage_chart_get_type ()));
- if (model) {
- planner_usage_chart_set_model (chart, model);
- }
+ chart = PLANNER_USAGE_CHART (gtk_type_new
+ (planner_usage_chart_get_type ()));
+ if (model) {
+ planner_usage_chart_set_model (chart, model);
+ }
- return GTK_WIDGET (chart);
+ return GTK_WIDGET (chart);
}
void
planner_usage_chart_set_model (PlannerUsageChart *chart,
- GtkTreeModel *model)
+ GtkTreeModel *model)
{
- PlannerUsageChartPriv *priv;
- MrpProject *project;
- MrpTask *root;
- gulong signal_id;
+ PlannerUsageChartPriv *priv;
+ MrpProject *project;
+ MrpTask *root;
+ gulong signal_id;
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
- priv = chart->priv;
+ priv = chart->priv;
if (model == priv->model) {
- return;
- }
-
- if (priv->model) {
- usage_chart_disconnect_signals (chart);
- g_object_unref (priv->model);
- }
-
- priv->model = model;
- if (model) {
- g_object_ref (model);
- usage_chart_build_tree (chart);
- project =
- planner_usage_model_get_project (PLANNER_USAGE_MODEL
- (model));
- root = mrp_project_get_root_task (project);
- g_object_set (priv->background, "project", project, NULL);
-
- signal_id = g_signal_connect (project,
- "notify::project-start",
- G_CALLBACK
- (usage_chart_project_start_changed),
- chart);
- usage_chart_add_signal (chart, project, signal_id,
- "notify::project-start");
-
- g_signal_connect (root,
+ return;
+ }
+
+ if (priv->model) {
+ usage_chart_disconnect_signals (chart);
+ g_object_unref (priv->model);
+ }
+
+ priv->model = model;
+ if (model) {
+ g_object_ref (model);
+ usage_chart_build_tree (chart);
+ project =
+ planner_usage_model_get_project (PLANNER_USAGE_MODEL
+ (model));
+ root = mrp_project_get_root_task (project);
+ g_object_set (priv->background, "project", project, NULL);
+
+ signal_id = g_signal_connect (project,
+ "notify::project-start",
+ G_CALLBACK
+ (usage_chart_project_start_changed),
+ chart);
+ usage_chart_add_signal (chart, project, signal_id,
+ "notify::project-start");
+
+ g_signal_connect (root,
"notify::finish",
G_CALLBACK
(usage_chart_root_finish_changed),
chart);
- signal_id = g_signal_connect (model,
- "row-changed",
- G_CALLBACK
- (usage_chart_row_changed),
- chart);
- usage_chart_add_signal (chart, model, signal_id,
- "row-changed");
-
- signal_id = g_signal_connect (model,
- "row-inserted",
- G_CALLBACK
- (usage_chart_row_inserted),
- chart);
- usage_chart_add_signal (chart, model, signal_id,
- "row-inserted");
-
- signal_id = g_signal_connect (model,
- "row-deleted",
- G_CALLBACK
- (usage_chart_row_deleted),
- chart);
- usage_chart_add_signal (chart, model, signal_id,
- "row-deleted");
-
- /*
- * signal_id = g_signal_connect(model,
- * "row-reordered",
- * G_CALLBACK (usage_chart_row_reordered),
- * chart);
- * usage_chart_add_signal (chart, model, signal_id,"row-reordered");
- */
-
- priv->project_start = mrp_project_get_project_start (project);
- g_object_set (priv->background,
+ signal_id = g_signal_connect (model,
+ "row-changed",
+ G_CALLBACK
+ (usage_chart_row_changed),
+ chart);
+ usage_chart_add_signal (chart, model, signal_id,
+ "row-changed");
+
+ signal_id = g_signal_connect (model,
+ "row-inserted",
+ G_CALLBACK
+ (usage_chart_row_inserted),
+ chart);
+ usage_chart_add_signal (chart, model, signal_id,
+ "row-inserted");
+
+ signal_id = g_signal_connect (model,
+ "row-deleted",
+ G_CALLBACK
+ (usage_chart_row_deleted),
+ chart);
+ usage_chart_add_signal (chart, model, signal_id,
+ "row-deleted");
+
+ /*
+ * signal_id = g_signal_connect(model,
+ * "row-reordered",
+ * G_CALLBACK (usage_chart_row_reordered),
+ * chart);
+ * usage_chart_add_signal (chart, model, signal_id,"row-reordered");
+ */
+
+ priv->project_start = mrp_project_get_project_start (project);
+ g_object_set (priv->background,
"project-start", priv->project_start,
NULL);
- priv->last_time = mrp_task_get_finish (root);
+ priv->last_time = mrp_task_get_finish (root);
- priv->height_changed = TRUE;
- usage_chart_reflow_now (chart);
+ priv->height_changed = TRUE;
+ usage_chart_reflow_now (chart);
- }
- g_object_notify (G_OBJECT (chart), "model");
+ }
+ g_object_notify (G_OBJECT (chart), "model");
}
GtkTreeModel *
@@ -1058,152 +1059,152 @@ planner_usage_chart_get_model (PlannerUsageChart *chart)
static void
usage_chart_build_tree (PlannerUsageChart * chart)
{
- PlannerUsageChartPriv *priv;
- GtkTreeIter iter;
- GtkTreePath *path;
- TreeNode *node;
- GtkTreeIter child;
+ PlannerUsageChartPriv *priv;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ TreeNode *node;
+ GtkTreeIter child;
- priv = chart->priv;
+ priv = chart->priv;
- path = gtk_tree_path_new_root ();
- if (!gtk_tree_model_get_iter (chart->priv->model, &iter, path)) {
- gtk_tree_path_free (path);
- return;
- }
+ path = gtk_tree_path_new_root ();
+ if (!gtk_tree_model_get_iter (chart->priv->model, &iter, path)) {
+ gtk_tree_path_free (path);
+ return;
+ }
- gtk_tree_path_free (path);
+ gtk_tree_path_free (path);
- do {
- MrpResource *res;
+ do {
+ MrpResource *res;
- res = planner_usage_model_get_resource (PLANNER_USAGE_MODEL
- (priv->model),
- &iter);
+ res = planner_usage_model_get_resource (PLANNER_USAGE_MODEL
+ (priv->model),
+ &iter);
path = gtk_tree_model_get_path (priv->model, &iter);
- node = usage_chart_insert_resource (chart, path, res);
- gtk_tree_path_free (path);
- if (gtk_tree_model_iter_children (priv->model, &child, &iter)) {
- do {
- MrpAssignment *assign;
- assign = planner_usage_model_get_assignment
- (PLANNER_USAGE_MODEL (priv->model),
- &child);
- path = gtk_tree_model_get_path (priv->model,
- &child);
- node = usage_chart_insert_assignment (chart,
- path,
- assign);
- gtk_tree_path_free (path);
- } while (gtk_tree_model_iter_next
- (priv->model, &child));
- }
- } while (gtk_tree_model_iter_next (priv->model, &iter));
-
- /* FIXME: free paths used as keys. */
+ node = usage_chart_insert_resource (chart, path, res);
+ gtk_tree_path_free (path);
+ if (gtk_tree_model_iter_children (priv->model, &child, &iter)) {
+ do {
+ MrpAssignment *assign;
+ assign = planner_usage_model_get_assignment
+ (PLANNER_USAGE_MODEL (priv->model),
+ &child);
+ path = gtk_tree_model_get_path (priv->model,
+ &child);
+ node = usage_chart_insert_assignment (chart,
+ path,
+ assign);
+ gtk_tree_path_free (path);
+ } while (gtk_tree_model_iter_next
+ (priv->model, &child));
+ }
+ } while (gtk_tree_model_iter_next (priv->model, &iter));
+
+ /* FIXME: free paths used as keys. */
}
static TreeNode *
usage_chart_insert_row (PlannerUsageChart *chart,
- GtkTreePath *path,
- MrpResource *resource,
+ GtkTreePath *path,
+ MrpResource *resource,
MrpAssignment *assign)
{
- PlannerUsageChartPriv *priv;
- GnomeCanvasItem *item;
- TreeNode *tree_node;
-
- priv = chart->priv;
-
- item = gnome_canvas_item_new (gnome_canvas_root (priv->canvas),
- PLANNER_TYPE_USAGE_ROW,
- "resource", resource,
- "assignment", assign,
- "scale", SCALE (priv->zoom),
- "zoom", priv->zoom,
+ PlannerUsageChartPriv *priv;
+ GnomeCanvasItem *item;
+ TreeNode *tree_node;
+
+ priv = chart->priv;
+
+ item = gnome_canvas_item_new (gnome_canvas_root (priv->canvas),
+ PLANNER_TYPE_USAGE_ROW,
+ "resource", resource,
+ "assignment", assign,
+ "scale", SCALE (priv->zoom),
+ "zoom", priv->zoom,
NULL);
- tree_node = usage_chart_tree_node_new ();
- tree_node->item = item;
- tree_node->resource = resource;
- tree_node->assignment = assign;
- usage_chart_tree_node_insert_path (priv->tree, path, tree_node);
- return tree_node;
+ tree_node = usage_chart_tree_node_new ();
+ tree_node->item = item;
+ tree_node->resource = resource;
+ tree_node->assignment = assign;
+ usage_chart_tree_node_insert_path (priv->tree, path, tree_node);
+ return tree_node;
}
static TreeNode *
usage_chart_insert_resource (PlannerUsageChart *chart,
- GtkTreePath *path,
+ GtkTreePath *path,
MrpResource *resource)
{
- TreeNode *node;
+ TreeNode *node;
- node = usage_chart_insert_row (chart, path, resource, NULL);
- node->expanded = 0;
+ node = usage_chart_insert_row (chart, path, resource, NULL);
+ node->expanded = 0;
return node;
}
static TreeNode *
usage_chart_insert_assignment (PlannerUsageChart *chart,
- GtkTreePath *path,
+ GtkTreePath *path,
MrpAssignment *assign)
{
- return usage_chart_insert_row (chart, path, NULL, assign);
+ return usage_chart_insert_row (chart, path, NULL, assign);
}
static void
usage_chart_tree_node_insert_path (TreeNode *node,
- GtkTreePath *path,
+ GtkTreePath *path,
TreeNode *new_node)
{
- gint *indices, i, depth;
+ gint *indices, i, depth;
depth = gtk_tree_path_get_depth (path);
- indices = gtk_tree_path_get_indices (path);
-
- for (i = 0; i < depth - 1; i++) {
- node = node->children[indices[i]];
- }
-
- node->num_children++;
- node->children =
- g_realloc (node->children,
- sizeof (gpointer) * node->num_children);
-
- if (node->num_children - 1 == indices[i]) {
- /* Don't need to move if the new node is at the end. */
- } else {
- memmove (node->children + indices[i] + 1,
- node->children + indices[i],
- sizeof (gpointer) * (node->num_children -
- indices[i] - 1));
- }
-
- node->children[indices[i]] = new_node;
- new_node->parent = node;
+ indices = gtk_tree_path_get_indices (path);
+
+ for (i = 0; i < depth - 1; i++) {
+ node = node->children[indices[i]];
+ }
+
+ node->num_children++;
+ node->children =
+ g_realloc (node->children,
+ sizeof (gpointer) * node->num_children);
+
+ if (node->num_children - 1 == indices[i]) {
+ /* Don't need to move if the new node is at the end. */
+ } else {
+ memmove (node->children + indices[i] + 1,
+ node->children + indices[i],
+ sizeof (gpointer) * (node->num_children -
+ indices[i] - 1));
+ }
+
+ node->children[indices[i]] = new_node;
+ new_node->parent = node;
}
static void
usage_chart_project_start_changed (MrpProject *project,
- GParamSpec *spec,
- PlannerUsageChart *chart)
+ GParamSpec *spec,
+ PlannerUsageChart *chart)
{
- mrptime t;
+ mrptime t;
- t = mrp_project_get_project_start (project);
+ t = mrp_project_get_project_start (project);
chart->priv->project_start = t;
- g_object_set (chart->priv->background, "project-start", t, NULL);
+ g_object_set (chart->priv->background, "project-start", t, NULL);
usage_chart_reflow_now (chart);
}
static void
usage_chart_root_finish_changed (MrpTask *root,
- GParamSpec *spec,
- PlannerUsageChart *chart)
+ GParamSpec *spec,
+ PlannerUsageChart *chart)
{
chart->priv->last_time = mrp_task_get_finish (root);
usage_chart_reflow (chart, FALSE);
@@ -1211,248 +1212,248 @@ usage_chart_root_finish_changed (MrpTask *root,
static void
usage_chart_add_signal (PlannerUsageChart *chart,
- gpointer instance,
+ gpointer instance,
gulong sig_id,
gchar *sig_name)
{
- ConnectData *data;
+ ConnectData *data;
- data = g_new0 (ConnectData, 1);
- data->instance = instance;
- data->id = sig_id;
- chart->priv->signal_ids = g_list_prepend (chart->priv->signal_ids, data);
+ data = g_new0 (ConnectData, 1);
+ data->instance = instance;
+ data->id = sig_id;
+ chart->priv->signal_ids = g_list_prepend (chart->priv->signal_ids, data);
}
static void
usage_chart_disconnect_signals (PlannerUsageChart *chart)
{
- GList *l;
- ConnectData *data;
+ GList *l;
+ ConnectData *data;
- for (l = chart->priv->signal_ids; l; l = l->next) {
- data = l->data;
- g_signal_handler_disconnect (data->instance, data->id);
- g_free (data);
- }
+ for (l = chart->priv->signal_ids; l; l = l->next) {
+ data = l->data;
+ g_signal_handler_disconnect (data->instance, data->id);
+ g_free (data);
+ }
- g_list_free (chart->priv->signal_ids);
+ g_list_free (chart->priv->signal_ids);
chart->priv->signal_ids = NULL;
}
static void
show_hide_descendants (TreeNode *node, gboolean show)
{
- gint i;
-
- for (i = 0; i < node->num_children; i++) {
- planner_usage_row_set_visible (PLANNER_USAGE_ROW
- (node->children[i]->item),
- show);
- if (!show || (show && node->children[i]->expanded)) {
- show_hide_descendants (node->children[i], show);
- }
- }
+ gint i;
+
+ for (i = 0; i < node->num_children; i++) {
+ planner_usage_row_set_visible (PLANNER_USAGE_ROW
+ (node->children[i]->item),
+ show);
+ if (!show || (show && node->children[i]->expanded)) {
+ show_hide_descendants (node->children[i], show);
+ }
+ }
}
static void
expand_descendants (TreeNode *node)
{
- gint i;
+ gint i;
- for (i = 0; i < node->num_children; i++) {
- node->children[i]->expanded = TRUE;
- expand_descendants (node->children[i]);
- }
+ for (i = 0; i < node->num_children; i++) {
+ node->children[i]->expanded = TRUE;
+ expand_descendants (node->children[i]);
+ }
}
static void
collapse_descendants (TreeNode *node)
{
- gint i;
+ gint i;
- for (i = 0; i < node->num_children; i++) {
- node->children[i]->expanded = FALSE;
- collapse_descendants (node->children[i]);
- }
+ for (i = 0; i < node->num_children; i++) {
+ node->children[i]->expanded = FALSE;
+ collapse_descendants (node->children[i]);
+ }
}
void
planner_usage_chart_expand_row (PlannerUsageChart *chart,
- GtkTreePath *path)
+ GtkTreePath *path)
{
- TreeNode *node;
+ TreeNode *node;
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
node = usage_chart_tree_node_at_path (chart->priv->tree, path);
- if (node) {
- node->expanded = TRUE;
- show_hide_descendants (node, TRUE);
- usage_chart_reflow (chart, TRUE);
- }
+ if (node) {
+ node->expanded = TRUE;
+ show_hide_descendants (node, TRUE);
+ usage_chart_reflow (chart, TRUE);
+ }
}
void
planner_usage_chart_collapse_row (PlannerUsageChart *chart,
- GtkTreePath *path)
+ GtkTreePath *path)
{
- TreeNode *node;
+ TreeNode *node;
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
- node = usage_chart_tree_node_at_path (chart->priv->tree, path);
- if (node) {
- node->expanded = FALSE;
- collapse_descendants (node);
- show_hide_descendants (node, FALSE);
- usage_chart_reflow (chart, TRUE);
- }
+ node = usage_chart_tree_node_at_path (chart->priv->tree, path);
+ if (node) {
+ node->expanded = FALSE;
+ collapse_descendants (node);
+ show_hide_descendants (node, FALSE);
+ usage_chart_reflow (chart, TRUE);
+ }
}
void
planner_usage_chart_expand_all (PlannerUsageChart *chart)
{
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
- expand_descendants (chart->priv->tree);
- show_hide_descendants (chart->priv->tree, TRUE);
- usage_chart_reflow (chart, TRUE);
+ expand_descendants (chart->priv->tree);
+ show_hide_descendants (chart->priv->tree, TRUE);
+ usage_chart_reflow (chart, TRUE);
}
void
planner_usage_chart_collapse_all (PlannerUsageChart *chart)
{
- TreeNode *node;
- int i;
+ TreeNode *node;
+ int i;
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
- node = chart->priv->tree;
- for (i = 0; i < node->num_children; i++) {
- node->children[i]->expanded = FALSE;
- collapse_descendants (node->children[i]);
- show_hide_descendants (node->children[i], FALSE);
- }
+ node = chart->priv->tree;
+ for (i = 0; i < node->num_children; i++) {
+ node->children[i]->expanded = FALSE;
+ collapse_descendants (node->children[i]);
+ show_hide_descendants (node->children[i], FALSE);
+ }
- usage_chart_reflow (chart, TRUE);
+ usage_chart_reflow (chart, TRUE);
}
static TreeNode *
usage_chart_tree_node_at_path (TreeNode *node, GtkTreePath *path)
{
- gint *indices, i, depth;
+ gint *indices, i, depth;
- depth = gtk_tree_path_get_depth (path);
- indices = gtk_tree_path_get_indices (path);
- for (i = 0; i < depth; i++) {
- node = node->children[indices[i]];
- }
+ depth = gtk_tree_path_get_depth (path);
+ indices = gtk_tree_path_get_indices (path);
+ for (i = 0; i < depth; i++) {
+ node = node->children[indices[i]];
+ }
- return node;
+ return node;
}
static void
usage_chart_row_changed (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
gpointer data)
{
}
static void
usage_chart_row_inserted (GtkTreeModel *model,
- GtkTreePath *path,
- GtkTreeIter *iter,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
gpointer data)
{
- PlannerUsageChart *chart;
- PlannerUsageChartPriv *priv;
- gboolean free_path = FALSE;
- gboolean free_iter = FALSE;
- MrpResource *res;
- MrpAssignment *assign;
- TreeNode *node = NULL;
-
- chart = data;
- priv = chart->priv;
-
- if (path == NULL) {
- path = gtk_tree_model_get_path (model, iter);
- free_path = TRUE;
- }
+ PlannerUsageChart *chart;
+ PlannerUsageChartPriv *priv;
+ gboolean free_path = FALSE;
+ gboolean free_iter = FALSE;
+ MrpResource *res;
+ MrpAssignment *assign;
+ TreeNode *node = NULL;
+
+ chart = data;
+ priv = chart->priv;
+
+ if (path == NULL) {
+ path = gtk_tree_model_get_path (model, iter);
+ free_path = TRUE;
+ }
else if (iter == NULL) {
- iter = g_new0 (GtkTreeIter, 1);
- free_iter = TRUE;
- gtk_tree_model_get_iter (model, iter, path);
- }
+ iter = g_new0 (GtkTreeIter, 1);
+ free_iter = TRUE;
+ gtk_tree_model_get_iter (model, iter, path);
+ }
res = planner_usage_model_get_resource (PLANNER_USAGE_MODEL (model),
- iter);
- assign = planner_usage_model_get_assignment (PLANNER_USAGE_MODEL
- (model), iter);
- if (res) {
- node = usage_chart_insert_resource (chart, path, res);
- }
+ iter);
+ assign = planner_usage_model_get_assignment (PLANNER_USAGE_MODEL
+ (model), iter);
+ if (res) {
+ node = usage_chart_insert_resource (chart, path, res);
+ }
if (assign && !node) {
- node = usage_chart_insert_assignment (chart, path, assign);
+ node = usage_chart_insert_assignment (chart, path, assign);
}
- usage_chart_reflow (chart, TRUE);
+ usage_chart_reflow (chart, TRUE);
if (free_path) {
- gtk_tree_path_free (path);
- }
+ gtk_tree_path_free (path);
+ }
- if (free_iter) {
- g_free (iter);
- }
+ if (free_iter) {
+ g_free (iter);
+ }
}
static void
usage_chart_row_deleted (GtkTreeModel *model,
- GtkTreePath *path,
+ GtkTreePath *path,
gpointer data)
{
- PlannerUsageChart *chart;
- PlannerUsageChartPriv *priv;
- TreeNode *node;
-
- chart = PLANNER_USAGE_CHART (data);
- priv = chart->priv;
-
- node = usage_chart_tree_node_at_path (priv->tree, path);
- usage_chart_tree_node_remove (node);
- usage_chart_remove_children (chart, node);
- /*
- * g_return_if_fail (path != NULL || iter != NULL);
- * fprintf(stderr,"On degage une ligne\n");
- * if (path == NULL) {
- * path = gtk_tree_model_get_path(model,iter);
- * free_path=TRUE;
- * } else if (iter == NULL) {
- * iter = g_new0(GtkTreeIter,1);
- * free_iter = TRUE;
- * gtk_tree_model_get_iter(model,iter,path);
- * }
- * res = planner_usage_model_get_resource(PLANNER_USAGE_MODEL(model),iter);
- * assign = planner_usage_model_get_assignment(PLANNER_USAGE_MODEL(model),iter);
- * if (res) {
- * usage_chart_remove_resource(chart,path,res);
- * }
- * if (assign) {
- * usage_chart_remove_assignment(chart,path,assign);
- * }
- */
- usage_chart_reflow (chart, TRUE);
- /*
- * if (free_path) {
- * gt_tree_path_free(path);
- * }
- * if (free_iter) {
- * g_free(iter);
- * }
- */
+ PlannerUsageChart *chart;
+ PlannerUsageChartPriv *priv;
+ TreeNode *node;
+
+ chart = PLANNER_USAGE_CHART (data);
+ priv = chart->priv;
+
+ node = usage_chart_tree_node_at_path (priv->tree, path);
+ usage_chart_tree_node_remove (node);
+ usage_chart_remove_children (chart, node);
+ /*
+ * g_return_if_fail (path != NULL || iter != NULL);
+ * fprintf(stderr,"On degage une ligne\n");
+ * if (path == NULL) {
+ * path = gtk_tree_model_get_path(model,iter);
+ * free_path=TRUE;
+ * } else if (iter == NULL) {
+ * iter = g_new0(GtkTreeIter,1);
+ * free_iter = TRUE;
+ * gtk_tree_model_get_iter(model,iter,path);
+ * }
+ * res = planner_usage_model_get_resource(PLANNER_USAGE_MODEL(model),iter);
+ * assign = planner_usage_model_get_assignment(PLANNER_USAGE_MODEL(model),iter);
+ * if (res) {
+ * usage_chart_remove_resource(chart,path,res);
+ * }
+ * if (assign) {
+ * usage_chart_remove_assignment(chart,path,assign);
+ * }
+ */
+ usage_chart_reflow (chart, TRUE);
+ /*
+ * if (free_path) {
+ * gt_tree_path_free(path);
+ * }
+ * if (free_iter) {
+ * g_free(iter);
+ * }
+ */
}
/*
@@ -1477,60 +1478,60 @@ usage_chart_resource_assignment_added (MrpResource *res,
static void
usage_chart_tree_node_remove (TreeNode *node)
{
- TreeNode *parent;
- gint i, pos;
-
- parent = node->parent;
- pos = -1;
- for (i = 0; i < parent->num_children; i++) {
- if (parent->children[i] == node) {
- pos = i;
- break;
- }
- }
- g_assert (pos != -1);
-
- memmove (parent->children + pos,
- parent->children + pos + 1,
- sizeof (gpointer) * (parent->num_children - pos - 1));
- parent->num_children--;
- parent->children =
- g_realloc (parent->children,
- sizeof (gpointer) * parent->num_children);
- node->parent = NULL;
+ TreeNode *parent;
+ gint i, pos;
+
+ parent = node->parent;
+ pos = -1;
+ for (i = 0; i < parent->num_children; i++) {
+ if (parent->children[i] == node) {
+ pos = i;
+ break;
+ }
+ }
+ g_assert (pos != -1);
+
+ memmove (parent->children + pos,
+ parent->children + pos + 1,
+ sizeof (gpointer) * (parent->num_children - pos - 1));
+ parent->num_children--;
+ parent->children =
+ g_realloc (parent->children,
+ sizeof (gpointer) * parent->num_children);
+ node->parent = NULL;
}
static void
usage_chart_remove_children (PlannerUsageChart *chart, TreeNode *node)
{
- gint i;
+ gint i;
- for (i = 0; i < node->num_children; i++) {
- usage_chart_remove_children (chart, node->children[i]);
- }
+ for (i = 0; i < node->num_children; i++) {
+ usage_chart_remove_children (chart, node->children[i]);
+ }
gtk_object_destroy (GTK_OBJECT (node->item));
node->item = NULL;
- node->assignment = NULL;
- node->resource = NULL;
+ node->assignment = NULL;
+ node->resource = NULL;
g_free (node->children);
- node->children = NULL;
+ node->children = NULL;
- g_free (node);
+ g_free (node);
}
void
planner_usage_chart_setup_root_task (PlannerUsageChart *chart)
{
- PlannerUsageChartPriv *priv;
- MrpProject *project;
- MrpTask *root;
+ PlannerUsageChartPriv *priv;
+ MrpProject *project;
+ MrpTask *root;
- g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
+ g_return_if_fail (PLANNER_IS_USAGE_CHART (chart));
- priv = chart->priv;
+ priv = chart->priv;
project = planner_usage_model_get_project (PLANNER_USAGE_MODEL (priv->model));
root = mrp_project_get_root_task (project);
diff --git a/src/planner-usage-model.c b/src/planner-usage-model.c
index 397969c..2715868 100644
--- a/src/planner-usage-model.c
+++ b/src/planner-usage-model.c
@@ -35,21 +35,21 @@
#include "planner-usage-model.h"
enum {
- RESOURCE_ADDED,
- RESOURCE_REMOVED,
- TASK_ADDED,
- TASK_REMOVED,
- ASSIGNMENT_ADDED,
- ASSIGNMENT_REMOVED,
- LAST_SIGNAL
+ RESOURCE_ADDED,
+ RESOURCE_REMOVED,
+ TASK_ADDED,
+ TASK_REMOVED,
+ ASSIGNMENT_ADDED,
+ ASSIGNMENT_REMOVED,
+ LAST_SIGNAL
};
struct _PlannerUsageModelPriv {
- MrpProject *project;
- GHashTable *resource2node;
- GHashTable *assign2node;
- GNode *tree;
- gboolean in_new;
+ MrpProject *project;
+ GHashTable *resource2node;
+ GHashTable *assign2node;
+ GNode *tree;
+ gboolean in_new;
};
static void usage_model_init (PlannerUsageModel *model);
@@ -82,791 +82,791 @@ static guint signals[LAST_SIGNAL];
GType
planner_usage_model_get_type (void)
{
- static GType type = 0;
- if (!type) {
- static const GTypeInfo info = {
- sizeof (PlannerUsageModelClass),
- NULL, /*base init */
- NULL, /*base finalize */
- (GClassInitFunc) usage_model_class_init,
- NULL, /*class finalize */
- NULL, /*class data */
- sizeof (PlannerUsageModel),
- 0,
- (GInstanceInitFunc) usage_model_init
- };
- static const GInterfaceInfo tree_model_info = {
- (GInterfaceInitFunc) usage_model_tree_model_init,
- NULL,
- NULL
- };
-
- type = g_type_register_static (G_TYPE_OBJECT,
- "PlannerUsageModel",
- &info, 0);
- g_type_add_interface_static (type,
- GTK_TYPE_TREE_MODEL,
- &tree_model_info);
- }
- return type;
+ static GType type = 0;
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (PlannerUsageModelClass),
+ NULL, /*base init */
+ NULL, /*base finalize */
+ (GClassInitFunc) usage_model_class_init,
+ NULL, /*class finalize */
+ NULL, /*class data */
+ sizeof (PlannerUsageModel),
+ 0,
+ (GInstanceInitFunc) usage_model_init
+ };
+ static const GInterfaceInfo tree_model_info = {
+ (GInterfaceInitFunc) usage_model_tree_model_init,
+ NULL,
+ NULL
+ };
+
+ type = g_type_register_static (G_TYPE_OBJECT,
+ "PlannerUsageModel",
+ &info, 0);
+ g_type_add_interface_static (type,
+ GTK_TYPE_TREE_MODEL,
+ &tree_model_info);
+ }
+ return type;
}
MrpProject *
planner_usage_model_get_project (PlannerUsageModel *model)
{
- return model->priv->project;
+ return model->priv->project;
}
static void
usage_model_init (PlannerUsageModel *model)
{
- PlannerUsageModelPriv *priv;
+ PlannerUsageModelPriv *priv;
- priv = g_new0 (PlannerUsageModelPriv, 1);
- model->priv = priv;
+ priv = g_new0 (PlannerUsageModelPriv, 1);
+ model->priv = priv;
- priv->resource2node = g_hash_table_new (NULL, NULL);
- priv->assign2node = g_hash_table_new (NULL, NULL);
+ priv->resource2node = g_hash_table_new (NULL, NULL);
+ priv->assign2node = g_hash_table_new (NULL, NULL);
}
static void
usage_model_finalize (GObject *object)
{
- PlannerUsageModel *model = PLANNER_USAGE_MODEL (object);
+ PlannerUsageModel *model = PLANNER_USAGE_MODEL (object);
- g_free (model->priv);
+ g_free (model->priv);
- if (G_OBJECT_CLASS (parent_class)->finalize) {
- G_OBJECT_CLASS (parent_class)->finalize (object);
- }
+ if (G_OBJECT_CLASS (parent_class)->finalize) {
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+ }
}
static void
usage_model_class_init (PlannerUsageModelClass *klass)
{
- GObjectClass *object_class;
- object_class = (GObjectClass *) klass;
- parent_class = g_type_class_peek_parent (klass);
- object_class->finalize = usage_model_finalize;
- signals[RESOURCE_ADDED] =
- g_signal_new ("resource-added",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- planner_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, MRP_TYPE_RESOURCE);
- signals[RESOURCE_REMOVED] =
- g_signal_new ("resource-removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- planner_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, MRP_TYPE_RESOURCE);
- signals[TASK_ADDED] =
- g_signal_new ("task-added",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- planner_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, MRP_TYPE_TASK);
- signals[TASK_REMOVED] =
- g_signal_new ("task-removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- planner_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, MRP_TYPE_TASK);
-
- signals[ASSIGNMENT_ADDED] =
- g_signal_new ("assignment-added",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- planner_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, MRP_TYPE_ASSIGNMENT);
- signals[ASSIGNMENT_REMOVED] =
- g_signal_new ("assignment-removed",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- planner_marshal_VOID__OBJECT,
- G_TYPE_NONE, 1, MRP_TYPE_ASSIGNMENT);
+ GObjectClass *object_class;
+ object_class = (GObjectClass *) klass;
+ parent_class = g_type_class_peek_parent (klass);
+ object_class->finalize = usage_model_finalize;
+ signals[RESOURCE_ADDED] =
+ g_signal_new ("resource-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ planner_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, MRP_TYPE_RESOURCE);
+ signals[RESOURCE_REMOVED] =
+ g_signal_new ("resource-removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ planner_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, MRP_TYPE_RESOURCE);
+ signals[TASK_ADDED] =
+ g_signal_new ("task-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ planner_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, MRP_TYPE_TASK);
+ signals[TASK_REMOVED] =
+ g_signal_new ("task-removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ planner_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, MRP_TYPE_TASK);
+
+ signals[ASSIGNMENT_ADDED] =
+ g_signal_new ("assignment-added",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ planner_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, MRP_TYPE_ASSIGNMENT);
+ signals[ASSIGNMENT_REMOVED] =
+ g_signal_new ("assignment-removed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ planner_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, MRP_TYPE_ASSIGNMENT);
}
static int
usage_model_get_n_columns (GtkTreeModel *tree_model)
{
- return NUM_COLS;
+ return NUM_COLS;
}
static GType
usage_model_get_column_type (GtkTreeModel *tree_model, gint column)
{
- switch (column) {
- case COL_RESNAME:
- return G_TYPE_STRING;
- case COL_TASKNAME:
- return G_TYPE_STRING;
- case COL_RESOURCE:
- return MRP_TYPE_RESOURCE;
- case COL_ASSIGNMENT:
- return MRP_TYPE_ASSIGNMENT;
- default:
- return G_TYPE_INVALID;
- }
+ switch (column) {
+ case COL_RESNAME:
+ return G_TYPE_STRING;
+ case COL_TASKNAME:
+ return G_TYPE_STRING;
+ case COL_RESOURCE:
+ return MRP_TYPE_RESOURCE;
+ case COL_ASSIGNMENT:
+ return MRP_TYPE_ASSIGNMENT;
+ default:
+ return G_TYPE_INVALID;
+ }
}
static gboolean
usage_model_get_iter (GtkTreeModel *tree_model,
- GtkTreeIter *iter, GtkTreePath *path)
+ GtkTreeIter *iter, GtkTreePath *path)
{
- PlannerUsageModel *model;
- GtkTreeIter parent;
- gint *indices;
- gint depth, i;
+ PlannerUsageModel *model;
+ GtkTreeIter parent;
+ gint *indices;
+ gint depth, i;
- model = PLANNER_USAGE_MODEL (tree_model);
+ model = PLANNER_USAGE_MODEL (tree_model);
- indices = gtk_tree_path_get_indices (path);
- depth = gtk_tree_path_get_depth (path);
+ indices = gtk_tree_path_get_indices (path);
+ depth = gtk_tree_path_get_depth (path);
- g_return_val_if_fail (depth > 0, FALSE);
+ g_return_val_if_fail (depth > 0, FALSE);
- parent.stamp = model->stamp;
- parent.user_data = model->priv->tree;
+ parent.stamp = model->stamp;
+ parent.user_data = model->priv->tree;
- if (!gtk_tree_model_iter_nth_child
- (tree_model, iter, &parent, indices[0])) {
- return FALSE;
- }
+ if (!gtk_tree_model_iter_nth_child
+ (tree_model, iter, &parent, indices[0])) {
+ return FALSE;
+ }
- for (i = 1; i < depth; i++) {
- parent = *iter;
- if (!gtk_tree_model_iter_nth_child
- (tree_model, iter, &parent, indices[i])) {
- return FALSE;
- }
- }
+ for (i = 1; i < depth; i++) {
+ parent = *iter;
+ if (!gtk_tree_model_iter_nth_child
+ (tree_model, iter, &parent, indices[i])) {
+ return FALSE;
+ }
+ }
- return TRUE;
+ return TRUE;
}
static GtkTreePath *
usage_model_get_path_from_node (PlannerUsageModel *model, GNode *node)
{
- GtkTreePath *path;
- GNode *parent;
- GNode *child;
- gint i = 0;
+ GtkTreePath *path;
+ GNode *parent;
+ GNode *child;
+ gint i = 0;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
- g_return_val_if_fail (node != NULL, NULL);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
+ g_return_val_if_fail (node != NULL, NULL);
- parent = node->parent;
+ parent = node->parent;
- if (parent == NULL && node == model->priv->tree) {
- return gtk_tree_path_new_root ();
- }
+ if (parent == NULL && node == model->priv->tree) {
+ return gtk_tree_path_new_root ();
+ }
- g_assert (parent != NULL);
+ g_assert (parent != NULL);
- if (parent == model->priv->tree) {
- path = gtk_tree_path_new ();
- } else {
- path = usage_model_get_path_from_node (model, parent);
- }
- child = g_node_first_child (parent);
+ if (parent == model->priv->tree) {
+ path = gtk_tree_path_new ();
+ } else {
+ path = usage_model_get_path_from_node (model, parent);
+ }
+ child = g_node_first_child (parent);
- if (path == NULL) {
- return NULL;
- }
+ if (path == NULL) {
+ return NULL;
+ }
- if (child == NULL) {
- gtk_tree_path_free (path);
- return NULL;
- }
+ if (child == NULL) {
+ gtk_tree_path_free (path);
+ return NULL;
+ }
- for (; child; child = g_node_next_sibling (child)) {
- if (child == node) {
- break;
- }
- i++;
- }
+ for (; child; child = g_node_next_sibling (child)) {
+ if (child == node) {
+ break;
+ }
+ i++;
+ }
- if (child == NULL) {
- gtk_tree_path_free (path);
- return NULL;
- }
- gtk_tree_path_append_index (path, i);
- return path;
+ if (child == NULL) {
+ gtk_tree_path_free (path);
+ return NULL;
+ }
+ gtk_tree_path_append_index (path, i);
+ return path;
}
GtkTreePath *
planner_usage_model_get_path_from_resource (PlannerUsageModel *model,
- MrpResource *resource)
+ MrpResource *resource)
{
- GNode *node;
+ GNode *node;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
- g_return_val_if_fail (MRP_IS_RESOURCE (resource), NULL);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
+ g_return_val_if_fail (MRP_IS_RESOURCE (resource), NULL);
- node = g_hash_table_lookup (model->priv->resource2node, resource);
+ node = g_hash_table_lookup (model->priv->resource2node, resource);
- return usage_model_get_path_from_node (PLANNER_USAGE_MODEL (model),
- node);
+ return usage_model_get_path_from_node (PLANNER_USAGE_MODEL (model),
+ node);
}
GtkTreePath *
planner_usage_model_get_path_from_assignment (PlannerUsageModel *model,
MrpAssignment *assignment)
{
- GNode *node;
+ GNode *node;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
- g_return_val_if_fail (MRP_IS_ASSIGNMENT (assignment), NULL);
+ 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);
+ node = g_hash_table_lookup (model->priv->assign2node, assignment);
- return usage_model_get_path_from_node (PLANNER_USAGE_MODEL (model),
+ return usage_model_get_path_from_node (PLANNER_USAGE_MODEL (model),
node);
}
static GtkTreePath *
usage_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- GNode *node;
+ GNode *node;
- g_return_val_if_fail (iter != NULL, NULL);
- g_return_val_if_fail (iter->user_data != NULL, NULL);
- g_return_val_if_fail (iter->stamp ==
- PLANNER_USAGE_MODEL (tree_model)->stamp, NULL);
+ g_return_val_if_fail (iter != NULL, NULL);
+ g_return_val_if_fail (iter->user_data != NULL, NULL);
+ g_return_val_if_fail (iter->stamp ==
+ PLANNER_USAGE_MODEL (tree_model)->stamp, NULL);
- node = iter->user_data;
+ node = iter->user_data;
- return usage_model_get_path_from_node (PLANNER_USAGE_MODEL
- (tree_model), node);
+ return usage_model_get_path_from_node (PLANNER_USAGE_MODEL
+ (tree_model), node);
}
static void
usage_model_get_value (GtkTreeModel *tree_model,
- GtkTreeIter *iter, gint column, GValue *value)
-{
- GNode *node;
- MrpTask *task;
- MrpResource *resource;
- MrpAssignment *assign;
- gchar *str = NULL;
-
- g_return_if_fail (iter != NULL);
- node = iter->user_data;
- if (MRP_IS_ASSIGNMENT (node->data)) {
- assign = MRP_ASSIGNMENT (node->data);
- task = mrp_assignment_get_task (assign);
- resource = mrp_assignment_get_resource (assign);
- } else {
- if (MRP_IS_RESOURCE (node->data)) {
- resource = MRP_RESOURCE (node->data);
- assign = NULL;
- task = NULL;
- } else {
- resource = NULL;
- assign = NULL;
- task = NULL;
- g_warning ("Type mismatch (%s:%d)", __FILE__,
- __LINE__);
- }
- }
- g_assert (resource != NULL);
-
- switch (column) {
- case COL_RESNAME:
- g_object_get (resource, "name", &str, NULL);
- if (str == NULL) {
- str = g_strdup ("");
- }
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, str);
- g_free (str);
- break;
-
- case COL_TASKNAME:
- if (task) {
- g_object_get (task, "name", &str, NULL);
- }
- if (str == NULL) { /*Implicit: || task == NULL */
- str = g_strdup ("");
- }
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, str);
- g_free (str);
- break;
-
- case COL_RESOURCE:
- g_value_init (value, MRP_TYPE_RESOURCE);
- g_value_set_object (value, resource);
- break;
-
- case COL_ASSIGNMENT:
- g_value_init (value, MRP_TYPE_ASSIGNMENT);
- g_value_set_object (value, assign);
- break;
-
- default:
- g_warning ("Bad column %d requested", column);
- }
+ GtkTreeIter *iter, gint column, GValue *value)
+{
+ GNode *node;
+ MrpTask *task;
+ MrpResource *resource;
+ MrpAssignment *assign;
+ gchar *str = NULL;
+
+ g_return_if_fail (iter != NULL);
+ node = iter->user_data;
+ if (MRP_IS_ASSIGNMENT (node->data)) {
+ assign = MRP_ASSIGNMENT (node->data);
+ task = mrp_assignment_get_task (assign);
+ resource = mrp_assignment_get_resource (assign);
+ } else {
+ if (MRP_IS_RESOURCE (node->data)) {
+ resource = MRP_RESOURCE (node->data);
+ assign = NULL;
+ task = NULL;
+ } else {
+ resource = NULL;
+ assign = NULL;
+ task = NULL;
+ g_warning ("Type mismatch (%s:%d)", __FILE__,
+ __LINE__);
+ }
+ }
+ g_assert (resource != NULL);
+
+ switch (column) {
+ case COL_RESNAME:
+ g_object_get (resource, "name", &str, NULL);
+ if (str == NULL) {
+ str = g_strdup ("");
+ }
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, str);
+ g_free (str);
+ break;
+
+ case COL_TASKNAME:
+ if (task) {
+ g_object_get (task, "name", &str, NULL);
+ }
+ if (str == NULL) { /*Implicit: || task == NULL */
+ str = g_strdup ("");
+ }
+ g_value_init (value, G_TYPE_STRING);
+ g_value_set_string (value, str);
+ g_free (str);
+ break;
+
+ case COL_RESOURCE:
+ g_value_init (value, MRP_TYPE_RESOURCE);
+ g_value_set_object (value, resource);
+ break;
+
+ case COL_ASSIGNMENT:
+ g_value_init (value, MRP_TYPE_ASSIGNMENT);
+ g_value_set_object (value, assign);
+ break;
+
+ default:
+ g_warning ("Bad column %d requested", column);
+ }
}
static gboolean
usage_model_iter_next (GtkTreeModel *model, GtkTreeIter *iter)
{
- GNode *node, *next;
+ GNode *node, *next;
- node = iter->user_data;
+ node = iter->user_data;
- next = g_node_next_sibling (node);
+ next = g_node_next_sibling (node);
- if (next == NULL) {
- iter->user_data = NULL;
- return FALSE;
- }
+ if (next == NULL) {
+ iter->user_data = NULL;
+ return FALSE;
+ }
- iter->user_data = next;
- iter->stamp = PLANNER_USAGE_MODEL (model)->stamp;
- return TRUE;
+ iter->user_data = next;
+ iter->stamp = PLANNER_USAGE_MODEL (model)->stamp;
+ return TRUE;
}
static gboolean
usage_model_iter_children (GtkTreeModel *tree_model,
- GtkTreeIter *iter, GtkTreeIter *parent)
+ GtkTreeIter *iter, GtkTreeIter *parent)
{
- GNode *node, *child;
+ GNode *node, *child;
- if (parent) {
- node = parent->user_data;
- } else {
- node = PLANNER_USAGE_MODEL (tree_model)->priv->tree;
- }
+ if (parent) {
+ node = parent->user_data;
+ } else {
+ node = PLANNER_USAGE_MODEL (tree_model)->priv->tree;
+ }
- child = g_node_first_child (node);
+ child = g_node_first_child (node);
- if (child == NULL) {
- iter->user_data = NULL;
- return FALSE;
- }
+ if (child == NULL) {
+ iter->user_data = NULL;
+ return FALSE;
+ }
- iter->user_data = child;
- iter->stamp = PLANNER_USAGE_MODEL (tree_model)->stamp;
- return TRUE;
+ iter->user_data = child;
+ iter->stamp = PLANNER_USAGE_MODEL (tree_model)->stamp;
+ return TRUE;
}
static gboolean
usage_model_iter_has_child (GtkTreeModel *model, GtkTreeIter *iter)
{
- GNode *node;
- node = iter->user_data;
- return (g_node_n_children (node) > 0);
+ GNode *node;
+ node = iter->user_data;
+ return (g_node_n_children (node) > 0);
}
static gint
usage_model_iter_n_children (GtkTreeModel *tree_model, GtkTreeIter *iter)
{
- GNode *node;
- if (iter) {
- node = iter->user_data;
- } else {
- node = PLANNER_USAGE_MODEL (tree_model)->priv->tree;
- }
- return g_node_n_children (node);
+ GNode *node;
+ if (iter) {
+ node = iter->user_data;
+ } else {
+ node = PLANNER_USAGE_MODEL (tree_model)->priv->tree;
+ }
+ return g_node_n_children (node);
}
static gboolean
usage_model_iter_nth_child (GtkTreeModel *tree_model,
- GtkTreeIter *iter,
- GtkTreeIter *parent_iter, gint n)
-{
- PlannerUsageModel *model;
- GNode *parent;
- GNode *child;
-
- g_return_val_if_fail (parent_iter == NULL
- || parent_iter->user_data != NULL, FALSE);
-
- model = PLANNER_USAGE_MODEL (tree_model);
-
- if (parent_iter == NULL) {
- parent = model->priv->tree;
- } else {
- parent = parent_iter->user_data;
- }
- child = g_node_nth_child (parent, n);
- if (child) {
- iter->user_data = child;
- iter->stamp = model->stamp;
- return TRUE;
- } else {
- iter->user_data = NULL;
- return FALSE;
- }
+ GtkTreeIter *iter,
+ GtkTreeIter *parent_iter, gint n)
+{
+ PlannerUsageModel *model;
+ GNode *parent;
+ GNode *child;
+
+ g_return_val_if_fail (parent_iter == NULL
+ || parent_iter->user_data != NULL, FALSE);
+
+ model = PLANNER_USAGE_MODEL (tree_model);
+
+ if (parent_iter == NULL) {
+ parent = model->priv->tree;
+ } else {
+ parent = parent_iter->user_data;
+ }
+ child = g_node_nth_child (parent, n);
+ if (child) {
+ iter->user_data = child;
+ iter->stamp = model->stamp;
+ return TRUE;
+ } else {
+ iter->user_data = NULL;
+ return FALSE;
+ }
}
static gboolean
usage_model_iter_parent (GtkTreeModel *tree_model,
- GtkTreeIter *iter, GtkTreeIter *child)
-{
- GNode *node;
- GNode *parent;
- node = child->user_data;
- parent = node->parent;
- if (parent == NULL) {
- iter->user_data = NULL;
- return FALSE;
- } else {
- iter->user_data = parent;
- iter->stamp = PLANNER_USAGE_MODEL (tree_model)->stamp;
- return TRUE;
- }
+ GtkTreeIter *iter, GtkTreeIter *child)
+{
+ GNode *node;
+ GNode *parent;
+ node = child->user_data;
+ parent = node->parent;
+ if (parent == NULL) {
+ iter->user_data = NULL;
+ return FALSE;
+ } else {
+ iter->user_data = parent;
+ iter->stamp = PLANNER_USAGE_MODEL (tree_model)->stamp;
+ return TRUE;
+ }
}
static void
usage_model_tree_model_init (GtkTreeModelIface *iface)
{
- iface->get_n_columns = usage_model_get_n_columns;
- iface->get_column_type = usage_model_get_column_type;
- iface->get_iter = usage_model_get_iter;
- iface->get_path = usage_model_get_path;
- iface->get_value = usage_model_get_value;
- iface->iter_next = usage_model_iter_next;
- iface->iter_children = usage_model_iter_children;
- iface->iter_has_child = usage_model_iter_has_child;
- iface->iter_n_children = usage_model_iter_n_children;
- iface->iter_nth_child = usage_model_iter_nth_child;
- iface->iter_parent = usage_model_iter_parent;
+ iface->get_n_columns = usage_model_get_n_columns;
+ iface->get_column_type = usage_model_get_column_type;
+ iface->get_iter = usage_model_get_iter;
+ iface->get_path = usage_model_get_path;
+ iface->get_value = usage_model_get_value;
+ iface->iter_next = usage_model_iter_next;
+ iface->iter_children = usage_model_iter_children;
+ iface->iter_has_child = usage_model_iter_has_child;
+ iface->iter_n_children = usage_model_iter_n_children;
+ iface->iter_nth_child = usage_model_iter_nth_child;
+ iface->iter_parent = usage_model_iter_parent;
}
PlannerUsageModel *
planner_usage_model_new (MrpProject *project)
{
- PlannerUsageModel *model;
- PlannerUsageModelPriv *priv;
+ PlannerUsageModel *model;
+ PlannerUsageModelPriv *priv;
- GList *resources, *r;
- MrpResource *resource;
+ GList *resources, *r;
+ MrpResource *resource;
- model = PLANNER_USAGE_MODEL (g_object_new
- (PLANNER_TYPE_USAGE_MODEL, NULL));
- priv = model->priv;
- priv->in_new = TRUE;
+ model = PLANNER_USAGE_MODEL (g_object_new
+ (PLANNER_TYPE_USAGE_MODEL, NULL));
+ priv = model->priv;
+ priv->in_new = TRUE;
- priv->project = project;
+ priv->project = project;
- resources = mrp_project_get_resources (project);
+ resources = mrp_project_get_resources (project);
- priv->tree = g_node_new (NULL);
+ priv->tree = g_node_new (NULL);
- for (r = resources; r; r = r->next) {
- resource = r->data;
- usage_model_resource_added_cb (project, resource, model);
- }
+ for (r = resources; r; r = r->next) {
+ resource = r->data;
+ usage_model_resource_added_cb (project, resource, model);
+ }
- g_signal_connect_object (project,
- "resource_added",
- G_CALLBACK (usage_model_resource_added_cb),
- model, 0);
- g_signal_connect_object (project,
- "resource_removed",
- G_CALLBACK
- (usage_model_resource_removed_cb), model,
- 0);
- g_signal_connect_object (project, "task_inserted",
- G_CALLBACK (usage_model_task_added_cb),
- model, 0);
- g_signal_connect_object (project, "task_removed",
- G_CALLBACK (usage_model_task_removed_cb),
- model, 0);
+ g_signal_connect_object (project,
+ "resource_added",
+ G_CALLBACK (usage_model_resource_added_cb),
+ model, 0);
+ g_signal_connect_object (project,
+ "resource_removed",
+ G_CALLBACK
+ (usage_model_resource_removed_cb), model,
+ 0);
+ g_signal_connect_object (project, "task_inserted",
+ G_CALLBACK (usage_model_task_added_cb),
+ model, 0);
+ g_signal_connect_object (project, "task_removed",
+ G_CALLBACK (usage_model_task_removed_cb),
+ model, 0);
- priv->in_new = FALSE;
+ priv->in_new = FALSE;
- return model;
+ return model;
}
MrpAssignment *
planner_usage_model_get_assignment (PlannerUsageModel *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- MrpAssignment *assign;
+ MrpAssignment *assign;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
- assign = ((GNode *) iter->user_data)->data;
+ assign = ((GNode *) iter->user_data)->data;
- if (assign == NULL) {
- g_warning ("Eeek");
- return NULL;
- } else {
- if (MRP_IS_ASSIGNMENT (assign)) {
- return assign;
- } else {
- return NULL;
- }
- }
+ if (assign == NULL) {
+ g_warning ("Eeek");
+ return NULL;
+ } else {
+ if (MRP_IS_ASSIGNMENT (assign)) {
+ return assign;
+ } else {
+ return NULL;
+ }
+ }
}
MrpResource *
planner_usage_model_get_resource (PlannerUsageModel *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- MrpResource *res;
+ MrpResource *res;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
- res = ((GNode *) iter->user_data)->data;
+ res = ((GNode *) iter->user_data)->data;
- if (res == NULL) {
- g_warning ("Eeek");
- return NULL;
- } else {
- if (MRP_IS_RESOURCE (res)) {
- return res;
- } else {
- return NULL;
- }
- }
+ if (res == NULL) {
+ g_warning ("Eeek");
+ return NULL;
+ } else {
+ if (MRP_IS_RESOURCE (res)) {
+ return res;
+ } else {
+ return NULL;
+ }
+ }
}
gboolean
planner_usage_model_is_assignment (PlannerUsageModel *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
- return MRP_IS_ASSIGNMENT (((GNode *) iter->user_data)->data);
+ return MRP_IS_ASSIGNMENT (((GNode *) iter->user_data)->data);
}
gboolean
planner_usage_model_is_resource (PlannerUsageModel *model,
- GtkTreeIter *iter)
+ GtkTreeIter *iter)
{
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
- return MRP_IS_RESOURCE (((GNode *) iter->user_data)->data);
+ return MRP_IS_RESOURCE (((GNode *) iter->user_data)->data);
}
MrpAssignment *
planner_usage_model_path_get_assignment (PlannerUsageModel *model,
- GtkTreePath *path)
+ GtkTreePath *path)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- return planner_usage_model_get_assignment (model, &iter);
+ return planner_usage_model_get_assignment (model, &iter);
}
MrpResource *
planner_usage_model_path_get_resource (PlannerUsageModel *model,
- GtkTreePath *path)
+ GtkTreePath *path)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), NULL);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- return planner_usage_model_get_resource (model, &iter);
+ return planner_usage_model_get_resource (model, &iter);
}
gboolean
planner_usage_model_path_is_resource (PlannerUsageModel *model,
- GtkTreePath *path)
+ GtkTreePath *path)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- return planner_usage_model_is_resource (model, &iter);
+ return planner_usage_model_is_resource (model, &iter);
}
gboolean
planner_usage_model_path_is_assignment (PlannerUsageModel *model,
- GtkTreePath *path)
+ GtkTreePath *path)
{
- GtkTreeIter iter;
+ GtkTreeIter iter;
- g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
+ g_return_val_if_fail (PLANNER_IS_USAGE_MODEL (model), FALSE);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- return planner_usage_model_is_assignment (model, &iter);
+ return planner_usage_model_is_assignment (model, &iter);
}
static void
usage_model_resource_assignment_added_cb (MrpResource *res,
- MrpAssignment *assign,
- PlannerUsageModel *model)
+ MrpAssignment *assign,
+ PlannerUsageModel *model)
{
- PlannerUsageModelPriv *priv;
- GNode *res_node;
- GNode *assign_node;
- GtkTreePath *path;
- GtkTreeIter iter;
+ PlannerUsageModelPriv *priv;
+ GNode *res_node;
+ GNode *assign_node;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- priv = model->priv;
+ priv = model->priv;
- res_node = g_hash_table_lookup (model->priv->resource2node, res);
- assign_node = g_node_new (assign);
- g_node_append (res_node, assign_node);
- g_hash_table_insert (model->priv->assign2node, assign, assign_node);
+ res_node = g_hash_table_lookup (model->priv->resource2node, res);
+ assign_node = g_node_new (assign);
+ g_node_append (res_node, assign_node);
+ g_hash_table_insert (model->priv->assign2node, assign, assign_node);
- path = usage_model_get_path_from_node (model, assign_node);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
+ path = usage_model_get_path_from_node (model, assign_node);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
- if (g_node_n_children (res_node) == 1) {
- path = usage_model_get_path_from_node (model, res_node);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model),
- path, &iter);
- gtk_tree_path_free (path);
- }
+ if (g_node_n_children (res_node) == 1) {
+ path = usage_model_get_path_from_node (model, res_node);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model),
+ path, &iter);
+ gtk_tree_path_free (path);
+ }
}
static void
usage_model_resource_assignment_removed_cb (MrpResource *res,
- MrpAssignment *assign,
- PlannerUsageModel *model)
+ MrpAssignment *assign,
+ PlannerUsageModel *model)
{
- GNode *res_node;
- GNode *assign_node;
- GtkTreePath *path;
- GtkTreeIter iter;
+ GNode *res_node;
+ GNode *assign_node;
+ GtkTreePath *path;
+ GtkTreeIter iter;
- res_node = g_hash_table_lookup (model->priv->resource2node, res);
- assign_node = g_hash_table_lookup (model->priv->assign2node, assign);
+ res_node = g_hash_table_lookup (model->priv->resource2node, res);
+ assign_node = g_hash_table_lookup (model->priv->assign2node, assign);
- path = usage_model_get_path_from_node (model, assign_node);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ path = usage_model_get_path_from_node (model, assign_node);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- g_hash_table_remove (model->priv->assign2node, assign);
- g_node_unlink (assign_node);
- g_node_destroy (assign_node);
+ g_hash_table_remove (model->priv->assign2node, assign);
+ g_node_unlink (assign_node);
+ g_node_destroy (assign_node);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
+ gtk_tree_path_free (path);
- if (g_node_n_children (res_node) == 0) {
- path = usage_model_get_path_from_node (model, res_node);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model),
- path, &iter);
- gtk_tree_path_free (path);
- }
+ if (g_node_n_children (res_node) == 0) {
+ path = usage_model_get_path_from_node (model, res_node);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (model),
+ path, &iter);
+ gtk_tree_path_free (path);
+ }
}
static void
usage_model_resource_added_cb (MrpProject *project,
- MrpResource *resource,
- PlannerUsageModel *model)
-{
- PlannerUsageModelPriv *priv;
- GList *tasks, *t;
- GNode *rnode;
- MrpAssignment *assign;
- GtkTreePath *path;
- GtkTreeIter iter;
-
- priv = model->priv;
-
- g_signal_connect_object (resource,
- "assignment_added",
- G_CALLBACK
- (usage_model_resource_assignment_added_cb),
- model, 0);
- g_signal_connect_object (resource, "assignment_removed",
- G_CALLBACK
- (usage_model_resource_assignment_removed_cb),
- model, 0);
- rnode = g_node_new (resource);
- g_node_append (priv->tree, rnode);
- g_hash_table_insert (priv->resource2node, resource, rnode);
-
- path = usage_model_get_path_from_node (model, rnode);
- usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
- gtk_tree_path_free (path);
-
- tasks = mrp_resource_get_assignments (resource);
- for (t = tasks; t; t = t->next) {
- assign = MRP_ASSIGNMENT (t->data);
- usage_model_resource_assignment_added_cb (resource, assign,
- model);
- /*
- *tnode = g_node_new(assign);
- *g_node_append(rnode,tnode);
- *g_hash_table_insert (priv->assign2node, assign, tnode);
- *
- *path = usage_model_get_path
- */
- }
+ MrpResource *resource,
+ PlannerUsageModel *model)
+{
+ PlannerUsageModelPriv *priv;
+ GList *tasks, *t;
+ GNode *rnode;
+ MrpAssignment *assign;
+ GtkTreePath *path;
+ GtkTreeIter iter;
+
+ priv = model->priv;
+
+ g_signal_connect_object (resource,
+ "assignment_added",
+ G_CALLBACK
+ (usage_model_resource_assignment_added_cb),
+ model, 0);
+ g_signal_connect_object (resource, "assignment_removed",
+ G_CALLBACK
+ (usage_model_resource_assignment_removed_cb),
+ model, 0);
+ rnode = g_node_new (resource);
+ g_node_append (priv->tree, rnode);
+ g_hash_table_insert (priv->resource2node, resource, rnode);
+
+ path = usage_model_get_path_from_node (model, rnode);
+ usage_model_get_iter (GTK_TREE_MODEL (model), &iter, path);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (model), path, &iter);
+ gtk_tree_path_free (path);
+
+ tasks = mrp_resource_get_assignments (resource);
+ for (t = tasks; t; t = t->next) {
+ assign = MRP_ASSIGNMENT (t->data);
+ usage_model_resource_assignment_added_cb (resource, assign,
+ model);
+ /*
+ *tnode = g_node_new(assign);
+ *g_node_append(rnode,tnode);
+ *g_hash_table_insert (priv->assign2node, assign, tnode);
+ *
+ *path = usage_model_get_path
+ */
+ }
}
static void
usage_model_resource_removed_cb (MrpProject *project,
- MrpResource *resource,
- PlannerUsageModel *model)
-{
- PlannerUsageModelPriv *priv;
- GNode *node;
- GtkTreePath *path;
- /*GtkTreeIter iter; */
-
- priv = model->priv;
-
- g_signal_handlers_disconnect_by_func (resource,
- usage_model_resource_assignment_added_cb,
- model);
- g_signal_handlers_disconnect_by_func (resource,
- usage_model_resource_assignment_removed_cb,
- model);
-
- /*
- *Look the resource in the tree
- */
- node = g_hash_table_lookup (priv->resource2node, resource);
- g_hash_table_remove (priv->resource2node, resource);
-
- /*
- *Remove the resource.
- */
- path = usage_model_get_path_from_node (model, node);
- g_node_destroy (node);
- /*usage_model_get_iter(GTK_TREE_MODEL(model),&iter,path); */
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
- gtk_tree_path_free (path);
+ MrpResource *resource,
+ PlannerUsageModel *model)
+{
+ PlannerUsageModelPriv *priv;
+ GNode *node;
+ GtkTreePath *path;
+ /*GtkTreeIter iter; */
+
+ priv = model->priv;
+
+ g_signal_handlers_disconnect_by_func (resource,
+ usage_model_resource_assignment_added_cb,
+ model);
+ g_signal_handlers_disconnect_by_func (resource,
+ usage_model_resource_assignment_removed_cb,
+ model);
+
+ /*
+ *Look the resource in the tree
+ */
+ node = g_hash_table_lookup (priv->resource2node, resource);
+ g_hash_table_remove (priv->resource2node, resource);
+
+ /*
+ *Remove the resource.
+ */
+ path = usage_model_get_path_from_node (model, node);
+ g_node_destroy (node);
+ /*usage_model_get_iter(GTK_TREE_MODEL(model),&iter,path); */
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
+ gtk_tree_path_free (path);
}
static void
usage_model_task_added_cb (MrpProject *project,
- MrpTask *task, PlannerUsageModel *model)
+ MrpTask *task, PlannerUsageModel *model)
{
- g_signal_emit (model, signals[TASK_ADDED], 0, task);
+ g_signal_emit (model, signals[TASK_ADDED], 0, task);
}
static void
usage_model_task_removed_cb (MrpProject *project,
- MrpTask *task, PlannerUsageModel *model)
+ MrpTask *task, PlannerUsageModel *model)
{
- g_signal_emit (model, signals[TASK_REMOVED], 0, task);
+ g_signal_emit (model, signals[TASK_REMOVED], 0, task);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]