~ubuntu-branches/ubuntu/wily/baobab/wily-proposed

« back to all changes in this revision

Viewing changes to src/baobab-chart.c

  • Committer: Package Import Robot
  • Author(s): Jackson Doak
  • Date: 2014-10-15 23:15:13 UTC
  • mfrom: (2.2.1 experimental) (2.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20141015231513-6cpun88orgfpyzdv
Tags: 3.14.1-1ubuntu1
* Merge from Debian unstable. (LP: #1268721) Remaining changes:
* debian/patches/use_traditional_titlebars_in_unity.patch:
  - Use the traditional menubar under Unity
* debian/patches/git_fix_pie_chart.patch:
  - Fx top level pie chart. (LP: #1393333)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * baobab-chart.c
 
1
/* baobab-chart.c generated by valac 0.26.0.7-2832, the Vala compiler
 
2
 * generated from baobab-chart.vala, do not modify */
 
3
 
 
4
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 
5
/* Baobab - disk usage analyzer
3
6
 *
4
 
 * Copyright (C) 2006, 2007, 2008 Igalia
 
7
 * Copyright (C) 2006, 2007, 2008  Igalia
 
8
 * Copyright (C) 2013  Stefano Facchini <stefano.facchini@gmail.com>
5
9
 *
6
10
 * This program is free software; you can redistribute it and/or modify
7
11
 * it under the terms of the GNU General Public License as published by
18
22
 * Foundation, Inc., 51 Franklin St, Fifth Floor,
19
23
 * Boston, MA  02110-1301  USA
20
24
 *
21
 
 * Authors:
 
25
 * Authors of the original code:
22
26
 *   Felipe Erias <femorandeira@igalia.com>
23
27
 *   Pablo Santamaria <psantamaria@igalia.com>
24
28
 *   Jacobo Aragunde <jaragunde@igalia.com>
31
35
 *   Alejandro Garcia <alex@igalia.com>
32
36
 */
33
37
 
34
 
#ifdef HAVE_CONFIG_H
35
 
#include <config.h>
36
 
#endif
37
 
 
38
 
#include <glib/gi18n.h>
 
38
#include <glib.h>
 
39
#include <glib-object.h>
 
40
#include <stdlib.h>
 
41
#include <string.h>
 
42
#include <float.h>
 
43
#include <math.h>
39
44
#include <gtk/gtk.h>
40
 
#include "baobab-chart.h"
41
 
 
42
 
G_DEFINE_ABSTRACT_TYPE (BaobabChart, baobab_chart, GTK_TYPE_WIDGET);
43
 
 
44
 
#define BAOBAB_CHART_MAX_DEPTH 8
45
 
#define BAOBAB_CHART_MIN_DEPTH 1
46
 
 
47
 
struct _BaobabChartPrivate
48
 
{
49
 
  guint name_column;
50
 
  guint size_column;
51
 
  guint info_column;
52
 
  guint percentage_column;
53
 
  guint valid_column;
54
 
  gboolean button_pressed;
55
 
  gboolean is_frozen;
56
 
  cairo_surface_t *memento;
57
 
 
58
 
  guint max_depth;
59
 
  gboolean model_changed;
60
 
 
61
 
  GtkTreeModel *model;
62
 
  GtkTreeRowReference *root;
63
 
 
64
 
  GList *first_item;
65
 
  GList *last_item;
66
 
  GList *highlighted_item;
67
 
 
68
 
  GtkWidget *popup_menu;
69
 
};
70
 
 
71
 
/* Signals */
72
 
enum
73
 
{
74
 
  ITEM_ACTIVATED,
75
 
  LAST_SIGNAL
76
 
};
77
 
 
78
 
static guint baobab_chart_signals [LAST_SIGNAL] = { 0 };
79
 
 
80
 
/* Properties */
81
 
enum
82
 
{
83
 
  PROP_0,
84
 
  PROP_MAX_DEPTH,
85
 
  PROP_MODEL,
86
 
  PROP_ROOT,
87
 
};
88
 
 
89
 
/* Colors */
90
 
const BaobabChartColor baobab_chart_tango_colors[] = {{0.94, 0.16, 0.16}, /* tango: ef2929 */
91
 
                                                      {0.68, 0.49, 0.66}, /* tango: ad7fa8 */
92
 
                                                      {0.45, 0.62, 0.82}, /* tango: 729fcf */
93
 
                                                      {0.54, 0.89, 0.20}, /* tango: 8ae234 */
94
 
                                                      {0.91, 0.73, 0.43}, /* tango: e9b96e */
95
 
                                                      {0.99, 0.68, 0.25}}; /* tango: fcaf3e */
96
 
 
97
 
static void baobab_chart_class_init (BaobabChartClass *class);
98
 
static void baobab_chart_init (BaobabChart *object);
99
 
static void baobab_chart_realize (GtkWidget *widget);
100
 
static void baobab_chart_unrealize (GtkWidget *widget);
101
 
static void baobab_chart_dispose (GObject *object);
102
 
static void baobab_chart_size_allocate (GtkWidget *widget,
103
 
                                        GtkAllocation *allocation);
104
 
static void baobab_chart_set_property (GObject *object,
105
 
                                       guint prop_id,
106
 
                                       const GValue *value,
107
 
                                       GParamSpec *pspec);
108
 
static void baobab_chart_get_property (GObject *object,
109
 
                                       guint prop_id,
110
 
                                       GValue *value,
111
 
                                       GParamSpec *pspec);
112
 
static void baobab_chart_free_items (BaobabChart *chart);
113
 
static void baobab_chart_draw_chart (BaobabChart *chart,
114
 
                                     cairo_t *cr);
115
 
static void baobab_chart_update_draw (BaobabChart *chart,
116
 
                                      GtkTreePath *path);
117
 
static gboolean baobab_chart_draw (GtkWidget *chart,
118
 
                                   cairo_t *cr);
119
 
static void baobab_chart_interpolate_colors (BaobabChartColor *color,
120
 
                                             BaobabChartColor colora,
121
 
                                             BaobabChartColor colorb,
122
 
                                             gdouble percentage);
123
 
static gint baobab_chart_button_press_event (GtkWidget      *widget,
124
 
                                             GdkEventButton *event);
125
 
static gboolean baobab_chart_popup_menu (GtkWidget *widget);
126
 
static gint baobab_chart_scroll (GtkWidget *widget,
127
 
                                 GdkEventScroll *event);
128
 
static gint baobab_chart_motion_notify (GtkWidget *widget,
129
 
                                        GdkEventMotion *event);
130
 
static gint baobab_chart_leave_notify (GtkWidget *widget,
131
 
                                       GdkEventCrossing *event);
132
 
static void baobab_chart_disconnect_signals (BaobabChart *chart,
133
 
                                             GtkTreeModel *model);
134
 
static void baobab_chart_connect_signals (BaobabChart *chart,
135
 
                                          GtkTreeModel *model);
136
 
static void baobab_chart_get_items (BaobabChart *chart, GtkTreePath *root);
137
 
static gboolean baobab_chart_query_tooltip (GtkWidget  *widget,
138
 
                                            gint        x,
139
 
                                            gint        y,
140
 
                                            gboolean    keyboard_mode,
141
 
                                            GtkTooltip *tooltip,
142
 
                                            gpointer    user_data);
143
 
static void baobab_chart_item_activated (BaobabChart *chart,
144
 
                                         GtkTreeIter *iter);
145
 
 
146
 
 
147
 
static void
148
 
baobab_chart_class_init (BaobabChartClass *class)
149
 
{
150
 
  GObjectClass *obj_class;
151
 
  GtkWidgetClass *widget_class;
152
 
 
153
 
  obj_class = G_OBJECT_CLASS (class);
154
 
  widget_class = GTK_WIDGET_CLASS (class);
155
 
 
156
 
  /* GtkObject signals */
157
 
  obj_class->set_property = baobab_chart_set_property;
158
 
  obj_class->get_property = baobab_chart_get_property;
159
 
  obj_class->dispose = baobab_chart_dispose;
160
 
 
161
 
  /* GtkWidget signals */
162
 
  widget_class->realize = baobab_chart_realize;
163
 
  widget_class->unrealize = baobab_chart_unrealize;
164
 
  widget_class->draw = baobab_chart_draw;
165
 
  widget_class->size_allocate = baobab_chart_size_allocate;
166
 
  widget_class->button_press_event = baobab_chart_button_press_event;
167
 
  widget_class->popup_menu = baobab_chart_popup_menu;
168
 
  widget_class->scroll_event = baobab_chart_scroll;
169
 
 
170
 
  /* BaobabChart signals */
171
 
  class->item_activated = baobab_chart_item_activated;
172
 
 
173
 
  /* BaobabChart abstract methods */
174
 
  class->draw_item               = NULL;
175
 
  class->pre_draw                = NULL;
176
 
  class->post_draw               = NULL;
177
 
  class->calculate_item_geometry = NULL;
178
 
  class->is_point_over_item      = NULL;
179
 
  class->get_item_rectangle      = NULL;
180
 
  class->can_zoom_in             = NULL;
181
 
  class->can_zoom_out            = NULL;
182
 
 
183
 
  g_object_class_install_property (obj_class,
184
 
                                   PROP_MAX_DEPTH,
185
 
                                   g_param_spec_int ("max-depth",
186
 
                                   _("Maximum depth"),
187
 
                                   _("The maximum depth drawn in the chart from the root"),
188
 
                                   1,
189
 
                                   BAOBAB_CHART_MAX_DEPTH,
190
 
                                   BAOBAB_CHART_MAX_DEPTH,
191
 
                                   G_PARAM_READWRITE));
192
 
 
193
 
  g_object_class_install_property (obj_class,
194
 
                                   PROP_MODEL,
195
 
                                   g_param_spec_object ("model",
196
 
                                   _("Chart model"),
197
 
                                   _("Set the model of the chart"),
198
 
                                   GTK_TYPE_TREE_MODEL,
199
 
                                   G_PARAM_READWRITE));
200
 
 
201
 
  g_object_class_install_property (obj_class,
202
 
                                   PROP_ROOT,
203
 
                                   g_param_spec_boxed ("root",
204
 
                                   _("Chart root node"),
205
 
                                   _("Set the root node from the model"),
206
 
                                   GTK_TYPE_TREE_ITER,
207
 
                                   G_PARAM_READWRITE));
208
 
 
209
 
  baobab_chart_signals[ITEM_ACTIVATED] =
210
 
    g_signal_new ("item-activated",
211
 
          G_TYPE_FROM_CLASS (obj_class),
212
 
          G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
213
 
          G_STRUCT_OFFSET (BaobabChartClass, item_activated),
214
 
          NULL, NULL,
215
 
          g_cclosure_marshal_VOID__BOXED,
216
 
          G_TYPE_NONE, 1,
217
 
          GTK_TYPE_TREE_ITER);
218
 
 
219
 
  g_type_class_add_private (obj_class, sizeof (BaobabChartPrivate));
220
 
}
221
 
 
222
 
static void
223
 
baobab_chart_init (BaobabChart *chart)
224
 
{
225
 
  chart->priv = G_TYPE_INSTANCE_GET_PRIVATE (chart, BAOBAB_TYPE_CHART, BaobabChartPrivate);
226
 
 
227
 
  chart->priv->model = NULL;
228
 
  chart->priv->max_depth = BAOBAB_CHART_MAX_DEPTH;
229
 
  chart->priv->name_column = 0;
230
 
  chart->priv->size_column = 0;
231
 
  chart->priv->info_column = 0;
232
 
  chart->priv->percentage_column = 0;
233
 
  chart->priv->valid_column = 0;
234
 
  chart->priv->button_pressed = FALSE;
235
 
  chart->priv->is_frozen = FALSE;
236
 
  chart->priv->memento = NULL;
237
 
  chart->priv->root = NULL;
238
 
 
239
 
  chart->priv->first_item = NULL;
240
 
  chart->priv->last_item = NULL;
241
 
  chart->priv->highlighted_item = NULL;
242
 
}
243
 
 
244
 
static void
245
 
baobab_chart_dispose (GObject *object)
246
 
{
247
 
  BaobabChart *chart;
248
 
 
249
 
  chart = BAOBAB_CHART (object);
250
 
 
251
 
  baobab_chart_free_items (chart);
252
 
 
253
 
  if (chart->priv->model)
254
 
    {
255
 
      baobab_chart_disconnect_signals (chart, chart->priv->model);
256
 
      g_object_unref (chart->priv->model);
257
 
      chart->priv->model = NULL;
258
 
    }
259
 
 
260
 
  if (chart->priv->root)
261
 
    {
262
 
      gtk_tree_row_reference_free (chart->priv->root);
263
 
      chart->priv->root = NULL;
264
 
    }
265
 
 
266
 
  G_OBJECT_CLASS (baobab_chart_parent_class)->dispose (object);
267
 
}
268
 
 
269
 
static void
270
 
baobab_chart_realize (GtkWidget *widget)
271
 
{
272
 
  BaobabChart *chart;
273
 
  GdkWindowAttr attributes;
274
 
  gint attributes_mask;
275
 
  GtkAllocation allocation;
276
 
  GdkWindow *window;
277
 
  GtkStyleContext *context;
278
 
 
279
 
  g_return_if_fail (BAOBAB_IS_CHART (widget));
280
 
 
281
 
  chart = BAOBAB_CHART (widget);
282
 
  gtk_widget_set_realized (widget, TRUE);
283
 
 
284
 
  gtk_widget_get_allocation (widget, &allocation);
285
 
 
286
 
  attributes.window_type = GDK_WINDOW_CHILD;
287
 
  attributes.x = allocation.x;
288
 
  attributes.y = allocation.y;
289
 
  attributes.width = allocation.width;
290
 
  attributes.height = allocation.height;
291
 
  attributes.wclass = GDK_INPUT_OUTPUT;
292
 
  attributes.visual = gtk_widget_get_visual (widget);
293
 
  attributes.event_mask = gtk_widget_get_events (widget);
294
 
 
295
 
  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
296
 
 
297
 
  window = gdk_window_new (gtk_widget_get_parent_window (widget),
298
 
                           &attributes,
299
 
                           attributes_mask);
300
 
  gtk_widget_set_window (widget, window);
301
 
  gdk_window_set_user_data (window, chart);
302
 
 
303
 
  context = gtk_widget_get_style_context (widget);
304
 
  gtk_style_context_set_background (context, window);
305
 
 
306
 
  gtk_widget_add_events (widget,
307
 
                         GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
308
 
                         GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK |
309
 
                         GDK_POINTER_MOTION_HINT_MASK | GDK_LEAVE_NOTIFY_MASK |
310
 
                         GDK_SCROLL_MASK);
311
 
}
312
 
 
313
 
static void
314
 
baobab_chart_unrealize (GtkWidget *widget)
315
 
{
316
 
  BaobabChart *chart;
317
 
 
318
 
  chart = BAOBAB_CHART (widget);
319
 
 
320
 
  if (chart->priv->popup_menu)
321
 
    {
322
 
      gtk_widget_destroy (chart->priv->popup_menu);
323
 
      chart->priv->popup_menu = NULL;
324
 
    }
325
 
 
326
 
  GTK_WIDGET_CLASS (baobab_chart_parent_class)->unrealize (widget);
327
 
}
328
 
 
329
 
static void
330
 
baobab_chart_size_allocate (GtkWidget     *widget,
331
 
                            GtkAllocation *allocation)
332
 
{
333
 
  BaobabChart *chart;
334
 
  BaobabChartClass *class;
335
 
 
336
 
  g_return_if_fail (BAOBAB_IS_CHART (widget));
337
 
  g_return_if_fail (allocation != NULL);
338
 
 
339
 
  chart = BAOBAB_CHART (widget);
340
 
  class = BAOBAB_CHART_GET_CLASS (chart);
341
 
 
342
 
  gtk_widget_set_allocation (widget, allocation);
343
 
 
344
 
  if (gtk_widget_get_realized (widget))
345
 
    {
346
 
      GList *node;
347
 
 
348
 
      gdk_window_move_resize (gtk_widget_get_window (widget),
349
 
                              allocation->x, allocation->y,
350
 
                              allocation->width, allocation->height);
351
 
 
352
 
      for (node = chart->priv->first_item; node != NULL; node = node->next)
353
 
        {
354
 
          BaobabChartItem *item;
355
 
 
356
 
          item = (BaobabChartItem *) node->data;
357
 
          item->has_visible_children = FALSE;
358
 
          item->visible = FALSE;
359
 
          class->calculate_item_geometry (chart, item);
360
 
        }
361
 
    }
362
 
}
363
 
 
364
 
static void
365
 
baobab_chart_set_property (GObject         *object,
366
 
                           guint            prop_id,
367
 
                           const GValue    *value,
368
 
                           GParamSpec      *pspec)
369
 
{
370
 
  BaobabChart *chart = BAOBAB_CHART (object);
371
 
 
372
 
  switch (prop_id)
373
 
    {
374
 
    case PROP_MAX_DEPTH:
375
 
      baobab_chart_set_max_depth (chart, g_value_get_int (value));
376
 
      break;
377
 
    case PROP_MODEL:
378
 
      baobab_chart_set_model (chart, g_value_get_object (value));
379
 
      break;
380
 
    case PROP_ROOT:
381
 
      baobab_chart_set_root (chart, g_value_get_object (value));
382
 
      break;
383
 
    default:
384
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
385
 
      break;
386
 
    }
387
 
}
388
 
 
389
 
static void
390
 
baobab_chart_get_property (GObject    *object,
391
 
                           guint       prop_id,
392
 
                           GValue     *value,
393
 
                           GParamSpec *pspec)
394
 
{
395
 
  BaobabChart *chart = BAOBAB_CHART (object);
396
 
 
397
 
  switch (prop_id)
398
 
    {
399
 
    case PROP_MAX_DEPTH:
400
 
      g_value_set_int (value, chart->priv->max_depth);
401
 
      break;
402
 
    case PROP_MODEL:
403
 
      g_value_set_object (value, chart->priv->model);
404
 
      break;
405
 
    case PROP_ROOT:
406
 
      g_value_set_object (value, chart->priv->root);
407
 
      break;
408
 
    default:
409
 
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
410
 
      break;
411
 
    }
412
 
}
413
 
 
414
 
static GList *
415
 
baobab_chart_add_item (BaobabChart *chart,
416
 
                       guint        depth,
417
 
                       gdouble      rel_start,
418
 
                       gdouble      rel_size,
419
 
                       GtkTreeIter  iter)
420
 
{
421
 
  BaobabChartItem *item;
422
 
  gchar *name;
423
 
  guint64 size;
424
 
 
425
 
  gtk_tree_model_get (chart->priv->model, &iter,
426
 
                      chart->priv->name_column, &name,
427
 
                      chart->priv->size_column, &size,
428
 
                      -1);
429
 
 
430
 
  item = g_new (BaobabChartItem, 1);
431
 
  item->name = name;
432
 
  item->size = g_format_size (size);
433
 
  item->depth = depth;
434
 
  item->rel_start = rel_start;
435
 
  item->rel_size = rel_size;
436
 
  item->has_any_child = FALSE;
437
 
  item->visible = FALSE;
438
 
  item->has_visible_children = FALSE;
439
 
 
440
 
  item->iter = iter;
441
 
 
442
 
  item->parent = NULL;
443
 
  item->data = NULL;
444
 
 
445
 
  chart->priv->last_item = g_list_prepend (chart->priv->last_item, item);
446
 
 
447
 
  return chart->priv->last_item;
448
 
}
449
 
 
450
 
static void
451
 
baobab_chart_free_items (BaobabChart *chart)
452
 
{
453
 
  BaobabChartItem *item;
454
 
  GList *node;
455
 
  GList *next;
456
 
 
457
 
  node = chart->priv->first_item;
458
 
 
459
 
  while (node != NULL)
460
 
    {
461
 
      next = node->next;
462
 
 
463
 
      item = (BaobabChartItem *) node->data;
464
 
 
465
 
      g_free (item->name);
466
 
      g_free (item->size);
467
 
 
468
 
      g_free (item->data);
469
 
      item->data = NULL;
470
 
 
471
 
      g_free (item);
472
 
      g_list_free_1 (node);
473
 
 
474
 
      node = next;
475
 
    }
476
 
 
477
 
  chart->priv->first_item = NULL;
478
 
  chart->priv->last_item = NULL;
479
 
  chart->priv->highlighted_item = NULL;
480
 
}
481
 
 
482
 
static void
483
 
baobab_chart_get_items (BaobabChart *chart,
484
 
                        GtkTreePath *root)
485
 
{
486
 
  GList *node;
487
 
  GtkTreeIter initial_iter = {0};
488
 
  gdouble size;
489
 
  GtkTreePath *model_root_path;
490
 
  GtkTreeIter model_root_iter;
491
 
  BaobabChartClass *class;
492
 
  GtkTreeIter child_iter = {0};
493
 
  GList *child_node;
494
 
  BaobabChartItem *child;
495
 
  gdouble rel_start;
496
 
 
497
 
  /* First we free current item list */
498
 
  baobab_chart_free_items (chart);
499
 
 
500
 
  /* Get the tree iteration corresponding to root */
501
 
  if (!gtk_tree_model_get_iter (chart->priv->model, &initial_iter, root))
502
 
    {
503
 
      chart->priv->model_changed = FALSE;
504
 
      return;
505
 
    }
506
 
 
507
 
  model_root_path = gtk_tree_path_new_first ();
508
 
  gtk_tree_model_get_iter (chart->priv->model, &model_root_iter, model_root_path);
509
 
  gtk_tree_path_free (model_root_path);
510
 
 
511
 
  gtk_tree_model_get (chart->priv->model, &model_root_iter,
512
 
                      chart->priv->percentage_column, &size, -1);
513
 
 
514
 
  /* Create first item */
515
 
  node = baobab_chart_add_item (chart, 0, 0, 100, initial_iter);
516
 
 
517
 
  /* Iterate through childs building the list */
518
 
  class = BAOBAB_CHART_GET_CLASS (chart);
519
 
 
520
 
  do
521
 
    {
522
 
      BaobabChartItem *item;
523
 
 
524
 
      item = (BaobabChartItem *) node->data;
525
 
      item->has_any_child = gtk_tree_model_iter_children (chart->priv->model, &child_iter, &(item->iter));
526
 
 
527
 
      /* Calculate item geometry */
528
 
      class->calculate_item_geometry (chart, item);
529
 
 
530
 
      if (!item->visible)
531
 
        {
532
 
          node = node->prev;
533
 
          continue;
534
 
        }
535
 
 
536
 
      /* Get item's children and add them to the list */
537
 
      if ((item->has_any_child) && (item->depth < chart->priv->max_depth + 1))
538
 
        {
539
 
          rel_start = 0;
540
 
 
541
 
          do
542
 
            {
543
 
              gtk_tree_model_get (chart->priv->model, &child_iter, chart->priv->percentage_column, &size, -1);
544
 
 
545
 
              child_node = baobab_chart_add_item (chart,
546
 
                                                  item->depth + 1,
547
 
                                                  rel_start,
548
 
                                                  size,
549
 
                                                  child_iter);
550
 
              child = (BaobabChartItem *) child_node->data;
551
 
              child->parent = node;
552
 
              rel_start += size;
553
 
            }
554
 
          while (gtk_tree_model_iter_next (chart->priv->model, &child_iter));
555
 
        }
556
 
 
557
 
      node = node->prev;
558
 
    }
559
 
  while (node != NULL);
560
 
 
561
 
  /* Reverse the list, 'cause we created it from the tail, for efficiency reasons */
562
 
  chart->priv->first_item = g_list_reverse (chart->priv->last_item);
563
 
 
564
 
  chart->priv->model_changed = FALSE;
565
 
}
566
 
 
567
 
static void
568
 
baobab_chart_draw_chart (BaobabChart *chart,
569
 
                         cairo_t     *cr)
570
 
{
571
 
  BaobabChartClass *class;
572
 
  GList *node;
573
 
 
574
 
  class = BAOBAB_CHART_GET_CLASS (chart);
575
 
 
576
 
  /* call pre-draw abstract method */
577
 
  if (class->pre_draw)
578
 
    class->pre_draw (chart, cr);
579
 
 
580
 
  cairo_save (cr);
581
 
 
582
 
  for (node = chart->priv->first_item; node != NULL; node = node->next)
583
 
    {
584
 
      BaobabChartItem *item;
585
 
      GdkRectangle clip;
586
 
 
587
 
      item = (BaobabChartItem *) node->data;
588
 
 
589
 
      if (gdk_cairo_get_clip_rectangle (cr, &clip) &&
590
 
          (item->visible) &&
591
 
          (gdk_rectangle_intersect (&clip, &item->rect, NULL)) &&
592
 
          (item->depth <= chart->priv->max_depth))
593
 
        {
594
 
          gboolean highlighted;
595
 
 
596
 
          highlighted = (node == chart->priv->highlighted_item);
597
 
          class->draw_item (chart, cr, item, highlighted);
598
 
        }
599
 
    }
600
 
 
601
 
  cairo_restore (cr);
602
 
 
603
 
  /* call post-draw abstract method */
604
 
  if (class->post_draw)
605
 
    class->post_draw (chart, cr);
606
 
}
607
 
 
608
 
static void
609
 
baobab_chart_update_draw (BaobabChart* chart,
610
 
                          GtkTreePath *path)
611
 
{
612
 
  GtkTreePath *root_path = NULL;
613
 
  gint root_depth, node_depth;
614
 
 
615
 
  if (!gtk_widget_get_realized ( GTK_WIDGET (chart)))
616
 
    return;
617
 
 
618
 
  if (chart->priv->root != NULL)
619
 
    {
620
 
      root_path = gtk_tree_row_reference_get_path (chart->priv->root);
621
 
 
622
 
      if (root_path == NULL)
623
 
        {
624
 
          gtk_tree_row_reference_free (chart->priv->root);
625
 
          chart->priv->root = NULL;
626
 
        }
627
 
    }
628
 
 
629
 
  if (chart->priv->root == NULL)
630
 
    root_path = gtk_tree_path_new_first ();
631
 
 
632
 
  root_depth = gtk_tree_path_get_depth (root_path);
633
 
  node_depth = gtk_tree_path_get_depth (path);
634
 
 
635
 
  if (((node_depth-root_depth)<=chart->priv->max_depth)&&
636
 
      ((gtk_tree_path_is_ancestor (root_path, path))||
637
 
       (gtk_tree_path_compare (root_path, path) == 0)))
638
 
    {
639
 
      gtk_widget_queue_draw (GTK_WIDGET (chart));
640
 
    }
641
 
 
642
 
  gtk_tree_path_free (root_path);
643
 
}
644
 
 
645
 
static void
646
 
baobab_chart_row_changed (GtkTreeModel *model,
647
 
                          GtkTreePath  *path,
648
 
                          GtkTreeIter  *iter,
649
 
                          BaobabChart  *chart)
650
 
{
651
 
  g_return_if_fail (path != NULL || iter != NULL);
652
 
 
653
 
  chart->priv->model_changed = TRUE;
654
 
  baobab_chart_update_draw (chart, path);
655
 
}
656
 
 
657
 
static void
658
 
baobab_chart_row_inserted (GtkTreeModel *model,
659
 
                           GtkTreePath  *path,
660
 
                           GtkTreeIter  *iter,
661
 
                           BaobabChart  *chart)
662
 
{
663
 
  g_return_if_fail (path != NULL || iter != NULL);
664
 
 
665
 
  chart->priv->model_changed = TRUE;
666
 
  baobab_chart_update_draw (chart, path);
667
 
}
668
 
 
669
 
static void
670
 
baobab_chart_row_has_child_toggled (GtkTreeModel *model,
671
 
                                    GtkTreePath  *path,
672
 
                                    GtkTreeIter  *iter,
673
 
                                    BaobabChart  *chart)
674
 
{
675
 
  g_return_if_fail (path != NULL || iter != NULL);
676
 
 
677
 
  chart->priv->model_changed = TRUE;
678
 
  baobab_chart_update_draw (chart, path);
679
 
}
680
 
 
681
 
static void
682
 
baobab_chart_row_deleted (GtkTreeModel *model,
683
 
                          GtkTreePath  *path,
684
 
                          BaobabChart  *chart)
685
 
{
686
 
  g_return_if_fail (path != NULL);
687
 
 
688
 
  chart->priv->model_changed = TRUE;
689
 
  baobab_chart_update_draw (chart, path);
690
 
}
691
 
 
692
 
static void
693
 
baobab_chart_rows_reordered (GtkTreeModel *model,
694
 
                             GtkTreePath  *path,
695
 
                             GtkTreeIter  *iter,
696
 
                             gint         *new_order,
697
 
                             BaobabChart  *chart)
698
 
{
699
 
  g_return_if_fail (path != NULL || iter != NULL);
700
 
 
701
 
  chart->priv->model_changed = TRUE;
702
 
  baobab_chart_update_draw (chart, path);
703
 
}
704
 
 
705
 
static gboolean
706
 
baobab_chart_draw (GtkWidget *widget,
707
 
                   cairo_t   *cr)
708
 
{
709
 
  BaobabChart *chart;
710
 
 
711
 
  chart = BAOBAB_CHART (widget);
712
 
 
713
 
  /* the columns are not set we paint nothing */
714
 
  if (chart->priv->name_column == chart->priv->percentage_column)
715
 
    return FALSE;
716
 
 
717
 
  /* there is no model we can not paint */
718
 
  if ((chart->priv->is_frozen) || (chart->priv->model == NULL))
719
 
    {
720
 
      if (chart->priv->memento != NULL)
721
 
        {
722
 
          gint w, h, aw, ah;
723
 
          gdouble p, sx, sy;
724
 
 
725
 
          w = cairo_image_surface_get_width (chart->priv->memento);
726
 
          h = cairo_image_surface_get_height (chart->priv->memento);
727
 
 
728
 
          aw = gtk_widget_get_allocated_width (widget);
729
 
          ah = gtk_widget_get_allocated_height (widget);
730
 
 
731
 
          if (w > 0 && h > 0 && !(aw == w && aw == h))
732
 
            {
733
 
              /* minimal available proportion */
734
 
              p = MIN (aw / (1.0 * w), ah / (1.0 * h));
735
 
 
736
 
              sx = (gdouble) (aw - w * p) / 2.0;
737
 
              sy = (gdouble) (ah - h * p) / 2.0;
738
 
 
739
 
              cairo_translate (cr, sx, sy);
740
 
              cairo_scale (cr, p, p);
741
 
            }
742
 
 
743
 
          cairo_set_source_surface (cr, chart->priv->memento, 0, 0);
744
 
          cairo_paint (cr);
745
 
        }
746
 
    }
747
 
  else
748
 
    {
749
 
      GtkTreePath *root_path = NULL;
750
 
 
751
 
      cairo_set_source_rgb (cr, 1, 1, 1);
752
 
      cairo_fill_preserve (cr);
753
 
 
754
 
      if (chart->priv->root != NULL)
755
 
        root_path = gtk_tree_row_reference_get_path (chart->priv->root);
756
 
 
757
 
      if (root_path == NULL)
758
 
        {
759
 
          root_path = gtk_tree_path_new_first ();
760
 
          chart->priv->root = NULL;
761
 
        }
762
 
 
763
 
      /* Check if tree model was modified in any way */
764
 
      if ((chart->priv->model_changed) || (chart->priv->first_item == NULL))
765
 
        {
766
 
          baobab_chart_get_items (chart, root_path);
767
 
        }
768
 
      else
769
 
        {
770
 
          GtkTreePath *current_path;
771
 
 
772
 
          /* Check if root was changed */
773
 
          current_path = gtk_tree_model_get_path (chart->priv->model,
774
 
                         &((BaobabChartItem*) chart->priv->first_item->data)->iter);
775
 
 
776
 
          if (gtk_tree_path_compare (root_path, current_path) != 0)
777
 
            baobab_chart_get_items (chart, root_path);
778
 
 
779
 
          gtk_tree_path_free (current_path);
780
 
        }
781
 
 
782
 
      gtk_tree_path_free (root_path);
783
 
 
784
 
      baobab_chart_draw_chart (chart, cr);
785
 
    }
786
 
 
787
 
  return FALSE;
788
 
}
789
 
 
790
 
static void
791
 
baobab_chart_interpolate_colors (BaobabChartColor *color,
792
 
                                 BaobabChartColor colora,
793
 
                                 BaobabChartColor colorb,
794
 
                                 gdouble percentage)
795
 
{
796
 
  gdouble diff;
797
 
 
798
 
  diff = colora.red - colorb.red;
799
 
  color->red = colora.red-diff*percentage;
800
 
 
801
 
  diff = colora.green - colorb.green;
802
 
  color->green = colora.green-diff*percentage;
803
 
 
804
 
  diff = colora.blue - colorb.blue;
805
 
  color->blue = colora.blue-diff*percentage;
806
 
}
807
 
 
808
 
void
809
 
baobab_chart_get_item_color (BaobabChartColor *color,
810
 
                             gdouble rel_position,
811
 
                             gint depth,
812
 
                             gboolean highlighted)
813
 
{
814
 
  gdouble intensity;
815
 
  gint color_number;
816
 
  gint next_color_number;
817
 
  gdouble maximum;
818
 
  static const BaobabChartColor level_color = {0.83, 0.84, 0.82};
819
 
  static const BaobabChartColor level_color_hl = {0.88, 0.89, 0.87};
820
 
 
821
 
  intensity = 1 - (((depth-1)*0.3) / BAOBAB_CHART_MAX_DEPTH);
822
 
 
823
 
  if (depth == 0)
824
 
    *color = level_color;
825
 
  else
826
 
    {
827
 
      color_number = rel_position / (100/3);
828
 
      next_color_number = (color_number + 1) % 6;
829
 
 
830
 
      baobab_chart_interpolate_colors (color,
831
 
                                       baobab_chart_tango_colors[color_number],
832
 
                                       baobab_chart_tango_colors[next_color_number],
833
 
                                       (rel_position - color_number * 100/3) / (100/3));
834
 
      color->red = color->red * intensity;
835
 
      color->green = color->green * intensity;
836
 
      color->blue = color->blue * intensity;
837
 
    }
838
 
 
839
 
  if (highlighted)
840
 
    {
841
 
      if (depth == 0)
842
 
        *color = level_color_hl;
843
 
      else
844
 
        {
845
 
          maximum = MAX (color->red,
846
 
                         MAX (color->green,
847
 
                              color->blue));
848
 
          color->red /= maximum;
849
 
          color->green /= maximum;
850
 
          color->blue /= maximum;
851
 
        }
852
 
    }
853
 
}
854
 
 
855
 
static void
856
 
popup_menu_detach (GtkWidget *attach_widget,
857
 
                   GtkMenu   *menu)
858
 
{
859
 
  BAOBAB_CHART (attach_widget)->priv->popup_menu = NULL;
860
 
}
861
 
 
862
 
static void
863
 
popup_menu_activate_up (GtkMenuItem *checkmenuitem,
864
 
                        BaobabChart *chart)
865
 
{
866
 
  baobab_chart_move_up_root (chart);
867
 
}
868
 
 
869
 
static void
870
 
popup_menu_activate_zoom_in (GtkMenuItem *checkmenuitem,
871
 
                             BaobabChart *chart)
872
 
{
873
 
  baobab_chart_zoom_in (chart);
874
 
}
875
 
 
876
 
static void
877
 
popup_menu_activate_zoom_out (GtkMenuItem *checkmenuitem,
878
 
                              BaobabChart *chart)
879
 
{
880
 
  baobab_chart_zoom_out (chart);
881
 
}
882
 
 
883
 
static void
884
 
do_popup_menu (BaobabChart    *chart,
885
 
               GdkEventButton *event)
886
 
{
887
 
  GtkWidget *menu;
888
 
  GtkWidget *up_item;
889
 
  GtkWidget *zoom_in_item;
890
 
  GtkWidget *zoom_out_item;
891
 
  GtkTreePath *root_path;
892
 
 
893
 
  menu = gtk_menu_new ();
894
 
  chart->priv->popup_menu = menu;
895
 
 
896
 
  gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (chart), popup_menu_detach);
897
 
 
898
 
  up_item = gtk_image_menu_item_new_with_mnemonic (_("_Move to parent folder"));
899
 
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (up_item),
900
 
                                 gtk_image_new_from_stock(GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU));
901
 
 
902
 
  zoom_in_item = gtk_image_menu_item_new_with_mnemonic (_("Zoom _in")) ;
903
 
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (zoom_in_item),
904
 
                                 gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
905
 
 
906
 
  zoom_out_item = gtk_image_menu_item_new_with_mnemonic (_("Zoom _out"));
907
 
  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (zoom_out_item),
908
 
                                 gtk_image_new_from_stock(GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
909
 
 
910
 
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), up_item);
911
 
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), gtk_separator_menu_item_new ());
912
 
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), zoom_in_item);
913
 
  gtk_menu_shell_append (GTK_MENU_SHELL (menu), zoom_out_item);
