[baobab/wip/vala: 34/65] Use radio buttons for chart selection
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [baobab/wip/vala: 34/65] Use radio buttons for chart selection
- Date: Thu, 5 Apr 2012 12:17:49 +0000 (UTC)
commit 33138d309911ce56b5b98f3ca85534a0c86dff87
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jan 22 10:56:53 2012 +0100
Use radio buttons for chart selection
Use two radio buttons at the bottom for the chart selection instead of
the combobox. I would like to use symbolic icons though...
data/baobab-main-window.ui | 142 +++++++++++++++++++++++++++----------------
src/baobab-window.vala | 38 +++++++++---
2 files changed, 117 insertions(+), 63 deletions(-)
---
diff --git a/data/baobab-main-window.ui b/data/baobab-main-window.ui
index 6194568..0bef4b5 100644
--- a/data/baobab-main-window.ui
+++ b/data/baobab-main-window.ui
@@ -22,12 +22,12 @@
<property name="tooltip_text" translatable="yes">Scan home folder</property>
<property name="use_action_appearance">False</property>
<property name="is_important">True</property>
+ <property name="action_name">win.scan-home</property>
<property name="label" translatable="yes">Scan Home</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-home</property>
- <property name="action_name">win.scan-home</property>
<child internal-child="accessible">
- <object class="AtkObject" id="tbscanhome1-atkobject">
+ <object class="AtkObject" id="scan-home-button-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Scan home folder</property>
</object>
</child>
@@ -46,10 +46,10 @@
<property name="tooltip_markup" translatable="yes">Scan filesystem</property>
<property name="tooltip_text" translatable="yes">Scan filesystem</property>
<property name="use_action_appearance">False</property>
+ <property name="action_name">win.scan-filesystem</property>
<property name="label" translatable="yes">Scan Filesystem</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-harddisk</property>
- <property name="action_name">win.scan-filesystem</property>
</object>
<packing>
<property name="expand">False</property>
@@ -65,10 +65,10 @@
<property name="tooltip_markup" translatable="yes">Scan a folder</property>
<property name="tooltip_text" translatable="yes">Scan a folder</property>
<property name="use_action_appearance">False</property>
+ <property name="action_name">win.scan-folder</property>
<property name="label" translatable="yes">Scan Folder</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-directory</property>
- <property name="action_name">win.scan-folder</property>
</object>
<packing>
<property name="expand">False</property>
@@ -84,10 +84,10 @@
<property name="tooltip_markup" translatable="yes">Scan a remote folder</property>
<property name="tooltip_text" translatable="yes">Scan a remote folder</property>
<property name="use_action_appearance">False</property>
+ <property name="action_name">win.scan-remote</property>
<property name="label" translatable="yes">Scan Remote Folder</property>
<property name="use_underline">True</property>
<property name="stock_id">gtk-network</property>
- <property name="action_name">win.scan-remote</property>
</object>
<packing>
<property name="expand">False</property>
@@ -112,8 +112,8 @@
<property name="tooltip_markup" translatable="yes">Stop scanning</property>
<property name="tooltip_text" translatable="yes">Stop scanning</property>
<property name="use_action_appearance">False</property>
- <property name="stock_id">gtk-stop</property>
<property name="action_name">win.stop</property>
+ <property name="stock_id">gtk-stop</property>
</object>
<packing>
<property name="expand">False</property>
@@ -129,8 +129,8 @@
<property name="tooltip_markup" translatable="yes">Reload</property>
<property name="tooltip_text" translatable="yes">Reload</property>
<property name="use_action_appearance">False</property>
- <property name="stock_id">gtk-refresh</property>
<property name="action_name">win.reload</property>
+ <property name="stock_id">gtk-refresh</property>
</object>
<packing>
<property name="expand">False</property>
@@ -146,46 +146,6 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">6</property>
- <property name="margin_right">25</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="hexpand">True</property>
- <property name="xalign">0.0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBoxText" id="chart-type-combo">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">25</property>
- <property name="margin_right">6</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="active">0</property>
- <property name="id_column">1</property>
- <items>
- <item id="rings" translatable="yes">View as Rings Chart</item>
- <item id="treemap" translatable="yes">View as Treemap Chart</item>
- </items>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
<object class="GtkPaned" id="hpaned">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -289,20 +249,96 @@
</packing>
</child>
<child>
- <object class="GtkNotebook" id="chart-notebook">
+ <object class="GtkGrid" id="chart-grid">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="show_tabs">False</property>
- <property name="show_border">False</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<child>
- <object class="BaobabRingschart" id="rings-chart">
+ <object class="GtkNotebook" id="chart-notebook">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="show_tabs">False</property>
+ <property name="show_border">False</property>
+ <child>
+ <object class="BaobabRingschart" id="rings-chart">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="BaobabTreemap" id="treemap-chart">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
<child>
- <object class="BaobabTreemap" id="treemap-chart">
+ <object class="GtkButtonBox" id="chart-buttonbox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_right">20</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="homogeneous">True</property>
+ <property name="layout_style">end</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkToggleButton" id="rings-button">
+ <property name="label" translatable="yes">Rings</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0.5</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="action_name">win.active-chart</property>
+ <property name="action_target">'rings'</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToggleButton" id="treemap-button">
+ <property name="label" translatable="yes">Treemap</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0.5</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="action_name">win.active-chart</property>
+ <property name="action_target">'treemap'</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
</object>
<packing>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index 9fdbc4f..11bc6df 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -1,14 +1,20 @@
namespace Baobab {
public class Window : Gtk.ApplicationWindow {
+ Settings ui_settings;
Gtk.TreeView treeview;
- Gtk.Widget chart_type_combo;
+ Gtk.Notebook chart_notebook;
Chart rings_chart;
Chart treemap_chart;
Scanner? scanner;
static Gdk.Cursor busy_cursor;
+ void radio_activate (SimpleAction action, Variant? parameter) {
+ action.change_state (parameter);
+ }
+
private const GLib.ActionEntry[] action_entries = {
+ { "active-chart", radio_activate, "s", "'rings'", on_chart_type_changed },
{ "scan-home", on_scan_home_activate },
{ "scan-filesystem", on_scan_filesystem_activate },
{ "scan-folder", on_scan_folder_activate },
@@ -64,17 +70,13 @@ namespace Baobab {
}
// Cache some objects from the builder.
- chart_type_combo = builder.get_object ("chart-type-combo") as Gtk.Widget;
+ 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;
- var ui_settings = Application.get_ui_settings ();
-
- // Setup the logic for switching between the chart types.
- var charts_notebook = builder.get_object ("chart-notebook");
- chart_type_combo.bind_property ("active", charts_notebook, "page", BindingFlags.SYNC_CREATE);
- ui_settings.bind ("active-chart", chart_type_combo, "active-id", SettingsBindFlags.GET_NO_CHANGES);
+ ui_settings = Application.get_ui_settings ();
+ lookup_action ("active-chart").change_state (ui_settings.get_value ("active-chart"));
// Setup drag-n-drop
drag_data_received.connect(on_drag_data_received);
@@ -89,6 +91,22 @@ namespace Baobab {
show ();
}
+ void on_chart_type_changed (SimpleAction action, Variant value) {
+ switch (value as string) {
+ case "rings":
+ chart_notebook.page = 0;
+ break;
+ case "treemap":
+ chart_notebook.page = 1;
+ break;
+ default:
+ return;
+ }
+
+ ui_settings.set_value ("active-chart", value);
+ action.set_state (value);
+ }
+
void on_scan_home_activate () {
var dir = File.new_for_path (GLib.Environment.get_home_dir ());
scan_directory (dir);
@@ -228,12 +246,12 @@ namespace Baobab {
disable_drop ();
rings_chart.freeze_updates();
treemap_chart.freeze_updates ();
- chart_type_combo.set_sensitive (false);
+ (lookup_action ("active-chart") as SimpleAction).set_enabled (false);
} else {
enable_drop ();
rings_chart.thaw_updates();
treemap_chart.thaw_updates ();
- chart_type_combo.set_sensitive (true);
+ (lookup_action ("active-chart") as SimpleAction).set_enabled (true);
}
var window = get_window ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]