[baobab/wip/vala] Implement basic chart navigation
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala] Implement basic chart navigation
- Date: Sun, 15 Jan 2012 10:48:33 +0000 (UTC)
commit b9824ec7a2b24380f4c84e5b0b01e9b92b8fb6e5
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jan 15 11:45:57 2012 +0100
Implement basic chart navigation
Add a default handler to chart item-activated signal that allows to
drill in/out of the chart.
src/baobab-chart.c | 34 ++++++++++++++++++++++++++++++++--
1 files changed, 32 insertions(+), 2 deletions(-)
---
diff --git a/src/baobab-chart.c b/src/baobab-chart.c
index e3da649..1c8d2a9 100644
--- a/src/baobab-chart.c
+++ b/src/baobab-chart.c
@@ -142,6 +142,9 @@ static gboolean baobab_chart_query_tooltip (GtkWidget *widget,
gboolean keyboard_mode,
GtkTooltip *tooltip,
gpointer user_data);
+static void baobab_chart_item_activated (BaobabChart *chart,
+ GtkTreeIter *iter);
+
static void
baobab_chart_class_init (BaobabChartClass *class)
@@ -166,7 +169,10 @@ baobab_chart_class_init (BaobabChartClass *class)
widget_class->popup_menu = baobab_chart_popup_menu;
widget_class->scroll_event = baobab_chart_scroll;
- /* Baobab Chart abstract methods */
+ /* BaobabChart signals */
+ class->item_activated = baobab_chart_item_activated;
+
+ /* BaobabChart abstract methods */
class->draw_item = NULL;
class->pre_draw = NULL;
class->post_draw = NULL;
@@ -203,7 +209,7 @@ baobab_chart_class_init (BaobabChartClass *class)
G_PARAM_READWRITE));
baobab_chart_signals[ITEM_ACTIVATED] =
- g_signal_new ("item_activated",
+ g_signal_new ("item-activated",
G_TYPE_FROM_CLASS (obj_class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (BaobabChartClass, item_activated),
@@ -1205,6 +1211,30 @@ baobab_chart_query_tooltip (GtkWidget *widget,
return TRUE;
}
+static void
+baobab_chart_item_activated (BaobabChart *chart,
+ GtkTreeIter *iter)
+{
+ GtkTreePath *root_path;
+ GtkTreePath *path;
+
+ root_path = baobab_chart_get_root (chart);
+ path = gtk_tree_model_get_path (chart->priv->model, iter);
+
+ if (root_path != NULL && gtk_tree_path_compare (root_path, path) == 0)
+ {
+ /* When the root is activated we try to move up */
+ baobab_chart_move_up_root (chart);
+ }
+ else
+ {
+ baobab_chart_set_root (chart, path);
+ }
+
+ gtk_tree_path_free (root_path);
+ gtk_tree_path_free (path);
+}
+
static GdkPixbuf *
baobab_chart_get_pixbuf (BaobabChart *chart)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]