914
 
 
915
 
  g_signal_connect (up_item, "activate",
916
 
                    G_CALLBACK (popup_menu_activate_up), chart);
917
 
  g_signal_connect (zoom_in_item, "activate",
918
 
                    G_CALLBACK (popup_menu_activate_zoom_in), chart);
919
 
  g_signal_connect (zoom_out_item, "activate",
920
 
                    G_CALLBACK (popup_menu_activate_zoom_out), chart);
921
 
 
922
 
  gtk_widget_show_all (menu);
923
 
 
924
 
  root_path = baobab_chart_get_root (chart);
925
 
 
926
 
  gtk_widget_set_sensitive (up_item,
927
 
                            (!chart->priv->is_frozen) &&
928
 
                            ((root_path != NULL) &&
929
 
                            (gtk_tree_path_get_depth (root_path) > 1)));
930
 
  gtk_widget_set_sensitive (zoom_in_item,
931
 
                            baobab_chart_can_zoom_in (chart));
932
 
  gtk_widget_set_sensitive (zoom_out_item,
933
 
                            baobab_chart_can_zoom_out (chart));
934
 
 
935
 
  gtk_menu_popup (GTK_MENU (menu),
936
 
                  NULL, NULL, NULL, NULL,
937
 
                  event ? event->button : 0,
938
 
                  event ? event->time : gtk_get_current_event_time ());
939
 
 
940
 
  gtk_tree_path_free (root_path);
941
 
}
942
 
 
943
 
static gint
944
 
baobab_chart_button_press_event (GtkWidget      *widget,
945
 
                                 GdkEventButton *event)
946
 
{
947
 
  BaobabChart *chart = BAOBAB_CHART (widget);
948
 
 
949
 
  if (event->type == GDK_BUTTON_PRESS)
950
 
    {
951
 
      if (gdk_event_triggers_context_menu ((GdkEvent *) event))
952
 
        {
953
 
          do_popup_menu (chart, event);
954
 
          return TRUE;
955
 
        }
956
 
      else if (!chart->priv->is_frozen)
957
 
        {
958
 
          switch (event->button)
959
 
            {
960
 
              case 1:
961
 
                if (chart->priv->highlighted_item != NULL)
962
 
                  {
963
 
                    GtkTreePath *path, *root_path;
964
 
                    GtkTreeIter *iter;
965
 
 
966
 
                    iter = &((BaobabChartItem*) chart->priv->highlighted_item->data)->iter;
967
 
                    path = gtk_tree_model_get_path (chart->priv->model, iter);
968
 
 
969
 
                    if (chart->priv->root)
970
 
                      root_path = gtk_tree_row_reference_get_path (chart->priv->root);
971
 
                    else
972
 
                      root_path = gtk_tree_path_new_first ();
973
 
 
974
 
                    if (gtk_tree_path_compare (path, root_path) == 0)
975
 
                      {
976
 
                        /* Go back to the parent dir */
977
 
                        baobab_chart_move_up_root (chart);
978
 
                      }
979
 
                    else
980
 
                      {
981
 
                        /* Enter into a subdir */
982
 
                        g_signal_emit (chart,
983
 
                                       baobab_chart_signals[ITEM_ACTIVATED], 0,
984
 
                                       iter);
985
 
                      }
986
 
 
987
 
                    gtk_tree_path_free (path);
988
 
                  }
989
 
 
990
 
                break;
991
 
 
992
 
              case 2:
993
 
                /* Go back to the parent dir */
994
 
                baobab_chart_move_up_root (chart);
995
 
                break;
996
 
            }
997
 
 
998
 
          return TRUE;
999
 
        }
1000
 
    }
1001
 
 
1002
 
  return FALSE;
1003
 
}
1004
 
 
1005
 
static gboolean
1006
 
baobab_chart_popup_menu (GtkWidget *widget)
1007
 
{
1008
 
  do_popup_menu (BAOBAB_CHART (widget), NULL);
1009
 
 
1010
 
  return TRUE;
1011
 
}
1012
 
 
1013
 
static gint
1014
 
baobab_chart_scroll (GtkWidget *widget,
1015
 
                     GdkEventScroll *event)
1016
 
{
1017
 
  BaobabChart *chart = BAOBAB_CHART (widget);
1018
 
 
1019
 
  switch (event->direction)
1020
 
    {
1021
 
    case GDK_SCROLL_LEFT :
1022
 
    case GDK_SCROLL_UP :
1023
 
      if (baobab_chart_can_zoom_out (chart))
1024
 
        baobab_chart_zoom_out (chart);
1025
 
      /* change the selected item when zooming */
1026
 
      baobab_chart_motion_notify (widget, (GdkEventMotion *)event);
1027
 
      break;
1028
 
 
1029
 
    case GDK_SCROLL_RIGHT :
1030
 
    case GDK_SCROLL_DOWN :
1031
 
      if (baobab_chart_can_zoom_in (chart))
1032
 
        baobab_chart_zoom_in (chart);
1033
 
      break;
1034
 
 
1035
 
    case GDK_SCROLL_SMOOTH :
1036
 
      /* since we don't add GDK_SMOOTH_SCROLL_MASK to received
1037
 
         events, this is actually never reached and it's here
1038
 
         just to silence compiler warnings */
1039
 
      break;
1040
 
    }
1041
 
 
1042
 
  return FALSE;
1043
 
}
1044
 
 
1045
 
static void
1046
 
baobab_chart_set_item_highlight (BaobabChart *chart,
1047
 
                                 GList       *node,
1048
 
                                 gboolean     highlighted)
1049
 
{
1050
 
  BaobabChartItem *item;
1051
 
 
1052
 
  if (node == NULL)
1053
 
    return;
1054
 
 
1055
 
  item = (BaobabChartItem *) node->data;
1056
 
 
1057
 
  if (highlighted)
1058
 
    chart->priv->highlighted_item = node;
1059
 
  else
1060
 
    chart->priv->highlighted_item = NULL;
1061
 
 
1062
 
  gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (chart)),
1063
 
                              &item->rect, TRUE);
1064
 
}
1065
 
 
1066
 
static gint
1067
 
baobab_chart_motion_notify (GtkWidget      *widget,
1068
 
                            GdkEventMotion *event)
1069
 
{
1070
 
  BaobabChart *chart;
1071
 
  BaobabChartPrivate *priv;
1072
 
  BaobabChartClass *class;
1073
 
  GList *node;
1074
 
  BaobabChartItem *item;
1075
 
  gboolean found = FALSE;
1076
 
 
1077
 
  chart = BAOBAB_CHART (widget);
1078
 
  priv = chart->priv;
1079
 
 
1080
 
  class = BAOBAB_CHART_GET_CLASS (widget);
1081
 
 
1082
 
  /* Check if the pointer is over an item */
1083
 
  for (node = priv->last_item; node != NULL; node = node->prev)
1084
 
    {
1085
 
      item = (BaobabChartItem *) node->data;
1086
 
 
1087
 
      if ((item->visible) && (class->is_point_over_item (chart, item, event->x, event->y)))
1088
 
        {
1089
 
          if (chart->priv->highlighted_item != node)
1090
 
            {
1091
 
              baobab_chart_set_item_highlight (chart, priv->highlighted_item, FALSE);
1092
 
 
1093
 
              gtk_widget_set_has_tooltip (widget, TRUE);
1094
 
              baobab_chart_set_item_highlight (chart, node, TRUE);
1095
 
            }
1096
 
 
1097
 
          found = TRUE;
1098
 
          break;
1099
 
        }
1100
 
    }
1101
 
 
1102
 
  /* If we never found a highlighted item, but there is an old highlighted item,
1103
 
     redraw it to turn it off */
1104
 
  if (! found)
1105
 
    {
1106
 
      baobab_chart_set_item_highlight (chart, priv->highlighted_item, FALSE);
1107
 
      gtk_widget_set_has_tooltip (widget, FALSE);
1108
 
    }
1109
 
 
1110
 
  /* Continue receiving motion notifies */
1111
 
  gdk_event_request_motions (event);
1112
 
 
1113
 
  return FALSE;
1114
 
}
1115
 
 
1116
 
static gint
1117
 
baobab_chart_leave_notify (GtkWidget        *widget,
1118
 
                           GdkEventCrossing *event)
1119
 
{
1120
 
  BaobabChart *chart;
1121
 
 
1122
 
  chart = BAOBAB_CHART (widget);
1123
 
 
1124
 
  baobab_chart_set_item_highlight (chart, chart->priv->highlighted_item, FALSE);
1125
 
 
1126
 
  return FALSE;
1127
 
}
1128
 
 
1129
 
static void
1130
 
baobab_chart_connect_signals (BaobabChart *chart,
1131
 
                              GtkTreeModel *model)
1132
 
{
1133
 
  g_signal_connect (model,
1134
 
                    "row_changed",
1135
 
                    G_CALLBACK (baobab_chart_row_changed),
1136
 
                    chart);
1137
 
  g_signal_connect (model,
1138
 
                    "row_inserted",
1139
 
                    G_CALLBACK (baobab_chart_row_inserted),
1140
 
                    chart);
1141
 
  g_signal_connect (model,
1142
 
                    "row_has_child_toggled",
1143
 
                    G_CALLBACK (baobab_chart_row_has_child_toggled),
1144
 
                    chart);
1145
 
  g_signal_connect (model,
1146
 
                    "row_deleted",
1147
 
                    G_CALLBACK (baobab_chart_row_deleted),
1148
 
                    chart);
1149
 
  g_signal_connect (model,
1150
 
                    "rows_reordered",
1151
 
                    G_CALLBACK (baobab_chart_rows_reordered),
1152
 
                    chart);
1153
 
  g_signal_connect (chart,
1154
 
                    "query-tooltip",
1155
 
                    G_CALLBACK (baobab_chart_query_tooltip),
1156
 
                    chart);
1157
 
  g_signal_connect (chart,
1158
 
                    "motion-notify-event",
1159
 
                    G_CALLBACK (baobab_chart_motion_notify),
1160
 
                    chart);
1161
 
  g_signal_connect (chart,
1162
 
                    "leave-notify-event",
1163
 
                    G_CALLBACK (baobab_chart_leave_notify),
1164
 
                    chart);
1165
 
}
1166
 
 
1167
 
static void
1168
 
baobab_chart_disconnect_signals (BaobabChart  *chart,
1169
 
                                 GtkTreeModel *model)
1170
 
{
1171
 
  g_signal_handlers_disconnect_by_func (model,
1172
 
                                        baobab_chart_row_changed,
1173
 
                                        chart);
1174
 
  g_signal_handlers_disconnect_by_func (model,
1175
 
                                        baobab_chart_row_inserted,
1176
 
                                        chart);
1177
 
  g_signal_handlers_disconnect_by_func (model,
1178
 
                                        baobab_chart_row_has_child_toggled,
1179
 
                                        chart);
1180
 
  g_signal_handlers_disconnect_by_func (model,
1181
 
                                        baobab_chart_row_deleted,
1182
 
                                        chart);
1183
 
  g_signal_handlers_disconnect_by_func (model,
1184
 
                                        baobab_chart_rows_reordered,
1185
 
                                        chart);
1186
 
  g_signal_handlers_disconnect_by_func (chart,
1187
 
                                        baobab_chart_query_tooltip,
1188
 
                                        chart);
1189
 
  g_signal_handlers_disconnect_by_func (chart,
1190
 
                                        baobab_chart_motion_notify,
1191
 
                                        chart);
1192
 
  g_signal_handlers_disconnect_by_func (chart,
1193
 
                                        baobab_chart_leave_notify,
1194
 
                                        chart);
1195
 
}
1196
 
 
1197
 
static gboolean
1198
 
baobab_chart_query_tooltip (GtkWidget  *widget,
1199
 
                            gint        x,
1200
 
                            gint        y,
1201
 
                            gboolean    keyboard_mode,
1202
 
                            GtkTooltip *tooltip,
1203
 
                            gpointer    user_data)
1204
 
{
1205
 
  BaobabChart *chart = BAOBAB_CHART (widget);
1206
 
  BaobabChartItem *item;
1207
 
  char *markup;
1208
 
  char *escaped;
1209
 
 
1210
 
  if (chart->priv->highlighted_item == NULL)
1211
 
    return FALSE;
1212
 
 
1213
 
  item = (BaobabChartItem *) chart->priv->highlighted_item->data;
1214
 
 
1215
 
  if ( (item->name == NULL) || (item->size == NULL) )
1216
 
    return FALSE;
1217
 
 
1218
 
  gtk_tooltip_set_tip_area (tooltip, &item->rect);
1219
 
 
1220
 
  markup = g_strconcat (item->name,
1221
 
                        "\n",
1222
 
                        item->size,
1223
 
                        NULL);
1224
 
  escaped = g_markup_escape_text (markup, -1);
1225
 
  gtk_tooltip_set_markup (tooltip, escaped);
1226
 
  g_free (markup);
1227
 
  g_free (escaped);
1228
 
 
1229
 
  return TRUE;
1230
 
}
1231
 
 
1232
 
static void
1233
 
baobab_chart_item_activated (BaobabChart *chart,
1234
 
                             GtkTreeIter *iter)
1235
 
{
1236
 
  GtkTreePath *path;
1237
 
 
1238
 
  path = gtk_tree_model_get_path (chart->priv->model, iter);
1239
 
  baobab_chart_set_root (chart, path);
1240
 
 
1241
 
  gtk_tree_path_free (path);
1242
 
}
1243
 
 
1244
 
/* Public functions start here */
1245
 
 
1246
 
/**
1247
 
 * baobab_chart_new:
1248
 
 *
1249
 
 * Constructor for the baobab_chart class
1250
 
 *
1251
 
 * Returns: a new #BaobabChart object
1252
 
 **/
1253
 
BaobabChart *
1254
 
baobab_chart_new (void)
1255
 
{
1256
 
  return g_object_new (BAOBAB_TYPE_CHART, NULL);
1257
 
}
1258
 
 
1259
 
/**
1260
 
 * baobab_chart_set_model_with_columns:
1261
 
 * @chart: the #BaobabChart whose model is going to be set
1262
 
 * @model: the #GtkTreeModel which is going to set as the model of
1263
 
 * @chart
1264
 
 * @name_column: number of column inside @model where the file name is
1265
 
 * stored
1266
 
 * @size_column: number of column inside @model where the file size is
1267
 
 * stored
1268
 
 * @info_column: number of column inside @model where the percentage
1269
 
 * of disk usage is stored
1270
 
 * @percentage_column: number of column inside @model where the disk
1271
 
 * usage percentage is stored
1272
 
 * @valid_column: number of column inside @model where the flag indicating
1273
 
 * if the row data is right or not.
1274
 
 * @root: a #GtkTreePath indicating the node of @model which will be
1275
 
 * used as root.
1276
 
 *
1277
 
 * Sets @model as the #GtkTreeModel used by @chart. Indicates the
1278
 
 * columns inside @model where the values file name, file
1279
 
 * size, file information, disk usage percentage and data correction are stored, and
1280
 
 * the node which will be used as the root of @chart.  Once
1281
 
 * the model has been successfully set, a redraw of the window is
1282
 
 * forced.
1283
 
 * This function is intended to be used the first time a #GtkTreeModel
1284
 
 * is assigned to @chart, or when the columns containing the needed data
1285
 
 * are going to change. In other cases, #baobab_chart_set_model should
1286
 
 * be used.
1287
 
 * This function does not change the state of the signals from the model, which
1288
 
 * is controlled by he #baobab_chart_freeze_updates and the
1289
 
 * #baobab_chart_thaw_updates functions.
1290
 
 *
1291
 
 * Fails if @chart is not a #BaobabChart or if @model is not a
1292
 
 * #GtkTreeModel.
1293
 
 **/
1294
 
void
1295
 
