[gnome-utils] Persist the currently selected chart type
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-utils] Persist the currently selected chart type
- Date: Sat, 9 Oct 2010 13:26:21 +0000 (UTC)
commit f25c7e2f44abda9ed71b4dd774f5dbb715bd7c0b
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Sep 27 21:14:32 2010 +0200
Persist the currently selected chart type
baobab/data/baobab.schemas.in | 14 ++++++-
baobab/src/baobab.c | 97 +++++++++++++++++++++++++++++++---------
baobab/src/baobab.h | 2 +
baobab/src/callbacks.c | 33 --------------
baobab/src/callbacks.h | 1 -
5 files changed, 90 insertions(+), 57 deletions(-)
---
diff --git a/baobab/data/baobab.schemas.in b/baobab/data/baobab.schemas.in
index 34a4250..3ce4f66 100644
--- a/baobab/data/baobab.schemas.in
+++ b/baobab/data/baobab.schemas.in
@@ -64,7 +64,19 @@
are drawn.</long>
</locale>
</schema>
-
+
+ <schema>
+ <key>/schemas/apps/baobab/ui/active_chart</key>
+ <applyto>/apps/baobab/ui/active_chart</applyto>
+ <owner>baobab</owner>
+ <type>string</type>
+ <default>rings</default>
+ <locale name="C">
+ <short>Chart currently active</short>
+ <long>Which type of chart should be displayed.</long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
diff --git a/baobab/src/baobab.c b/baobab/src/baobab.c
index 6048efe..184847a 100644
--- a/baobab/src/baobab.c
+++ b/baobab/src/baobab.c
@@ -1094,19 +1094,69 @@ drag_data_received_handl (GtkWidget *widget,
}
static void
+set_active_chart (GtkWidget *chart)
+{
+ if (baobab.current_chart != chart) {
+ if (baobab.current_chart) {
+ baobab_chart_freeze_updates (baobab.current_chart);
+
+ g_object_ref (baobab.current_chart);
+ gtk_container_remove (GTK_CONTAINER (baobab.chart_frame),
+ baobab.current_chart);
+ }
+
+ gtk_container_add (GTK_CONTAINER (baobab.chart_frame), chart);
+ g_object_unref (chart);
+
+ baobab_chart_thaw_updates (chart);
+
+ baobab.current_chart = chart;
+
+ gtk_widget_show_all (baobab.chart_frame);
+
+ gconf_client_set_string (baobab.gconf_client,
+ BAOBAB_ACTIVE_CHART_KEY,
+ baobab.current_chart == baobab.rings_chart ? "rings" : "treemap",
+ NULL);
+ }
+}
+
+static void
+on_chart_type_change (GtkWidget *combo, gpointer user_data)
+{
+ GtkWidget *chart;
+ guint active;
+
+ active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+
+ switch (active) {
+ case 0:
+ chart = baobab.rings_chart;
+ break;
+ case 1:
+ chart = baobab.treemap_chart;
+ break;
+ default:
+ g_return_if_reached ();
+ }
+
+ set_active_chart (chart);
+}
+
+static void
initialize_charts (void)
{
GtkWidget *hpaned_main;
- GtkWidget *chart_frame;
GtkWidget *hbox1;
+ char *saved_chart;
- chart_frame = gtk_frame_new (NULL);
- gtk_frame_set_label_align (GTK_FRAME (chart_frame), 0.0, 0.0);
- gtk_frame_set_shadow_type (GTK_FRAME (chart_frame), GTK_SHADOW_IN);
+ baobab.chart_frame = gtk_frame_new (NULL);
+ gtk_frame_set_label_align (GTK_FRAME (baobab.chart_frame), 0.0, 0.0);
+ gtk_frame_set_shadow_type (GTK_FRAME (baobab.chart_frame), GTK_SHADOW_IN);
hpaned_main = GTK_WIDGET (gtk_builder_get_object (baobab.main_ui, "hpaned_main"));
gtk_paned_pack2 (GTK_PANED (hpaned_main),
- chart_frame, TRUE, TRUE);
+ baobab.chart_frame, TRUE, TRUE);
gtk_paned_set_position (GTK_PANED (hpaned_main), 480);
baobab.chart_type_combo = gtk_combo_box_new_text ();
@@ -1114,7 +1164,6 @@ initialize_charts (void)
_("View as Rings Chart"));
gtk_combo_box_append_text (GTK_COMBO_BOX (baobab.chart_type_combo),
_("View as Treemap Chart"));
- gtk_combo_box_set_active (GTK_COMBO_BOX (baobab.chart_type_combo), 0);
gtk_widget_show (baobab.chart_type_combo);
g_signal_connect (baobab.chart_type_combo,
"changed",
@@ -1143,13 +1192,14 @@ initialize_charts (void)
NULL);
baobab_chart_set_max_depth (baobab.treemap_chart, 1);
g_signal_connect (baobab.treemap_chart, "item_activated",
- G_CALLBACK (on_chart_item_activated), NULL);
+ G_CALLBACK (on_chart_item_activated), NULL);
g_signal_connect (baobab.treemap_chart, "button-release-event",
- G_CALLBACK (on_chart_button_release), NULL);
+ G_CALLBACK (on_chart_button_release), NULL);
g_signal_connect (baobab.treemap_chart, "drag-data-received",
- G_CALLBACK (drag_data_received_handl), NULL);
+ G_CALLBACK (drag_data_received_handl), NULL);
gtk_widget_show (baobab.treemap_chart);
- /* Ends Baobab's Treemap Chart */
+ g_object_ref_sink (baobab.treemap_chart);
+ baobab_chart_freeze_updates (baobab.treemap_chart);
/* Baobab's Rings Chart */
baobab.rings_chart = (GtkWidget *) baobab_ringschart_new ();
@@ -1167,22 +1217,26 @@ initialize_charts (void)
NULL));
baobab_chart_set_max_depth (baobab.rings_chart, 1);
g_signal_connect (baobab.rings_chart, "item_activated",
- G_CALLBACK (on_chart_item_activated), NULL);
+ G_CALLBACK (on_chart_item_activated), NULL);
g_signal_connect (baobab.rings_chart, "button-release-event",
- G_CALLBACK (on_chart_button_release), NULL);
+ G_CALLBACK (on_chart_button_release), NULL);
g_signal_connect (baobab.rings_chart, "drag-data-received",
- G_CALLBACK (drag_data_received_handl), NULL);
+ G_CALLBACK (drag_data_received_handl), NULL);
gtk_widget_show (baobab.rings_chart);
- /* Ends Baobab's Treemap Chart */
-
- baobab.current_chart = baobab.rings_chart;
+ g_object_ref_sink (baobab.rings_chart);
+ baobab_chart_freeze_updates (baobab.rings_chart);
- g_object_ref_sink (baobab.treemap_chart);
- baobab_chart_freeze_updates (baobab.treemap_chart);
+ saved_chart = baobab_gconf_get_string_with_default (baobab.gconf_client,
+ BAOBAB_ACTIVE_CHART_KEY,
+ "rings");
- gtk_container_add (GTK_CONTAINER (chart_frame),
- baobab.current_chart);
- gtk_widget_show_all (chart_frame);
+ if (0 == g_ascii_strcasecmp (saved_chart, "treemap")) {
+ set_active_chart (baobab.treemap_chart);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (baobab.chart_type_combo), 1);
+ } else {
+ set_active_chart (baobab.rings_chart);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (baobab.chart_type_combo), 0);
+ }
check_drop_targets (FALSE);
}
@@ -1288,7 +1342,6 @@ main (int argc, char *argv[])
first_row ();
baobab_set_statusbar (_("Ready"));
- /* The ringschart */
initialize_charts ();
/* commandline */
diff --git a/baobab/src/baobab.h b/baobab/src/baobab.h
index 421250a..63b6b73 100644
--- a/baobab/src/baobab.h
+++ b/baobab/src/baobab.h
@@ -41,6 +41,7 @@ struct BaobabSearchOpt;
#define BAOBAB_TOOLBAR_VISIBLE_KEY BAOBAB_KEY_DIR "/ui/toolbar_visible"
#define BAOBAB_STATUSBAR_VISIBLE_KEY BAOBAB_KEY_DIR "/ui/statusbar_visible"
#define BAOBAB_SUBFLSTIPS_VISIBLE_KEY BAOBAB_KEY_DIR "/ui/baobab_subfoldertips_visible"
+#define BAOBAB_ACTIVE_CHART_KEY BAOBAB_KEY_DIR "/ui/active_chart"
#define BAOBAB_EXCLUDED_DIRS_KEY BAOBAB_KEY_DIR "/properties/skip_scan_uri_list"
#define BAOBAB_ENABLE_HOME_MONITOR_KEY BAOBAB_KEY_DIR "/properties/enable_home_monitor"
#define SYSTEM_TOOLBAR_STYLE_KEY "/desktop/gnome/interface/toolbar_style"
@@ -73,6 +74,7 @@ struct _BaobabApplication {
GtkBuilder *main_ui;
GtkWidget *window;
GtkWidget *tree_view;
+ GtkWidget *chart_frame;
GtkWidget *rings_chart;
GtkWidget *treemap_chart;
GtkWidget *current_chart;
diff --git a/baobab/src/callbacks.c b/baobab/src/callbacks.c
index ae27631..f9a1629 100644
--- a/baobab/src/callbacks.c
+++ b/baobab/src/callbacks.c
@@ -366,36 +366,3 @@ on_chart_snapshot_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data)
baobab_chart_save_snapshot (baobab.current_chart);
}
-void
-on_chart_type_change (GtkWidget *combo, gpointer user_data)
-{
- GtkWidget *chart;
- GtkWidget *frame;
-
- guint active;
-
- active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
-
- switch (active) {
- case 0:
- chart = baobab.rings_chart;
- break;
- case 1:
- chart = baobab.treemap_chart;
- break;
- default:
- g_return_if_reached ();
- }
-
- frame = gtk_widget_get_parent (baobab.current_chart);
-
- baobab_chart_freeze_updates (baobab.current_chart);
- baobab_chart_thaw_updates (chart);
-
- g_object_ref_sink (baobab.current_chart);
- gtk_container_remove (GTK_CONTAINER (frame), baobab.current_chart);
- gtk_container_add (GTK_CONTAINER (frame), chart);
-
- baobab.current_chart = chart;
-}
-
diff --git a/baobab/src/callbacks.h b/baobab/src/callbacks.h
index 93e70fb..8c1e4ae 100644
--- a/baobab/src/callbacks.h
+++ b/baobab/src/callbacks.h
@@ -57,6 +57,5 @@ void on_move_upwards_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
void on_zoom_in_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
void on_zoom_out_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
void on_chart_snapshot_cb (GtkCheckMenuItem *checkmenuitem, gpointer user_data);
-void on_chart_type_change (GtkWidget *combo, gpointer user_data);
#endif /* __BAOBAB_CALLBACKS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]