[baobab/wip/vala: 38/53] Sync the treeview selection when chart item is activated
- From: Paolo Borelli <pborelli 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 22:04:45 +0000 (UTC)
commit 72f60d198b7953ddc85f87f477dcfdc2c6656ade
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 998b585..1794774 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -90,18 +90,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);
@@ -221,6 +224,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;
@@ -262,7 +275,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]