baobab_chart_set_model_with_columns (BaobabChart  *chart,
1296
 
                                     GtkTreeModel *model,
1297
 
                                     guint         name_column,
1298
 
                                     guint         size_column,
1299
 
                                     guint         info_column,
1300
 
                                     guint         percentage_column,
1301
 
                                     guint         valid_column,
1302
 
                                     GtkTreePath  *root)
1303
 
{
1304
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1305
 
  g_return_if_fail (GTK_IS_TREE_MODEL (model));
1306
 
 
1307
 
 
1308
 
  baobab_chart_set_model (chart, model);
1309
 
 
1310
 
  if (root != NULL)
1311
 
    {
1312
 
      chart->priv->root = gtk_tree_row_reference_new (model, root);
1313
 
      g_object_notify (G_OBJECT (chart), "root");
1314
 
    }
1315
 
 
1316
 
  chart->priv->name_column = name_column;
1317
 
  chart->priv->size_column = size_column;
1318
 
  chart->priv->info_column = info_column;
1319
 
  chart->priv->percentage_column = percentage_column;
1320
 
  chart->priv->valid_column = valid_column;
1321
 
}
1322
 
 
1323
 
/**
1324
 
 * baobab_chart_set_model:
1325
 
 * @chart: the #BaobabChart whose model is going to be set
1326
 
 * @model: the #GtkTreeModel which is going to set as the model of
1327
 
 * @chart
1328
 
 *
1329
 
 * Sets @model as the #GtkTreeModel used by @chart, and takes the needed
1330
 
 * data from the columns especified in the last call to
1331
 
 * #baobab_chart_set_model_with_colums.
1332
 
 * This function does not change the state of the signals from the model, which
1333
 
 * is controlled by he #baobab_chart_freeze_updates and the
1334
 
 * #baobab_chart_thaw_updates functions.
1335
 
 *
1336
 
 * Fails if @chart is not a #BaobabChart or if @model is not a
1337
 
 * #GtkTreeModel.
1338
 
 **/
1339
 
void
1340
 
baobab_chart_set_model (BaobabChart  *chart,
1341
 
                        GtkTreeModel *model)
1342
 
{
1343
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1344
 
  g_return_if_fail (GTK_IS_TREE_MODEL (model));
1345
 
 
1346
 
  if (model == chart->priv->model)
1347
 
    return;
1348
 
 
1349
 
  if (chart->priv->model)
1350
 
    {
1351
 
      if (! chart->priv->is_frozen)
1352
 
        baobab_chart_disconnect_signals (chart, chart->priv->model);
1353
 
      g_object_unref (chart->priv->model);
1354
 
    }
1355
 
 
1356
 
  chart->priv->model = model;
1357
 
  g_object_ref (chart->priv->model);
1358
 
 
1359
 
  if (! chart->priv->is_frozen)
1360
 
    baobab_chart_connect_signals (chart, chart->priv->model);
1361
 
 
1362
 
  if (chart->priv->root)
1363
 
    gtk_tree_row_reference_free (chart->priv->root);
1364
 
 
1365
 
  chart->priv->root = NULL;
1366
 
 
1367
 
  g_object_notify (G_OBJECT (chart), "model");
1368
 
 
1369
 
  gtk_widget_queue_draw (GTK_WIDGET (chart));
1370
 
}
1371
 
 
1372
 
/**
1373
 
 * baobab_chart_get_model:
1374
 
 * @chart: a #BaobabChart whose model will be returned.
1375
 
 *
1376
 
 * Returns the #GtkTreeModel which is the model used by @chart.
1377
 
 *
1378
 
 * Returns: %NULL if @chart is not a #BaobabChart.
1379
 
 **/
1380
 
GtkTreeModel *
1381
 
baobab_chart_get_model (BaobabChart *chart)
1382
 
{
1383
 
  g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
1384
 
 
1385
 
  return chart->priv->model;
1386
 
}
1387
 
 
1388
 
/**
1389
 
 * baobab_chart_set_max_depth:
1390
 
 * @chart: a #BaobabChart
1391
 
 * @max_depth: the new maximum depth to show in the widget.
1392
 
 *
1393
 
 * Sets the maximum number of nested levels that are going to be show in the
1394
 
 * wigdet, and causes a redraw of the widget to show the new maximum
1395
 
 * depth. If max_depth is < 1 MAX_DRAWABLE_DEPTH is used.
1396
 
 *
1397
 
 * Fails if @chart is not a #BaobabChart.
1398
 
 **/
1399
 
void
1400
 
baobab_chart_set_max_depth (BaobabChart *chart,
1401
 
                            guint        max_depth)
1402
 
{
1403
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1404
 
 
1405
 
  max_depth = MIN (max_depth, BAOBAB_CHART_MAX_DEPTH);
1406
 
  max_depth = MAX (max_depth, BAOBAB_CHART_MIN_DEPTH);
1407
 
 
1408
 
  if (max_depth == chart->priv->max_depth)
1409
 
    return;
1410
 
 
1411
 
  chart->priv->max_depth = max_depth;
1412
 
  g_object_notify (G_OBJECT (chart), "max-depth");
1413
 
 
1414
 
  chart->priv->model_changed = TRUE;
1415
 
 
1416
 
  gtk_widget_queue_draw (GTK_WIDGET (chart));
1417
 
}
1418
 
 
1419
 
/**
1420
 
 * baobab_chart_get_max_depth:
1421
 
 * @chart: a #BaobabChart.
1422
 
 *
1423
 
 * Returns the maximum number of levels that will be show in the
1424
 
 * widget.
1425
 
 *
1426
 
 * Fails if @chart is not a #BaobabChart.
1427
 
 **/
1428
 
guint
1429
 
baobab_chart_get_max_depth (BaobabChart *chart)
1430
 
{
1431
 
  g_return_val_if_fail (BAOBAB_IS_CHART (chart), 0);
1432
 
 
1433
 
  return chart->priv->max_depth;
1434
 
}
1435
 
 
1436
 
/**
1437
 
 * baobab_chart_set_root:
1438
 
 * @chart: a #BaobabChart
1439
 
 * @root: a #GtkTreePath indicating the node which will be used as
1440
 
 * the widget root.
1441
 
 *
1442
 
 * Sets the node pointed by @root as the new root of the widget
1443
 
 * @chart.
1444
 
 *
1445
 
 * Fails if @chart is not a #BaobabChart or if @chart has not
1446
 
 * a #GtkTreeModel set.
1447
 
 **/
1448
 
void
1449
 
baobab_chart_set_root (BaobabChart *chart,
1450
 
                       GtkTreePath *root)
1451
 
{
1452
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1453
 
  g_return_if_fail (chart->priv->model != NULL);
1454
 
 
1455
 
  if (chart->priv->root)
1456
 
    {
1457
 
      /* Check that given root is different from current */
1458
 
      GtkTreePath *current_root = gtk_tree_row_reference_get_path (chart->priv->root);
1459
 
      if (current_root && (gtk_tree_path_compare (current_root, root) == 0))
1460
 
        return;
1461
 
 
1462
 
      /* Free current root */
1463
 
      gtk_tree_row_reference_free (chart->priv->root);
1464
 
    }
1465
 
  else if (!root)
1466
 
    return;
1467
 
 
1468
 
  chart->priv->root = root ? gtk_tree_row_reference_new (chart->priv->model, root) : NULL;
1469
 
 
1470
 
  g_object_notify (G_OBJECT (chart), "root");
1471
 
 
1472
 
  gtk_widget_queue_draw (GTK_WIDGET (chart));
1473
 
}
1474
 
 
1475
 
/**
1476
 
 * baobab_chart_get_root:
1477
 
 * @chart: a #BaobabChart.
1478
 
 *
1479
 
 * Returns a #GtkTreePath pointing to the root of the widget. The
1480
 
 * programmer has the responsibility to free the used memory once
1481
 
 * finished with the returned value. It returns NULL if there is no
1482
 
 * root node defined
1483
 
 *
1484
 
 * Fails if @chart is not a #BaobabChart.
1485
 
 **/
1486
 
GtkTreePath *
1487
 
baobab_chart_get_root (BaobabChart *chart)
1488
 
{
1489
 
  g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
1490
 
 
1491
 
  if (chart->priv->root)
1492
 
    return gtk_tree_row_reference_get_path (chart->priv->root);
1493
 
  else
1494
 
    return NULL;
1495
 
}
1496
 
 
1497
 
/**
1498
 
 * baobab_chart_freeze_updates:
1499
 
 * @chart: the #BaobabChart whose model signals are going to be frozen.
1500
 
 *
1501
 
 * Disconnects @chart from the signals emitted by its model, and sets
1502
 
 * the window of @chart to a "processing" state, so that the window
1503
 
 * ignores changes in the chart's model and mouse events.
1504
 
 * In order to connect again the window to the model, a call to
1505
 
 * #baobab_chart_thaw_updates must be done.
1506
 
 *
1507
 
 * Fails if @chart is not a #BaobabChart.
1508
 
 **/
1509
 
void
1510
 
baobab_chart_freeze_updates (BaobabChart *chart)
1511
 
{
1512
 
  cairo_surface_t *surface = NULL;
1513
 
  GtkAllocation allocation;
1514
 
 
1515
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1516
 
 
1517
 
  if (chart->priv->is_frozen)
1518
 
    return;
1519
 
 
1520
 
  if (chart->priv->model)
1521
 
    baobab_chart_disconnect_signals (chart, chart->priv->model);
1522
 
 
1523
 
  gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
1524
 
  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1525
 
                                        allocation.width,
1526
 
                                        allocation.height);
1527
 
 
1528
 
  if (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS)
1529
 
    {
1530
 
      cairo_t *cr;
1531
 
 
1532
 
      cr = cairo_create (surface);
1533
 
 
1534
 
      baobab_chart_draw_chart (chart, cr);
1535
 
 
1536
 
      cairo_rectangle (cr,
1537
 
                       0, 0,
1538
 
                       allocation.width,
1539
 
                       allocation.height);
1540
 
 
1541
 
      cairo_set_source_rgba (cr, 0.93, 0.93, 0.93, 0.5);  /* tango: eeeeec */
1542
 
      cairo_fill_preserve (cr);
1543
 
 
1544
 
      cairo_clip (cr);
1545
 
 
1546
 
      chart->priv->memento = surface;
1547
 
 
1548
 
      cairo_destroy (cr);
1549
 
    }
1550
 
 
1551
 
  chart->priv->is_frozen = TRUE;
1552
 
 
1553
 
  gtk_widget_queue_draw (GTK_WIDGET (chart));
1554
 
}
1555
 
 
1556
 
/**
1557
 
 * baobab_chart_thaw_updates:
1558
 
 * @chart: the #BaobabChart whose model signals are frozen.
1559
 
 *
1560
 
 * Reconnects @chart to the signals emitted by its model, which
1561
 
 * were disconnected through a call to #baobab_chart_freeze_updates.
1562
 
 * Takes the window out of its "processing" state and forces a redraw
1563
 
 * of the widget.
1564
 
 *
1565
 
 * Fails if @chart is not a #BaobabChart.
1566
 
 **/
1567
 
void
1568
 
baobab_chart_thaw_updates (BaobabChart *chart)
1569
 
{
1570
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1571
 
 
1572
 
  if (chart->priv->is_frozen)
1573
 
    {
1574
 
      if (chart->priv->model)
1575
 
        baobab_chart_connect_signals (chart, chart->priv->model);
1576
 
 
1577
 
      if (chart->priv->memento)
1578
 
        {
1579
 
          cairo_surface_destroy (chart->priv->memento);
1580
 
          chart->priv->memento = NULL;
1581
 
        }
1582
 
 
1583
 
      chart->priv->is_frozen = FALSE;
1584
 
 
1585
 
      chart->priv->model_changed = TRUE;
1586
 
      gtk_widget_queue_draw (GTK_WIDGET (chart));
1587
 
    }
1588
 
}
1589
 
 
1590
 
/**
1591
 
 * baobab_chart_zoom_in:
1592
 
 * @chart: the #BaobabChart requested to zoom in.
1593
 
 *
1594
 
 * Zooms in the chart by decreasing its maximun depth.
1595
 
 *
1596
 
 * Fails if @chart is not a #BaobabChart.
1597
 
 **/
1598
 
void
1599
 
baobab_chart_zoom_in (BaobabChart *chart)
1600
 
{
1601
 
  BaobabChartClass *class;
1602
 
  guint new_max_depth;
1603
 
 
1604
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1605
 
 
1606
 
  class = BAOBAB_CHART_GET_CLASS (chart);
1607
 
 
1608
 
  if (class->can_zoom_in != NULL)
1609
 
    new_max_depth = class->can_zoom_in (chart);
1610
 
  else
1611
 
    new_max_depth = chart->priv->max_depth - 1;
1612
 
 
1613
 
  baobab_chart_set_max_depth (chart, new_max_depth);
1614
 
}
1615
 
 
1616
 
/**
1617
 
 * baobab_chart_zoom_out:
1618
 
 * @chart: the #BaobabChart requested to zoom out.
1619
 
 *
1620
 
 * Zooms out the chart by increasing its maximun depth.
1621
 
 *
1622
 
 * Fails if @chart is not a #BaobabChart.
1623
 
 **/
1624
 
void
1625
 
baobab_chart_zoom_out (BaobabChart *chart)
1626
 
{
1627
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1628
 
 
1629
 
  baobab_chart_set_max_depth (chart, baobab_chart_get_max_depth (chart) + 1);
1630
 
}
1631
 
 
1632
 
/**
1633
 
 * baobab_chart_can_zoom_in:
1634
 
 * @chart: the #BaobabChart to ask if can be zoomed in.
1635
 
 *
1636
 
 * Returns a boolean telling whether the chart can be zoomed in, given its current
1637
 
 * visualization conditions.
1638
 
 *
1639
 
 * Fails if @chart is not a #BaobabChart.
1640
 
 **/
1641
 
gboolean
1642
 
baobab_chart_can_zoom_in (BaobabChart *chart)
1643
 
{
1644
 
  BaobabChartClass *class;
1645
 
 
1646
 
  g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
1647
 
 
1648
 
  if (chart->priv->is_frozen)
1649
 
    return FALSE;
1650
 
 
1651
 
  class = BAOBAB_CHART_GET_CLASS (chart);
1652
 
 
1653
 
  if (class->can_zoom_in != NULL)
1654
 
    return class->can_zoom_in (chart) > 0;
1655
 
  else
1656
 
    return chart->priv->max_depth > 1;
1657
 
}
1658
 
 
1659
 
/**
1660
 
 * baobab_chart_can_zoom_out:
1661
 
 * @chart: the #BaobabChart to ask if can be zoomed out.
1662
 
 *
1663
 
 * Returns a boolean telling whether the chart can be zoomed out, given its current
1664
 
 * visualization conditions.
1665
 
 *
1666
 
 * Fails if @chart is not a #BaobabChart.
1667
 
 **/
1668
 
gboolean
1669
 
baobab_chart_can_zoom_out (BaobabChart *chart)
1670
 
{
1671
 
  BaobabChartClass *class;
1672
 
 
1673
 
  g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
1674
 
 
1675
 
  if (chart->priv->is_frozen)
1676
 
    return FALSE;
1677
 
 
1678
 
  class = BAOBAB_CHART_GET_CLASS (chart);
1679
 
 
1680
 
  if (class->can_zoom_out != NULL)
1681
 
    return class->can_zoom_out (chart) > 0;
1682
 
  else
1683
 
    return (chart->priv->max_depth < BAOBAB_CHART_MAX_DEPTH);
1684
 
}
1685
 
 
1686
 
/**
1687
 
 * baobab_chart_move_up_root:
1688
 
 * @chart: the #BaobabChart whose root is requested to move up one level.
1689
 
 *
1690
 
 * Move root to the inmediate parent of the current root item of @chart.
1691
 
 *
1692
 
 * Fails if @chart is not a #BaobabChart.
1693
 
 **/
1694
 
void
1695
 
baobab_chart_move_up_root (BaobabChart *chart)
1696
 
{
1697
 
  GtkTreeIter parent_iter;
1698
 
  GtkTreePath *path;
1699
 
  GtkTreeIter root_iter;
1700
 
 
1701
 
  gint valid;
1702
 
  GtkTreePath *parent_path;
1703
 
 
1704
 
  g_return_if_fail (BAOBAB_IS_CHART (chart));
1705
 
 
1706
 
  if (chart->priv->root == NULL)
1707
 
    return;
1708
 
 
1709
 
  path = gtk_tree_row_reference_get_path (chart->priv->root);
1710
 
 
1711
 
  if (path != NULL)
1712
 
    gtk_tree_model_get_iter (chart->priv->model, &root_iter, path);
1713
 
  else
1714
 
    return;
1715
 
 
1716
 
  if (gtk_tree_model_iter_parent (chart->priv->model, &parent_iter, &root_iter))
1717
 
    {
1718
 
      gtk_tree_model_get (chart->priv->model, &parent_iter, chart->priv->valid_column,
1719
 
                          &valid, -1);
1720
 
 
1721
 
      if (valid == -1)
1722
 
        return;
1723
 
 
1724
 
      gtk_tree_row_reference_free (chart->priv->root);
1725
 
      parent_path = gtk_tree_model_get_path (chart->priv->model, &parent_iter);
1726
 
      chart->priv->root = gtk_tree_row_reference_new (chart->priv->model, parent_path);
1727
 
      gtk_tree_path_free (parent_path);
1728
 
 
1729
 
      g_signal_emit (BAOBAB_CHART (chart),
1730
 
                     baobab_chart_signals[ITEM_ACTIVATED],
1731
 
                     0, &parent_iter);
1732
 
 
1733
 
      gtk_widget_queue_draw (GTK_WIDGET (chart));
1734
 
    }
1735
 
 
1736
 
  gtk_tree_path_free (path);
1737
 
}
1738
 
 
1739
 
/**
1740
 
 * baobab_chart_is_frozen:
1741
 
 * @chart: the #BaobabChart to ask if frozen.
1742
 
 *
1743
 
 * Returns a boolean telling whether the chart is in a frozen state, meanning 
1744
 
 * that no actions should be taken uppon it.
1745
 
 *
1746
 
 * Fails if @chart is not a #BaobabChart.
1747
 
 **/
1748
 
gboolean
1749
 
baobab_chart_is_frozen (BaobabChart *chart)
1750
 
{
1751
 
  g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
1752
 
 
1753
 
  return chart->priv->is_frozen;
1754
 
}
1755
 
 
1756
 
/**
1757
 
 * baobab_chart_is_frozen:
1758
 
 * @chart: the #BaobabChart to obtain the highlighted it from.
1759
 
 *
1760
 
 * Returns a BaobabChartItem corresponding to the item that currently has mouse 
1761
 
 * pointer over, or NULL if no item is highlighted.
1762
 
 *
1763
 
 * Fails if @chart is not a #BaobabChart.
1764
 
 **/
1765
 
BaobabChartItem *
1766
 
baobab_chart_get_highlighted_item (BaobabChart *chart)
1767
 
{
1768
 
  g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
1769
 
 
1770
 
  return (chart->priv->highlighted_item ?
1771
 
    (BaobabChartItem *) chart->priv->highlighted_item->data : NULL);
1772
 
}
 
45
#include <gdk/gdk.h>
 
46
#include <cairo.h>
 
47
#include <gio/gio.h>
 
48
#include <gobject/gvaluecollector.h>
 
49
 
 
50
 
 
51
#define BAOBAB_TYPE_CHART_ITEM (baobab_chart_item_get_type ())
 
52
#define BAOBAB_CHART_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_CHART_ITEM, BaobabChartItem))
 
53
#define BAOBAB_CHART_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_CHART_ITEM, BaobabChartItemClass))
 
54
#define BAOBAB_IS_CHART_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_CHART_ITEM))
 
55
#define BAOBAB_IS_CHART_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_CHART_ITEM))
 
56
#define BAOBAB_CHART_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_CHART_ITEM, BaobabChartItemClass))
 
57
 
 
58
typedef struct _BaobabChartItem BaobabChartItem;
 
59
typedef struct _BaobabChartItemClass BaobabChartItemClass;
 
60
typedef struct _BaobabChartItemPrivate BaobabChartItemPrivate;
 
61
#define _g_free0(var) (var = (g_free (var), NULL))
 
62
typedef struct _BaobabParamSpecChartItem BaobabParamSpecChartItem;
 
63
 
 
64
#define BAOBAB_TYPE_CHART (baobab_chart_get_type ())
 
65
#define BAOBAB_CHART(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_CHART, BaobabChart))
 
66
#define BAOBAB_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_CHART, BaobabChartClass))
 
67
#define BAOBAB_IS_CHART(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_CHART))
 
68
#define BAOBAB_IS_CHART_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_CHART))
 
69
#define BAOBAB_CHART_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_CHART, BaobabChartClass))
 
70
 
 
71
typedef struct _BaobabChart BaobabChart;
 
72
typedef struct _BaobabChartClass BaobabChartClass;
 
73
typedef struct _BaobabChartPrivate BaobabChartPrivate;
 
74
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 
75
#define __g_list_free__baobab_chart_item_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__baobab_chart_item_unref0_ (var), NULL)))
 
76
#define _gtk_tree_row_reference_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_row_reference_free (var), NULL)))
 
77
#define _baobab_chart_item_unref0(var) ((var == NULL) ? NULL : (var = (baobab_chart_item_unref (var), NULL)))
 
78
#define _gtk_tree_path_free0(var) ((var == NULL) ? NULL : (var = (gtk_tree_path_free (var), NULL)))
 
79
#define _cairo_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_destroy (var), NULL)))
 
80
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))
 
81
#define __vala_GdkEventMotion_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEventMotion_free (var), NULL)))
 
82
 
 
83
#define BAOBAB_TYPE_WINDOW (baobab_window_get_type ())
 
84
#define BAOBAB_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_WINDOW, BaobabWindow))
 
85
#define BAOBAB_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_WINDOW, BaobabWindowClass))
 
86
#define BAOBAB_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_WINDOW))
 
87
#define BAOBAB_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_WINDOW))
 
88
#define BAOBAB_WINDOW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_WINDOW, BaobabWindowClass))
 
89
 
 
90
typedef struct _BaobabWindow BaobabWindow;
 
91
typedef struct _BaobabWindowClass BaobabWindowClass;
 
92
 
 
93
#define BAOBAB_TYPE_APPLICATION (baobab_application_get_type ())
 
94
#define BAOBAB_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BAOBAB_TYPE_APPLICATION, BaobabApplication))
 
95
#define BAOBAB_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BAOBAB_TYPE_APPLICATION, BaobabApplicationClass))
 
96
#define BAOBAB_IS_APPLICATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BAOBAB_TYPE_APPLICATION))
 
97
#define BAOBAB_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BAOBAB_TYPE_APPLICATION))
 
98
#define BAOBAB_APPLICATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BAOBAB_TYPE_APPLICATION, BaobabApplicationClass))
 
99
 
 
100
typedef struct _BaobabApplication BaobabApplication;
 
101
typedef struct _BaobabApplicationClass BaobabApplicationClass;
 
102
 
 
103
struct _BaobabChartItem {
 
104
        GTypeInstance parent_instance;
 
105
        volatile int ref_count;
 
106
        BaobabChartItemPrivate * priv;
 
107
        gchar* name;
 
108
        gchar* size;
 
109
        guint depth;
 
110
        gdouble rel_start;
 
111
        gdouble rel_size;
 
112
        GtkTreeIter iter;
 
113
        gboolean visible;
 
114
        gboolean has_any_child;
 
115
        gboolean has_visible_children;
 
116
        GdkRectangle rect;
 
117
        GList* parent;
 
118
};
 
119
 
 
120
struct _BaobabChartItemClass {
 
121
        GTypeClass parent_class;
 
122
        void (*finalize) (BaobabChartItem *self);
 
123
};
 
124
 
 
125
struct _BaobabParamSpecChartItem {
 
126
        GParamSpec parent_instance;
 
127
};
 
128
 
 
129
struct _BaobabChart {
 
130
        GtkDrawingArea parent_instance;
 
131
        BaobabChartPrivate * priv;
 
132
};
 
133
 
 
134
struct _BaobabChartClass {
 
135
        GtkDrawingAreaClass parent_class;
 
136
        void (*post_draw) (BaobabChart* self, cairo_t* cr);
 
137
        void (*draw_item) (BaobabChart* self, cairo_t* cr, BaobabChartItem* item, gboolean highlighted);
 
138
        void (*calculate_item_geometry) (BaobabChart* self, BaobabChartItem* item);
 
139
        gboolean (*is_point_over_item) (BaobabChart* self, BaobabChartItem* item, gdouble x, gdouble y);
 
140
        void (*get_item_rectangle) (BaobabChart* self, BaobabChartItem* item);
 
141
        gboolean (*can_zoom_in) (BaobabChart* self);
 
142
        gboolean (*can_zoom_out) (BaobabChart* self);
 
143
        BaobabChartItem* (*create_new_chartitem) (BaobabChart* self);
 
144
        void (*item_activated) (BaobabChart* self, GtkTreeIter* iter);
 
145
};
 
146
 
 
147
struct _BaobabChartPrivate {
 
148
        guint name_column;
 
149
        guint size_column;
 
150
        guint info_column;
 
151
        guint percentage_column;
 
152
        guint valid_column;
 
153
        gboolean model_changed;
 
154
        GtkMenu* context_menu;
 
155
        GList* items;
 
156
        guint max_depth_;
 
157
        GtkTreeModel* model_;
 
158
        GtkTreeRowReference* root_;
 
159
        BaobabChartItem* highlighted_item_;
 
160
        GSimpleActionGroup* action_group;
 
161
};
 
162
 
 
163
 
 
164
static gpointer baobab_chart_item_parent_class = NULL;
 
165
static gpointer baobab_chart_parent_class = NULL;
 
166
 
 
167
gpointer baobab_chart_item_ref (gpointer instance);
 
168
void baobab_chart_item_unref (gpointer instance);
 
