[baobab/wip/vala: 38/53] Sync the treeview selection when chart item is activated
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 38/53] Sync the treeview selection when chart item is activated
- Date: Thu, 5 Apr 2012 21:36:55 +0000 (UTC)
commit 3b836e398bd8eae829cfabb5376d2bf769c9a8d4
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Jan 30 21:16:00 2012 +0100
Sync the treeview selection when chart item is activated
src/baobab-window.vala | 21 +++++++++++++++++----
src/baobab.vapi | 2 ++
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 6d4df45..83f48d6 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -70,18 +70,21 @@ namespace Baobab {
}
// Cache some objects from the builder.
+ treeview = builder.get_object ("treeview") as Gtk.TreeView;
chart_notebook = builder.get_object ("chart-notebook") as Gtk.Notebook;
rings_chart = builder.get_object ("rings-chart") as Chart;
treemap_chart = builder.get_object ("treemap-chart") as Chart;
- treeview = builder.get_object ("treeview") as Gtk.TreeView;
- setup_treeview_popup (builder);
+ setup_treeview (builder);
ui_settings = Application.get_ui_settings ();
lookup_action ("active-chart").change_state (ui_settings.get_value ("active-chart"));
+ rings_chart.item_activated.connect (on_chart_item_activated);
+ treemap_chart.item_activated.connect (on_chart_item_activated);
+
// Setup drag-n-drop
- drag_data_received.connect(on_drag_data_received);
+ drag_data_received.connect (on_drag_data_received);
enable_drop ();
add (builder.get_object ("window-contents") as Gtk.Widget);
@@ -201,6 +204,16 @@ namespace Baobab {
null);
}
+ void on_chart_item_activated (Chart chart, Gtk.TreeIter iter) {
+ var path = scanner.get_path (iter);
+
+ if (!treeview.is_row_expanded (path)) {
+ treeview.expand_to_path (path);
+ }
+
+ treeview.set_cursor (path, null, false);
+ }
+
void on_drag_data_received (Gtk.Widget widget, Gdk.DragContext context, int x, int y,
Gtk.SelectionData selection_data, uint target_type, uint time) {
File dir = null;
@@ -242,7 +255,7 @@ namespace Baobab {
return true;
}
- void setup_treeview_popup (Gtk.Builder builder) {
+ void setup_treeview (Gtk.Builder builder) {
var popup = builder.get_object ("treeview-popup-menu") as Gtk.Menu;
var open_item = builder.get_object ("treeview-popup-open") as Gtk.MenuItem;
var trash_item = builder.get_object ("treeview-popup-trash") as Gtk.MenuItem;
diff --git a/src/baobab.vapi b/src/baobab.vapi
index 91ce737..572f636 100644
--- a/src/baobab.vapi
+++ b/src/baobab.vapi
@@ -12,6 +12,8 @@ namespace Baobab {
[CCode (cheader_filename = "baobab-chart.h")]
public class Chart : Gtk.Widget {
+ public virtual signal void item_activated (Gtk.TreeIter iter);
+
public void set_model_with_columns (Gtk.TreeModel model, uint name_column, uint size_column, uint info_column, uint percentage_column, uint valid_column, Gtk.TreePath? root);
public Gtk.TreeModel model { get; set; }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]