31
35
* Alejandro Garcia <alex@igalia.com>
38
#include <glib/gi18n.h>
39
#include <glib-object.h>
39
44
#include <gtk/gtk.h>
40
#include "baobab-chart.h"
42
G_DEFINE_ABSTRACT_TYPE (BaobabChart, baobab_chart, GTK_TYPE_WIDGET);
44
#define BAOBAB_CHART_MAX_DEPTH 8
45
#define BAOBAB_CHART_MIN_DEPTH 1
47
struct _BaobabChartPrivate
52
guint percentage_column;
54
gboolean button_pressed;
56
cairo_surface_t *memento;
59
gboolean model_changed;
62
GtkTreeRowReference *root;
66
GList *highlighted_item;
68
GtkWidget *popup_menu;
78
static guint baobab_chart_signals [LAST_SIGNAL] = { 0 };
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 */
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,
108
static void baobab_chart_get_property (GObject *object,
112
static void baobab_chart_free_items (BaobabChart *chart);
113
static void baobab_chart_draw_chart (BaobabChart *chart,
115
static void baobab_chart_update_draw (BaobabChart *chart,
117
static gboolean baobab_chart_draw (GtkWidget *chart,
119
static void baobab_chart_interpolate_colors (BaobabChartColor *color,
120
BaobabChartColor colora,
121
BaobabChartColor colorb,
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,
140
gboolean keyboard_mode,
143
static void baobab_chart_item_activated (BaobabChart *chart,
148
baobab_chart_class_init (BaobabChartClass *class)
150
GObjectClass *obj_class;
151
GtkWidgetClass *widget_class;
153
obj_class = G_OBJECT_CLASS (class);
154
widget_class = GTK_WIDGET_CLASS (class);
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;
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;
170
/* BaobabChart signals */
171
class->item_activated = baobab_chart_item_activated;
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;
183
g_object_class_install_property (obj_class,
185
g_param_spec_int ("max-depth",
187
_("The maximum depth drawn in the chart from the root"),
189
BAOBAB_CHART_MAX_DEPTH,
190
BAOBAB_CHART_MAX_DEPTH,
193
g_object_class_install_property (obj_class,
195
g_param_spec_object ("model",
197
_("Set the model of the chart"),
201
g_object_class_install_property (obj_class,
203
g_param_spec_boxed ("root",
204
_("Chart root node"),
205
_("Set the root node from the model"),
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),
215
g_cclosure_marshal_VOID__BOXED,
219
g_type_class_add_private (obj_class, sizeof (BaobabChartPrivate));
223
baobab_chart_init (BaobabChart *chart)
225
chart->priv = G_TYPE_INSTANCE_GET_PRIVATE (chart, BAOBAB_TYPE_CHART, BaobabChartPrivate);
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;
239
chart->priv->first_item = NULL;
240
chart->priv->last_item = NULL;
241
chart->priv->highlighted_item = NULL;
245
baobab_chart_dispose (GObject *object)
249
chart = BAOBAB_CHART (object);
251
baobab_chart_free_items (chart);
253
if (chart->priv->model)
255
baobab_chart_disconnect_signals (chart, chart->priv->model);
256
g_object_unref (chart->priv->model);
257
chart->priv->model = NULL;
260
if (chart->priv->root)
262
gtk_tree_row_reference_free (chart->priv->root);
263
chart->priv->root = NULL;
266
G_OBJECT_CLASS (baobab_chart_parent_class)->dispose (object);
270
baobab_chart_realize (GtkWidget *widget)
273
GdkWindowAttr attributes;
274
gint attributes_mask;
275
GtkAllocation allocation;
277
GtkStyleContext *context;
279
g_return_if_fail (BAOBAB_IS_CHART (widget));
281
chart = BAOBAB_CHART (widget);
282
gtk_widget_set_realized (widget, TRUE);
284
gtk_widget_get_allocation (widget, &allocation);
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);
295
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
297
window = gdk_window_new (gtk_widget_get_parent_window (widget),
300
gtk_widget_set_window (widget, window);
301
gdk_window_set_user_data (window, chart);
303
context = gtk_widget_get_style_context (widget);
304
gtk_style_context_set_background (context, window);
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 |
314
baobab_chart_unrealize (GtkWidget *widget)
318
chart = BAOBAB_CHART (widget);
320
if (chart->priv->popup_menu)
322
gtk_widget_destroy (chart->priv->popup_menu);
323
chart->priv->popup_menu = NULL;
326
GTK_WIDGET_CLASS (baobab_chart_parent_class)->unrealize (widget);
330
baobab_chart_size_allocate (GtkWidget *widget,
331
GtkAllocation *allocation)
334
BaobabChartClass *class;
336
g_return_if_fail (BAOBAB_IS_CHART (widget));
337
g_return_if_fail (allocation != NULL);
339
chart = BAOBAB_CHART (widget);
340
class = BAOBAB_CHART_GET_CLASS (chart);
342
gtk_widget_set_allocation (widget, allocation);
344
if (gtk_widget_get_realized (widget))
348
gdk_window_move_resize (gtk_widget_get_window (widget),
349
allocation->x, allocation->y,
350
allocation->width, allocation->height);
352
for (node = chart->priv->first_item; node != NULL; node = node->next)
354
BaobabChartItem *item;
356
item = (BaobabChartItem *) node->data;
357
item->has_visible_children = FALSE;
358
item->visible = FALSE;
359
class->calculate_item_geometry (chart, item);
365
baobab_chart_set_property (GObject *object,
370
BaobabChart *chart = BAOBAB_CHART (object);
375
baobab_chart_set_max_depth (chart, g_value_get_int (value));
378
baobab_chart_set_model (chart, g_value_get_object (value));
381
baobab_chart_set_root (chart, g_value_get_object (value));
384
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
390
baobab_chart_get_property (GObject *object,
395
BaobabChart *chart = BAOBAB_CHART (object);
400
g_value_set_int (value, chart->priv->max_depth);
403
g_value_set_object (value, chart->priv->model);
406
g_value_set_object (value, chart->priv->root);
409
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
415
baobab_chart_add_item (BaobabChart *chart,
421
BaobabChartItem *item;
425
gtk_tree_model_get (chart->priv->model, &iter,
426
chart->priv->name_column, &name,
427
chart->priv->size_column, &size,
430
item = g_new (BaobabChartItem, 1);
432
item->size = g_format_size (size);
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;
445
chart->priv->last_item = g_list_prepend (chart->priv->last_item, item);
447
return chart->priv->last_item;
451
baobab_chart_free_items (BaobabChart *chart)
453
BaobabChartItem *item;
457
node = chart->priv->first_item;
463
item = (BaobabChartItem *) node->data;
472
g_list_free_1 (node);
477
chart->priv->first_item = NULL;
478
chart->priv->last_item = NULL;
479
chart->priv->highlighted_item = NULL;
483
baobab_chart_get_items (BaobabChart *chart,
487
GtkTreeIter initial_iter = {0};
489
GtkTreePath *model_root_path;
490
GtkTreeIter model_root_iter;
491
BaobabChartClass *class;
492
GtkTreeIter child_iter = {0};
494
BaobabChartItem *child;
497
/* First we free current item list */
498
baobab_chart_free_items (chart);
500
/* Get the tree iteration corresponding to root */
501
if (!gtk_tree_model_get_iter (chart->priv->model, &initial_iter, root))
503
chart->priv->model_changed = FALSE;
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);
511
gtk_tree_model_get (chart->priv->model, &model_root_iter,
512
chart->priv->percentage_column, &size, -1);
514
/* Create first item */
515
node = baobab_chart_add_item (chart, 0, 0, 100, initial_iter);
517
/* Iterate through childs building the list */
518
class = BAOBAB_CHART_GET_CLASS (chart);
522
BaobabChartItem *item;
524
item = (BaobabChartItem *) node->data;
525
item->has_any_child = gtk_tree_model_iter_children (chart->priv->model, &child_iter, &(item->iter));
527
/* Calculate item geometry */
528
class->calculate_item_geometry (chart, item);
536
/* Get item's children and add them to the list */
537
if ((item->has_any_child) && (item->depth < chart->priv->max_depth + 1))
543
gtk_tree_model_get (chart->priv->model, &child_iter, chart->priv->percentage_column, &size, -1);
545
child_node = baobab_chart_add_item (chart,
550
child = (BaobabChartItem *) child_node->data;
551
child->parent = node;
554
while (gtk_tree_model_iter_next (chart->priv->model, &child_iter));
559
while (node != NULL);
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);
564
chart->priv->model_changed = FALSE;
568
baobab_chart_draw_chart (BaobabChart *chart,
571
BaobabChartClass *class;
574
class = BAOBAB_CHART_GET_CLASS (chart);
576
/* call pre-draw abstract method */
578
class->pre_draw (chart, cr);
582
for (node = chart->priv->first_item; node != NULL; node = node->next)
584
BaobabChartItem *item;
587
item = (BaobabChartItem *) node->data;
589
if (gdk_cairo_get_clip_rectangle (cr, &clip) &&
591
(gdk_rectangle_intersect (&clip, &item->rect, NULL)) &&
592
(item->depth <= chart->priv->max_depth))
594
gboolean highlighted;
596
highlighted = (node == chart->priv->highlighted_item);
597
class->draw_item (chart, cr, item, highlighted);
603
/* call post-draw abstract method */
604
if (class->post_draw)
605
class->post_draw (chart, cr);
609
baobab_chart_update_draw (BaobabChart* chart,
612
GtkTreePath *root_path = NULL;
613
gint root_depth, node_depth;
615
if (!gtk_widget_get_realized ( GTK_WIDGET (chart)))
618
if (chart->priv->root != NULL)
620
root_path = gtk_tree_row_reference_get_path (chart->priv->root);
622
if (root_path == NULL)
624
gtk_tree_row_reference_free (chart->priv->root);
625
chart->priv->root = NULL;
629
if (chart->priv->root == NULL)
630
root_path = gtk_tree_path_new_first ();
632
root_depth = gtk_tree_path_get_depth (root_path);
633
node_depth = gtk_tree_path_get_depth (path);
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)))
639
gtk_widget_queue_draw (GTK_WIDGET (chart));
642
gtk_tree_path_free (root_path);
646
baobab_chart_row_changed (GtkTreeModel *model,
651
g_return_if_fail (path != NULL || iter != NULL);
653
chart->priv->model_changed = TRUE;
654
baobab_chart_update_draw (chart, path);
658
baobab_chart_row_inserted (GtkTreeModel *model,
663
g_return_if_fail (path != NULL || iter != NULL);
665
chart->priv->model_changed = TRUE;
666
baobab_chart_update_draw (chart, path);
670
baobab_chart_row_has_child_toggled (GtkTreeModel *model,
675
g_return_if_fail (path != NULL || iter != NULL);
677
chart->priv->model_changed = TRUE;
678
baobab_chart_update_draw (chart, path);
682
baobab_chart_row_deleted (GtkTreeModel *model,
686
g_return_if_fail (path != NULL);
688
chart->priv->model_changed = TRUE;
689
baobab_chart_update_draw (chart, path);
693
baobab_chart_rows_reordered (GtkTreeModel *model,
699
g_return_if_fail (path != NULL || iter != NULL);
701
chart->priv->model_changed = TRUE;
702
baobab_chart_update_draw (chart, path);
706
baobab_chart_draw (GtkWidget *widget,
711
chart = BAOBAB_CHART (widget);
713
/* the columns are not set we paint nothing */
714
if (chart->priv->name_column == chart->priv->percentage_column)
717
/* there is no model we can not paint */
718
if ((chart->priv->is_frozen) || (chart->priv->model == NULL))
720
if (chart->priv->memento != NULL)
725
w = cairo_image_surface_get_width (chart->priv->memento);
726
h = cairo_image_surface_get_height (chart->priv->memento);
728
aw = gtk_widget_get_allocated_width (widget);
729
ah = gtk_widget_get_allocated_height (widget);
731
if (w > 0 && h > 0 && !(aw == w && aw == h))
733
/* minimal available proportion */
734
p = MIN (aw / (1.0 * w), ah / (1.0 * h));
736
sx = (gdouble) (aw - w * p) / 2.0;
737
sy = (gdouble) (ah - h * p) / 2.0;
739
cairo_translate (cr, sx, sy);
740
cairo_scale (cr, p, p);
743
cairo_set_source_surface (cr, chart->priv->memento, 0, 0);
749
GtkTreePath *root_path = NULL;
751
cairo_set_source_rgb (cr, 1, 1, 1);
752
cairo_fill_preserve (cr);
754
if (chart->priv->root != NULL)
755
root_path = gtk_tree_row_reference_get_path (chart->priv->root);
757
if (root_path == NULL)
759
root_path = gtk_tree_path_new_first ();
760
chart->priv->root = NULL;
763
/* Check if tree model was modified in any way */
764
if ((chart->priv->model_changed) || (chart->priv->first_item == NULL))
766
baobab_chart_get_items (chart, root_path);
770
GtkTreePath *current_path;
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);
776
if (gtk_tree_path_compare (root_path, current_path) != 0)
777
baobab_chart_get_items (chart, root_path);
779
gtk_tree_path_free (current_path);
782
gtk_tree_path_free (root_path);
784
baobab_chart_draw_chart (chart, cr);
791
baobab_chart_interpolate_colors (BaobabChartColor *color,
792
BaobabChartColor colora,
793
BaobabChartColor colorb,
798
diff = colora.red - colorb.red;
799
color->red = colora.red-diff*percentage;
801
diff = colora.green - colorb.green;
802
color->green = colora.green-diff*percentage;
804
diff = colora.blue - colorb.blue;
805
color->blue = colora.blue-diff*percentage;
809
baobab_chart_get_item_color (BaobabChartColor *color,
810
gdouble rel_position,
812
gboolean highlighted)
816
gint next_color_number;
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};
821
intensity = 1 - (((depth-1)*0.3) / BAOBAB_CHART_MAX_DEPTH);
824
*color = level_color;
827
color_number = rel_position / (100/3);
828
next_color_number = (color_number + 1) % 6;
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;
842
*color = level_color_hl;
845
maximum = MAX (color->red,
848
color->red /= maximum;
849
color->green /= maximum;
850
color->blue /= maximum;
856
popup_menu_detach (GtkWidget *attach_widget,
859
BAOBAB_CHART (attach_widget)->priv->popup_menu = NULL;
863
popup_menu_activate_up (GtkMenuItem *checkmenuitem,
866
baobab_chart_move_up_root (chart);
870
popup_menu_activate_zoom_in (GtkMenuItem *checkmenuitem,
873
baobab_chart_zoom_in (chart);
877
popup_menu_activate_zoom_out (GtkMenuItem *checkmenuitem,
880
baobab_chart_zoom_out (chart);
884
do_popup_menu (BaobabChart *chart,
885
GdkEventButton *event)
889
GtkWidget *zoom_in_item;
890
GtkWidget *zoom_out_item;
891
GtkTreePath *root_path;
893
menu = gtk_menu_new ();
894
chart->priv->popup_menu = menu;
896
gtk_menu_attach_to_widget (GTK_MENU (menu), GTK_WIDGET (chart), popup_menu_detach);
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));
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));
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));
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);
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);
922
gtk_widget_show_all (menu);
924
root_path = baobab_chart_get_root (chart);
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));
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 ());
940
gtk_tree_path_free (root_path);
944
baobab_chart_button_press_event (GtkWidget *widget,
945
GdkEventButton *event)
947
BaobabChart *chart = BAOBAB_CHART (widget);
949
if (event->type == GDK_BUTTON_PRESS)
951
if (gdk_event_triggers_context_menu ((GdkEvent *) event))
953
do_popup_menu (chart, event);
956
else if (!chart->priv->is_frozen)
958
switch (event->button)
961
if (chart->priv->highlighted_item != NULL)
963
GtkTreePath *path, *root_path;
966
iter = &((BaobabChartItem*) chart->priv->highlighted_item->data)->iter;
967
path = gtk_tree_model_get_path (chart->priv->model, iter);
969
if (chart->priv->root)
970
root_path = gtk_tree_row_reference_get_path (chart->priv->root);
972
root_path = gtk_tree_path_new_first ();
974
if (gtk_tree_path_compare (path, root_path) == 0)
976
/* Go back to the parent dir */
977
baobab_chart_move_up_root (chart);
981
/* Enter into a subdir */
982
g_signal_emit (chart,
983
baobab_chart_signals[ITEM_ACTIVATED], 0,
987
gtk_tree_path_free (path);
993
/* Go back to the parent dir */
994
baobab_chart_move_up_root (chart);
1006
baobab_chart_popup_menu (GtkWidget *widget)
1008
do_popup_menu (BAOBAB_CHART (widget), NULL);
1014
baobab_chart_scroll (GtkWidget *widget,
1015
GdkEventScroll *event)
1017
BaobabChart *chart = BAOBAB_CHART (widget);
1019
switch (event->direction)
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);
1029
case GDK_SCROLL_RIGHT :
1030
case GDK_SCROLL_DOWN :
1031
if (baobab_chart_can_zoom_in (chart))
1032
baobab_chart_zoom_in (chart);
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 */
1046
baobab_chart_set_item_highlight (BaobabChart *chart,
1048
gboolean highlighted)
1050
BaobabChartItem *item;
1055
item = (BaobabChartItem *) node->data;
1058
chart->priv->highlighted_item = node;
1060
chart->priv->highlighted_item = NULL;
1062
gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (chart)),
1067
baobab_chart_motion_notify (GtkWidget *widget,
1068
GdkEventMotion *event)
1071
BaobabChartPrivate *priv;
1072
BaobabChartClass *class;
1074
BaobabChartItem *item;
1075
gboolean found = FALSE;
1077
chart = BAOBAB_CHART (widget);
1080
class = BAOBAB_CHART_GET_CLASS (widget);
1082
/* Check if the pointer is over an item */
1083
for (node = priv->last_item; node != NULL; node = node->prev)
1085
item = (BaobabChartItem *) node->data;
1087
if ((item->visible) && (class->is_point_over_item (chart, item, event->x, event->y)))
1089
if (chart->priv->highlighted_item != node)
1091
baobab_chart_set_item_highlight (chart, priv->highlighted_item, FALSE);
1093
gtk_widget_set_has_tooltip (widget, TRUE);
1094
baobab_chart_set_item_highlight (chart, node, TRUE);
1102
/* If we never found a highlighted item, but there is an old highlighted item,
1103
redraw it to turn it off */
1106
baobab_chart_set_item_highlight (chart, priv->highlighted_item, FALSE);
1107
gtk_widget_set_has_tooltip (widget, FALSE);
1110
/* Continue receiving motion notifies */
1111
gdk_event_request_motions (event);
1117
baobab_chart_leave_notify (GtkWidget *widget,
1118
GdkEventCrossing *event)
1122
chart = BAOBAB_CHART (widget);
1124
baobab_chart_set_item_highlight (chart, chart->priv->highlighted_item, FALSE);
1130
baobab_chart_connect_signals (BaobabChart *chart,
1131
GtkTreeModel *model)
1133
g_signal_connect (model,
1135
G_CALLBACK (baobab_chart_row_changed),
1137
g_signal_connect (model,
1139
G_CALLBACK (baobab_chart_row_inserted),
1141
g_signal_connect (model,
1142
"row_has_child_toggled",
1143
G_CALLBACK (baobab_chart_row_has_child_toggled),
1145
g_signal_connect (model,
1147
G_CALLBACK (baobab_chart_row_deleted),
1149
g_signal_connect (model,
1151
G_CALLBACK (baobab_chart_rows_reordered),
1153
g_signal_connect (chart,
1155
G_CALLBACK (baobab_chart_query_tooltip),
1157
g_signal_connect (chart,
1158
"motion-notify-event",
1159
G_CALLBACK (baobab_chart_motion_notify),
1161
g_signal_connect (chart,
1162
"leave-notify-event",
1163
G_CALLBACK (baobab_chart_leave_notify),
1168
baobab_chart_disconnect_signals (BaobabChart *chart,
1169
GtkTreeModel *model)
1171
g_signal_handlers_disconnect_by_func (model,
1172
baobab_chart_row_changed,
1174
g_signal_handlers_disconnect_by_func (model,
1175
baobab_chart_row_inserted,
1177
g_signal_handlers_disconnect_by_func (model,
1178
baobab_chart_row_has_child_toggled,
1180
g_signal_handlers_disconnect_by_func (model,
1181
baobab_chart_row_deleted,
1183
g_signal_handlers_disconnect_by_func (model,
1184
baobab_chart_rows_reordered,
1186
g_signal_handlers_disconnect_by_func (chart,
1187
baobab_chart_query_tooltip,
1189
g_signal_handlers_disconnect_by_func (chart,
1190
baobab_chart_motion_notify,
1192
g_signal_handlers_disconnect_by_func (chart,
1193
baobab_chart_leave_notify,
1198
baobab_chart_query_tooltip (GtkWidget *widget,
1201
gboolean keyboard_mode,
1202
GtkTooltip *tooltip,
1205
BaobabChart *chart = BAOBAB_CHART (widget);
1206
BaobabChartItem *item;
1210
if (chart->priv->highlighted_item == NULL)
1213
item = (BaobabChartItem *) chart->priv->highlighted_item->data;
1215
if ( (item->name == NULL) || (item->size == NULL) )
1218
gtk_tooltip_set_tip_area (tooltip, &item->rect);
1220
markup = g_strconcat (item->name,
1224
escaped = g_markup_escape_text (markup, -1);
1225
gtk_tooltip_set_markup (tooltip, escaped);
1233
baobab_chart_item_activated (BaobabChart *chart,
1238
path = gtk_tree_model_get_path (chart->priv->model, iter);
1239
baobab_chart_set_root (chart, path);
1241
gtk_tree_path_free (path);
1244
/* Public functions start here */
1249
* Constructor for the baobab_chart class
1251
* Returns: a new #BaobabChart object
1254
baobab_chart_new (void)
1256
return g_object_new (BAOBAB_TYPE_CHART, NULL);
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
1264
* @name_column: number of column inside @model where the file name is
1266
* @size_column: number of column inside @model where the file size is
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
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
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
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.
1291
* Fails if @chart is not a #BaobabChart or if @model is not a
1295
baobab_chart_set_model_with_columns (BaobabChart *chart,
1296
GtkTreeModel *model,
1300
guint percentage_column,
1304
g_return_if_fail (BAOBAB_IS_CHART (chart));
1305
g_return_if_fail (GTK_IS_TREE_MODEL (model));
1308
baobab_chart_set_model (chart, model);
1312
chart->priv->root = gtk_tree_row_reference_new (model, root);
1313
g_object_notify (G_OBJECT (chart), "root");
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;
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
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.
1336
* Fails if @chart is not a #BaobabChart or if @model is not a
1340
baobab_chart_set_model (BaobabChart *chart,
1341
GtkTreeModel *model)
1343
g_return_if_fail (BAOBAB_IS_CHART (chart));
1344
g_return_if_fail (GTK_IS_TREE_MODEL (model));
1346
if (model == chart->priv->model)
1349
if (chart->priv->model)
1351
if (! chart->priv->is_frozen)
1352
baobab_chart_disconnect_signals (chart, chart->priv->model);
1353
g_object_unref (chart->priv->model);
1356
chart->priv->model = model;
1357
g_object_ref (chart->priv->model);
1359
if (! chart->priv->is_frozen)
1360
baobab_chart_connect_signals (chart, chart->priv->model);
1362
if (chart->priv->root)
1363
gtk_tree_row_reference_free (chart->priv->root);
1365
chart->priv->root = NULL;
1367
g_object_notify (G_OBJECT (chart), "model");
1369
gtk_widget_queue_draw (GTK_WIDGET (chart));
1373
* baobab_chart_get_model:
1374
* @chart: a #BaobabChart whose model will be returned.
1376
* Returns the #GtkTreeModel which is the model used by @chart.
1378
* Returns: %NULL if @chart is not a #BaobabChart.
1381
baobab_chart_get_model (BaobabChart *chart)
1383
g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
1385
return chart->priv->model;
1389
* baobab_chart_set_max_depth:
1390
* @chart: a #BaobabChart
1391
* @max_depth: the new maximum depth to show in the widget.
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.
1397
* Fails if @chart is not a #BaobabChart.
1400
baobab_chart_set_max_depth (BaobabChart *chart,
1403
g_return_if_fail (BAOBAB_IS_CHART (chart));
1405
max_depth = MIN (max_depth, BAOBAB_CHART_MAX_DEPTH);
1406
max_depth = MAX (max_depth, BAOBAB_CHART_MIN_DEPTH);
1408
if (max_depth == chart->priv->max_depth)
1411
chart->priv->max_depth = max_depth;
1412
g_object_notify (G_OBJECT (chart), "max-depth");
1414
chart->priv->model_changed = TRUE;
1416
gtk_widget_queue_draw (GTK_WIDGET (chart));
1420
* baobab_chart_get_max_depth:
1421
* @chart: a #BaobabChart.
1423
* Returns the maximum number of levels that will be show in the
1426
* Fails if @chart is not a #BaobabChart.
1429
baobab_chart_get_max_depth (BaobabChart *chart)
1431
g_return_val_if_fail (BAOBAB_IS_CHART (chart), 0);
1433
return chart->priv->max_depth;
1437
* baobab_chart_set_root:
1438
* @chart: a #BaobabChart
1439
* @root: a #GtkTreePath indicating the node which will be used as
1442
* Sets the node pointed by @root as the new root of the widget
1445
* Fails if @chart is not a #BaobabChart or if @chart has not
1446
* a #GtkTreeModel set.
1449
baobab_chart_set_root (BaobabChart *chart,
1452
g_return_if_fail (BAOBAB_IS_CHART (chart));
1453
g_return_if_fail (chart->priv->model != NULL);
1455
if (chart->priv->root)
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))
1462
/* Free current root */
1463
gtk_tree_row_reference_free (chart->priv->root);
1468
chart->priv->root = root ? gtk_tree_row_reference_new (chart->priv->model, root) : NULL;
1470
g_object_notify (G_OBJECT (chart), "root");
1472
gtk_widget_queue_draw (GTK_WIDGET (chart));
1476
* baobab_chart_get_root:
1477
* @chart: a #BaobabChart.
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
1484
* Fails if @chart is not a #BaobabChart.
1487
baobab_chart_get_root (BaobabChart *chart)
1489
g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
1491
if (chart->priv->root)
1492
return gtk_tree_row_reference_get_path (chart->priv->root);
1498
* baobab_chart_freeze_updates:
1499
* @chart: the #BaobabChart whose model signals are going to be frozen.
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.
1507
* Fails if @chart is not a #BaobabChart.
1510
baobab_chart_freeze_updates (BaobabChart *chart)
1512
cairo_surface_t *surface = NULL;
1513
GtkAllocation allocation;
1515
g_return_if_fail (BAOBAB_IS_CHART (chart));
1517
if (chart->priv->is_frozen)
1520
if (chart->priv->model)
1521
baobab_chart_disconnect_signals (chart, chart->priv->model);
1523
gtk_widget_get_allocation (GTK_WIDGET (chart), &allocation);
1524
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
1528
if (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS)
1532
cr = cairo_create (surface);
1534
baobab_chart_draw_chart (chart, cr);
1536
cairo_rectangle (cr,
1541
cairo_set_source_rgba (cr, 0.93, 0.93, 0.93, 0.5); /* tango: eeeeec */
1542
cairo_fill_preserve (cr);
1546
chart->priv->memento = surface;
1551
chart->priv->is_frozen = TRUE;
1553
gtk_widget_queue_draw (GTK_WIDGET (chart));
1557
* baobab_chart_thaw_updates:
1558
* @chart: the #BaobabChart whose model signals are frozen.
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
1565
* Fails if @chart is not a #BaobabChart.
1568
baobab_chart_thaw_updates (BaobabChart *chart)
1570
g_return_if_fail (BAOBAB_IS_CHART (chart));
1572
if (chart->priv->is_frozen)
1574
if (chart->priv->model)
1575
baobab_chart_connect_signals (chart, chart->priv->model);
1577
if (chart->priv->memento)
1579
cairo_surface_destroy (chart->priv->memento);
1580
chart->priv->memento = NULL;
1583
chart->priv->is_frozen = FALSE;
1585
chart->priv->model_changed = TRUE;
1586
gtk_widget_queue_draw (GTK_WIDGET (chart));
1591
* baobab_chart_zoom_in:
1592
* @chart: the #BaobabChart requested to zoom in.
1594
* Zooms in the chart by decreasing its maximun depth.
1596
* Fails if @chart is not a #BaobabChart.
1599
baobab_chart_zoom_in (BaobabChart *chart)
1601
BaobabChartClass *class;
1602
guint new_max_depth;
1604
g_return_if_fail (BAOBAB_IS_CHART (chart));
1606
class = BAOBAB_CHART_GET_CLASS (chart);
1608
if (class->can_zoom_in != NULL)
1609
new_max_depth = class->can_zoom_in (chart);
1611
new_max_depth = chart->priv->max_depth - 1;
1613
baobab_chart_set_max_depth (chart, new_max_depth);
1617
* baobab_chart_zoom_out:
1618
* @chart: the #BaobabChart requested to zoom out.
1620
* Zooms out the chart by increasing its maximun depth.
1622
* Fails if @chart is not a #BaobabChart.
1625
baobab_chart_zoom_out (BaobabChart *chart)
1627
g_return_if_fail (BAOBAB_IS_CHART (chart));
1629
baobab_chart_set_max_depth (chart, baobab_chart_get_max_depth (chart) + 1);
1633
* baobab_chart_can_zoom_in:
1634
* @chart: the #BaobabChart to ask if can be zoomed in.
1636
* Returns a boolean telling whether the chart can be zoomed in, given its current
1637
* visualization conditions.
1639
* Fails if @chart is not a #BaobabChart.
1642
baobab_chart_can_zoom_in (BaobabChart *chart)
1644
BaobabChartClass *class;
1646
g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
1648
if (chart->priv->is_frozen)
1651
class = BAOBAB_CHART_GET_CLASS (chart);
1653
if (class->can_zoom_in != NULL)
1654
return class->can_zoom_in (chart) > 0;
1656
return chart->priv->max_depth > 1;
1660
* baobab_chart_can_zoom_out:
1661
* @chart: the #BaobabChart to ask if can be zoomed out.
1663
* Returns a boolean telling whether the chart can be zoomed out, given its current
1664
* visualization conditions.
1666
* Fails if @chart is not a #BaobabChart.
1669
baobab_chart_can_zoom_out (BaobabChart *chart)
1671
BaobabChartClass *class;
1673
g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
1675
if (chart->priv->is_frozen)
1678
class = BAOBAB_CHART_GET_CLASS (chart);
1680
if (class->can_zoom_out != NULL)
1681
return class->can_zoom_out (chart) > 0;
1683
return (chart->priv->max_depth < BAOBAB_CHART_MAX_DEPTH);
1687
* baobab_chart_move_up_root:
1688
* @chart: the #BaobabChart whose root is requested to move up one level.
1690
* Move root to the inmediate parent of the current root item of @chart.
1692
* Fails if @chart is not a #BaobabChart.
1695
baobab_chart_move_up_root (BaobabChart *chart)
1697
GtkTreeIter parent_iter;
1699
GtkTreeIter root_iter;
1702
GtkTreePath *parent_path;
1704
g_return_if_fail (BAOBAB_IS_CHART (chart));
1706
if (chart->priv->root == NULL)
1709
path = gtk_tree_row_reference_get_path (chart->priv->root);
1712
gtk_tree_model_get_iter (chart->priv->model, &root_iter, path);
1716
if (gtk_tree_model_iter_parent (chart->priv->model, &parent_iter, &root_iter))
1718
gtk_tree_model_get (chart->priv->model, &parent_iter, chart->priv->valid_column,
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);
1729
g_signal_emit (BAOBAB_CHART (chart),
1730
baobab_chart_signals[ITEM_ACTIVATED],
1733
gtk_widget_queue_draw (GTK_WIDGET (chart));
1736
gtk_tree_path_free (path);
1740
* baobab_chart_is_frozen:
1741
* @chart: the #BaobabChart to ask if frozen.
1743
* Returns a boolean telling whether the chart is in a frozen state, meanning
1744
* that no actions should be taken uppon it.
1746
* Fails if @chart is not a #BaobabChart.
1749
baobab_chart_is_frozen (BaobabChart *chart)
1751
g_return_val_if_fail (BAOBAB_IS_CHART (chart), FALSE);
1753
return chart->priv->is_frozen;
1757
* baobab_chart_is_frozen:
1758
* @chart: the #BaobabChart to obtain the highlighted it from.
1760
* Returns a BaobabChartItem corresponding to the item that currently has mouse
1761
* pointer over, or NULL if no item is highlighted.
1763
* Fails if @chart is not a #BaobabChart.
1766
baobab_chart_get_highlighted_item (BaobabChart *chart)
1768
g_return_val_if_fail (BAOBAB_IS_CHART (chart), NULL);
1770
return (chart->priv->highlighted_item ?
1771
(BaobabChartItem *) chart->priv->highlighted_item->data : NULL);
48
#include <gobject/gvaluecollector.h>
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))
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;
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))
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)))
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))
90
typedef struct _BaobabWindow BaobabWindow;
91
typedef struct _BaobabWindowClass BaobabWindowClass;
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))
100
typedef struct _BaobabApplication BaobabApplication;
101
typedef struct _BaobabApplicationClass BaobabApplicationClass;
103
struct _BaobabChartItem {
104
GTypeInstance parent_instance;
105
volatile int ref_count;
106
BaobabChartItemPrivate * priv;
114
gboolean has_any_child;
115
gboolean has_visible_children;
120
struct _BaobabChartItemClass {
121
GTypeClass parent_class;
122
void (*finalize) (BaobabChartItem *self);
125
struct _BaobabParamSpecChartItem {
126
GParamSpec parent_instance;
129
struct _BaobabChart {
130
GtkDrawingArea parent_instance;
131
BaobabChartPrivate * priv;
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);
147
struct _BaobabChartPrivate {
151
guint percentage_column;
153
gboolean model_changed;
154
GtkMenu* context_menu;
157
GtkTreeModel* model_;
158
GtkTreeRowReference* root_;
159
BaobabChartItem* highlighted_item_;
160
GSimpleActionGroup* action_group;
164
static gpointer baobab_chart_item_parent_class = NULL;
165
static gpointer baobab_chart_parent_class = NULL;
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;
175
BAOBAB_CHART_ITEM_DUMMY_PROPERTY
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))
182
BAOBAB_CHART_DUMMY_PROPERTY,
183
BAOBAB_CHART_MAX_DEPTH,
186
BAOBAB_CHART_HIGHLIGHTED_ITEM
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);
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}};
276
BaobabChartItem* baobab_chart_item_construct (GType object_type) {
277
BaobabChartItem* self = NULL;
278
self = (BaobabChartItem*) g_type_create_instance (object_type);
283
static void baobab_value_chart_item_init (GValue* value) {
284
value->data[0].v_pointer = NULL;
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);
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);
299
dest_value->data[0].v_pointer = NULL;
304
static gpointer baobab_value_chart_item_peek_pointer (const GValue* value) {
305
return value->data[0].v_pointer;
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);
318
value->data[0].v_pointer = baobab_chart_item_ref (object);
320
value->data[0].v_pointer = NULL;
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;
330
return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
332
if (!value->data[0].v_pointer) {
334
} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
335
*object_p = value->data[0].v_pointer;
337
*object_p = baobab_chart_item_ref (value->data[0].v_pointer);
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);
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;
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;
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);
368
value->data[0].v_pointer = NULL;
371
baobab_chart_item_unref (old);
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;
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;
385
value->data[0].v_pointer = NULL;
388
baobab_chart_item_unref (old);
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;
399
static void baobab_chart_item_instance_init (BaobabChartItem * self) {
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);
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);
423
return baobab_chart_item_type_id__volatile;
427
gpointer baobab_chart_item_ref (gpointer instance) {
428
BaobabChartItem* self;
430
g_atomic_int_inc (&self->ref_count);
435
void baobab_chart_item_unref (gpointer instance) {
436
BaobabChartItem* self;
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);
445
static void _baobab_chart_item_unref0_ (gpointer var) {
446
(var == NULL) ? NULL : (var = (baobab_chart_item_unref (var), NULL));
450
static void _g_list_free__baobab_chart_item_unref0_ (GList* self) {
451
g_list_foreach (self, (GFunc) _baobab_chart_item_unref0_, NULL);
456
static void _baobab_chart_open_file_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
457
baobab_chart_open_file ((BaobabChart*) self);
461
static void _baobab_chart_copy_path_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
462
baobab_chart_copy_path ((BaobabChart*) self);
466
static void _baobab_chart_trash_file_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
467
baobab_chart_trash_file ((BaobabChart*) self);
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);
476
static void _baobab_chart_zoom_in_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
477
baobab_chart_zoom_in ((BaobabChart*) self);
481
static void _baobab_chart_zoom_out_gsimple_action_activate_callback (GSimpleAction* action, GVariant* parameter, gpointer self) {
482
baobab_chart_zoom_out ((BaobabChart*) self);
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;
494
g_return_if_fail (self != NULL);
495
g_return_if_fail (m != NULL);
497
baobab_chart_set_model (self, _tmp0_);
499
if (_tmp1_ != NULL) {
500
GtkTreePath* _tmp2_ = NULL;
502
baobab_chart_set_root (self, _tmp2_);
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_;
517
static void baobab_chart_real_post_draw (BaobabChart* self, cairo_t* cr) {
518
g_return_if_fail (cr != NULL);
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);
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)));
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);
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)));
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);
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)));
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);
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)));
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);
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)));
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);
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)));
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);
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)));
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);
612
static gpointer _baobab_chart_item_ref0 (gpointer self) {
613
return self ? baobab_chart_item_ref (self) : NULL;
617
static void baobab_chart_real_size_allocate (GtkWidget* base, GtkAllocation* allocation) {
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;
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);
636
BaobabChartItem* _tmp3_ = NULL;
637
BaobabChartItem* _tmp4_ = NULL;
638
BaobabChartItem* _tmp5_ = NULL;
640
_tmp3_->has_visible_children = FALSE;
642
_tmp4_->visible = FALSE;
644
baobab_chart_calculate_item_geometry (self, _tmp5_);
645
_baobab_chart_item_unref0 (item);
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);
657
GList* _tmp0_ = NULL;
658
GList* _tmp1_ = NULL;
659
_tmp0_ = self->priv->items;
660
_tmp1_ = g_list_last (_tmp0_);
663
gboolean _tmp2_ = FALSE;
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;
675
GList* _tmp3_ = NULL;
676
GList* _tmp4_ = NULL;
678
_tmp4_ = _tmp3_->prev;
683
if (!(_tmp5_ != NULL)) {
687
_tmp7_ = _tmp6_->data;
688
_tmp8_ = _baobab_chart_item_ref0 ((BaobabChartItem*) _tmp7_);
691
_tmp11_ = _tmp10_->visible;
693
BaobabChartItem* _tmp12_ = NULL;
694
gdouble _tmp13_ = 0.0;
695
gdouble _tmp14_ = 0.0;
696
gboolean _tmp15_ = FALSE;
700
_tmp15_ = baobab_chart_is_point_over_item (self, _tmp12_, _tmp13_, _tmp14_);
706
BaobabChartItem* _tmp16_ = NULL;
708
baobab_chart_set_highlighted_item (self, _tmp16_);
710
_baobab_chart_item_unref0 (item);
713
_baobab_chart_item_unref0 (item);
717
baobab_chart_set_highlighted_item (self, NULL);
723
static gboolean baobab_chart_real_motion_notify_event (GtkWidget* base, GdkEventMotion* event) {
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);
738
_tmp4_ = baobab_chart_highlight_item_at_point (self, _tmp1_, _tmp3_);
739
gtk_widget_set_has_tooltip ((GtkWidget*) self, _tmp4_);
741
gdk_event_request_motions (_tmp5_);
747
static gboolean baobab_chart_real_leave_notify_event (GtkWidget* base, GdkEventCrossing* event) {
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_);
759
baobab_chart_set_highlighted_item (self, NULL);
766
static GList* baobab_chart_add_item (BaobabChart* self, guint depth, gdouble rel_start, gdouble rel_size, GtkTreeIter* iter) {
767
GList* result = NULL;
770
GtkTreeModel* _tmp0_ = NULL;
771
GtkTreeModel* _tmp1_ = NULL;
772
GtkTreeIter _tmp2_ = {0};
775
BaobabChartItem* item = NULL;
776
BaobabChartItem* _tmp5_ = NULL;
777
gchar* _tmp6_ = NULL;
778
gchar* _tmp7_ = NULL;
780
gdouble _tmp9_ = 0.0;
781
gdouble _tmp10_ = 0.0;
782
GtkTreeIter _tmp11_ = {0};
783
BaobabChartItem* _tmp12_ = 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);
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);
796
_tmp6_ = g_strdup (name);
797
_g_free0 (item->name);
799
_tmp7_ = g_format_size_full (size, G_FORMAT_SIZE_DEFAULT);
800
_g_free0 (item->size);
803
item->depth = _tmp8_;
805
item->rel_start = _tmp9_;
807
item->rel_size = _tmp10_;
808
item->has_any_child = FALSE;
809
item->visible = FALSE;
810
item->has_visible_children = FALSE;
812
item->iter = _tmp11_;
814
_tmp12_ = _baobab_chart_item_ref0 (item);
815
self->priv->items = g_list_prepend (self->priv->items, _tmp12_);
816
_tmp13_ = self->priv->items;
819
_baobab_chart_item_unref0 (item);
825
static void baobab_chart_get_items (BaobabChart* self, GtkTreePath* root_path) {
827
GtkTreeIter initial_iter = {0};
828
GtkTreeIter _tmp0_ = {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};
850
GtkTreeIter _tmp16_ = {0};
851
GList* _tmp17_ = NULL;
852
g_return_if_fail (self != NULL);
853
g_return_if_fail (root_path != NULL);
856
initial_iter = _tmp0_;
859
__g_list_free__baobab_chart_item_unref0_0 (self->priv->items);
860
self->priv->items = NULL;
861
_tmp2_ = baobab_chart_get_model (self);
864
_tmp6_ = gtk_tree_model_get_iter (_tmp3_, &_tmp5_, _tmp4_);
865
initial_iter = _tmp5_;
867
self->priv->model_changed = FALSE;
868
_gtk_tree_path_free0 (model_root_path);
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);
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);
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_);
888
gboolean _tmp18_ = FALSE;
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;
911
GList* _tmp19_ = NULL;
913
if (!(_tmp19_ != NULL)) {
919
_tmp21_ = _tmp20_->data;
920
_tmp22_ = _baobab_chart_item_ref0 ((BaobabChartItem*) _tmp21_);
923
_tmp24_ = baobab_chart_get_model (self);
926
_tmp27_ = _tmp26_->iter;
927
_tmp29_ = gtk_tree_model_iter_children (_tmp25_, &_tmp28_, &_tmp27_);
928
child_iter = _tmp28_;
929
_tmp23_->has_any_child = _tmp29_;
931
baobab_chart_calculate_item_geometry (self, _tmp30_);
933
_tmp32_ = _tmp31_->visible;
935
GList* _tmp33_ = NULL;
936
GList* _tmp34_ = NULL;
938
_tmp34_ = _tmp33_->prev;
940
_baobab_chart_item_unref0 (item);
944
_tmp37_ = _tmp36_->has_any_child;
946
BaobabChartItem* _tmp38_ = NULL;
951
_tmp39_ = _tmp38_->depth;
952
_tmp40_ = baobab_chart_get_max_depth (self);
954
_tmp35_ = _tmp39_ < (_tmp41_ + 1);
959
rel_start = (gdouble) 0;
961
gboolean _tmp42_ = FALSE;
964
GtkTreeModel* _tmp46_ = NULL;
965
GtkTreeModel* _tmp47_ = NULL;
966
GtkTreeIter _tmp48_ = {0};
968
BaobabChartItem* _tmp50_ = NULL;
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;
983
GtkTreeModel* _tmp43_ = NULL;
984
GtkTreeModel* _tmp44_ = NULL;
985
gboolean _tmp45_ = FALSE;
986
_tmp43_ = baobab_chart_get_model (self);
988
_tmp45_ = gtk_tree_model_iter_next (_tmp44_, &child_iter);
994
_tmp46_ = baobab_chart_get_model (self);
996
_tmp48_ = child_iter;
997
_tmp49_ = self->priv->percentage_column;
998
gtk_tree_model_get (_tmp47_, &_tmp48_, _tmp49_, &size, -1, -1);
1000
_tmp51_ = _tmp50_->depth;
1001
_tmp52_ = rel_start;
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_);
1012
_tmp59_->parent = _tmp60_;
1013
_tmp61_ = rel_start;
1015
rel_start = _tmp61_ + _tmp62_;
1016
_baobab_chart_item_unref0 (child);
1021
_tmp64_ = _tmp63_->prev;
1023
_baobab_chart_item_unref0 (item);
1026
self->priv->items = g_list_reverse (self->priv->items);
1027
self->priv->model_changed = FALSE;
1028
_gtk_tree_path_free0 (model_root_path);
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);
1040
cairo_save (_tmp0_);
1041
_tmp1_ = self->priv->items;
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);
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;
1060
_tmp8_ = gdk_cairo_get_clip_rectangle (_tmp6_, &_tmp7_);
1063
BaobabChartItem* _tmp9_ = NULL;
1064
gboolean _tmp10_ = FALSE;
1066
_tmp10_ = _tmp9_->visible;
1072
BaobabChartItem* _tmp11_ = NULL;
1073
GdkRectangle _tmp12_ = {0};
1074
gboolean _tmp13_ = FALSE;
1076
_tmp12_ = _tmp11_->rect;
1077
_tmp13_ = gdk_rectangle_intersect (&clip, &_tmp12_, NULL);
1083
BaobabChartItem* _tmp14_ = NULL;
1088
_tmp15_ = _tmp14_->depth;
1089
_tmp16_ = baobab_chart_get_max_depth (self);
1091
_tmp3_ = _tmp15_ <= _tmp17_;
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;
1104
_tmp19_ = baobab_chart_get_highlighted_item (self);
1106
highlighted = _tmp18_ == _tmp20_;
1109
_tmp23_ = highlighted;
1110
baobab_chart_draw_item (self, _tmp21_, _tmp22_, _tmp23_);
1112
_baobab_chart_item_unref0 (item);
1117
cairo_restore (_tmp24_);
1119
baobab_chart_post_draw (self, _tmp25_);
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;
1131
gint node_depth = 0;
1132
GtkTreePath* _tmp6_ = NULL;
1134
gboolean _tmp8_ = FALSE;
1139
g_return_if_fail (self != NULL);
1140
g_return_if_fail (path != NULL);
1141
_tmp0_ = gtk_widget_get_realized ((GtkWidget*) self);
1145
_tmp1_ = baobab_chart_get_root (self);
1148
_tmp4_ = gtk_tree_path_get_depth (_tmp3_);
1150
_gtk_tree_path_free0 (_tmp3_);
1151
root_depth = _tmp5_;
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);
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);
1171
_tmp18_ = gtk_tree_path_is_ancestor (_tmp16_, _tmp17_);
1173
_gtk_tree_path_free0 (_tmp16_);
1177
GtkTreePath* _tmp20_ = NULL;
1178
GtkTreePath* _tmp21_ = NULL;
1179
GtkTreePath* _tmp22_ = NULL;
1180
GtkTreePath* _tmp23_ = NULL;
1182
_tmp20_ = baobab_chart_get_root (self);
1186
_tmp24_ = gtk_tree_path_compare (_tmp22_, _tmp23_);
1187
_tmp13_ = _tmp24_ == 0;
1188
_gtk_tree_path_free0 (_tmp22_);
1195
gtk_widget_queue_draw ((GtkWidget*) self);
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;
1208
baobab_chart_update_draw (self, _tmp0_);
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;
1220
baobab_chart_update_draw (self, _tmp0_);
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;
1231
baobab_chart_update_draw (self, _tmp0_);
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;
1243
baobab_chart_update_draw (self, _tmp0_);
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;
1254
baobab_chart_update_draw (self, _tmp0_);
1258
static gboolean baobab_chart_real_draw (GtkWidget* base, cairo_t* cr) {
1260
gboolean result = FALSE;
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_) {
1273
_tmp2_ = baobab_chart_get_model (self);
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};
1283
GtkAllocation _tmp28_ = {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;
1297
GList* _tmp6_ = NULL;
1298
_tmp6_ = self->priv->items;
1299
_tmp4_ = _tmp6_ == NULL;
1302
GtkTreePath* _tmp7_ = NULL;
1303
GtkTreePath* _tmp8_ = NULL;
1304
GtkTreePath* _tmp9_ = NULL;
1305
_tmp7_ = baobab_chart_get_root (self);
1308
baobab_chart_get_items (self, _tmp9_);
1309
_gtk_tree_path_free0 (_tmp9_);
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;
1323
gboolean _tmp21_ = FALSE;
1324
_tmp10_ = baobab_chart_get_model (self);
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);
1334
_tmp19_ = current_path;
1335
_tmp20_ = gtk_tree_path_compare (_tmp18_, _tmp19_);
1336
_tmp21_ = _tmp20_ != 0;
1337
_gtk_tree_path_free0 (_tmp18_);
1339
GtkTreePath* _tmp22_ = NULL;
1340
GtkTreePath* _tmp23_ = NULL;
1341
GtkTreePath* _tmp24_ = NULL;
1342
_tmp22_ = baobab_chart_get_root (self);
1345
baobab_chart_get_items (self, _tmp24_);
1346
_gtk_tree_path_free0 (_tmp24_);
1348
_gtk_tree_path_free0 (current_path);
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_);
1359
_tmp32_ = cairo_create (_tmp31_);
1360
source_cr = _tmp32_;
1361
_tmp33_ = source_cr;
1362
baobab_chart_draw_chart (self, _tmp33_);
1365
cairo_set_source_surface (_tmp34_, _tmp35_, (gdouble) 0, (gdouble) 0);
1367
cairo_paint (_tmp36_);
1368
_cairo_destroy0 (source_cr);
1369
_cairo_surface_destroy0 (source);
1376
static void baobab_chart_interpolate_colors (BaobabChart* self, GdkRGBA* colora, GdkRGBA* colorb, gdouble percentage, GdkRGBA* result) {
1377
GdkRGBA color = {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));
1408
_tmp1_ = _tmp0_.red;
1410
_tmp3_ = _tmp2_.red;
1411
diff = _tmp1_ - _tmp3_;
1413
_tmp5_ = _tmp4_.red;
1415
_tmp7_ = percentage;
1416
color.red = _tmp5_ - (_tmp6_ * _tmp7_);
1418
_tmp9_ = _tmp8_.green;
1420
_tmp11_ = _tmp10_.green;
1421
diff = _tmp9_ - _tmp11_;
1423
_tmp13_ = _tmp12_.green;
1425
_tmp15_ = percentage;
1426
color.green = _tmp13_ - (_tmp14_ * _tmp15_);
1428
_tmp17_ = _tmp16_.blue;
1430
_tmp19_ = _tmp18_.blue;
1431
diff = _tmp17_ - _tmp19_;
1433
_tmp21_ = _tmp20_.blue;
1435
_tmp23_ = percentage;
1436
color.blue = _tmp21_ - (_tmp22_ * _tmp23_);
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;
1450
gboolean _tmp17_ = FALSE;
1451
g_return_if_fail (self != NULL);
1452
memset (&color, 0, sizeof (GdkRGBA));
1454
intensity = 1 - (((_tmp0_ - 1) * 0.3) / BAOBAB_CHART_MAX_DEPTH);
1456
if (_tmp1_ == ((guint) 0)) {
1457
color = level_color;
1459
gint color_number = 0;
1460
gdouble _tmp2_ = 0.0;
1461
gint next_color_number = 0;
1464
GdkRGBA _tmp5_ = {0};
1466
GdkRGBA _tmp7_ = {0};
1467
gdouble _tmp8_ = 0.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_);
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_;
1498
_tmp17_ = highlighted;
1502
if (_tmp18_ == ((guint) 0)) {
1503
color = level_color_hi;
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;
1521
_tmp20_ = _tmp19_.red;
1523
_tmp22_ = _tmp21_.green;
1525
_tmp24_ = _tmp23_.blue;
1526
_tmp25_ = MAX (_tmp22_, _tmp24_);
1527
_tmp26_ = MAX (_tmp20_, _tmp25_);
1529
_tmp27_ = color.red;
1531
color.red = _tmp27_ / _tmp28_;
1532
_tmp29_ = color.green;
1534
color.green = _tmp29_ / _tmp30_;
1535
_tmp31_ = color.blue;
1537
color.blue = _tmp31_ / _tmp32_;
1545
static gboolean baobab_chart_real_button_press_event (GtkWidget* base, GdkEventButton* event) {
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);
1553
_tmp1_ = _tmp0_->type;
1554
if (_tmp1_ == GDK_BUTTON_PRESS) {
1555
GdkEventButton* _tmp2_ = NULL;
1556
gboolean _tmp3_ = FALSE;
1557
GdkEventButton* _tmp5_ = NULL;
1560
_tmp3_ = gdk_event_triggers_context_menu ((GdkEvent*) _tmp2_);
1562
GdkEventButton* _tmp4_ = NULL;
1564
baobab_chart_show_popup_menu (self, _tmp4_);
1569
_tmp6_ = _tmp5_->button;
1571
case GDK_BUTTON_PRIMARY:
1573
GdkEventButton* _tmp7_ = NULL;
1574
gdouble _tmp8_ = 0.0;
1575
GdkEventButton* _tmp9_ = NULL;
1576
gdouble _tmp10_ = 0.0;
1577
gboolean _tmp11_ = FALSE;
1581
_tmp10_ = _tmp9_->y;
1582
_tmp11_ = baobab_chart_highlight_item_at_point (self, _tmp8_, _tmp10_);
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;
1596
gboolean _tmp23_ = FALSE;
1597
_tmp12_ = baobab_chart_get_model (self);
1599
_tmp14_ = baobab_chart_get_highlighted_item (self);
1601
_tmp16_ = _tmp15_->iter;
1602
_tmp17_ = gtk_tree_model_get_path (_tmp13_, &_tmp16_);
1604
_tmp18_ = baobab_chart_get_root (self);
1608
_tmp22_ = gtk_tree_path_compare (_tmp20_, _tmp21_);
1609
_tmp23_ = _tmp22_ == 0;
1610
_gtk_tree_path_free0 (_tmp20_);
1612
baobab_chart_move_up_root (self);
1614
BaobabChartItem* _tmp24_ = NULL;
1615
BaobabChartItem* _tmp25_ = NULL;
1616
GtkTreeIter _tmp26_ = {0};
1617
_tmp24_ = baobab_chart_get_highlighted_item (self);
1619
_tmp26_ = _tmp25_->iter;
1620
g_signal_emit_by_name (self, "item-activated", &_tmp26_);
1622
_gtk_tree_path_free0 (path);
1626
case GDK_BUTTON_MIDDLE:
1628
baobab_chart_move_up_root (self);
1642
static GdkEventMotion* _vala_GdkEventMotion_copy (GdkEventMotion* self) {
1643
return g_boxed_copy (gdk_event_get_type (), self);
1647
static gpointer __vala_GdkEventMotion_copy0 (gpointer self) {
1648
return self ? _vala_GdkEventMotion_copy (self) : NULL;
1652
static void _vala_GdkEventMotion_free (GdkEventMotion* self) {
1653
g_boxed_free (gdk_event_get_type (), self);
1657
static gboolean baobab_chart_real_scroll_event (GtkWidget* base, GdkEventScroll* event) {
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);
1668
_tmp1_ = __vala_GdkEventMotion_copy0 ((GdkEventMotion*) _tmp0_);
1671
_tmp3_ = _tmp2_->direction;
1673
case GDK_SCROLL_LEFT:
1676
GdkEventMotion* _tmp4_ = NULL;
1677
gboolean _tmp5_ = FALSE;
1678
baobab_chart_zoom_out (self);
1680
g_signal_emit_by_name ((GtkWidget*) self, "motion-notify-event", _tmp4_, &_tmp5_);
1683
case GDK_SCROLL_RIGHT:
1684
case GDK_SCROLL_DOWN:
1686
GdkEventMotion* _tmp6_ = NULL;
1687
gboolean _tmp7_ = FALSE;
1688
baobab_chart_zoom_in (self);
1690
g_signal_emit_by_name ((GtkWidget*) self, "motion-notify-event", _tmp6_, &_tmp7_);
1693
case GDK_SCROLL_SMOOTH:
1701
__vala_GdkEventMotion_free0 (e);
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);
1715
_tmp3_ = _tmp2_->iter;
1716
baobab_window_open_item (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_WINDOW) ? ((BaobabWindow*) _tmp0_) : NULL, &_tmp3_);
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);
1729
_tmp3_ = _tmp2_->iter;
1730
baobab_window_copy_path (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_WINDOW) ? ((BaobabWindow*) _tmp0_) : NULL, &_tmp3_);
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);
1743
_tmp3_ = _tmp2_->iter;
1744
baobab_window_trash_file (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, BAOBAB_TYPE_WINDOW) ? ((BaobabWindow*) _tmp0_) : NULL, &_tmp3_);
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);
1765
_tmp2_ = baobab_chart_get_root (self);
1768
gtk_tree_model_get_iter (_tmp1_, &_tmp5_, _tmp4_);
1770
_gtk_tree_path_free0 (_tmp4_);
1771
_tmp6_ = baobab_chart_get_model (self);
1774
_tmp10_ = gtk_tree_model_iter_parent (_tmp7_, &_tmp9_, &_tmp8_);
1775
parent_iter = _tmp9_;
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);
1785
_tmp13_ = parent_iter;
1786
_tmp14_ = gtk_tree_model_get_path (_tmp12_, &_tmp13_);
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_);
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);
1803
_tmp1_ = baobab_chart_get_max_depth (self);
1805
baobab_chart_set_max_depth (self, _tmp2_ - 1);
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);
1817
_tmp1_ = baobab_chart_get_max_depth (self);
1819
baobab_chart_set_max_depth (self, _tmp2_ + 1);
1824
static gpointer _g_object_ref0 (gpointer self) {
1825
return self ? g_object_ref (self) : NULL;
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 ();
1841
_tmp2_ = gtk_application_get_menu_by_id ((GtkApplication*) _tmp1_, "chartmenu");
1842
_tmp3_ = _g_object_ref0 (_tmp2_);
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);
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);
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);
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);
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);
1903
g_simple_action_set_enabled (_tmp15_, _tmp16_);
1905
if (_tmp17_ != NULL) {
1906
GtkMenu* _tmp18_ = NULL;
1907
GdkEventButton* _tmp19_ = NULL;
1909
GdkEventButton* _tmp21_ = NULL;
1910
guint32 _tmp22_ = 0U;
1911
_tmp18_ = self->priv->context_menu;
1913
_tmp20_ = _tmp19_->button;
1915
_tmp22_ = _tmp21_->time;
1916
gtk_menu_popup (_tmp18_, NULL, NULL, NULL, NULL, _tmp20_, _tmp22_);
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_);
1924
_g_object_unref0 (action);
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);
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);
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);
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);
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);
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);
1962
g_signal_connect_object (_tmp0_, "row-changed", (GCallback) _baobab_chart_row_changed_gtk_tree_model_row_changed, self, 0);
1964
g_signal_connect_object (_tmp1_, "row-inserted", (GCallback) _baobab_chart_row_inserted_gtk_tree_model_row_inserted, self, 0);
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);
1968
g_signal_connect_object (_tmp3_, "row-deleted", (GCallback) _baobab_chart_row_deleted_gtk_tree_model_row_deleted, self, 0);
1970
g_signal_connect_object (_tmp4_, "rows-reordered", (GCallback) _baobab_chart_rows_reordered_gtk_tree_model_rows_reordered, self, 0);
1974
static void baobab_chart_disconnect_model_signals (BaobabChart* self, GtkTreeModel* m) {
1975
GtkTreeModel* _tmp0_ = NULL;
1977
GtkTreeModel* _tmp2_ = NULL;
1979
GtkTreeModel* _tmp4_ = NULL;
1981
GtkTreeModel* _tmp6_ = NULL;
1983
GtkTreeModel* _tmp8_ = NULL;
1985
g_return_if_fail (self != NULL);
1986
g_return_if_fail (m != NULL);
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);
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);
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);
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);
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);
2005
static gboolean baobab_chart_real_query_tooltip (GtkWidget* base, gint x, gint y, gboolean keyboard_tooltip, GtkTooltip* tooltip) {
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);
2035
if (_tmp3_ == NULL) {
2038
BaobabChartItem* _tmp4_ = NULL;
2039
BaobabChartItem* _tmp5_ = NULL;
2040
const gchar* _tmp6_ = NULL;
2041
_tmp4_ = baobab_chart_get_highlighted_item (self);
2043
_tmp6_ = _tmp5_->name;
2044
_tmp1_ = _tmp6_ == NULL;
2049
BaobabChartItem* _tmp7_ = NULL;
2050
BaobabChartItem* _tmp8_ = NULL;
2051
const gchar* _tmp9_ = NULL;
2052
_tmp7_ = baobab_chart_get_highlighted_item (self);
2054
_tmp9_ = _tmp8_->size;
2055
_tmp0_ = _tmp9_ == NULL;
2062
_tmp11_ = baobab_chart_get_highlighted_item (self);
2064
_tmp13_ = _tmp12_->rect;
2065
gtk_tooltip_set_tip_area (_tmp10_, &_tmp13_);
2066
_tmp14_ = baobab_chart_get_highlighted_item (self);
2068
_tmp16_ = _tmp15_->name;
2069
_tmp17_ = g_strconcat (_tmp16_, "\n", NULL);
2071
_tmp19_ = baobab_chart_get_highlighted_item (self);
2073
_tmp21_ = _tmp20_->size;
2074
_tmp22_ = g_strconcat (_tmp18_, _tmp21_, NULL);
2080
_tmp26_ = g_markup_escape_text (_tmp25_, (gssize) (-1));
2082
gtk_tooltip_set_markup (_tmp24_, _tmp27_);
2090
BaobabChart* baobab_chart_construct (GType object_type) {
2091
BaobabChart * self = NULL;
2092
self = (BaobabChart*) g_object_new (object_type, NULL);
2097
guint baobab_chart_get_max_depth (BaobabChart* self) {
2100
g_return_val_if_fail (self != NULL, 0U);
2101
_tmp0_ = self->priv->max_depth_;
2107
void baobab_chart_set_max_depth (BaobabChart* self, guint value) {
2114
g_return_if_fail (self != NULL);
2116
_tmp1_ = CLAMP (_tmp0_, BAOBAB_CHART_MIN_DEPTH, BAOBAB_CHART_MAX_DEPTH);
2118
_tmp2_ = self->priv->max_depth_;
2120
if (_tmp2_ == _tmp3_) {
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");
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_;
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_;
2151
if (_tmp0_ == _tmp1_) {
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_);
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");
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_);
2188
if (_tmp3_ != NULL) {
2192
_gtk_tree_row_reference_free0 (self->priv->root_);
2193
self->priv->root_ = NULL;
2194
_gtk_tree_path_free0 (path);
2196
_tmp4_ = gtk_tree_path_new_first ();
2202
static gpointer _gtk_tree_row_reference_copy0 (gpointer self) {
2203
return self ? gtk_tree_row_reference_copy (self) : NULL;
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);
2217
if (_tmp1_ == NULL) {
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;
2235
_tmp6_ = _tmp8_ != NULL;
2240
GtkTreePath* _tmp9_ = NULL;
2241
GtkTreePath* _tmp10_ = NULL;
2243
_tmp9_ = current_root;
2245
_tmp11_ = gtk_tree_path_compare (_tmp9_, _tmp10_);
2246
_tmp5_ = _tmp11_ == 0;
2251
_gtk_tree_path_free0 (current_root);
2254
_gtk_tree_path_free0 (current_root);
2256
GtkTreePath* _tmp12_ = NULL;
2258
if (_tmp12_ == NULL) {
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);
2271
_tmp18_ = gtk_tree_row_reference_new (_tmp16_, _tmp17_);
2272
_gtk_tree_row_reference_free0 (_tmp13_);
2275
_gtk_tree_row_reference_free0 (_tmp13_);
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");
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_;
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_;
2308
if (_tmp0_ == _tmp1_) {
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);
2322
if (_tmp6_ != NULL) {
2323
GdkWindow* _tmp7_ = NULL;
2324
BaobabChartItem* _tmp8_ = NULL;
2325
GdkRectangle _tmp9_ = {0};
2326
_tmp7_ = gtk_widget_get_window ((GtkWidget*) self);
2328
_tmp9_ = _tmp8_->rect;
2329
gdk_window_invalidate_rect (_tmp7_, &_tmp9_, TRUE);
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");
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);
2349
_tmp3_ = gtk_tree_model_get_path (_tmp1_, &_tmp2_);
2351
baobab_chart_set_root (self, _tmp4_);
2352
_gtk_tree_path_free0 (_tmp4_);
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;
2368
data1 = param_values->data[0].v_pointer;
2369
data2 = closure->data;
2371
callback = (GMarshalFunc_VOID__BOXED) (marshal_data ? marshal_data : cc->callback);
2372
callback (data1, g_value_get_boxed (param_values + 1), data2);
2376
static GObject * baobab_chart_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
2378
GObjectClass * parent_class;
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);
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);
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;
2438
static void baobab_chart_finalize (GObject* obj) {
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);
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);
2459
return baobab_chart_type_id__volatile;
2463
static void _vala_baobab_chart_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
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));
2470
case BAOBAB_CHART_MODEL:
2471
g_value_set_object (value, baobab_chart_get_model (self));
2473
case BAOBAB_CHART_ROOT:
2474
g_value_take_boxed (value, baobab_chart_get_root (self));
2476
case BAOBAB_CHART_HIGHLIGHTED_ITEM:
2477
baobab_value_set_chart_item (value, baobab_chart_get_highlighted_item (self));
2480
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
2486
static void _vala_baobab_chart_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
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));
2493
case BAOBAB_CHART_MODEL:
2494
baobab_chart_set_model (self, g_value_get_object (value));
2496
case BAOBAB_CHART_ROOT:
2497
baobab_chart_set_root (self, g_value_get_boxed (value));
2499
case BAOBAB_CHART_HIGHLIGHTED_ITEM:
2500
baobab_chart_set_highlighted_item (self, baobab_value_get_chart_item (value));
2503
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);