169
GParamSpec* baobab_param_spec_chart_item (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
 
170
void baobab_value_set_chart_item (GValue* value, gpointer v_object);
 
171
void baobab_value_take_chart_item (GValue* value, gpointer v_object);
 
172
gpointer baobab_value_get_chart_item (const GValue* value);
 
173
GType baobab_chart_item_get_type (void) G_GNUC_CONST;
 
174
enum  {
 
175
        BAOBAB_CHART_ITEM_DUMMY_PROPERTY
 
176
};
 
177
BaobabChartItem* baobab_chart_item_construct (GType object_type);
 
178
static void baobab_chart_item_finalize (BaobabChartItem* obj);
 
179
GType baobab_chart_get_type (void) G_GNUC_CONST;
 
180
#define BAOBAB_CHART_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BAOBAB_TYPE_CHART, BaobabChartPrivate))
 
181
enum  {
 
182
        BAOBAB_CHART_DUMMY_PROPERTY,
 
183
        BAOBAB_CHART_MAX_DEPTH,
 
184
        BAOBAB_CHART_MODEL,
 
185
        BAOBAB_CHART_ROOT,
 
186
        BAOBAB_CHART_HIGHLIGHTED_ITEM
 
187
};
 
188
static void _baobab_chart_item_unref0_ (gpointer var);
 
189
static void _g_list_free__baobab_chart_item_unref0_ (GList* self);
 
190
#define BAOBAB_CHART_MAX_DEPTH ((guint) 5)
 
191
#define BAOBAB_CHART_MIN_DEPTH ((guint) 1)
 
192
void baobab_chart_open_file (BaobabChart* self);
 
193
static void _baobab_chart_open_file_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
 
194
void baobab_chart_copy_path (BaobabChart* self);
 
195
static void _baobab_chart_copy_path_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
 
196
void baobab_chart_trash_file (BaobabChart* self);
 
197
static void _baobab_chart_trash_file_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
 
198
void baobab_chart_move_up_root (BaobabChart* self);
 
199
static void _baobab_chart_move_up_root_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
 
200
void baobab_chart_zoom_in (BaobabChart* self);
 
201
static void _baobab_chart_zoom_in_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
 
202
void baobab_chart_zoom_out (BaobabChart* self);
 
203
static void _baobab_chart_zoom_out_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self);
 
204
void baobab_chart_set_model_with_columns (BaobabChart* self, GtkTreeModel* m, guint name_column_, guint size_column_, guint info_column_, guint percentage_column_, guint valid_column_, GtkTreePath* r);
 
205
void baobab_chart_set_model (BaobabChart* self, GtkTreeModel* value);
 
206
void baobab_chart_set_root (BaobabChart* self, GtkTreePath* value);
 
207
void baobab_chart_post_draw (BaobabChart* self, cairo_t* cr);
 
208
static void baobab_chart_real_post_draw (BaobabChart* self, cairo_t* cr);
 
209
void baobab_chart_draw_item (BaobabChart* self, cairo_t* cr, BaobabChartItem* item, gboolean highlighted);
 
210
static void baobab_chart_real_draw_item (BaobabChart* self, cairo_t* cr, BaobabChartItem* item, gboolean highlighted);
 
211
void baobab_chart_calculate_item_geometry (BaobabChart* self, BaobabChartItem* item);
 
212
static void baobab_chart_real_calculate_item_geometry (BaobabChart* self, BaobabChartItem* item);
 
213
gboolean baobab_chart_is_point_over_item (BaobabChart* self, BaobabChartItem* item, gdouble x, gdouble y);
 
214
static gboolean baobab_chart_real_is_point_over_item (BaobabChart* self, BaobabChartItem* item, gdouble x, gdouble y);
 
215
void baobab_chart_get_item_rectangle (BaobabChart* self, BaobabChartItem* item);
 
216
static void baobab_chart_real_get_item_rectangle (BaobabChart* self, BaobabChartItem* item);
 
217
gboolean baobab_chart_can_zoom_in (BaobabChart* self);
 
218
static gboolean baobab_chart_real_can_zoom_in (BaobabChart* self);
 
219
gboolean baobab_chart_can_zoom_out (BaobabChart* self);
 
220
static gboolean baobab_chart_real_can_zoom_out (BaobabChart* self);
 
221
BaobabChartItem* baobab_chart_create_new_chartitem (BaobabChart* self);
 
222
static BaobabChartItem* baobab_chart_real_create_new_chartitem (BaobabChart* self);
 
223
static void baobab_chart_real_size_allocate (GtkWidget* base, GtkAllocation* allocation);
 
224
static gboolean baobab_chart_highlight_item_at_point (BaobabChart* self, gdouble x, gdouble y);
 
225
void baobab_chart_set_highlighted_item (BaobabChart* self, BaobabChartItem* value);
 
226
static gboolean baobab_chart_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event);
 
227
static gboolean baobab_chart_real_leave_notify_event (GtkWidget* base, GdkEventCrossing* event);
 
228
static GList* baobab_chart_add_item (BaobabChart* self, guint depth, gdouble rel_start, gdouble rel_size, GtkTreeIter* iter);
 
229
GtkTreeModel* baobab_chart_get_model (BaobabChart* self);
 
230
static void baobab_chart_get_items (BaobabChart* self, GtkTreePath* root_path);
 
231
guint baobab_chart_get_max_depth (BaobabChart* self);
 
232
static void baobab_chart_draw_chart (BaobabChart* self, cairo_t* cr);
 
233
BaobabChartItem* baobab_chart_get_highlighted_item (BaobabChart* self);
 
234
static void baobab_chart_update_draw (BaobabChart* self, GtkTreePath* path);
 
235
GtkTreePath* baobab_chart_get_root (BaobabChart* self);
 
236
static void baobab_chart_row_changed (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter);
 
237
static void baobab_chart_row_inserted (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter);
 
238
static void baobab_chart_row_deleted (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path);
 
239
static void baobab_chart_row_has_child_toggled (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter);
 
240
static void baobab_chart_rows_reordered (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, void* new_order);
 
241
static gboolean baobab_chart_real_draw (GtkWidget* base, cairo_t* cr);
 
242
static void baobab_chart_interpolate_colors (BaobabChart* self, GdkRGBA* colora, GdkRGBA* colorb, gdouble percentage, GdkRGBA* result);
 
243
void baobab_chart_get_item_color (BaobabChart* self, gdouble rel_position, guint depth, gboolean highlighted, GdkRGBA* result);
 
244
static gboolean baobab_chart_real_button_press_event (GtkWidget* base, GdkEventButton* event);
 
245
static void baobab_chart_show_popup_menu (BaobabChart* self, GdkEventButton* event);
 
246
static gboolean baobab_chart_real_scroll_event (GtkWidget* base, GdkEventScroll* event);
 
247
static GdkEventMotion* _vala_GdkEventMotion_copy (GdkEventMotion* self);
 
248
static void _vala_GdkEventMotion_free (GdkEventMotion* self);
 
249
GType baobab_window_get_type (void) G_GNUC_CONST;
 
250
void baobab_window_open_item (BaobabWindow* self, GtkTreeIter* iter);
 
251
void baobab_window_copy_path (BaobabWindow* self, GtkTreeIter* iter);
 
252
void baobab_window_trash_file (BaobabWindow* self, GtkTreeIter* iter);
 
253
void baobab_chart_set_max_depth (BaobabChart* self, guint value);
 
254
static void baobab_chart_build_context_menu (BaobabChart* self);
 
255
GType baobab_application_get_type (void) G_GNUC_CONST;
 
256
BaobabApplication* baobab_application_get_default (void);
 
257
static void baobab_chart_connect_model_signals (BaobabChart* self, GtkTreeModel* m);
 
258
static void _baobab_chart_row_changed_gtk_tree_model_row_changed (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, gpointer self);
 
259
static void _baobab_chart_row_inserted_gtk_tree_model_row_inserted (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, gpointer self);
 
260
static void _baobab_chart_row_has_child_toggled_gtk_tree_model_row_has_child_toggled (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, gpointer self);
 
261
static void _baobab_chart_row_deleted_gtk_tree_model_row_deleted (GtkTreeModel* _sender, GtkTreePath* path, gpointer self);
 
262
static void _baobab_chart_rows_reordered_gtk_tree_model_rows_reordered (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, void* new_order, gpointer self);
 
263
static void baobab_chart_disconnect_model_signals (BaobabChart* self, GtkTreeModel* m);
 
264
static gboolean baobab_chart_real_query_tooltip (GtkWidget* base, gint x, gint y, gboolean keyboard_tooltip, GtkTooltip* tooltip);
 
265
BaobabChart* baobab_chart_construct (GType object_type);
 
266
static void baobab_chart_real_item_activated (BaobabChart* self, GtkTreeIter* iter);
 
267
static void g_cclosure_user_marshal_VOID__BOXED (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
 
268
static GObject * baobab_chart_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
 
269
static void baobab_chart_finalize (GObject* obj);
 
270
static void _vala_baobab_chart_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
 
271
static void _vala_baobab_chart_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
 
272
 
 
273
static const GdkRGBA BAOBAB_CHART_TANGO_COLORS[6] = {{0.94, 0.16, 0.16, 1.0}, {0.68, 0.49, 0.66, 1.0}, {0.45, 0.62, 0.82, 1.0}, {0.54, 0.89, 0.20, 1.0}, {0.91, 0.73, 0.43, 1.0}, {0.99, 0.68, 0.25, 1.0}};
 
274
static const GActionEntry BAOBAB_CHART_action_entries[6] = {{"open-file", _baobab_chart_open_file_gsimple_action_activate_callback}, {"copy-path", _baobab_chart_copy_path_gsimple_action_activate_callback}, {"trash-file", _baobab_chart_trash_file_gsimple_action_activate_callback}, {"move-up", _baobab_chart_move_up_root_gsimple_action_activate_callback}, {"zoom-in", _baobab_chart_zoom_in_gsimple_action_activate_callback}, {"zoom-out", _baobab_chart_zoom_out_gsimple_action_activate_callback}};
 
275
 
 
276
BaobabChartItem* baobab_chart_item_construct (GType object_type) {
 
277
        BaobabChartItem* self = NULL;
 
278
        self = (BaobabChartItem*) g_type_create_instance (object_type);
 
279
        return self;
 
280
}
 
281
 
 
282
 
 
283
static void baobab_value_chart_item_init (GValue* value) {
 
284
        value->data[0].v_pointer = NULL;
 
285
}
 
286
 
 
287
 
 
288
static void baobab_value_chart_item_free_value (GValue* value) {
 
289
        if (value->data[0].v_pointer) {
 
290
                baobab_chart_item_unref (value->data[0].v_pointer);
 
291
        }
 
292
}
 
293
 
 
294
 
 
295
static void baobab_value_chart_item_copy_value (const GValue* src_value, GValue* dest_value) {
 
296
        if (src_value->data[0].v_pointer) {
 
297
                dest_value->data[0].v_pointer = baobab_chart_item_ref (src_value->data[0].v_pointer);
 
298
        } else {
 
299
                dest_value->data[0].v_pointer = NULL;
 
300
        }
 
301
}
 
302
 
 
303
 
 
304
static gpointer baobab_value_chart_item_peek_pointer (const GValue* value) {
 
305
        return value->data[0].v_pointer;
 
306
}
 
307
 
 
308
 
 
309
static gchar* baobab_value_chart_item_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
 
310
        if (collect_values[0].v_pointer) {
 
311
                BaobabChartItem* object;
 
312
                object = collect_values[0].v_pointer;
 
313
                if (object->parent_instance.g_class == NULL) {
 
314
                        return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
 
315
                } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
 
316
                        return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
 
317
                }
 
318
                value->data[0].v_pointer = baobab_chart_item_ref (object);
 
319
        } else {
 
320
                value->data[0].v_pointer = NULL;
 
321
        }
 
322
        return NULL;
 
323
}
 
324
 
 
325
 
 
326
static gchar* baobab_value_chart_item_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
 
327
        BaobabChartItem** object_p;
 
328
        object_p = collect_values[0].v_pointer;
 
329
        if (!object_p) {
 
330
                return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
 
331
        }
 
332
        if (!value->data[0].v_pointer) {
 
333
                *object_p = NULL;
 
334
        } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
 
335
                *object_p = value->data[0].v_pointer;
 
336
        } else {
 
337
                *object_p = baobab_chart_item_ref (value->data[0].v_pointer);
 
338
        }
 
339
        return NULL;
 
340
}
 
341
 
 
342
 
 
343
GParamSpec* baobab_param_spec_chart_item (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
 
344
        BaobabParamSpecChartItem* spec;
 
345
        g_return_val_if_fail (g_type_is_a (object_type, BAOBAB_TYPE_CHART_ITEM), NULL);
 
346
        spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
 
347
        G_PARAM_SPEC (spec)->value_type = object_type;
 
348
        return G_PARAM_SPEC (spec);
 
349
}
 
350
 
 
351
 
 
352
gpointer baobab_value_get_chart_item (const GValue* value) {
 
353
        g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BAOBAB_TYPE_CHART_ITEM), NULL);
 
354
        return value->data[0].v_pointer;
 
355
}
 
356
 
 
357
 
 
358
void baobab_value_set_chart_item (GValue* value, gpointer v_object) {
 
359
        BaobabChartItem* old;
 
360
        g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BAOBAB_TYPE_CHART_ITEM));
 
361
        old = value->data[0].v_pointer;
 
362
        if (v_object) {
 
363
                g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BAOBAB_TYPE_CHART_ITEM));
 
364
                g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
 
365
                value->data[0].v_pointer = v_object;
 
366
                baobab_chart_item_ref (value->data[0].v_pointer);
 
367
        } else {
 
368
                value->data[0].v_pointer = NULL;
 
369
        }
 
370
        if (old) {
 
371
                baobab_chart_item_unref (old);
 
372
        }
 
373
}
 
374
 
 
375
 
 
376
void baobab_value_take_chart_item (GValue* value, gpointer v_object) {
 
377
        BaobabChartItem* old;
 
378
        g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, BAOBAB_TYPE_CHART_ITEM));
 
379
        old = value->data[0].v_pointer;
 
380
        if (v_object) {
 
381
                g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, BAOBAB_TYPE_CHART_ITEM));
 
382
                g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
 
383
                value->data[0].v_pointer = v_object;
 
384
        } else {
 
385
                value->data[0].v_pointer = NULL;
 
386
        }
 
387
        if (old) {
 
388
                baobab_chart_item_unref (old);
 
389
        }
 
390
}
 
391
 
 
392
 
 
393
static void baobab_chart_item_class_init (BaobabChartItemClass * klass) {
 
394
        baobab_chart_item_parent_class = g_type_class_peek_parent (klass);
 
395
        ((BaobabChartItemClass *) klass)->finalize = baobab_chart_item_finalize;
 
396
}
 
397
 
 
398
 
 
399
static void baobab_chart_item_instance_init (BaobabChartItem * self) {
 
400
        self->ref_count = 1;
 
401
}
 
402
 
 
403
 
 
404
static void baobab_chart_item_finalize (BaobabChartItem* obj) {
 
405
        BaobabChartItem * self;
 
406
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, BAOBAB_TYPE_CHART_ITEM, BaobabChartItem);
 
407
        g_signal_handlers_destroy (self);
 
408
        _g_free0 (self->name);
 
409
        _g_free0 (self->size);
 
410
}
 
411
 
 
412
 
 
413
GType baobab_chart_item_get_type (void) {
 
414
        static volatile gsize baobab_chart_item_type_id__volatile = 0;
 
415
        if (g_once_init_enter (&baobab_chart_item_type_id__volatile)) {
 
416
                static const GTypeValueTable g_define_type_value_table = { baobab_value_chart_item_init, baobab_value_chart_item_free_value, baobab_value_chart_item_copy_value, baobab_value_chart_item_peek_pointer, "p", baobab_value_chart_item_collect_value, "p", baobab_value_chart_item_lcopy_value };
 
417
                static const GTypeInfo g_define_type_info = { sizeof (BaobabChartItemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) baobab_chart_item_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BaobabChartItem), 0, (GInstanceInitFunc) baobab_chart_item_instance_init, &g_define_type_value_table };
 
418
                static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
 
419
                GType baobab_chart_item_type_id;
 
420
                baobab_chart_item_type_id = g_type_register_fundamental (g_type_fundamental_next (), "BaobabChartItem", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
 
421
                g_once_init_leave (&baobab_chart_item_type_id__volatile, baobab_chart_item_type_id);
 
422
        }
 
423
        return baobab_chart_item_type_id__volatile;
 
424
}
 
425
 
 
426
 
 
427
gpointer baobab_chart_item_ref (gpointer instance) {
 
428
        BaobabChartItem* self;
 
429
        self = instance;
 
430
        g_atomic_int_inc (&self->ref_count);
 
431
        return instance;
 
432
}
 
433
 
 
434
 
 
435
void baobab_chart_item_unref (gpointer instance) {
 
436
        BaobabChartItem* self;
 
437
        self = instance;
 
438
        if (g_atomic_int_dec_and_test (&self->ref_count)) {
 
439
                BAOBAB_CHART_ITEM_GET_CLASS (self)->finalize (self);
 
440
                g_type_free_instance ((GTypeInstance *) self);
 
441
        }
 
442
}
 
443
 
 
444
 
 
445
static void _baobab_chart_item_unref0_ (gpointer var) {
 
446
        (var == NULL) ? NULL : (var = (baobab_chart_item_unref (var), NULL));
 
447
}
 
448
 
 
449
 
 
450
static void _g_list_free__baobab_chart_item_unref0_ (GList* self) {
 
451
        g_list_foreach (self, (GFunc) _baobab_chart_item_unref0_, NULL);
 
452
        g_list_free (self);
 
453
}
 
454
 
 
455
 
 
456
static void _baobab_chart_open_file_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
 
457
        baobab_chart_open_file ((BaobabChart*) self);
 
458
}
 
459
 
 
460
 
 
461
static void _baobab_chart_copy_path_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
 
462
        baobab_chart_copy_path ((BaobabChart*) self);
 
463
}
 
464
 
 
465
 
 
466
static void _baobab_chart_trash_file_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
 
467
        baobab_chart_trash_file ((BaobabChart*) self);
 
468
}
 
469
 
 
470
 
 
471
static void _baobab_chart_move_up_root_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
 
472
        baobab_chart_move_up_root ((BaobabChart*) self);
 
473
}
 
474
 
 
475
 
 
476
static void _baobab_chart_zoom_in_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
 
477
        baobab_chart_zoom_in ((BaobabChart*) self);
 
478
}
 
479
 
 
480
 
 
481
static void _baobab_chart_zoom_out_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
 
482
        baobab_chart_zoom_out ((BaobabChart*) self);
 
483
}
 
484
 
 
485
 
 
486
void baobab_chart_set_model_with_columns (BaobabChart* self, GtkTreeModel* m, guint name_column_, guint size_column_, guint info_column_, guint percentage_column_, guint valid_column_, GtkTreePath* r) {
 
487
        GtkTreeModel* _tmp0_ = NULL;
 
488
        GtkTreePath* _tmp1_ = NULL;
 
489
        guint _tmp3_ = 0U;
 
490
        guint _tmp4_ = 0U;
 
491
        guint _tmp5_ = 0U;
 
492
        guint _tmp6_ = 0U;
 
493
        guint _tmp7_ = 0U;
 
494
        g_return_if_fail (self != NULL);
 
495
        g_return_if_fail (m != NULL);
 
496
        _tmp0_ = m;
 
497
        baobab_chart_set_model (self, _tmp0_);
 
498
        _tmp1_ = r;
 
499
        if (_tmp1_ != NULL) {
 
500
                GtkTreePath* _tmp2_ = NULL;
 
501
                _tmp2_ = r;
 
502
                baobab_chart_set_root (self, _tmp2_);
 
503
        }
 
504
        _tmp3_ = name_column_;
 
505
        self->priv->name_column = _tmp3_;
 
506
        _tmp4_ = size_column_;
 
507
        self->priv->size_column = _tmp4_;
 
508
        _tmp5_ = info_column_;
 
509
        self->priv->info_column = _tmp5_;
 
510
        _tmp6_ = percentage_column_;
 
511
        self->priv->percentage_column = _tmp6_;
 
512
        _tmp7_ = valid_column_;
 
513
        self->priv->valid_column = _tmp7_;
 
514
}
 
515
 
 
516
 
 
517
static void baobab_chart_real_post_draw (BaobabChart* self, cairo_t* cr) {
 
518
        g_return_if_fail (cr != NULL);
 
519
}
 
520
 
 
521
 
 
522
void baobab_chart_post_draw (BaobabChart* self, cairo_t* cr) {
 
523
        g_return_if_fail (self != NULL);
 
524
        BAOBAB_CHART_GET_CLASS (self)->post_draw (self, cr);
 
525
}
 
526
 
 
527
 
 
528
static void baobab_chart_real_draw_item (BaobabChart* self, cairo_t* cr, BaobabChartItem* item, gboolean highlighted) {
 
529
        g_critical ("Type `%s' does not implement abstract method `baobab_chart_draw_item'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
 
530
        return;
 
531
}
 
532
 
 
533
 
 
534
void baobab_chart_draw_item (BaobabChart* self, cairo_t* cr, BaobabChartItem* item, gboolean highlighted) {
 
535
        g_return_if_fail (self != NULL);
 
536
        BAOBAB_CHART_GET_CLASS (self)->draw_item (self, cr, item, highlighted);
 
537
}
 
538
 
 
539
 
 
540
static void baobab_chart_real_calculate_item_geometry (BaobabChart* self, BaobabChartItem* item) {
 
541
        g_critical ("Type `%s' does not implement abstract method `baobab_chart_calculate_item_geometry'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
 
542
        return;
 
543
}
 
544
 
 
545
 
 
546
void baobab_chart_calculate_item_geometry (BaobabChart* self, BaobabChartItem* item) {
 
547
        g_return_if_fail (self != NULL);
 
548
        BAOBAB_CHART_GET_CLASS (self)->calculate_item_geometry (self, item);
 
549
}
 
550
 
 
551
 
 
552
static gboolean baobab_chart_real_is_point_over_item (BaobabChart* self, BaobabChartItem* item, gdouble x, gdouble y) {
 
553
        g_critical ("Type `%s' does not implement abstract method `baobab_chart_is_point_over_item'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
 
554
        return FALSE;
 
555
}
 
556
 
 
557
 
 
558
gboolean baobab_chart_is_point_over_item (BaobabChart* self, BaobabChartItem* item, gdouble x, gdouble y) {
 
559
        g_return_val_if_fail (self != NULL, FALSE);
 
560
        return BAOBAB_CHART_GET_CLASS (self)->is_point_over_item (self, item, x, y);
 
561
}
 
562
 
 
563
 
 
564
static void baobab_chart_real_get_item_rectangle (BaobabChart* self, BaobabChartItem* item) {
 
565
        g_critical ("Type `%s' does not implement abstract method `baobab_chart_get_item_rectangle'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
 
566
        return;
 
567
}
 
568
 
 
569
 
 
570
void baobab_chart_get_item_rectangle (BaobabChart* self, BaobabChartItem* item) {
 
571
        g_return_if_fail (self != NULL);
 
572
        BAOBAB_CHART_GET_CLASS (self)->get_item_rectangle (self, item);
 
573
}
 
574
 
 
575
 
 
576
static gboolean baobab_chart_real_can_zoom_in (BaobabChart* self) {
 
577
        g_critical ("Type `%s' does not implement abstract method `baobab_chart_can_zoom_in'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
 
578
        return FALSE;
 
579
}
 
580
 
 
581
 
 
582
gboolean baobab_chart_can_zoom_in (BaobabChart* self) {
 
583
        g_return_val_if_fail (self != NULL, FALSE);
 
584
        return BAOBAB_CHART_GET_CLASS (self)->can_zoom_in (self);
 
585
}
 
586
 
 
587
 
 
588
static gboolean baobab_chart_real_can_zoom_out (BaobabChart* self) {
 
589
        g_critical ("Type `%s' does not implement abstract method `baobab_chart_can_zoom_out'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
 
590
        return FALSE;
 
591
}
 
592
 
 
593
 
 
594
gboolean baobab_chart_can_zoom_out (BaobabChart* self) {
 
595
        g_return_val_if_fail (self != NULL, FALSE);
 
596
        return BAOBAB_CHART_GET_CLASS (self)->can_zoom_out (self);
 
597
}
 
598
 
 
599
 
 
600
static BaobabChartItem* baobab_chart_real_create_new_chartitem (BaobabChart* self) {
 
601
        g_critical ("Type `%s' does not implement abstract method `baobab_chart_create_new_chartitem'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
 
602
        return NULL;
 
603
}
 
604
 
 
605
 
 
606
BaobabChartItem* baobab_chart_create_new_chartitem (BaobabChart* self) {
 
607
        g_return_val_if_fail (self != NULL, NULL);
 
608
        return BAOBAB_CHART_GET_CLASS (self)->create_new_chartitem (self);
 
609
}
 
610
 
 
611
 
 
612
static gpointer _baobab_chart_item_ref0 (gpointer self) {
 
613
        return self ? baobab_chart_item_ref (self) : NULL;
 
614
}
 
615
 
 
616
 
 
617
static void baobab_chart_real_size_allocate (GtkWidget* base, GtkAllocation* allocation) {
 
618
        BaobabChart * self;
 
619
        GtkAllocation _tmp0_ = {0};
 
620
        GList* _tmp1_ = NULL;
 
621
        self = (BaobabChart*) base;
 
622
        g_return_if_fail (allocation != NULL);
 
623
        _tmp0_ = *allocation;
 
624
        GTK_WIDGET_CLASS (baobab_chart_parent_class)->size_allocate ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_drawing_area_get_type (), GtkDrawingArea), &_tmp0_);
 
625
        _tmp1_ = self->priv->items;
 
626
        {
 
627
                GList* item_collection = NULL;
 
628
                GList* item_it = NULL;
 
629
                item_collection = _tmp1_;
 
630
                for (item_it = item_collection; item_it != NULL; item_it = item_it->next) {
 
631
                        BaobabChartItem* _tmp2_ = NULL;
 
632
                        BaobabChartItem* item = NULL;
 
633
                        _tmp2_ = _baobab_chart_item_ref0 ((BaobabChartItem*) item_it->data);
 
634
                        item = _tmp2_;
 
635
                        {
 
636
                                BaobabChartItem* _tmp3_ = NULL;
 
637
                                BaobabChartItem* _tmp4_ = NULL;
 
638
                                BaobabChartItem* _tmp5_ = NULL;
 
639
                                _tmp3_ = item;
 
640
                                _tmp3_->has_visible_children = FALSE;
 
641
                                _tmp4_ = item;
 
642
                                _tmp4_->visible = FALSE;
 
643
                                _tmp5_ = item;
 
644
                                baobab_chart_calculate_item_geometry (self, _tmp5_);
 
645
                                _baobab_chart_item_unref0 (item);
 
646
                        }
 
647
                }
 
648
        }
 
649
}
 
650
 
 
651
 
 
652
static gboolean baobab_chart_highlight_item_at_point (BaobabChart* self, gdouble x, gdouble y) {
 
653
        gboolean result = FALSE;
 
654
        g_return_val_if_fail (self != NULL, FALSE);
 
655
        {
 
656
                GList* node = NULL;
 
657
                GList* _tmp0_ = NULL;
 
658
                GList* _tmp1_ = NULL;
 
659
                _tmp0_ = self->priv->items;
 
660
                _tmp1_ = g_list_last (_tmp0_);
 
661
                node = _tmp1_;
 
662
                {
 
663
                        gboolean _tmp2_ = FALSE;
 
664
                        _tmp2_ = TRUE;
 
665
                        while (TRUE) {
 
666
                                GList* _tmp5_ = NULL;
 
667
                                BaobabChartItem* item = NULL;
 
668
                                GList* _tmp6_ = NULL;
 
669
                                gconstpointer _tmp7_ = NULL;
 
670
                                BaobabChartItem* _tmp8_ = NULL;
 
671
                                gboolean _tmp9_ = FALSE;
 
672
                                BaobabChartItem* _tmp10_ = NULL;
 
673
                                gboolean _tmp11_ = FALSE;
 
674
                                if (!_tmp2_) {
 
675
                                        GList* _tmp3_ = NULL;
 
676
                                        GList* _tmp4_ = NULL;
 
677
                                        _tmp3_ = node;
 
678
                                        _tmp4_ = _tmp3_->prev;
 
679
                                        node = _tmp4_;
 
680
                                }
 
681
                                _tmp2_ = FALSE;
 
682
                                _tmp5_ = node;
 
683
                                if (!(_tmp5_ != NULL)) {
 
684
                                        break;
 
685
                                }
 
686
                                _tmp6_ = node;
 
687
                                _tmp7_ = _tmp6_->data;
 
688
                                _tmp8_ = _baobab_chart_item_ref0 ((BaobabChartItem*) _tmp7_);
 
689
                                item = _tmp8_;
 
690
                                _tmp10_ = item;
 
691
                                _tmp11_ = _tmp10_->visible;
 
692
                                if (_tmp11_) {
 
693
                                        BaobabChartItem* _tmp12_ = NULL;
 
694
                                        gdouble _tmp13_ = 0.0;
 
695
                                        gdouble _tmp14_ = 0.0;
 
696
                                        gboolean _tmp15_ = FALSE;
 
697
                                        _tmp12_ = item;
 
698
                                        _tmp13_ = x;
 
699
                                        _tmp14_ = y;
 
700
                                        _tmp15_ = baobab_chart_is_point_over_item (self, _tmp12_, _tmp13_, _tmp14_);
 
701
                                        _tmp9_ = _tmp15_;
 
702
                                } else {
 
703
                                        _tmp9_ = FALSE;
 
704
                                }
 
705
                                if (_tmp9_) {
 
706
                                        BaobabChartItem* _tmp16_ = NULL;
 
707
                                        _tmp16_ = item;
 
708
                                        baobab_chart_set_highlighted_item (self, _tmp16_);
 
709
                                        result = TRUE;
 
710
                                        _baobab_chart_item_unref0 (item);
 
711
                                        return result;
 
712
                                }
 
713
                                _baobab_chart_item_unref0 (item);
 
714
                        }
 
715
                }
 
716
        }
 
717
        baobab_chart_set_highlighted_item (self, NULL);
 
718
        result = FALSE;
 
719
        return result;
 
720
}
 
721
 
 
722
 
 
723
static gboolean baobab_chart_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
 
724
        BaobabChart * self;
 
725
        gboolean result = FALSE;
 
726
        GdkEventMotion* _tmp0_ = NULL;
 
727
        gdouble _tmp1_ = 0.0;
 
728
        GdkEventMotion* _tmp2_ = NULL;
 
729
        gdouble _tmp3_ = 0.0;
 
730
        gboolean _tmp4_ = FALSE;
 
731
        GdkEventMotion* _tmp5_ = NULL;
 
732
        self = (BaobabChart*) base;
 
733
        g_return_val_if_fail (event != NULL, FALSE);
 
734
        _tmp0_ = event;
 
735
        _tmp1_ = _tmp0_->x;
 
736
        _tmp2_ = event;
 
737
        _tmp3_ = _tmp2_->y;
 
738
        _tmp4_ = baobab_chart_highlight_item_at_point (self, _tmp1_, _tmp3_);
 
739
        gtk_widget_set_has_tooltip ((GtkWidget*) self, _tmp4_);
 
740
        _tmp5_ = event;
 
741
        gdk_event_request_motions (_tmp5_);
 
742
        result = FALSE;
 
743
        return result;
 
744
}
 
745
 
 
746
 
 
747
static gboolean baobab_chart_real_leave_notify_event (GtkWidget* base, GdkEventCrossing* event) {
 
748
        BaobabChart * self;
 
749
        gboolean result = FALSE;
 
750
        GtkMenu* _tmp0_ = NULL;
 
751
        gboolean _tmp1_ = FALSE;
 
752
        gboolean _tmp2_ = FALSE;
 
753
        self = (BaobabChart*) base;
 
754
        g_return_val_if_fail (event != NULL, FALSE);
 
755
        _tmp0_ = self->priv->context_menu;
 
756
        _tmp1_ = gtk_widget_get_visible ((GtkWidget*) _tmp0_);
 
757
        _tmp2_ = _tmp1_;
 
758
        if (!_tmp2_) {
 
759
                baobab_chart_set_highlighted_item (self, NULL);
 
760
        }
 
761
        result = FALSE;
 
762
        return result;
 
763
}
 
764
 
 
765
 
 
766
static GList* baobab_chart_add_item (BaobabChart* self, guint depth, gdouble rel_start, gdouble rel_size, GtkTreeIter* iter) {
 
767
        GList* result = NULL;
 
768
        gchar* name = NULL;
 
769
        guint64 size = 0ULL;
 
770
        GtkTreeModel* _tmp0_ = NULL;
 
771
        GtkTreeModel* _tmp1_ = NULL;
 
772
        GtkTreeIter _tmp2_ = {0};
 
773
        guint _tmp3_ = 0U;
 
774
        guint _tmp4_ = 0U;
 
775
        BaobabChartItem* item = NULL;
 
776
        BaobabChartItem* _tmp5_ = NULL;
 
777
        gchar* _tmp6_ = NULL;
 
778
        gchar* _tmp7_ = NULL;
 
779
        guint _tmp8_ = 0U;
 
780
        gdouble _tmp9_ = 0.0;
 
781
        gdouble _tmp10_ = 0.0;
 
782
        GtkTreeIter _tmp11_ = {0};
 
783
        BaobabChartItem* _tmp12_ = NULL;
 
784
        GList* ret = NULL;
 
785
        GList* _tmp13_ = NULL;
 
786
        g_return_val_if_fail (self != NULL, NULL);
 
787
        g_return_val_if_fail (iter != NULL, NULL);
 
788
        _tmp0_ = baobab_chart_get_model (self);
 
789
        _tmp1_ = _tmp0_;
 
790
        _tmp2_ = *iter;
 
791
        _tmp3_ = self->priv->name_column;
 
792
        _tmp4_ = self->priv->size_column;
 
793
        gtk_tree_model_get (_tmp1_, &_tmp2_, _tmp3_, &name, _tmp4_, &size, -1, -1);
 
794
        _tmp5_ = baobab_chart_create_new_chartitem (self);
 
795
        item = _tmp5_;
 
796
        _tmp6_ = g_strdup (name);
 
797
        _g_free0 (item->name);
 
798
        item->name = _tmp6_;
 
799
        _tmp7_ = g_format_size_full (size, G_FORMAT_SIZE_DEFAULT);
 
800
        _g_free0 (item->size);
 
801
        item->size = _tmp7_;
 
802
        _tmp8_ = depth;
 
803
        item->depth = _tmp8_;
 
804
        _tmp9_ = rel_start;
 
805
        item->rel_start = _tmp9_;
 
806
        _tmp10_ = rel_size;
 
807
        item->rel_size = _tmp10_;
 
808
        item->has_any_child = FALSE;
 
809
        item->visible = FALSE;
 
810
        item->has_visible_children = FALSE;
 
811
        _tmp11_ = *iter;
 
812
        item->iter = _tmp11_;
 
813
        item->parent = NULL;
 
814
        _tmp12_ = _baobab_chart_item_ref0 (item);
 
815
        self->priv->items = g_list_prepend (self->priv->items, _tmp12_);
 
816
        _tmp13_ = self->priv->items;
 
817
        ret = _tmp13_;
 
818
        result = ret;
 
819
        _baobab_chart_item_unref0 (item);
 
820
        _g_free0 (name);
 
821
        return result;
 
822
}
 
823
 
 
824
 
 
825
static void baobab_chart_get_items (BaobabChart* self, GtkTreePath* root_path) {
 
826
        GList* node = NULL;
 
827
        GtkTreeIter initial_iter = {0};
 
828
        GtkTreeIter _tmp0_ = {0};
 
829
        gdouble size = 0.0;
 
830
        GtkTreePath* model_root_path = NULL;
 
831
        GtkTreeIter model_root_iter = {0};
 
832
        GtkTreeIter child_iter = {0};
 
833
        GtkTreeIter _tmp1_ = {0};
 
834
        GList* child_node = NULL;
 
835
        gdouble rel_start = 0.0;
 
836
        GtkTreeModel* _tmp2_ = NULL;
 
837
        GtkTreeModel* _tmp3_ = NULL;
 
838
        GtkTreePath* _tmp4_ = NULL;
 
839
        GtkTreeIter _tmp5_ = {0};
 
840
        gboolean _tmp6_ = FALSE;
 
841
        GtkTreePath* _tmp7_ = NULL;
 
842
        GtkTreeModel* _tmp8_ = NULL;
 
843
        GtkTreeModel* _tmp9_ = NULL;
 
844
        GtkTreePath* _tmp10_ = NULL;
 
845
        GtkTreeIter _tmp11_ = {0};
 
846
        GtkTreeModel* _tmp12_ = NULL;
 
847
        GtkTreeModel* _tmp13_ = NULL;
 
848
        GtkTreeIter _tmp14_ = {0};
 
849
        guint _tmp15_ = 0U;
 
850
        GtkTreeIter _tmp16_ = {0};
 
851
        GList* _tmp17_ = NULL;
 
852
        g_return_if_fail (self != NULL);
 
853
        g_return_if_fail (root_path != NULL);
 
854
        node = NULL;
 
855
        _tmp0_.stamp = 0;
 
856
        initial_iter = _tmp0_;
 
857
        _tmp1_.stamp = 0;
 
858
        child_iter = _tmp1_;
 
859
        __g_list_free__baobab_chart_item_unref0_0 (self->priv->items);
 
860
        self->priv->items = NULL;
 
861
        _tmp2_ = baobab_chart_get_model (self);
 
862
        _tmp3_ = _tmp2_;
 
863
        _tmp4_ = root_path;
 
864
        _tmp6_ = gtk_tree_model_get_iter (_tmp3_, &_tmp5_, _tmp4_);
 
865
        initial_iter = _tmp5_;
 
866
        if (!_tmp6_) {
 
867
                self->priv->model_changed = FALSE;
 
868
                _gtk_tree_path_free0 (model_root_path);
 
869
                return;
 
870
        }
 
871
        _tmp7_ = gtk_tree_path_new_first ();
 
872
        _gtk_tree_path_free0 (model_root_path);
 
873
        model_root_path = _tmp7_;
 
874
        _tmp8_ = baobab_chart_get_model (self);
 
875
        _tmp9_ = _tmp8_;
 
876
        _tmp10_ = model_root_path;
 
877
        gtk_tree_model_get_iter (_tmp9_, &_tmp11_, _tmp10_);
 
878
        model_root_iter = _tmp11_;
 
879
        _tmp12_ = baobab_chart_get_model (self);
 
880
        _tmp13_ = _tmp12_;
 
881
        _tmp14_ = model_root_iter;
 
882
        _tmp15_ = self->priv->percentage_column;
 
883
        gtk_tree_model_get (_tmp13_, &_tmp14_, _tmp15_, &size, -1, -1);
 
884
        _tmp16_ = initial_iter;
 
885
        _tmp17_ = baobab_chart_add_item (self, (guint) 0, (gdouble) 0, (gdouble) 100, &_tmp16_);
 
886
        node = _tmp17_;
 
887
        {
 
888
                gboolean _tmp18_ = FALSE;
 
889
                _tmp18_ = TRUE;
 
890
                while (TRUE) {
 
891
                        BaobabChartItem* item = NULL;
 
892
                        GList* _tmp20_ = NULL;
 
893
                        gconstpointer _tmp21_ = NULL;
 
894
                        BaobabChartItem* _tmp22_ = NULL;
 
895
                        BaobabChartItem* _tmp23_ = NULL;
 
896
                        GtkTreeModel* _tmp24_ = NULL;
 
897
                        GtkTreeModel* _tmp25_ = NULL;
 
898
                        BaobabChartItem* _tmp26_ = NULL;
 
899
                        GtkTreeIter _tmp27_ = {0};
 
900
                        GtkTreeIter _tmp28_ = {0};
 
901
                        gboolean _tmp29_ = FALSE;
 
902
                        BaobabChartItem* _tmp30_ = NULL;
 
903
                        BaobabChartItem* _tmp31_ = NULL;
 
904
                        gboolean _tmp32_ = FALSE;
 
905
                        gboolean _tmp35_ = FALSE;
 
906
                        BaobabChartItem* _tmp36_ = NULL;
 
907
                        gboolean _tmp37_ = FALSE;
 
908
                        GList* _tmp63_ = NULL;
 
909
                        GList* _tmp64_ = NULL;
 
910
                        if (!_tmp18_) {
 
911
                                GList* _tmp19_ = NULL;
 
912
                                _tmp19_ = node;
 
913
                                if (!(_tmp19_ != NULL)) {
 
914
                                        break;
 
915
                                }
 
916
                        }
 
917
                        _tmp18_ = FALSE;
 
918
                        _tmp20_ = node;
 
919
                        _tmp21_ = _tmp20_->data;
 
920
                        _tmp22_ = _baobab_chart_item_ref0 ((BaobabChartItem*) _tmp21_);
 
921
                        item = _tmp22_;
 
922
                        _tmp23_ = item;
 
923
                        _tmp24_ = baobab_chart_get_model (self);
 
924
                        _tmp25_ = _tmp24_;
 
925
                        _tmp26_ = item;
 
926
                        _tmp27_ = _tmp26_->iter;
 
927
                        _tmp29_ = gtk_tree_model_iter_children (_tmp25_, &_tmp28_, &_tmp27_);
 
928
                        child_iter = _tmp28_;
 
929
                        _tmp23_->has_any_child = _tmp29_;
 
930
                        _tmp30_ = item;
 
931
                        baobab_chart_calculate_item_geometry (self, _tmp30_);
 
932
                        _tmp31_ = item;
 
933
                        _tmp32_ = _tmp31_->visible;
 
934
                        if (!_tmp32_) {
 
935
                                GList* _tmp33_ = NULL;
 
936
                                GList* _tmp34_ = NULL;
 
937
                                _tmp33_ = node;
 
938
                                _tmp34_ = _tmp33_->prev;
 
939
                                node = _tmp34_;
 
940
                                _baobab_chart_item_unref0 (item);
 
941
                                continue;
 
942
                        }
 
943
                        _tmp36_ = item;
 
944
                        _tmp37_ = _tmp36_->has_any_child;
 
945
                        if (_tmp37_) {
 
946
                                BaobabChartItem* _tmp38_ = NULL;
 
947
                                guint _tmp39_ = 0U;
 
948
                                guint _tmp40_ = 0U;
 
949
                                guint _tmp41_ = 0U;
 
950
                                _tmp38_ = item;
 
951
                                _tmp39_ = _tmp38_->depth;
 
952
                                _tmp40_ = baobab_chart_get_max_depth (self);
 
953
                                _tmp41_ = _tmp40_;
 
954
                                _tmp35_ = _tmp39_ < (_tmp41_ + 1);
 
955
                        } else {
 
956
                                _tmp35_ = FALSE;
 
957
                        }
 
958
                        if (_tmp35_) {
 
959
                                rel_start = (gdouble) 0;
 
960
                                {
 
961
                                        gboolean _tmp42_ = FALSE;
 
962
                                        _tmp42_ = TRUE;
 
963
                                        while (TRUE) {
 
964
                                                GtkTreeModel* _tmp46_ = NULL;
 
965
                                                GtkTreeModel* _tmp47_ = NULL;
 
966
                                                GtkTreeIter _tmp48_ = {0};
 
967
                                                guint _tmp49_ = 0U;
 
968
                                                BaobabChartItem* _tmp50_ = NULL;
 
969
                                                guint _tmp51_ = 0U;
 
970
                                                gdouble _tmp52_ = 0.0;
 
971
                                                gdouble _tmp53_ = 0.0;
 
972
                                                GtkTreeIter _tmp54_ = {0};
 
973
                                                GList* _tmp55_ = NULL;
 
974
                                                BaobabChartItem* child = NULL;
 
975
                                                GList* _tmp56_ = NULL;
 
976
                                                gconstpointer _tmp57_ = NULL;
 
977
                                                BaobabChartItem* _tmp58_ = NULL;
 
978
                                                BaobabChartItem* _tmp59_ = NULL;
 
979
                                                GList* _tmp60_ = NULL;
 
980
                                                gdouble _tmp61_ = 0.0;
 
981
                                                gdouble _tmp62_ = 0.0;
 
982
                                                if (!_tmp42_) {
 
983
                                                        GtkTreeModel* _tmp43_ = NULL;
 
984
                                                        GtkTreeModel* _tmp44_ = NULL;
 
985
                                                        gboolean _tmp45_ = FALSE;
 
986
                                                        _tmp43_ = baobab_chart_get_model (self);
 
987
                                                        _tmp44_ = _tmp43_;
 
988
                                                        _tmp45_ = gtk_tree_model_iter_next (_tmp44_, &child_iter);
 
989
                                                        if (!_tmp45_) {
 
990
                                                                break;
 
991
                                                        }
 
992
                                                }
 
993
                                                _tmp42_ = FALSE;
 
994
                                                _tmp46_ = baobab_chart_get_model (self);
 
995
                                                _tmp47_ = _tmp46_;
 
996
                                                _tmp48_ = child_iter;
 
997
                                                _tmp49_ = self->priv->percentage_column;
 
998
                                                gtk_tree_model_get (_tmp47_, &_tmp48_, _tmp49_, &size, -1, -1);
 
999
                                                _tmp50_ = item;
 
1000
                                                _tmp51_ = _tmp50_->depth;
 
1001
                                                _tmp52_ = rel_start;
 
1002
                                                _tmp53_ = size;
 
1003
                                                _tmp54_ = child_iter;
 
1004
                                                _tmp55_ = baobab_chart_add_item (self, _tmp51_ + 1, _tmp52_, _tmp53_, &_tmp54_);
 
1005
                                                child_node = _tmp55_;
 
1006
                                                _tmp56_ = child_node;
 
1007
                                                _tmp57_ = _tmp56_->data;
 
1008
                                                _tmp58_ = _baobab_chart_item_ref0 ((BaobabChartItem*) _tmp57_);
 
1009
                                                child = _tmp58_;
 
1010
                                                _tmp59_ = child;
 
1011
                                                _tmp60_ = node;
 
1012
                                                _tmp59_->parent = _tmp60_;
 
1013
                                                _tmp61_ = rel_start;
 
1014
                                                _tmp62_ = size;
 
1015
                                                rel_start = _tmp61_ + _tmp62_;
 
1016
                                                _baobab_chart_item_unref0 (child);
 
1017
                                        }
 
1018
                                }
 
1019
                        }
 
1020
                        _tmp63_ = node;
 
1021
                        _tmp64_ = _tmp63_->prev;
 
1022
                        node = _tmp64_;
 
1023
                        _baobab_chart_item_unref0 (item);
 
1024
                }
 
1025
        }
 
1026
        self->priv->items = g_list_reverse (self->priv->items);
 
1027
        self->priv->model_changed = FALSE;
 
1028
        _gtk_tree_path_free0 (model_root_path);
 
1029
}
 
1030
 
 
1031
 
 
1032
static void baobab_chart_draw_chart (BaobabChart* self, cairo_t* cr) {
 
1033
        cairo_t* _tmp0_ = NULL;
 
1034
        GList* _tmp1_ = NULL;
 
1035
        cairo_t* _tmp24_ = NULL;
 
1036
        cairo_t* _tmp25_ = NULL;
 
1037
        g_return_if_fail (self != NULL);
 
1038
        g_return_if_fail (cr != NULL);
 
1039
        _tmp0_ = cr;
 
1040
        cairo_save (_tmp0_);
 
1041
        _tmp1_ = self->priv->items;
 
1042
        {
 
1043
                GList* item_collection = NULL;
 
1044
                GList* item_it = NULL;
 
1045
                item_collection = _tmp1_;
 
1046
                for (item_it = item_collection; item_it != NULL; item_it = item_it->next) {
 
1047
                        BaobabChartItem* _tmp2_ = NULL;
 
1048
                        BaobabChartItem* item = NULL;
 
1049
                        _tmp2_ = _baobab_chart_item_ref0 ((BaobabChartItem*) item_it->data);
 
1050
                        item = _tmp2_;
 
1051
                        {
 
1052
                                GdkRectangle clip = {0};
 
1053
                                gboolean _tmp3_ = FALSE;
 
1054
                                gboolean _tmp4_ = FALSE;
 
1055
                                gboolean _tmp5_ = FALSE;
 
1056
                                cairo_t* _tmp6_ = NULL;
 
1057
                                GdkRectangle _tmp7_ = {0};
 
1058
                                gboolean _tmp8_ = FALSE;
 
1059
                                _tmp6_ = cr;
 
1060
                                _tmp8_ = gdk_cairo_get_clip_rectangle (_tmp6_, &_tmp7_);
 
1061
                                clip = _tmp7_;
 
1062
                                if (_tmp8_) {
 
1063
                                        BaobabChartItem* _tmp9_ = NULL;
 
1064
                                        gboolean _tmp10_ = FALSE;
 
1065
                                        _tmp9_ = item;
 
1066
                                        _tmp10_ = _tmp9_->visible;
 
1067
                                        _tmp5_ = _tmp10_;
 
1068
                                } else {
 
1069
                                        _tmp5_ = FALSE;
 
1070
                                }
 
1071
                                if (_tmp5_) {
 
1072
                                        BaobabChartItem* _tmp11_ = NULL;
 
1073
                                        GdkRectangle _tmp12_ = {0};
 
1074
                                        gboolean _tmp13_ = FALSE;
 
1075
                                        _tmp11_ = item;
 
1076
                                        _tmp12_ = _tmp11_->rect;
 
1077
                                        _tmp13_ = gdk_rectangle_intersect (&clip, &_tmp12_, NULL);
 
1078
                                        _tmp4_ = _tmp13_;
 
1079
                                } else {
 
1080
                                        _tmp4_ = FALSE;
 
1081
                                }
 
1082
                                if (_tmp4_) {
 
1083
                                        BaobabChartItem* _tmp14_ = NULL;
 
1084
                                        guint _tmp15_ = 0U;
 
1085
                                        guint _tmp16_ = 0U;
 
1086
                                        guint _tmp17_ = 0U;
 
1087
                                        _tmp14_ = item;
 
1088
                                        _tmp15_ = _tmp14_->depth;
 
1089
                                        _tmp16_ = baobab_chart_get_max_depth (self);
 
1090
                                        _tmp17_ = _tmp16_;
 
1091
                                        _tmp3_ = _tmp15_ <= _tmp17_;
 
1092
                                } else {
 
1093
                                        _tmp3_ = FALSE;
 
1094
                                }
 
1095
                                if (_tmp3_) {
 
1096
                                        gboolean highlighted = FALSE;
 
1097
                                        BaobabChartItem* _tmp18_ = NULL;
 
1098
                                        BaobabChartItem* _tmp19_ = NULL;
 
1099
                                        BaobabChartItem* _tmp20_ = NULL;
 
1100
                                        cairo_t* _tmp21_ = NULL;
 
1101
                                        BaobabChartItem* _tmp22_ = NULL;
 
1102
                                        gboolean _tmp23_ = FALSE;
 
1103
                                        _tmp18_ = item;
 
1104
                                        _tmp19_ = baobab_chart_get_highlighted_item (self);
 
1105
                                        _tmp20_ = _tmp19_;
 
1106
                                        highlighted = _tmp18_ == _tmp20_;
 
1107
                                        _tmp21_ = cr;
 
1108
                                        _tmp22_ = item;
 
1109
                                        _tmp23_ = highlighted;
 
1110
                                        baobab_chart_draw_item (self, _tmp21_, _tmp22_, _tmp23_);
 
1111
                                }
 
1112
                                _baobab_chart_item_unref0 (item);
 
1113
                        }
 
1114
                }
 
1115
        }
 
1116
        _tmp24_ = cr;
 
1117
        cairo_restore (_tmp24_);
 
1118
        _tmp25_ = cr;
 
1119
        baobab_chart_post_draw (self, _tmp25_);
 
1120
}
 
1121
 
 
1122
 
 
1123
static void baobab_chart_update_draw (BaobabChart* self, GtkTreePath* path) {
 
1124
        gboolean _tmp0_ = FALSE;
 
1125
        gint root_depth = 0;
 
1126
        GtkTreePath* _tmp1_ = NULL;
 
1127
        GtkTreePath* _tmp2_ = NULL;
 
1128
        GtkTreePath* _tmp3_ = NULL;
 
1129
        gint _tmp4_ = 0;
 
1130
        gint _tmp5_ = 0;
 
1131
        gint node_depth = 0;
 
1132
        GtkTreePath* _tmp6_ = NULL;
 
1133
        gint _tmp7_ = 0;
 
1134
        gboolean _tmp8_ = FALSE;
 
1135
        gint _tmp9_ = 0;
 
1136
        gint _tmp10_ = 0;
 
1137
        guint _tmp11_ = 0U;
 
1138
        guint _tmp12_ = 0U;
 
1139
        g_return_if_fail (self != NULL);
 
1140
        g_return_if_fail (path != NULL);
 
1141
        _tmp0_ = gtk_widget_get_realized ((GtkWidget*) self);
 
1142
        if (!_tmp0_) {
 
1143
                return;
 
1144
        }
 
1145
        _tmp1_ = baobab_chart_get_root (self);
 
1146
        _tmp2_ = _tmp1_;
 
1147
        _tmp3_ = _tmp2_;
 
1148
        _tmp4_ = gtk_tree_path_get_depth (_tmp3_);
 
1149
        _tmp5_ = _tmp4_;
 
1150
        _gtk_tree_path_free0 (_tmp3_);
 
1151
        root_depth = _tmp5_;
 
1152
        _tmp6_ = path;
 
1153
        _tmp7_ = gtk_tree_path_get_depth (_tmp6_);
 
1154
        node_depth = _tmp7_;
 
1155
        _tmp9_ = node_depth;
 
1156
        _tmp10_ = root_depth;
 
1157
        _tmp11_ = baobab_chart_get_max_depth (self);
 
1158
        _tmp12_ = _tmp11_;
 
1159
        if (((guint) (_tmp9_ - _tmp10_)) <= _tmp12_) {
 
1160
                gboolean _tmp13_ = FALSE;
 
1161
                GtkTreePath* _tmp14_ = NULL;
 
1162
                GtkTreePath* _tmp15_ = NULL;
 
1163
                GtkTreePath* _tmp16_ = NULL;
 
1164
                GtkTreePath* _tmp17_ = NULL;
 
1165
                gboolean _tmp18_ = FALSE;
 
1166
                gboolean _tmp19_ = FALSE;
 
1167
                _tmp14_ = baobab_chart_get_root (self);
 
1168
                _tmp15_ = _tmp14_;
 
1169
                _tmp16_ = _tmp15_;
 
1170
                _tmp17_ = path;
 
1171
                _tmp18_ = gtk_tree_path_is_ancestor (_tmp16_, _tmp17_);
 
1172
                _tmp19_ = _tmp18_;
 
1173
                _gtk_tree_path_free0 (_tmp16_);
 
1174
                if (_tmp19_) {
 
1175
                        _tmp13_ = TRUE;
 
1176
                } else {
 
1177
                        GtkTreePath* _tmp20_ = NULL;
 
1178
                        GtkTreePath* _tmp21_ = NULL;
 
1179
                        GtkTreePath* _tmp22_ = NULL;
 
1180
                        GtkTreePath* _tmp23_ = NULL;
 
1181
                        gint _tmp24_ = 0;
 
1182
                        _tmp20_ = baobab_chart_get_root (self);
 
1183
                        _tmp21_ = _tmp20_;
 
1184
                        _tmp22_ = _tmp21_;
 
1185
                        _tmp23_ = path;
 
1186
                        _tmp24_ = gtk_tree_path_compare (_tmp22_, _tmp23_);
 
1187
                        _tmp13_ = _tmp24_ == 0;
 
1188
                        _gtk_tree_path_free0 (_tmp22_);
 
1189
                }
 
1190
                _tmp8_ = _tmp13_;
 
1191
        } else {
 
1192
                _tmp8_ = FALSE;
 
1193
        }
 
1194
        if (_tmp8_) {
 
1195
                gtk_widget_queue_draw ((GtkWidget*) self);
 
1196
        }
 
1197
}
 
1198
 
 
1199
 
 
1200
static void baobab_chart_row_changed (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter) {
 
1201
        GtkTreePath* _tmp0_ = NULL;
 
1202
        g_return_if_fail (self != NULL);
 
1203
        g_return_if_fail (model != NULL);
 
1204
        g_return_if_fail (path != NULL);
 
1205
        g_return_if_fail (iter != NULL);
 
1206
        self->priv->model_changed = TRUE;
 
1207
        _tmp0_ = path;
 
1208
        baobab_chart_update_draw (self, _tmp0_);
 
1209
}
 
1210
 
 
1211
 
 
1212
static void baobab_chart_row_inserted (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter) {
 
1213
        GtkTreePath* _tmp0_ = NULL;
 
1214
        g_return_if_fail (self != NULL);
 
1215
        g_return_if_fail (model != NULL);
 
1216
        g_return_if_fail (path != NULL);
 
1217
        g_return_if_fail (iter != NULL);
 
1218
        self->priv->model_changed = TRUE;
 
1219
        _tmp0_ = path;
 
1220
        baobab_chart_update_draw (self, _tmp0_);
 
1221
}
 
1222
 
 
1223
 
 
1224
static void baobab_chart_row_deleted (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path) {
 
1225
        GtkTreePath* _tmp0_ = NULL;
 
1226
        g_return_if_fail (self != NULL);
 
1227
        g_return_if_fail (model != NULL);
 
1228
        g_return_if_fail (path != NULL);
 
1229
        self->priv->model_changed = TRUE;
 
1230
        _tmp0_ = path;
 
1231
        baobab_chart_update_draw (self, _tmp0_);
 
1232
}
 
1233
 
 
1234
 
 
1235
static void baobab_chart_row_has_child_toggled (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter) {
 
1236
        GtkTreePath* _tmp0_ = NULL;
 
1237
        g_return_if_fail (self != NULL);
 
1238
        g_return_if_fail (model != NULL);
 
1239
        g_return_if_fail (path != NULL);
 
1240
        g_return_if_fail (iter != NULL);
 
1241
        self->priv->model_changed = TRUE;
 
1242
        _tmp0_ = path;
 
1243
        baobab_chart_update_draw (self, _tmp0_);
 
1244
}
 
1245
 
 
1246
 
 
1247
static void baobab_chart_rows_reordered (BaobabChart* self, GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, void* new_order) {
 
1248
        GtkTreePath* _tmp0_ = NULL;
 
1249
        g_return_if_fail (self != NULL);
 
1250
        g_return_if_fail (model != NULL);
 
1251
        g_return_if_fail (path != NULL);
 
1252
        self->priv->model_changed = TRUE;
 
1253
        _tmp0_ = path;
 
1254
        baobab_chart_update_draw (self, _tmp0_);
 
1255
}
 
1256
 
 
1257
 
 
1258
static gboolean baobab_chart_real_draw (GtkWidget* base, cairo_t* cr) {
 
1259
        BaobabChart * self;
 
1260
        gboolean result = FALSE;
 
1261
        guint _tmp0_ = 0U;
 
1262
        guint _tmp1_ = 0U;
 
1263
        GtkTreeModel* _tmp2_ = NULL;
 
1264
        GtkTreeModel* _tmp3_ = NULL;
 
1265
        self = (BaobabChart*) base;
 
1266
        g_return_val_if_fail (cr != NULL, FALSE);
 
1267
        _tmp0_ = self->priv->name_column;
 
1268
        _tmp1_ = self->priv->percentage_column;
 
1269
        if (_tmp0_ == _tmp1_) {
 
1270
                result = FALSE;
 
1271
                return result;
 
1272
        }
 
1273
        _tmp2_ = baobab_chart_get_model (self);
 
1274
        _tmp3_ = _tmp2_;
 
1275
        if (_tmp3_ != NULL) {
 
1276
                gboolean _tmp4_ = FALSE;
 
1277
                gboolean _tmp5_ = FALSE;
 
1278
                GtkAllocation allocation = {0};
 
1279
                GtkAllocation _tmp25_ = {0};
 
1280
                cairo_surface_t* source = NULL;
 
1281
                GtkAllocation _tmp26_ = {0};
 
1282
                gint _tmp27_ = 0;
 
1283
                GtkAllocation _tmp28_ = {0};
 
1284
                gint _tmp29_ = 0;
 
1285
                cairo_surface_t* _tmp30_ = NULL;
 
1286
                cairo_t* source_cr = NULL;
 
1287
                cairo_surface_t* _tmp31_ = NULL;
 
1288
                cairo_t* _tmp32_ = NULL;
 
1289
                cairo_t* _tmp33_ = NULL;
 
1290
                cairo_t* _tmp34_ = NULL;
 
1291
                cairo_surface_t* _tmp35_ = NULL;
 
1292
                cairo_t* _tmp36_ = NULL;
 
1293
                _tmp5_ = self->priv->model_changed;
 
1294
                if (_tmp5_) {
 
1295
                        _tmp4_ = TRUE;
 
1296
                } else {
 
1297
                        GList* _tmp6_ = NULL;
 
1298
                        _tmp6_ = self->priv->items;
 
1299
                        _tmp4_ = _tmp6_ == NULL;
 
1300
                }
 
1301
                if (_tmp4_) {
 
1302
                        GtkTreePath* _tmp7_ = NULL;
 
1303
                        GtkTreePath* _tmp8_ = NULL;
 
1304
                        GtkTreePath* _tmp9_ = NULL;
 
1305
                        _tmp7_ = baobab_chart_get_root (self);
 
1306
                        _tmp8_ = _tmp7_;
 
1307
                        _tmp9_ = _tmp8_;
 
1308
                        baobab_chart_get_items (self, _tmp9_);
 
1309
                        _gtk_tree_path_free0 (_tmp9_);
 
1310
                } else {
 
1311
                        GtkTreePath* current_path = NULL;
 
1312
                        GtkTreeModel* _tmp10_ = NULL;
 
1313
                        GtkTreeModel* _tmp11_ = NULL;
 
1314
                        GList* _tmp12_ = NULL;
 
1315
                        gconstpointer _tmp13_ = NULL;
 
1316
                        GtkTreeIter _tmp14_ = {0};
 
1317
                        GtkTreePath* _tmp15_ = NULL;
 
1318
                        GtkTreePath* _tmp16_ = NULL;
 
1319
                        GtkTreePath* _tmp17_ = NULL;
 
1320
                        GtkTreePath* _tmp18_ = NULL;
 
1321
                        GtkTreePath* _tmp19_ = NULL;
 
1322
                        gint _tmp20_ = 0;
 
1323
                        gboolean _tmp21_ = FALSE;
 
1324
                        _tmp10_ = baobab_chart_get_model (self);
 
1325
                        _tmp11_ = _tmp10_;
 
1326
                        _tmp12_ = self->priv->items;
 
1327
                        _tmp13_ = _tmp12_->data;
 
1328
                        _tmp14_ = ((BaobabChartItem*) _tmp13_)->iter;
 
1329
                        _tmp15_ = gtk_tree_model_get_path (_tmp11_, &_tmp14_);
 
1330
                        current_path = _tmp15_;
 
1331
                        _tmp16_ = baobab_chart_get_root (self);
 
1332
                        _tmp17_ = _tmp16_;
 
1333
                        _tmp18_ = _tmp17_;
 
1334
                        _tmp19_ = current_path;
 
1335
                        _tmp20_ = gtk_tree_path_compare (_tmp18_, _tmp19_);
 
1336
                        _tmp21_ = _tmp20_ != 0;
 
1337
                        _gtk_tree_path_free0 (_tmp18_);
 
1338
                        if (_tmp21_) {
 
1339
                                GtkTreePath* _tmp22_ = NULL;
 
1340
                                GtkTreePath* _tmp23_ = NULL;
 
1341
                                GtkTreePath* _tmp24_ = NULL;
 
1342
                                _tmp22_ = baobab_chart_get_root (self);
 
1343
                                _tmp23_ = _tmp22_;
 
1344
                                _tmp24_ = _tmp23_;
 
1345
                                baobab_chart_get_items (self, _tmp24_);
 
1346
                                _gtk_tree_path_free0 (_tmp24_);
 
1347
                        }
 
1348
                        _gtk_tree_path_free0 (current_path);
 
1349
                }
 
1350
                gtk_widget_get_allocation ((GtkWidget*) self, &_tmp25_);
 
1351
                allocation = _tmp25_;
 
1352
                _tmp26_ = allocation;
 
1353
                _tmp27_ = _tmp26_.width;
 
1354
                _tmp28_ = allocation;
 
1355
                _tmp29_ = _tmp28_.height;
 
1356
                _tmp30_ = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, _tmp27_, _tmp29_);
 
1357
                source = _tmp30_;
 
1358
                _tmp31_ = source;
 
1359
                _tmp32_ = cairo_create (_tmp31_);
 
1360
                source_cr = _tmp32_;
 
1361
                _tmp33_ = source_cr;
 
1362
                baobab_chart_draw_chart (self, _tmp33_);
 
1363
                _tmp34_ = cr;
 
1364
                _tmp35_ = source;
 
1365
                cairo_set_source_surface (_tmp34_, _tmp35_, (gdouble) 0, (gdouble) 0);
 
1366
                _tmp36_ = cr;
 
1367
                cairo_paint (_tmp36_);
 
1368
                _cairo_destroy0 (source_cr);
 
1369
                _cairo_surface_destroy0 (source);
 
1370
        }
 
1371
        result = FALSE;
 
1372
        return result;
 
1373
}
 
1374
 
 
1375
 
 
1376
static void baobab_chart_interpolate_colors (BaobabChart* self, GdkRGBA* colora, GdkRGBA* colorb, gdouble percentage, GdkRGBA* result) {
 
1377
        GdkRGBA color = {0};
 
1378
        gdouble diff = 0.0;
 
1379
        GdkRGBA _tmp0_ = {0};
 
1380
        gdouble _tmp1_ = 0.0;
 
1381
        GdkRGBA _tmp2_ = {0};
 
1382
        gdouble _tmp3_ = 0.0;
 
1383
        GdkRGBA _tmp4_ = {0};
 
1384
        gdouble _tmp5_ = 0.0;
 
1385
        gdouble _tmp6_ = 0.0;
 
1386
        gdouble _tmp7_ = 0.0;
 
1387
        GdkRGBA _tmp8_ = {0};
 
1388
        gdouble _tmp9_ = 0.0;
 
1389
        GdkRGBA _tmp10_ = {0};
 
1390
        gdouble _tmp11_ = 0.0;
 
1391
        GdkRGBA _tmp12_ = {0};
 
1392
        gdouble _tmp13_ = 0.0;
 
1393
        gdouble _tmp14_ = 0.0;
 
1394
        gdouble _tmp15_ = 0.0;
 
1395
        GdkRGBA _tmp16_ = {0};
 
1396
        gdouble _tmp17_ = 0.0;
 
1397
        GdkRGBA _tmp18_ = {0};
 
1398
        gdouble _tmp19_ = 0.0;
 
1399
        GdkRGBA _tmp20_ = {0};
 
1400
        gdouble _tmp21_ = 0.0;
 
1401
        gdouble _tmp22_ = 0.0;
 
1402
        gdouble _tmp23_ = 0.0;
 
1403
        g_return_if_fail (self != NULL);
 
1404
        g_return_if_fail (colora != NULL);
 
1405
        g_return_if_fail (colorb != NULL);
 
1406
        memset (&color, 0, sizeof (GdkRGBA));
 
1407
        _tmp0_ = *colora;
 
1408
        _tmp1_ = _tmp0_.red;
 
1409
        _tmp2_ = *colorb;
 
1410
        _tmp3_ = _tmp2_.red;
 
1411
        diff = _tmp1_ - _tmp3_;
 
1412
        _tmp4_ = *colora;
 
1413
        _tmp5_ = _tmp4_.red;
 
1414
        _tmp6_ = diff;
 
1415
        _tmp7_ = percentage;
 
1416
        color.red = _tmp5_ - (_tmp6_ * _tmp7_);
 
1417
        _tmp8_ = *colora;
 
1418
        _tmp9_ = _tmp8_.green;
 
1419
        _tmp10_ = *colorb;
 
1420
        _tmp11_ = _tmp10_.green;
 
1421
        diff = _tmp9_ - _tmp11_;
 
1422
        _tmp12_ = *colora;
 
1423
        _tmp13_ = _tmp12_.green;
 
1424
        _tmp14_ = diff;
 
1425
        _tmp15_ = percentage;
 
1426
        color.green = _tmp13_ - (_tmp14_ * _tmp15_);
 
1427
        _tmp16_ = *colora;
 
1428
        _tmp17_ = _tmp16_.blue;
 
1429
        _tmp18_ = *colorb;
 
1430
        _tmp19_ = _tmp18_.blue;
 
1431
        diff = _tmp17_ - _tmp19_;
 
1432
        _tmp20_ = *colora;
 
1433
        _tmp21_ = _tmp20_.blue;
 
1434
        _tmp22_ = diff;
 
1435
        _tmp23_ = percentage;
 
1436
        color.blue = _tmp21_ - (_tmp22_ * _tmp23_);
 
1437
        color.alpha = 1.0;
 
1438
        *result = color;
 
1439
        return;
 
1440
}
 
1441
 
 
1442
 
 
1443
void baobab_chart_get_item_color (BaobabChart* self, gdouble rel_position, guint depth, gboolean highlighted, GdkRGBA* result) {
 
1444
        static const GdkRGBA level_color = {0.83, 0.84, 0.82, 1.0};
 
1445
        static const GdkRGBA level_color_hi = {0.88, 0.89, 0.87, 1.0};
 
1446
        GdkRGBA color = {0};
 
1447
        gdouble intensity = 0.0;
 
1448
        guint _tmp0_ = 0U;
 
1449
        guint _tmp1_ = 0U;
 
1450
        gboolean _tmp17_ = FALSE;
 
1451
        g_return_if_fail (self != NULL);
 
1452
        memset (&color, 0, sizeof (GdkRGBA));
 
1453
        _tmp0_ = depth;
 
1454
        intensity = 1 - (((_tmp0_ - 1) * 0.3) / BAOBAB_CHART_MAX_DEPTH);
 
1455
        _tmp1_ = depth;
 
1456
        if (_tmp1_ == ((guint) 0)) {
 
1457
                color = level_color;
 
1458
        } else {
 
1459
                gint color_number = 0;
 
1460
                gdouble _tmp2_ = 0.0;
 
1461
                gint next_color_number = 0;
 
1462
                gint _tmp3_ = 0;
 
1463
                gint _tmp4_ = 0;
 
1464
                GdkRGBA _tmp5_ = {0};
 
1465
                gint _tmp6_ = 0;
 
1466
                GdkRGBA _tmp7_ = {0};
 
1467
                gdouble _tmp8_ = 0.0;
 
1468
                gint _tmp9_ = 0;
 
1469
                GdkRGBA _tmp10_ = {0};
 
1470
                gdouble _tmp11_ = 0.0;
 
1471
                gdouble _tmp12_ = 0.0;
 
1472
                gdouble _tmp13_ = 0.0;
 
1473
                gdouble _tmp14_ = 0.0;
 
1474
                gdouble _tmp15_ = 0.0;
 
1475
                gdouble _tmp16_ = 0.0;
 
1476
                _tmp2_ = rel_position;
 
1477
                color_number = (gint) (_tmp2_ / (100.0 / 3));
 
1478
                _tmp3_ = color_number;
 
1479
                next_color_number = (_tmp3_ + 1) % 6;
 
1480
                _tmp4_ = color_number;
 
1481
                _tmp5_ = BAOBAB_CHART_TANGO_COLORS[_tmp4_];
 
1482
                _tmp6_ = next_color_number;
 
1483
                _tmp7_ = BAOBAB_CHART_TANGO_COLORS[_tmp6_];
 
1484
                _tmp8_ = rel_position;
 
1485
                _tmp9_ = color_number;
 
1486
                baobab_chart_interpolate_colors (self, &_tmp5_, &_tmp7_, (_tmp8_ - ((_tmp9_ * 100) / 3)) / (100 / 3), &_tmp10_);
 
1487
                color = _tmp10_;
 
1488
                _tmp11_ = color.red;
 
1489
                _tmp12_ = intensity;
 
1490
                color.red = _tmp11_ * _tmp12_;
 
1491
                _tmp13_ = color.green;
 
1492
                _tmp14_ = intensity;
 
1493
                color.green = _tmp13_ * _tmp14_;
 
1494
                _tmp15_ = color.blue;
 
1495
                _tmp16_ = intensity;
 
1496
                color.blue = _tmp15_ * _tmp16_;
 
1497
        }
 
1498
        _tmp17_ = highlighted;
 
1499
        if (_tmp17_) {
 
1500
                guint _tmp18_ = 0U;
 
1501
                _tmp18_ = depth;
 
1502
                if (_tmp18_ == ((guint) 0)) {
 
1503
                        color = level_color_hi;
 
1504
                } else {
 
1505
                        gdouble maximum = 0.0;
 
1506
                        GdkRGBA _tmp19_ = {0};
 
1507
                        gdouble _tmp20_ = 0.0;
 
1508
                        GdkRGBA _tmp21_ = {0};
 
1509
                        gdouble _tmp22_ = 0.0;
 
1510
                        GdkRGBA _tmp23_ = {0};
 
1511
                        gdouble _tmp24_ = 0.0;
 
1512
                        gdouble _tmp25_ = 0.0;
 
1513
                        gdouble _tmp26_ = 0.0;
 
1514
                        gdouble _tmp27_ = 0.0;
 
1515
                        gdouble _tmp28_ = 0.0;
 
1516
                        gdouble _tmp29_ = 0.0;
 
1517
                        gdouble _tmp30_ = 0.0;
 
1518
                        gdouble _tmp31_ = 0.0;
 
1519
                        gdouble _tmp32_ = 0.0;
 
1520
                        _tmp19_ = color;
 
1521
                        _tmp20_ = _tmp19_.red;
 
1522
                        _tmp21_ = color;
 
1523
                        _tmp22_ = _tmp21_.green;
 
1524
                        _tmp23_ = color;
 
1525
                        _tmp24_ = _tmp23_.blue;
 
1526
                        _tmp25_ = MAX (_tmp22_, _tmp24_);
 
1527
                        _tmp26_ = MAX (_tmp20_, _tmp25_);
 
1528
                        maximum = _tmp26_;
 
1529
                        _tmp27_ = color.red;
 
1530
                        _tmp28_ = maximum;
 
1531
                        color.red = _tmp27_ / _tmp28_;
 
1532
                        _tmp29_ = color.green;
 
1533
                        _tmp30_ = maximum;
 
1534
                        color.green = _tmp29_ / _tmp30_;
 
1535
                        _tmp31_ = color.blue;
 
1536
                        _tmp32_ = maximum;
 
1537
                        color.blue = _tmp31_ / _tmp32_;
 
1538
                }
 
1539
        }
 
1540
        *result = color;
 
1541
        return;
 
1542
}
 
1543
 
 
1544
 
 
1545
static gboolean baobab_chart_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
 
1546
        BaobabChart * self;
 
1547
        gboolean result = FALSE;
 
1548
        GdkEventButton* _tmp0_ = NULL;
 
1549
        GdkEventType _tmp1_ = 0;
 
1550
        self = (BaobabChart*) base;
 
1551
        g_return_val_if_fail (event != NULL, FALSE);
 
1552
        _tmp0_ = event;
 
1553
        _tmp1_ = _tmp0_->type;
 
1554
        if (_tmp1_ == GDK_BUTTON_PRESS) {
 
1555
                GdkEventButton* _tmp2_ = NULL;
 
1556
                gboolean _tmp3_ = FALSE;
 
1557
                GdkEventButton* _tmp5_ = NULL;
 
1558
                guint _tmp6_ = 0U;
 
1559
                _tmp2_ = event;
 
1560
                _tmp3_ = gdk_event_triggers_context_menu ((GdkEvent*) _tmp2_);
 
1561
                if (_tmp3_) {
 
1562
                        GdkEventButton* _tmp4_ = NULL;
 
1563
                        _tmp4_ = event;
 
1564
                        baobab_chart_show_popup_menu (self, _tmp4_);
 
1565
                        result = TRUE;
 
1566
                        return result;
 
1567
                }
 
1568
                _tmp5_ = event;
 
1569
                _tmp6_ = _tmp5_->button;
 
1570
                switch (_tmp6_) {
 
1571
                        case GDK_BUTTON_PRIMARY:
 
1572
                        {
 
1573
                                GdkEventButton* _tmp7_ = NULL;
 
1574
                                gdouble _tmp8_ = 0.0;
 
1575
                                GdkEventButton* _tmp9_ = NULL;
 
1576
                                gdouble _tmp10_ = 0.0;
 
1577
                                gboolean _tmp11_ = FALSE;
 
1578
                                _tmp7_ = event;
 
1579
                                _tmp8_ = _tmp7_->x;
 
1580
                                _tmp9_ = event;
 
1581
                                _tmp10_ = _tmp9_->y;
 
1582
                                _tmp11_ = baobab_chart_highlight_item_at_point (self, _tmp8_, _tmp10_);
 
1583
                                if (_tmp11_) {
 
1584
                                        GtkTreePath* path = NULL;
 
1585
                                        GtkTreeModel* _tmp12_ = NULL;
 
1586
                                        GtkTreeModel* _tmp13_ = NULL;
 
1587
                                        BaobabChartItem* _tmp14_ = NULL;
 
1588
                                        BaobabChartItem* _tmp15_ = NULL;
 
1589
                                        GtkTreeIter _tmp16_ = {0};
 
1590
                                        GtkTreePath* _tmp17_ = NULL;
 
1591
                                        GtkTreePath* _tmp18_ = NULL;
 
1592
                                        GtkTreePath* _tmp19_ = NULL;
 
1593
                                        GtkTreePath* _tmp20_ = NULL;
 
1594
                                        GtkTreePath* _tmp21_ = NULL;
 
1595
                                        gint _tmp22_ = 0;
 
1596
                                        gboolean _tmp23_ = FALSE;
 
1597
                                        _tmp12_ = baobab_chart_get_model (self);
 
1598
                                        _tmp13_ = _tmp12_;
 
1599
                                        _tmp14_ = baobab_chart_get_highlighted_item (self);
 
1600
                                        _tmp15_ = _tmp14_;
 
1601
                                        _tmp16_ = _tmp15_->iter;
 
1602
                                        _tmp17_ = gtk_tree_model_get_path (_tmp13_, &_tmp16_);
 
1603
                                        path = _tmp17_;
 
1604
                                        _tmp18_ = baobab_chart_get_root (self);
 
1605
                                        _tmp19_ = _tmp18_;
 
1606
                                        _tmp20_ = _tmp19_;
 
1607
                                        _tmp21_ = path;
 
1608
                                        _tmp22_ = gtk_tree_path_compare (_tmp20_, _tmp21_);
 
1609
                                        _tmp23_ = _tmp22_ == 0;
 
1610
                                        _gtk_tree_path_free0 (_tmp20_);
 
1611
                                        if (_tmp23_) {
 
1612
                                                baobab_chart_move_up_root (self);
 
1613
                                        } else {
 
1614
                                                BaobabChartItem* _tmp24_ = NULL;
 
1615
                                                BaobabChartItem* _tmp25_ = NULL;
 
1616
                                                GtkTreeIter _tmp26_ = {0};
 
1617
                                                _tmp24_ = baobab_chart_get_highlighted_item (self);
 
1618
                                                _tmp25_ = _tmp24_;
 
1619
                                                _tmp26_ = _tmp25_->iter;
 
1620
                                                g_signal_emit_by_name (self, "item-activated", &_tmp26_);
 
1621
                                        }
 
1622
                                        _gtk_tree_path_free0 (path);
 
1623
                                }
 
1624
                                break;
 
1625
                        }
 
1626
                        case GDK_BUTTON_MIDDLE:
 
1627
                        {
 
1628
                                baobab_chart_move_up_root (self);
 
1629
                                break;
 
1630
                        }
 
1631
                        default:
 
1632
                        break;
 
1633
                }
 
1634
                result = TRUE;
 
1635
                return result;
 
1636
        }
 
1637
        result = FALSE;
 
1638
        return result;
 
1639
}
 
1640
 
 
1641
 
 
1642
static GdkEventMotion* _vala_GdkEventMotion_copy (GdkEventMotion* self) {
 
1643
        return g_boxed_copy (gdk_event_get_type (), self);
 
1644
}
 
1645
 
 
1646
 
 
1647
static gpointer __vala_GdkEventMotion_copy0 (gpointer self) {
 
1648
        return self ? _vala_GdkEventMotion_copy (self) : NULL;
 
1649
}
 
1650
 
 
1651
 
 
1652
static void _vala_GdkEventMotion_free (GdkEventMotion* self) {
 
1653
        g_boxed_free (gdk_event_get_type (), self);
 
1654
}
 
1655
 
 
1656
 
 
1657
static gboolean baobab_chart_real_scroll_event (GtkWidget* base, GdkEventScroll* event) {
 
1658
        BaobabChart * self;
 
1659
        gboolean result = FALSE;
 
1660
        GdkEventMotion* e = NULL;
 
1661
        GdkEventScroll* _tmp0_ = NULL;
 
1662
        GdkEventMotion* _tmp1_ = NULL;
 
1663
        GdkEventScroll* _tmp2_ = NULL;
 
1664
        GdkScrollDirection _tmp3_ = 0;
 
1665
        self = (BaobabChart*) base;
 
1666
        g_return_val_if_fail (event != NULL, FALSE);
 
1667
        _tmp0_ = event;
 
1668
        _tmp1_ = __vala_GdkEventMotion_copy0 ((GdkEventMotion*) _tmp0_);
 
1669
        e = _tmp1_;
 
1670
        _tmp2_ = event;
 
1671
        _tmp3_ = _tmp2_->direction;
 
1672
        switch (_tmp3_) {
 
1673
                case GDK_SCROLL_LEFT:
 
1674
                case GDK_SCROLL_UP:
 
1675
                {
 
1676
                        GdkEventMotion* _tmp4_ = NULL;
 
1677
                        gboolean _tmp5_ = FALSE;
 
1678
                        baobab_chart_zoom_out (self);
 
1679
                        _tmp4_ = e;
 
1680
                        g_signal_emit_by_name ((GtkWidget*) self, "motion-notify-event", _tmp4_, &_tmp5_);
 
1681
                        break;
 
1682
                }
 
1683
                case GDK_SCROLL_RIGHT:
 
1684
                case GDK_SCROLL_DOWN:
 
1685
                {
 
1686
                        GdkEventMotion* _tmp6_ = NULL;
 
1687
                        gboolean _tmp7_ = FALSE;
 
1688
                        baobab_chart_zoom_in (self);
 
1689
                        _tmp6_ = e;
 
1690
                        g_signal_emit_by_name ((GtkWidget*) self, "motion-notify-event", _tmp6_, &_tmp7_);
 
1691
                        break;
 
1692
                }
 
1693
                case GDK_SCROLL_SMOOTH:
 
1694
                {
 
1695
                        break;
 
1696
                }
 
1697
                default:
 
1698
                break;
 
1699
        }
 
1700
        result = FALSE;
 
1701
        __vala_GdkEventMotion_free0 (e);
 
1702
        return result;
 
1703
}
 
1704
 
 
1705
 
 
1706
void baobab_chart_open_file (BaobabChart* self) {
 
1707
        GtkWidget* _tmp0_ = NULL;
 
1708
        BaobabChartItem* _tmp1_ = NULL;
 
1709
        BaobabChartItem* _tmp2_ = NULL;
 
1710
        GtkTreeIter _tmp3_ = {0};
 
1711
        g_return_if_fail (self != NULL);
 
1712
        _tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self);
 
1713
        _tmp1_ = baobab_chart_get_highlighted_item (self);
 
1714
        _tmp2_ = _tmp1_;
 
1715
        _tmp3_ = _tmp2_->iter;
 
1716
        baobab_window_open_item (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_WINDOW) ? ((BaobabWindow*) _tmp0_) : NULL, &_tmp3_);
 
1717
}
 
1718
 
 
1719
 
 
1720
void baobab_chart_copy_path (BaobabChart* self) {
 
1721
        GtkWidget* _tmp0_ = NULL;
 
1722
        BaobabChartItem* _tmp1_ = NULL;
 
1723
        BaobabChartItem* _tmp2_ = NULL;
 
1724
        GtkTreeIter _tmp3_ = {0};
 
1725
        g_return_if_fail (self != NULL);
 
1726
        _tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self);
 
1727
        _tmp1_ = baobab_chart_get_highlighted_item (self);
 
1728
        _tmp2_ = _tmp1_;
 
1729
        _tmp3_ = _tmp2_->iter;
 
1730
        baobab_window_copy_path (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_WINDOW) ? ((BaobabWindow*) _tmp0_) : NULL, &_tmp3_);
 
1731
}
 
1732
 
 
1733
 
 
1734
void baobab_chart_trash_file (BaobabChart* self) {
 
1735
        GtkWidget* _tmp0_ = NULL;
 
1736
        BaobabChartItem* _tmp1_ = NULL;
 
1737
        BaobabChartItem* _tmp2_ = NULL;
 
1738
        GtkTreeIter _tmp3_ = {0};
 
1739
        g_return_if_fail (self != NULL);
 
1740
        _tmp0_ = gtk_widget_get_toplevel ((GtkWidget*) self);
 
1741
        _tmp1_ = baobab_chart_get_highlighted_item (self);
 
1742
        _tmp2_ = _tmp1_;
 
1743
        _tmp3_ = _tmp2_->iter;
 
1744
        baobab_window_trash_file (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_WINDOW) ? ((BaobabWindow*) _tmp0_) : NULL, &_tmp3_);
 
1745
}
 
1746
 
 
1747
 
 
1748
void baobab_chart_move_up_root (BaobabChart* self) {
 
1749
        GtkTreeIter iter = {0};
 
1750
        GtkTreeIter parent_iter = {0};
 
1751
        GtkTreeModel* _tmp0_ = NULL;
 
1752
        GtkTreeModel* _tmp1_ = NULL;
 
1753
        GtkTreePath* _tmp2_ = NULL;
 
1754
        GtkTreePath* _tmp3_ = NULL;
 
1755
        GtkTreePath* _tmp4_ = NULL;
 
1756
        GtkTreeIter _tmp5_ = {0};
 
1757
        GtkTreeModel* _tmp6_ = NULL;
 
1758
        GtkTreeModel* _tmp7_ = NULL;
 
1759
        GtkTreeIter _tmp8_ = {0};
 
1760
        GtkTreeIter _tmp9_ = {0};
 
1761
        gboolean _tmp10_ = FALSE;
 
1762
        g_return_if_fail (self != NULL);
 
1763
        _tmp0_ = baobab_chart_get_model (self);
 
1764
        _tmp1_ = _tmp0_;
 
1765
        _tmp2_ = baobab_chart_get_root (self);
 
1766
        _tmp3_ = _tmp2_;
 
1767
        _tmp4_ = _tmp3_;
 
1768
        gtk_tree_model_get_iter (_tmp1_, &_tmp5_, _tmp4_);
 
1769
        iter = _tmp5_;
 
1770
        _gtk_tree_path_free0 (_tmp4_);
 
1771
        _tmp6_ = baobab_chart_get_model (self);
 
1772
        _tmp7_ = _tmp6_;
 
1773
        _tmp8_ = iter;
 
1774
        _tmp10_ = gtk_tree_model_iter_parent (_tmp7_, &_tmp9_, &_tmp8_);
 
1775
        parent_iter = _tmp9_;
 
1776
        if (_tmp10_) {
 
1777
                GtkTreeModel* _tmp11_ = NULL;
 
1778
                GtkTreeModel* _tmp12_ = NULL;
 
1779
                GtkTreeIter _tmp13_ = {0};
 
1780
                GtkTreePath* _tmp14_ = NULL;
 
1781
                GtkTreePath* _tmp15_ = NULL;
 
1782
                GtkTreeIter _tmp16_ = {0};
 
1783
                _tmp11_ = baobab_chart_get_model (self);
 
1784
                _tmp12_ = _tmp11_;
 
1785
                _tmp13_ = parent_iter;
 
1786
                _tmp14_ = gtk_tree_model_get_path (_tmp12_, &_tmp13_);
 
1787
                _tmp15_ = _tmp14_;
 
1788
                baobab_chart_set_root (self, _tmp15_);
 
1789
                _gtk_tree_path_free0 (_tmp15_);
 
1790
                _tmp16_ = parent_iter;
 
1791
                g_signal_emit_by_name (self, "item-activated", &_tmp16_);
 
1792
        }
 
1793
}
 
1794
 
 
1795
 
 
1796
void baobab_chart_zoom_in (BaobabChart* self) {
 
1797
        gboolean _tmp0_ = FALSE;
 
1798
        g_return_if_fail (self != NULL);
 
1799
        _tmp0_ = baobab_chart_can_zoom_in (self);
 
1800
        if (_tmp0_) {
 
1801
                guint _tmp1_ = 0U;
 
1802
                guint _tmp2_ = 0U;
 
1803
                _tmp1_ = baobab_chart_get_max_depth (self);
 
1804
                _tmp2_ = _tmp1_;
 
1805
                baobab_chart_set_max_depth (self, _tmp2_ - 1);
 
1806
        }
 
1807
}
 
1808
 
 
1809
 
 
1810
void baobab_chart_zoom_out (BaobabChart* self) {
 
1811
        gboolean _tmp0_ = FALSE;
 
1812
        g_return_if_fail (self != NULL);
 
1813
        _tmp0_ = baobab_chart_can_zoom_out (self);
 
1814
        if (_tmp0_) {
 
1815
                guint _tmp1_ = 0U;
 
1816
                guint _tmp2_ = 0U;
 
1817
                _tmp1_ = baobab_chart_get_max_depth (self);
 
1818
                _tmp2_ = _tmp1_;
 
1819
                baobab_chart_set_max_depth (self, _tmp2_ + 1);
 
1820
        }
 
1821
}
 
1822
 
 
1823
 
 
1824
static gpointer _g_object_ref0 (gpointer self) {
 
1825
        return self ? g_object_ref (self) : NULL;
 
1826
}
 
1827
 
 
1828
 
 
1829
static void baobab_chart_build_context_menu (BaobabChart* self) {
 
1830
        GMenu* menu_model = NULL;
 
1831
        BaobabApplication* _tmp0_ = NULL;
 
1832
        BaobabApplication* _tmp1_ = NULL;
 
1833
        GMenu* _tmp2_ = NULL;
 
1834
        GMenu* _tmp3_ = NULL;
 
1835
        GMenu* _tmp4_ = NULL;
 
1836
        GtkMenu* _tmp5_ = NULL;
 
1837
        GtkMenu* _tmp6_ = NULL;
 
1838
        g_return_if_fail (self != NULL);
 
1839
        _tmp0_ = baobab_application_get_default ();
 
1840
        _tmp1_ = _tmp0_;
 
1841
        _tmp2_ = gtk_application_get_menu_by_id ((GtkApplication*) _tmp1_, "chartmenu");
 
1842
        _tmp3_ = _g_object_ref0 (_tmp2_);
 
1843
        _tmp4_ = _tmp3_;
 
1844
        _g_object_unref0 (_tmp1_);
 
1845
        menu_model = _tmp4_;
 
1846
        _tmp5_ = (GtkMenu*) gtk_menu_new_from_model ((GMenuModel*) menu_model);
 
1847
        g_object_ref_sink (_tmp5_);
 
1848
        _g_object_unref0 (self->priv->context_menu);
 
1849
        self->priv->context_menu = _tmp5_;
 
1850
        _tmp6_ = self->priv->context_menu;
 
1851
        gtk_menu_attach_to_widget (_tmp6_, (GtkWidget*) self, NULL);
 
1852
        _g_object_unref0 (menu_model);
 
1853
}
 
1854
 
 
1855
 
 
1856
static void baobab_chart_show_popup_menu (BaobabChart* self, GdkEventButton* event) {
 
1857
        gboolean enable = FALSE;
 
1858
        BaobabChartItem* _tmp0_ = NULL;
 
1859
        BaobabChartItem* _tmp1_ = NULL;
 
1860
        GSimpleAction* action = NULL;
 
1861
        GSimpleActionGroup* _tmp2_ = NULL;
 
1862
        GAction* _tmp3_ = NULL;
 
1863
        GSimpleAction* _tmp4_ = NULL;
 
1864
        GSimpleAction* _tmp5_ = NULL;
 
1865
        gboolean _tmp6_ = FALSE;
 
1866
        GSimpleActionGroup* _tmp7_ = NULL;
 
1867
        GAction* _tmp8_ = NULL;
 
1868
        GSimpleAction* _tmp9_ = NULL;
 
1869
        GSimpleAction* _tmp10_ = NULL;
 
1870
        gboolean _tmp11_ = FALSE;
 
1871
        GSimpleActionGroup* _tmp12_ = NULL;
 
1872
        GAction* _tmp13_ = NULL;
 
1873
        GSimpleAction* _tmp14_ = NULL;
 
1874
        GSimpleAction* _tmp15_ = NULL;
 
1875
        gboolean _tmp16_ = FALSE;
 
1876
        GdkEventButton* _tmp17_ = NULL;
 
1877
        g_return_if_fail (self != NULL);
 
1878
        _tmp0_ = baobab_chart_get_highlighted_item (self);
 
1879
        _tmp1_ = _tmp0_;
 
1880
        enable = _tmp1_ != NULL;
 
1881
        _tmp2_ = self->priv->action_group;
 
1882
        _tmp3_ = g_action_map_lookup_action ((GActionMap*) _tmp2_, "open-file");
 
1883
        _tmp4_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp3_) : NULL);
 
1884
        action = _tmp4_;
 
1885
        _tmp5_ = action;
 
1886
        _tmp6_ = enable;
 
1887
        g_simple_action_set_enabled (_tmp5_, _tmp6_);
 
1888
        _tmp7_ = self->priv->action_group;
 
1889
        _tmp8_ = g_action_map_lookup_action ((GActionMap*) _tmp7_, "copy-path");
 
1890
        _tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp8_) : NULL);
 
1891
        _g_object_unref0 (action);
 
1892
        action = _tmp9_;
 
1893
        _tmp10_ = action;
 
1894
        _tmp11_ = enable;
 
1895
        g_simple_action_set_enabled (_tmp10_, _tmp11_);
 
1896
        _tmp12_ = self->priv->action_group;
 
1897
        _tmp13_ = g_action_map_lookup_action ((GActionMap*) _tmp12_, "trash-file");
 
1898
        _tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, g_simple_action_get_type ()) ? ((GSimpleAction*) _tmp13_) : NULL);
 
1899
        _g_object_unref0 (action);
 
1900
        action = _tmp14_;
 
1901
        _tmp15_ = action;
 
1902
        _tmp16_ = enable;
 
1903
        g_simple_action_set_enabled (_tmp15_, _tmp16_);
 
1904
        _tmp17_ = event;
 
1905
        if (_tmp17_ != NULL) {
 
1906
                GtkMenu* _tmp18_ = NULL;
 
1907
                GdkEventButton* _tmp19_ = NULL;
 
1908
                guint _tmp20_ = 0U;
 
1909
                GdkEventButton* _tmp21_ = NULL;
 
1910
                guint32 _tmp22_ = 0U;
 
1911
                _tmp18_ = self->priv->context_menu;
 
1912
                _tmp19_ = event;
 
1913
                _tmp20_ = _tmp19_->button;
 
1914
                _tmp21_ = event;
 
1915
                _tmp22_ = _tmp21_->time;
 
1916
                gtk_menu_popup (_tmp18_, NULL, NULL, NULL, NULL, _tmp20_, _tmp22_);
 
1917
        } else {
 
1918
                GtkMenu* _tmp23_ = NULL;
 
1919
                guint32 _tmp24_ = 0U;
 
1920
                _tmp23_ = self->priv->context_menu;
 
1921
                _tmp24_ = gtk_get_current_event_time ();
 
1922
                gtk_menu_popup (_tmp23_, NULL, NULL, NULL, NULL, (guint) 0, _tmp24_);
 
1923
        }
 
1924
        _g_object_unref0 (action);
 
1925
}
 
1926
 
 
1927
 
 
1928
static void _baobab_chart_row_changed_gtk_tree_model_row_changed (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, gpointer self) {
 
1929
        baobab_chart_row_changed ((BaobabChart*) self, _sender, path, iter);
 
1930
}
 
1931
 
 
1932
 
 
1933
static void _baobab_chart_row_inserted_gtk_tree_model_row_inserted (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, gpointer self) {
 
1934
        baobab_chart_row_inserted ((BaobabChart*) self, _sender, path, iter);
 
1935
}
 
1936
 
 
1937
 
 
1938
static void _baobab_chart_row_has_child_toggled_gtk_tree_model_row_has_child_toggled (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, gpointer self) {
 
1939
        baobab_chart_row_has_child_toggled ((BaobabChart*) self, _sender, path, iter);
 
1940
}
 
1941
 
 
1942
 
 
1943
static void _baobab_chart_row_deleted_gtk_tree_model_row_deleted (GtkTreeModel* _sender, GtkTreePath* path, gpointer self) {
 
1944
        baobab_chart_row_deleted ((BaobabChart*) self, _sender, path);
 
1945
}
 
1946
 
 
1947
 
 
1948
static void _baobab_chart_rows_reordered_gtk_tree_model_rows_reordered (GtkTreeModel* _sender, GtkTreePath* path, GtkTreeIter* iter, void* new_order, gpointer self) {
 
1949
        baobab_chart_rows_reordered ((BaobabChart*) self, _sender, path, iter, new_order);
 
1950
}
 
1951
 
 
1952
 
 
1953
static void baobab_chart_connect_model_signals (BaobabChart* self, GtkTreeModel* m) {
 
1954
        GtkTreeModel* _tmp0_ = NULL;
 
1955
        GtkTreeModel* _tmp1_ = NULL;
 
1956
        GtkTreeModel* _tmp2_ = NULL;
 
1957
        GtkTreeModel* _tmp3_ = NULL;
 
1958
        GtkTreeModel* _tmp4_ = NULL;
 
1959
        g_return_if_fail (self != NULL);
 
1960
        g_return_if_fail (m != NULL);
 
1961
        _tmp0_ = m;
 
1962
        g_signal_connect_object (_tmp0_, "row-changed", (GCallback) _baobab_chart_row_changed_gtk_tree_model_row_changed, self, 0);
 
1963
        _tmp1_ = m;
 
1964
        g_signal_connect_object (_tmp1_, "row-inserted", (GCallback) _baobab_chart_row_inserted_gtk_tree_model_row_inserted, self, 0);
 
1965
        _tmp2_ = m;
 
1966
        g_signal_connect_object (_tmp2_, "row-has-child-toggled", (GCallback) _baobab_chart_row_has_child_toggled_gtk_tree_model_row_has_child_toggled, self, 0);
 
1967
        _tmp3_ = m;
 
1968
        g_signal_connect_object (_tmp3_, "row-deleted", (GCallback) _baobab_chart_row_deleted_gtk_tree_model_row_deleted, self, 0);
 
1969
        _tmp4_ = m;
 
1970
        g_signal_connect_object (_tmp4_, "rows-reordered", (GCallback) _baobab_chart_rows_reordered_gtk_tree_model_rows_reordered, self, 0);
 
1971
}
 
1972
 
 
1973
 
 
1974
static void baobab_chart_disconnect_model_signals (BaobabChart* self, GtkTreeModel* m) {
 
1975
        GtkTreeModel* _tmp0_ = NULL;
 
1976
        guint _tmp1_ = 0U;
 
1977
        GtkTreeModel* _tmp2_ = NULL;
 
1978
        guint _tmp3_ = 0U;
 
1979
        GtkTreeModel* _tmp4_ = NULL;
 
1980
        guint _tmp5_ = 0U;
 
1981
        GtkTreeModel* _tmp6_ = NULL;
 
1982
        guint _tmp7_ = 0U;
 
1983
        GtkTreeModel* _tmp8_ = NULL;
 
1984
        guint _tmp9_ = 0U;
 
1985
        g_return_if_fail (self != NULL);
 
1986
        g_return_if_fail (m != NULL);
 
1987
        _tmp0_ = m;
 
1988
        g_signal_parse_name ("row-changed", GTK_TYPE_TREE_MODEL, &_tmp1_, NULL, FALSE);
 
1989
        g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _baobab_chart_row_changed_gtk_tree_model_row_changed, self);
 
1990
        _tmp2_ = m;
 
1991
        g_signal_parse_name ("row-inserted", GTK_TYPE_TREE_MODEL, &_tmp3_, NULL, FALSE);
 
1992
        g_signal_handlers_disconnect_matched (_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _baobab_chart_row_inserted_gtk_tree_model_row_inserted, self);
 
1993
        _tmp4_ = m;
 
1994
        g_signal_parse_name ("row-has-child-toggled", GTK_TYPE_TREE_MODEL, &_tmp5_, NULL, FALSE);
 
1995
        g_signal_handlers_disconnect_matched (_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _baobab_chart_row_has_child_toggled_gtk_tree_model_row_has_child_toggled, self);
 
1996
        _tmp6_ = m;
 
1997
        g_signal_parse_name ("row-deleted", GTK_TYPE_TREE_MODEL, &_tmp7_, NULL, FALSE);
 
1998
        g_signal_handlers_disconnect_matched (_tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _baobab_chart_row_deleted_gtk_tree_model_row_deleted, self);
 
1999
        _tmp8_ = m;
 
2000
        g_signal_parse_name ("rows-reordered", GTK_TYPE_TREE_MODEL, &_tmp9_, NULL, FALSE);
 
2001
        g_signal_handlers_disconnect_matched (_tmp8_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp9_, 0, NULL, (GCallback) _baobab_chart_rows_reordered_gtk_tree_model_rows_reordered, self);
 
2002
}
 
2003
 
 
2004
 
 
2005
static gboolean baobab_chart_real_query_tooltip (GtkWidget* base, gint x, gint y, gboolean keyboard_tooltip, GtkTooltip* tooltip) {
 
2006
        BaobabChart * self;
 
2007
        gboolean result = FALSE;
 
2008
        gboolean _tmp0_ = FALSE;
 
2009
        gboolean _tmp1_ = FALSE;
 
2010
        BaobabChartItem* _tmp2_ = NULL;
 
2011
        BaobabChartItem* _tmp3_ = NULL;
 
2012
        GtkTooltip* _tmp10_ = NULL;
 
2013
        BaobabChartItem* _tmp11_ = NULL;
 
2014
        BaobabChartItem* _tmp12_ = NULL;
 
2015
        GdkRectangle _tmp13_ = {0};
 
2016
        gchar* markup = NULL;
 
2017
        BaobabChartItem* _tmp14_ = NULL;
 
2018
        BaobabChartItem* _tmp15_ = NULL;
 
2019
        const gchar* _tmp16_ = NULL;
 
2020
        gchar* _tmp17_ = NULL;
 
2021
        gchar* _tmp18_ = NULL;
 
2022
        BaobabChartItem* _tmp19_ = NULL;
 
2023
        BaobabChartItem* _tmp20_ = NULL;
 
2024
        const gchar* _tmp21_ = NULL;
 
2025
        gchar* _tmp22_ = NULL;
 
2026
        gchar* _tmp23_ = NULL;
 
2027
        GtkTooltip* _tmp24_ = NULL;
 
2028
        const gchar* _tmp25_ = NULL;
 
2029
        gchar* _tmp26_ = NULL;
 
2030
        gchar* _tmp27_ = NULL;
 
2031
        self = (BaobabChart*) base;
 
2032
        g_return_val_if_fail (tooltip != NULL, FALSE);
 
2033
        _tmp2_ = baobab_chart_get_highlighted_item (self);
 
2034
        _tmp3_ = _tmp2_;
 
2035
        if (_tmp3_ == NULL) {
 
2036
                _tmp1_ = TRUE;
 
2037
        } else {
 
2038
                BaobabChartItem* _tmp4_ = NULL;
 
2039
                BaobabChartItem* _tmp5_ = NULL;
 
2040
                const gchar* _tmp6_ = NULL;
 
2041
                _tmp4_ = baobab_chart_get_highlighted_item (self);
 
2042
                _tmp5_ = _tmp4_;
 
2043
                _tmp6_ = _tmp5_->name;
 
2044
                _tmp1_ = _tmp6_ == NULL;
 
2045
        }
 
2046
        if (_tmp1_) {
 
2047
                _tmp0_ = TRUE;
 
2048
        } else {
 
2049
                BaobabChartItem* _tmp7_ = NULL;
 
2050
                BaobabChartItem* _tmp8_ = NULL;
 
2051
                const gchar* _tmp9_ = NULL;
 
2052
                _tmp7_ = baobab_chart_get_highlighted_item (self);
 
2053
                _tmp8_ = _tmp7_;
 
2054
                _tmp9_ = _tmp8_->size;
 
2055
                _tmp0_ = _tmp9_ == NULL;
 
2056
        }
 
2057
        if (_tmp0_) {
 
2058
                result = FALSE;
 
2059
                return result;
 
2060
        }
 
2061
        _tmp10_ = tooltip;
 
2062
        _tmp11_ = baobab_chart_get_highlighted_item (self);
 
2063
        _tmp12_ = _tmp11_;
 
2064
        _tmp13_ = _tmp12_->rect;
 
2065
        gtk_tooltip_set_tip_area (_tmp10_, &_tmp13_);
 
2066
        _tmp14_ = baobab_chart_get_highlighted_item (self);
 
2067
        _tmp15_ = _tmp14_;
 
2068
        _tmp16_ = _tmp15_->name;
 
2069
        _tmp17_ = g_strconcat (_tmp16_, "\n", NULL);
 
2070
        _tmp18_ = _tmp17_;
 
2071
        _tmp19_ = baobab_chart_get_highlighted_item (self);
 
2072
        _tmp20_ = _tmp19_;
 
2073
        _tmp21_ = _tmp20_->size;
 
2074
        _tmp22_ = g_strconcat (_tmp18_, _tmp21_, NULL);
 
2075
        _tmp23_ = _tmp22_;
 
2076
        _g_free0 (_tmp18_);
 
2077
        markup = _tmp23_;
 
2078
        _tmp24_ = tooltip;
 
2079
        _tmp25_ = markup;
 
2080
        _tmp26_ = g_markup_escape_text (_tmp25_, (gssize) (-1));
 
2081
        _tmp27_ = _tmp26_;
 
2082
        gtk_tooltip_set_markup (_tmp24_, _tmp27_);
 
2083
        _g_free0 (_tmp27_);
 
2084
        result = TRUE;
 
2085
        _g_free0 (markup);
 
2086
        return result;
 
2087
}
 
2088
 
 
2089
 
 
2090
BaobabChart* baobab_chart_construct (GType object_type) {
 
2091
        BaobabChart * self = NULL;
 
2092
        self = (BaobabChart*) g_object_new (object_type, NULL);
 
2093
        return self;
 
2094
}
 
2095
 
 
2096
 
 
2097
guint baobab_chart_get_max_depth (BaobabChart* self) {
 
2098
        guint result;
 
2099
        guint _tmp0_ = 0U;
 
2100
        g_return_val_if_fail (self != NULL, 0U);
 
2101
        _tmp0_ = self->priv->max_depth_;
 
2102
        result = _tmp0_;
 
2103
        return result;
 
2104
}
 
2105
 
 
2106
 
 
2107
void baobab_chart_set_max_depth (BaobabChart* self, guint value) {
 
2108
        guint m = 0U;
 
2109
        guint _tmp0_ = 0U;
 
2110
        guint _tmp1_ = 0U;
 
2111
        guint _tmp2_ = 0U;
 
2112
        guint _tmp3_ = 0U;
 
2113
        guint _tmp4_ = 0U;
 
2114
        g_return_if_fail (self != NULL);
 
2115
        _tmp0_ = value;
 
2116
        _tmp1_ = CLAMP (_tmp0_, BAOBAB_CHART_MIN_DEPTH, BAOBAB_CHART_MAX_DEPTH);
 
2117
        m = _tmp1_;
 
2118
        _tmp2_ = self->priv->max_depth_;
 
2119
        _tmp3_ = m;
 
2120
        if (_tmp2_ == _tmp3_) {
 
2121
                return;
 
2122
        }
 
2123
        _tmp4_ = m;
 
2124
        self->priv->max_depth_ = _tmp4_;
 
2125
        self->priv->model_changed = TRUE;
 
2126
        gtk_widget_queue_draw ((GtkWidget*) self);
 
2127
        g_object_notify ((GObject *) self, "max-depth");
 
2128
}
 
2129
 
 
2130
 
 
2131
GtkTreeModel* baobab_chart_get_model (BaobabChart* self) {
 
2132
        GtkTreeModel* result;
 
2133
        GtkTreeModel* _tmp0_ = NULL;
 
2134
        g_return_val_if_fail (self != NULL, NULL);
 
2135
        _tmp0_ = self->priv->model_;
 
2136
        result = _tmp0_;
 
2137
        return result;
 
2138
}
 
2139
 
 
2140
 
 
2141
void baobab_chart_set_model (BaobabChart* self, GtkTreeModel* value) {
 
2142
        GtkTreeModel* _tmp0_ = NULL;
 
2143
        GtkTreeModel* _tmp1_ = NULL;
 
2144
        GtkTreeModel* _tmp2_ = NULL;
 
2145
        GtkTreeModel* _tmp4_ = NULL;
 
2146
        GtkTreeModel* _tmp5_ = NULL;
 
2147
        GtkTreeModel* _tmp6_ = NULL;
 
2148
        g_return_if_fail (self != NULL);
 
2149
        _tmp0_ = self->priv->model_;
 
2150
        _tmp1_ = value;
 
2151
        if (_tmp0_ == _tmp1_) {
 
2152
                return;
 
2153
        }
 
2154
        _tmp2_ = self->priv->model_;
 
2155
        if (_tmp2_ != NULL) {
 
2156
                GtkTreeModel* _tmp3_ = NULL;
 
2157
                _tmp3_ = self->priv->model_;
 
2158
                baobab_chart_disconnect_model_signals (self, _tmp3_);
 
2159
        }
 
2160
        _tmp4_ = value;
 
2161
        _tmp5_ = _g_object_ref0 (_tmp4_);
 
2162
        _g_object_unref0 (self->priv->model_);
 
2163
        self->priv->model_ = _tmp5_;
 
2164
        self->priv->model_changed = TRUE;
 
2165
        baobab_chart_set_root (self, NULL);
 
2166
        _tmp6_ = self->priv->model_;
 
2167
        baobab_chart_connect_model_signals (self, _tmp6_);
 
2168
        gtk_widget_queue_draw ((GtkWidget*) self);
 
2169
        g_object_notify ((GObject *) self, "model");
 
2170
}
 
2171
 
 
2172
 
 
2173
GtkTreePath* baobab_chart_get_root (BaobabChart* self) {
 
2174
        GtkTreePath* result;
 
2175
        const GtkTreeRowReference* _tmp0_ = NULL;
 
2176
        GtkTreePath* _tmp4_ = NULL;
 
2177
        g_return_val_if_fail (self != NULL, NULL);
 
2178
        _tmp0_ = self->priv->root_;
 
2179
        if (_tmp0_ != NULL) {
 
2180
                GtkTreePath* path = NULL;
 
2181
                const GtkTreeRowReference* _tmp1_ = NULL;
 
2182
                GtkTreePath* _tmp2_ = NULL;
 
2183
                GtkTreePath* _tmp3_ = NULL;
 
2184
                _tmp1_ = self->priv->root_;
 
2185
                _tmp2_ = gtk_tree_row_reference_get_path (_tmp1_);
 
2186
                path = _tmp2_;
 
2187
                _tmp3_ = path;
 
2188
                if (_tmp3_ != NULL) {
 
2189
                        result = path;
 
2190
                        return result;
 
2191
                }
 
2192
                _gtk_tree_row_reference_free0 (self->priv->root_);
 
2193
                self->priv->root_ = NULL;
 
2194
                _gtk_tree_path_free0 (path);
 
2195
        }
 
2196
        _tmp4_ = gtk_tree_path_new_first ();
 
2197
        result = _tmp4_;
 
2198
        return result;
 
2199
}
 
2200
 
 
2201
 
 
2202
static gpointer _gtk_tree_row_reference_copy0 (gpointer self) {
 
2203
        return self ? gtk_tree_row_reference_copy (self) : NULL;
 
2204
}
 
2205
 
 
2206
 
 
2207
void baobab_chart_set_root (BaobabChart* self, GtkTreePath* value) {
 
2208
        GtkTreeModel* _tmp0_ = NULL;
 
2209
        GtkTreeModel* _tmp1_ = NULL;
 
2210
        const GtkTreeRowReference* _tmp2_ = NULL;
 
2211
        GtkTreeRowReference* _tmp13_ = NULL;
 
2212
        GtkTreePath* _tmp14_ = NULL;
 
2213
        GtkTreeRowReference* _tmp19_ = NULL;
 
2214
        g_return_if_fail (self != NULL);
 
2215
        _tmp0_ = baobab_chart_get_model (self);
 
2216
        _tmp1_ = _tmp0_;
 
2217
        if (_tmp1_ == NULL) {
 
2218
                return;
 
2219
        }
 
2220
        _tmp2_ = self->priv->root_;
 
2221
        if (_tmp2_ != NULL) {
 
2222
                GtkTreePath* current_root = NULL;
 
2223
                const GtkTreeRowReference* _tmp3_ = NULL;
 
2224
                GtkTreePath* _tmp4_ = NULL;
 
2225
                gboolean _tmp5_ = FALSE;
 
2226
                gboolean _tmp6_ = FALSE;
 
2227
                GtkTreePath* _tmp7_ = NULL;
 
2228
                _tmp3_ = self->priv->root_;
 
2229
                _tmp4_ = gtk_tree_row_reference_get_path (_tmp3_);
 
2230
                current_root = _tmp4_;
 
2231
                _tmp7_ = current_root;
 
2232
                if (_tmp7_ != NULL) {
 
2233
                        GtkTreePath* _tmp8_ = NULL;
 
2234
                        _tmp8_ = value;
 
2235
                        _tmp6_ = _tmp8_ != NULL;
 
2236
                } else {
 
2237
                        _tmp6_ = FALSE;
 
2238
                }
 
2239
                if (_tmp6_) {
 
2240
                        GtkTreePath* _tmp9_ = NULL;
 
2241
                        GtkTreePath* _tmp10_ = NULL;
 
2242
                        gint _tmp11_ = 0;
 
2243
                        _tmp9_ = current_root;
 
2244
                        _tmp10_ = value;
 
2245
                        _tmp11_ = gtk_tree_path_compare (_tmp9_, _tmp10_);
 
2246
                        _tmp5_ = _tmp11_ == 0;
 
2247
                } else {
 
2248
                        _tmp5_ = FALSE;
 
2249
                }
 
2250
                if (_tmp5_) {
 
2251
                        _gtk_tree_path_free0 (current_root);
 
2252
                        return;
 
2253
                }
 
2254
                _gtk_tree_path_free0 (current_root);
 
2255
        } else {
 
2256
                GtkTreePath* _tmp12_ = NULL;
 
2257
                _tmp12_ = value;
 
2258
                if (_tmp12_ == NULL) {
 
2259
                        return;
 
2260
                }
 
2261
        }
 
2262
        _tmp14_ = value;
 
2263
        if (_tmp14_ != NULL) {
 
2264
                GtkTreeModel* _tmp15_ = NULL;
 
2265
                GtkTreeModel* _tmp16_ = NULL;
 
2266
                GtkTreePath* _tmp17_ = NULL;
 
2267
                GtkTreeRowReference* _tmp18_ = NULL;
 
2268
                _tmp15_ = baobab_chart_get_model (self);
 
2269
                _tmp16_ = _tmp15_;
 
2270
                _tmp17_ = value;
 
2271
                _tmp18_ = gtk_tree_row_reference_new (_tmp16_, _tmp17_);
 
2272
                _gtk_tree_row_reference_free0 (_tmp13_);
 
2273
                _tmp13_ = _tmp18_;
 
2274
        } else {
 
2275
                _gtk_tree_row_reference_free0 (_tmp13_);
 
2276
                _tmp13_ = NULL;
 
2277
        }
 
2278
        _tmp19_ = _gtk_tree_row_reference_copy0 (_tmp13_);
 
2279
        _gtk_tree_row_reference_free0 (self->priv->root_);
 
2280
        self->priv->root_ = _tmp19_;
 
2281
        baobab_chart_set_highlighted_item (self, NULL);
 
2282
        gtk_widget_queue_draw ((GtkWidget*) self);
 
2283
        _gtk_tree_row_reference_free0 (_tmp13_);
 
2284
        g_object_notify ((GObject *) self, "root");
 
2285
}
 
2286
 
 
2287
 
 
2288
BaobabChartItem* baobab_chart_get_highlighted_item (BaobabChart* self) {
 
2289
        BaobabChartItem* result;
 
2290
        BaobabChartItem* _tmp0_ = NULL;
 
2291
        g_return_val_if_fail (self != NULL, NULL);
 
2292
        _tmp0_ = self->priv->highlighted_item_;
 
2293
        result = _tmp0_;
 
2294
        return result;
 
2295
}
 
2296
 
 
2297
 
 
2298
void baobab_chart_set_highlighted_item (BaobabChart* self, BaobabChartItem* value) {
 
2299
        BaobabChartItem* _tmp0_ = NULL;
 
2300
        BaobabChartItem* _tmp1_ = NULL;
 
2301
        BaobabChartItem* _tmp2_ = NULL;
 
2302
        BaobabChartItem* _tmp6_ = NULL;
 
2303
        BaobabChartItem* _tmp10_ = NULL;
 
2304
        BaobabChartItem* _tmp11_ = NULL;
 
2305
        g_return_if_fail (self != NULL);
 
2306
        _tmp0_ = self->priv->highlighted_item_;
 
2307
        _tmp1_ = value;
 
2308
        if (_tmp0_ == _tmp1_) {
 
2309
                return;
 
2310
        }
 
2311
        _tmp2_ = self->priv->highlighted_item_;
 
2312
        if (_tmp2_ != NULL) {
 
2313
                GdkWindow* _tmp3_ = NULL;
 
2314
                BaobabChartItem* _tmp4_ = NULL;
 
2315
                GdkRectangle _tmp5_ = {0};
 
2316
                _tmp3_ = gtk_widget_get_window ((GtkWidget*) self);
 
2317
                _tmp4_ = self->priv->highlighted_item_;
 
2318
                _tmp5_ = _tmp4_->rect;
 
2319
                gdk_window_invalidate_rect (_tmp3_, &_tmp5_, TRUE);
 
2320
        }
 
2321
        _tmp6_ = value;
 
2322
        if (_tmp6_ != NULL) {
 
2323
                GdkWindow* _tmp7_ = NULL;
 
2324
                BaobabChartItem* _tmp8_ = NULL;
 
2325
                GdkRectangle _tmp9_ = {0};
 
2326
                _tmp7_ = gtk_widget_get_window ((GtkWidget*) self);
 
2327
                _tmp8_ = value;
 
2328
                _tmp9_ = _tmp8_->rect;
 
2329
                gdk_window_invalidate_rect (_tmp7_, &_tmp9_, TRUE);
 
2330
        }
 
2331
        _tmp10_ = value;
 
2332
        _tmp11_ = _baobab_chart_item_ref0 (_tmp10_);
 
2333
        _baobab_chart_item_unref0 (self->priv->highlighted_item_);
 
2334
        self->priv->highlighted_item_ = _tmp11_;
 
2335
        g_object_notify ((GObject *) self, "highlighted-item");
 
2336
}
 
2337
 
 
2338
 
 
2339
static void baobab_chart_real_item_activated (BaobabChart* self, GtkTreeIter* iter) {
 
2340
        GtkTreeModel* _tmp0_ = NULL;
 
2341
        GtkTreeModel* _tmp1_ = NULL;
 
2342
        GtkTreeIter _tmp2_ = {0};
 
2343
        GtkTreePath* _tmp3_ = NULL;
 
2344
        GtkTreePath* _tmp4_ = NULL;
 
2345
        g_return_if_fail (iter != NULL);
 
2346
        _tmp0_ = baobab_chart_get_model (self);
 
2347
        _tmp1_ = _tmp0_;
 
2348
        _tmp2_ = *iter;
 
2349
        _tmp3_ = gtk_tree_model_get_path (_tmp1_, &_tmp2_);
 
2350
        _tmp4_ = _tmp3_;
 
2351
        baobab_chart_set_root (self, _tmp4_);
 
2352
        _gtk_tree_path_free0 (_tmp4_);
 
2353
}
 
2354
 
 
2355
 
 
2356
static void g_cclosure_user_marshal_VOID__BOXED (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
 
2357
        typedef void (*GMarshalFunc_VOID__BOXED) (gpointer data1, gpointer arg_1, gpointer data2);
 
2358
        register GMarshalFunc_VOID__BOXED callback;
 
2359
        register GCClosure * cc;
 
2360
        register gpointer data1;
 
2361
        register gpointer data2;
 
2362
        cc = (GCClosure *) closure;
 
2363
        g_return_if_fail (n_param_values == 2);
 
2364
        if (G_CCLOSURE_SWAP_DATA (closure)) {
 
2365
                data1 = closure->data;
 
2366
                data2 = param_values->data[0].v_pointer;
 
2367
        } else {
 
2368
                data1 = param_values->data[0].v_pointer;
 
2369
                data2 = closure->data;
 
2370
        }
 
2371
        callback = (GMarshalFunc_VOID__BOXED) (marshal_data ? marshal_data : cc->callback);
 
2372
        callback (data1, g_value_get_boxed (param_values + 1), data2);
 
2373
}
 
2374
 
 
2375
 
 
2376
static GObject * baobab_chart_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
 
2377
        GObject * obj;
 
2378
        GObjectClass * parent_class;
 
2379
        BaobabChart * self;
 
2380
        GSimpleActionGroup* _tmp0_ = NULL;
 
2381
        GSimpleActionGroup* _tmp1_ = NULL;
 
2382
        GSimpleActionGroup* _tmp2_ = NULL;
 
2383
        parent_class = G_OBJECT_CLASS (baobab_chart_parent_class);
 
2384
        obj = parent_class->constructor (type, n_construct_properties, construct_properties);
 
2385
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, BAOBAB_TYPE_CHART, BaobabChart);
 
2386
        gtk_widget_add_events ((GtkWidget*) self, (gint) (((((GDK_EXPOSURE_MASK | GDK_ENTER_NOTIFY_MASK) | GDK_LEAVE_NOTIFY_MASK) | GDK_BUTTON_PRESS_MASK) | GDK_POINTER_MOTION_MASK) | GDK_SCROLL_MASK));
 
2387
        _tmp0_ = g_simple_action_group_new ();
 
2388
        _g_object_unref0 (self->priv->action_group);
 
2389
        self->priv->action_group = _tmp0_;
 
2390
        _tmp1_ = self->priv->action_group;
 
2391
        g_action_map_add_action_entries ((GActionMap*) _tmp1_, BAOBAB_CHART_action_entries, G_N_ELEMENTS (BAOBAB_CHART_action_entries), self);
 
2392
        _tmp2_ = self->priv->action_group;
 
2393
        gtk_widget_insert_action_group ((GtkWidget*) self, "chart", (GActionGroup*) _tmp2_);
 
2394
        baobab_chart_build_context_menu (self);
 
2395
        return obj;
 
2396
}
 
2397
 
 
2398
 
 
2399
static void baobab_chart_class_init (BaobabChartClass * klass) {
 
2400
        baobab_chart_parent_class = g_type_class_peek_parent (klass);
 
2401
        g_type_class_add_private (klass, sizeof (BaobabChartPrivate));
 
2402
        ((BaobabChartClass *) klass)->post_draw = baobab_chart_real_post_draw;
 
2403
        ((BaobabChartClass *) klass)->draw_item = baobab_chart_real_draw_item;
 
2404
        ((BaobabChartClass *) klass)->calculate_item_geometry = baobab_chart_real_calculate_item_geometry;
 
2405
        ((BaobabChartClass *) klass)->is_point_over_item = baobab_chart_real_is_point_over_item;
 
2406
        ((BaobabChartClass *) klass)->get_item_rectangle = baobab_chart_real_get_item_rectangle;
 
2407
        ((BaobabChartClass *) klass)->can_zoom_in = baobab_chart_real_can_zoom_in;
 
2408
        ((BaobabChartClass *) klass)->can_zoom_out = baobab_chart_real_can_zoom_out;
 
2409
        ((BaobabChartClass *) klass)->create_new_chartitem = baobab_chart_real_create_new_chartitem;
 
2410
        ((GtkWidgetClass *) klass)->size_allocate = baobab_chart_real_size_allocate;
 
2411
        ((GtkWidgetClass *) klass)->motion_notify_event = baobab_chart_real_motion_notify_event;
 
2412
        ((GtkWidgetClass *) klass)->leave_notify_event = baobab_chart_real_leave_notify_event;
 
2413
        ((GtkWidgetClass *) klass)->draw = baobab_chart_real_draw;
 
2414
        ((GtkWidgetClass *) klass)->button_press_event = baobab_chart_real_button_press_event;
 
2415
        ((GtkWidgetClass *) klass)->scroll_event = baobab_chart_real_scroll_event;
 
2416
        ((GtkWidgetClass *) klass)->query_tooltip = baobab_chart_real_query_tooltip;
 
2417
        ((BaobabChartClass *) klass)->item_activated = baobab_chart_real_item_activated;
 
2418
        G_OBJECT_CLASS (klass)->get_property = _vala_baobab_chart_get_property;
 
2419
        G_OBJECT_CLASS (klass)->set_property = _vala_baobab_chart_set_property;
 
2420
        G_OBJECT_CLASS (klass)->constructor = baobab_chart_constructor;
 
2421
        G_OBJECT_CLASS (klass)->finalize = baobab_chart_finalize;
 
2422
        g_object_class_install_property (G_OBJECT_CLASS (klass), BAOBAB_CHART_MAX_DEPTH, g_param_spec_uint ("max-depth", "max-depth", "max-depth", 0, G_MAXUINT, 0U, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
 
2423
        g_object_class_install_property (G_OBJECT_CLASS (klass), BAOBAB_CHART_MODEL, g_param_spec_object ("model", "model", "model", GTK_TYPE_TREE_MODEL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
 
2424
        g_object_class_install_property (G_OBJECT_CLASS (klass), BAOBAB_CHART_ROOT, g_param_spec_boxed ("root", "root", "root", gtk_tree_path_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
 
2425
        g_object_class_install_property (G_OBJECT_CLASS (klass), BAOBAB_CHART_HIGHLIGHTED_ITEM, baobab_param_spec_chart_item ("highlighted-item", "highlighted-item", "highlighted-item", BAOBAB_TYPE_CHART_ITEM, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
 
2426
        g_signal_new ("item_activated", BAOBAB_TYPE_CHART, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (BaobabChartClass, item_activated), NULL, NULL, g_cclosure_user_marshal_VOID__BOXED, G_TYPE_NONE, 1, GTK_TYPE_TREE_ITER);
 
2427
}
 
2428
 
 
2429
 
 
2430
static void baobab_chart_instance_init (BaobabChart * self) {
 
2431
        self->priv = BAOBAB_CHART_GET_PRIVATE (self);
 
2432
        self->priv->context_menu = NULL;
 
2433
        self->priv->max_depth_ = BAOBAB_CHART_MAX_DEPTH;
 
2434
        self->priv->highlighted_item_ = NULL;
 
2435
}
 
2436
 
 
2437
 
 
2438
static void baobab_chart_finalize (GObject* obj) {
 
2439
        BaobabChart * self;
 
2440
        self = G_TYPE_CHECK_INSTANCE_CAST (obj, BAOBAB_TYPE_CHART, BaobabChart);
 
2441
        _g_object_unref0 (self->priv->context_menu);
 
2442
        __g_list_free__baobab_chart_item_unref0_0 (self->priv->items);
 
2443
        _g_object_unref0 (self->priv->model_);
 
2444
        _gtk_tree_row_reference_free0 (self->priv->root_);
 
2445
        _baobab_chart_item_unref0 (self->priv->highlighted_item_);
 
2446
        _g_object_unref0 (self->priv->action_group);
 
2447
        G_OBJECT_CLASS (baobab_chart_parent_class)->finalize (obj);
 
2448
}
 
2449
 
 
2450
 
 
2451
GType baobab_chart_get_type (void) {
 
2452
        static volatile gsize baobab_chart_type_id__volatile = 0;
 
2453
        if (g_once_init_enter (&baobab_chart_type_id__volatile)) {
 
2454
                static const GTypeInfo g_define_type_info = { sizeof (BaobabChartClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) baobab_chart_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BaobabChart), 0, (GInstanceInitFunc) baobab_chart_instance_init, NULL };
 
2455
                GType baobab_chart_type_id;
 
2456
                baobab_chart_type_id = g_type_register_static (gtk_drawing_area_get_type (), "BaobabChart", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
 
2457
                g_once_init_leave (&baobab_chart_type_id__volatile, baobab_chart_type_id);
 
2458
        }
 
2459
        return baobab_chart_type_id__volatile;
 
2460
}
 
2461
 
 
2462
 
 
2463
static void _vala_baobab_chart_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
 
2464
        BaobabChart * self;
 
2465
        self = G_TYPE_CHECK_INSTANCE_CAST (object, BAOBAB_TYPE_CHART, BaobabChart);
 
2466
        switch (property_id) {
 
2467
                case BAOBAB_CHART_MAX_DEPTH:
 
2468
                g_value_set_uint (value, baobab_chart_get_max_depth (self));
 
2469
                break;
 
2470
                case BAOBAB_CHART_MODEL:
 
2471
                g_value_set_object (value, baobab_chart_get_model (self));
 
2472
                break;
 
2473
                case BAOBAB_CHART_ROOT:
 
2474
                g_value_take_boxed (value, baobab_chart_get_root (self));
 
2475
                break;
 
2476
                case BAOBAB_CHART_HIGHLIGHTED_ITEM:
 
2477
                baobab_value_set_chart_item (value, baobab_chart_get_highlighted_item (self));
 
2478
                break;
 
2479
                default:
 
2480
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
2481
                break;
 
2482
        }
 
2483
}
 
2484
 
 
2485
 
 
2486
static void _vala_baobab_chart_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
 
2487
        BaobabChart * self;
 
2488
        self = G_TYPE_CHECK_INSTANCE_CAST (object, BAOBAB_TYPE_CHART, BaobabChart);
 
2489
        switch (property_id) {
 
2490
                case BAOBAB_CHART_MAX_DEPTH:
 
2491
                baobab_chart_set_max_depth (self, g_value_get_uint (value));
 
2492
                break;
 
2493
                case BAOBAB_CHART_MODEL:
 
2494
                baobab_chart_set_model (self, g_value_get_object (value));
 
2495
                break;
 
2496
                case BAOBAB_CHART_ROOT:
 
2497
                baobab_chart_set_root (self, g_value_get_boxed (value));
 
2498
                break;
 
2499
                case BAOBAB_CHART_HIGHLIGHTED_ITEM:
 
2500
                baobab_chart_set_highlighted_item (self, baobab_value_get_chart_item (value));
 
2501
                break;
 
2502
                default:
 
2503
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
2504
                break;
 
2505
        }
 
2506
}
 
2507
 
 
2508
 
 
2509