From 9990b0c4c279bd1320d4c1efb3d92077727c0f8b Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Sat, 17 Nov 2012 19:47:39 -0500 Subject: Fix subfolder tooltips preference in disk-usage-analyzer --- baobab/src/baobab-ringschart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'baobab') diff --git a/baobab/src/baobab-ringschart.c b/baobab/src/baobab-ringschart.c index 4e51c01e..5418561c 100644 --- a/baobab/src/baobab-ringschart.c +++ b/baobab/src/baobab-ringschart.c @@ -623,7 +623,7 @@ baobab_ringschart_post_draw (GtkWidget *chart, cairo_t *cr) priv = BAOBAB_RINGSCHART_GET_PRIVATE (chart); - if (priv->drawing_subtips) + if (priv->subfoldertips_enabled) { /* Reverse the glist, which was created from the tail */ priv->subtip_items = g_list_reverse (priv->subtip_items); -- cgit v1.2.1 From 233037a709c7843cc63e49b90da961da04bed545 Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Sat, 17 Nov 2012 20:09:06 -0500 Subject: Don't set the toolbar type in the ui file so user's choice will be applied automatically (no need to load the preference from MateConf) --- baobab/data/baobab-main-window.ui | 1 - 1 file changed, 1 deletion(-) (limited to 'baobab') diff --git a/baobab/data/baobab-main-window.ui b/baobab/data/baobab-main-window.ui index 55f6215c..85298f4a 100644 --- a/baobab/data/baobab-main-window.ui +++ b/baobab/data/baobab-main-window.ui @@ -220,7 +220,6 @@ True GTK_ORIENTATION_HORIZONTAL - GTK_TOOLBAR_ICONS True False -- cgit v1.2.1 From 507090e64e66315d6dad960791489a477dced017 Mon Sep 17 00:00:00 2001 From: Brent Hull Date: Sat, 17 Nov 2012 22:13:08 -0500 Subject: Port disk-usage-analyzer to Gsettings (based on GNOME patch) --- baobab/README | 12 +- baobab/data/Makefile.am | 19 +- baobab/data/baobab-main-window.ui | 14 +- baobab/data/baobab.schemas.in | 70 ---- .../org.mate.disk-usage-analyzer.gschema.xml.in | 40 +++ baobab/src/Makefile.am | 8 +- baobab/src/baobab-prefs.c | 69 ++-- baobab/src/baobab-utils.c | 11 - baobab/src/baobab-utils.h | 1 - baobab/src/baobab.c | 366 +++++++++++---------- baobab/src/baobab.h | 26 +- baobab/src/callbacks.c | 82 +---- baobab/src/callbacks.h | 5 +- 13 files changed, 303 insertions(+), 420 deletions(-) delete mode 100644 baobab/data/baobab.schemas.in create mode 100644 baobab/data/org.mate.disk-usage-analyzer.gschema.xml.in (limited to 'baobab') diff --git a/baobab/README b/baobab/README index 9a148fa1..af16077d 100644 --- a/baobab/README +++ b/baobab/README @@ -24,21 +24,21 @@ Copyright What is Baobab ============== - Baobab is able to scan either specific directories or the whole + Baobab is able to scan either specific directories or the whole filesystem, in order to give the user a graphical tree representation including each directory size or percentage in the branch. - It also auto-detects in real-time any change made to your home - folder as far as any mounted/unmounted device. + It also auto-detects in real-time any change made to your home + folder as far as any mounted/unmounted device. A detailed documentation of the program could be read at: - http://www.mate.org/projects/baobab. + http://www.gnome.org/projects/baobab. System Requirements =================== Baobab should build on most unices. It needs the X11R6 (or xorg) -libraries, glib, gtk 2.x, mate-vfs2, mateconf2 libraries. +libraries, glib, and gtk 2.x. Author @@ -49,7 +49,7 @@ you are having trouble installing and/or running Baobab, feel free to e-mail me. You can check on the current status of Baobab via www at: - http://www.mate.org/projects/baobab + http://www.gnome.org/projects/baobab Comments, ideas and (most of all) bug reports (and especially patches) are very welcome. diff --git a/baobab/data/Makefile.am b/baobab/data/Makefile.am index 66bbd2b9..02dda3b3 100644 --- a/baobab/data/Makefile.am +++ b/baobab/data/Makefile.am @@ -11,21 +11,14 @@ $(baobabapp_in_files): $(baobabapp_in_files:.desktop.in=.desktop.in.in) @INTLTOOL_DESKTOP_RULE@ -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = baobab.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) -@INTLTOOL_SCHEMAS_RULE@ +gsettingsschema_in_files = org.mate.disk-usage-analyzer.gschema.xml.in +gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml) -man_MANS = mate-disk-usage-analyzer.1 +@INTLTOOL_XML_NOMERGE_RULE@ + +@GSETTINGS_RULES@ -if MATECONF_SCHEMAS_INSTALL -install-data-local: - if test -z "$(DESTDIR)" ; then \ - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(schemas_DATA) ; \ - fi -else -install-data-local: -endif +man_MANS = mate-disk-usage-analyzer.1 EXTRA_DIST = \ $(ui_DATA) \ diff --git a/baobab/data/baobab-main-window.ui b/baobab/data/baobab-main-window.ui index 85298f4a..e544c430 100644 --- a/baobab/data/baobab-main-window.ui +++ b/baobab/data/baobab-main-window.ui @@ -62,10 +62,10 @@ - + gtk-quit - esci1 - + menuquit + @@ -106,7 +106,6 @@ True view_tb _Toolbar - @@ -114,7 +113,6 @@ True view_sb St_atusbar - @@ -160,7 +158,7 @@ - + @@ -197,7 +195,6 @@ GDK_GRAVITY_NORTH_WEST True False - @@ -233,8 +230,7 @@ True True - - + diff --git a/baobab/data/baobab.schemas.in b/baobab/data/baobab.schemas.in deleted file mode 100644 index 10196119..00000000 --- a/baobab/data/baobab.schemas.in +++ /dev/null @@ -1,70 +0,0 @@ - - - - /schemas/apps/baobab/ui/toolbar_visible - /apps/baobab/ui/toolbar_visible - baobab - bool - TRUE - - Toolbar is Visible - Whether the toolbar should be visible in main window. - - - - - /schemas/apps/baobab/ui/statusbar_visible - /apps/baobab/ui/statusbar_visible - baobab - bool - FALSE - - Status Bar is Visible - Whether the status bar at the bottom of main window - should be visible. - - - - - /schemas/apps/baobab/properties/enable_home_monitor - /apps/baobab/properties/enable_home_monitor - baobab - bool - FALSE - - Enable monitoring of home directory - Whether any change to the home directory should - be monitored. - - - - - - /schemas/apps/baobab/properties/skip_scan_uri_list - /apps/baobab/properties/skip_scan_uri_list - baobab - list - string - [] - - Excluded partitions URIs - A list of URIs for partitions to be excluded from scanning. - - - - - /schemas/apps/baobab/ui/baobab_subfoldertips_visible - /apps/baobab/ui/baobab_subfoldertips_visible - baobab - bool - TRUE - - Subfolders tooltips visible - Whether the subfolder tooltips of the selected folder - are drawn. - - - - - - diff --git a/baobab/data/org.mate.disk-usage-analyzer.gschema.xml.in b/baobab/data/org.mate.disk-usage-analyzer.gschema.xml.in new file mode 100644 index 00000000..26801491 --- /dev/null +++ b/baobab/data/org.mate.disk-usage-analyzer.gschema.xml.in @@ -0,0 +1,40 @@ + + + + + + + + false + <_summary>Monitor Home + <_description>Whether any change to the home directory should be monitored. + + + [] + <_summary>Excluded partitions URIs + <_description>A list of URIs for partitions to be excluded from scanning. + + + + + true + <_summary>Toolbar is Visible + <_description>Whether the toolbar should be visible in main window. + + + false + <_summary>Statusbar is Visible + <_description>Whether the status bar at the bottom of main window should be visible. + + + true + <_summary>Subfolder tips visible + <_description>Whether the subfolder tooltips of the selected folder are drawn. + + + 'rings' + <_summary>Active Chart + <_description>Which type of chart should be displayed. + + + diff --git a/baobab/src/Makefile.am b/baobab/src/Makefile.am index 224ca126..0361a9a2 100644 --- a/baobab/src/Makefile.am +++ b/baobab/src/Makefile.am @@ -37,13 +37,17 @@ mate_disk_usage_analyzer_SOURCES = \ baobab-treemap.h mate_disk_usage_analyzer_CFLAGS = \ - $(MATE_UTILS_CFLAGS) \ + $(GLIB_CFLAGS) \ + $(GIO_CFLAGS) \ + $(GTK_CFLAGS) \ $(LIBGTOP_CFLAGS) \ $(NULL) mate_disk_usage_analyzer_LDFLAGS = -export-dynamic mate_disk_usage_analyzer_LDADD = \ -lm \ - $(MATE_UTILS_LIBS) \ + $(GLIB_LIBS) \ + $(GIO_LIBS) \ + $(GTK_LIBS) \ $(LIBGTOP_LIBS) \ $(NULL) diff --git a/baobab/src/baobab-prefs.c b/baobab/src/baobab-prefs.c index 48a75b9c..33af5159 100644 --- a/baobab/src/baobab-prefs.c +++ b/baobab/src/baobab-prefs.c @@ -28,13 +28,14 @@ #include #include #include -#include #include #include #include "baobab.h" #include "baobab-utils.h" #include "baobab-prefs.h" +#define BAOBAB_PREFERENCES_UI_FILE PKGDATADIR "/baobab-dialog-scan-props.ui" + enum { COL_CHECK, @@ -51,14 +52,11 @@ static gboolean add_excluded_item (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, - GSList **list) + GPtrArray *uris) { - GSList *l; gchar *mount; gboolean check; - l = *list; - gtk_tree_model_get (model, iter, COL_MOUNT, &mount, @@ -66,53 +64,43 @@ add_excluded_item (GtkTreeModel *model, -1); if (!check) { - l = g_slist_prepend (l, mount); + g_ptr_array_add (uris, mount); + } + else { + g_free (mount); } - - *list = l; return FALSE; } -static GSList * +static gchar ** get_excluded_locations (GtkTreeModel *model) { - GSList *l = NULL; + GPtrArray *uris; + + uris = g_ptr_array_new (); gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) add_excluded_item, - &l); - - return g_slist_reverse (l); -} - -static void -save_mateconf (GtkTreeModel *model) -{ - GSList *l; - - l = get_excluded_locations (model); + uris); - mateconf_client_set_list (baobab.mateconf_client, - BAOBAB_EXCLUDED_DIRS_KEY, MATECONF_VALUE_STRING, - l, NULL); + g_ptr_array_add (uris, NULL); - g_slist_foreach (l, (GFunc) g_free, NULL); - g_slist_free (l); + return (gchar **) g_ptr_array_free (uris, FALSE); } static void -enable_home_cb (GtkToggleButton *togglebutton, gpointer user_data) +save_excluded_uris (GtkTreeModel *model) { - gboolean enable; + gchar **uris; - enable = gtk_toggle_button_get_active (togglebutton); + uris = get_excluded_locations (model); - mateconf_client_set_bool (baobab.mateconf_client, - BAOBAB_ENABLE_HOME_MONITOR_KEY, - enable, - NULL); + g_settings_set_strv (baobab.prefs_settings, + BAOBAB_SETTINGS_EXCLUDED_URIS, + (const gchar * const *) uris); + g_strfreev (uris); } static void @@ -127,7 +115,7 @@ filechooser_response_cb (GtkDialog *dialog, break; case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_CLOSE: - save_mateconf (model); + save_excluded_uris (model); default: gtk_widget_destroy (GTK_WIDGET (dialog)); break; @@ -301,7 +289,9 @@ baobab_prefs_dialog (void) GError *error = NULL; builder = gtk_builder_new (); - gtk_builder_add_from_file (builder, BAOBAB_DIALOG_SCAN_UI_FILE, &error); + gtk_builder_add_from_file (builder, + BAOBAB_PREFERENCES_UI_FILE, + &error); if (error) { g_critical ("Can't load user interface file for the scan properties dialog: %s", @@ -331,11 +321,10 @@ baobab_prefs_dialog (void) fill_props_model (model); check_enablehome = GTK_WIDGET (gtk_builder_get_object (builder, "check_enable_home")); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_enablehome), - baobab.monitor_home != NULL); - - g_signal_connect (check_enablehome, "toggled", - G_CALLBACK (enable_home_cb), NULL); + g_settings_bind (baobab.prefs_settings, + BAOBAB_SETTINGS_MONITOR_HOME, + check_enablehome, "active", + G_SETTINGS_BIND_DEFAULT); g_signal_connect (dlg, "response", G_CALLBACK (filechooser_response_cb), model); diff --git a/baobab/src/baobab-utils.c b/baobab/src/baobab-utils.c index 5b3a0b46..3d2efe6d 100644 --- a/baobab/src/baobab-utils.c +++ b/baobab/src/baobab-utils.c @@ -505,17 +505,6 @@ trash_file (GFile *file) return TRUE; } -gchar * -baobab_mateconf_get_string_with_default (MateConfClient *client, - const gchar *key, - const gchar *def) -{ - gchar *val; - - val = mateconf_client_get_string (client, key, NULL); - return val ? val : g_strdup (def); -} - gboolean baobab_help_display (GtkWindow *parent, const gchar *file_name, diff --git a/baobab/src/baobab-utils.h b/baobab/src/baobab-utils.h index 37330240..27428313 100644 --- a/baobab/src/baobab-utils.h +++ b/baobab/src/baobab-utils.h @@ -42,7 +42,6 @@ gboolean can_trash_file (GFile *file); gboolean trash_file (GFile *file); void set_ui_action_sens (const gchar *name, gboolean sens); void set_ui_widget_sens (const gchar *name, gboolean sens); -gchar *baobab_mateconf_get_string_with_default (MateConfClient *client, const gchar *key, const gchar *def); gboolean baobab_help_display (GtkWindow *parent, const gchar *file_name, const gchar *link_id); gboolean is_virtual_filesystem (GFile *file); diff --git a/baobab/src/baobab.c b/baobab/src/baobab.c index 433628b4..02f3a480 100644 --- a/baobab/src/baobab.c +++ b/baobab/src/baobab.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "baobab.h" @@ -38,6 +37,8 @@ #include "baobab-treemap.h" #include "baobab-ringschart.h" +#define BAOBAB_UI_FILE PKGDATADIR "/baobab-main-window.ui" + static void push_iter_in_stack (GtkTreeIter *); static GtkTreeIter pop_iter_from_stack (void); @@ -629,36 +630,6 @@ monitor_home (gboolean enable) } } -void -baobab_set_toolbar_visible (gboolean visible) -{ - GtkToggleAction *action; - - if (visible) - gtk_widget_show (baobab.toolbar); - else - gtk_widget_hide (baobab.toolbar); - - /* make sure the check menu item is consistent */ - action = GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_tb")); - gtk_toggle_action_set_active (action, visible); -} - -void -baobab_set_statusbar_visible (gboolean visible) -{ - GtkToggleAction *action; - - if (visible) - gtk_widget_show (baobab.statusbar); - else - gtk_widget_hide (baobab.statusbar); - - /* make sure the check menu item is consistent */ - action = GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_sb")); - gtk_toggle_action_set_active (action, visible); -} - void baobab_set_statusbar (const gchar *text) { @@ -690,38 +661,6 @@ toolbar_reconfigured_cb (GtkToolItem *item, gtk_widget_set_size_request (spinner, size, size); } -static void -baobab_toolbar_style (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) -{ - gchar *toolbar_setting; - - toolbar_setting = baobab_mateconf_get_string_with_default (baobab.mateconf_client, - SYSTEM_TOOLBAR_STYLE_KEY, - "both"); - - if (!strcmp(toolbar_setting, "icons")) { - gtk_toolbar_set_style (GTK_TOOLBAR(baobab.toolbar), - GTK_TOOLBAR_ICONS); - } - else if (!strcmp(toolbar_setting, "both")) { - gtk_toolbar_set_style (GTK_TOOLBAR(baobab.toolbar), - GTK_TOOLBAR_BOTH); - } - else if (!strcmp(toolbar_setting, "both-horiz")) { - gtk_toolbar_set_style (GTK_TOOLBAR(baobab.toolbar), - GTK_TOOLBAR_BOTH_HORIZ); - } - else if (!strcmp(toolbar_setting, "text")) { - gtk_toolbar_set_style (GTK_TOOLBAR(baobab.toolbar), - GTK_TOOLBAR_TEXT); - } - - g_free (toolbar_setting); -} - static void baobab_create_toolbar (void) { @@ -754,13 +693,15 @@ baobab_create_toolbar (void) G_CALLBACK (toolbar_reconfigured_cb), baobab.spinner); toolbar_reconfigured_cb (item, baobab.spinner); - baobab_toolbar_style (NULL, 0, NULL, NULL); - - visible = mateconf_client_get_bool (baobab.mateconf_client, - BAOBAB_TOOLBAR_VISIBLE_KEY, - NULL); + g_settings_bind (baobab.ui_settings, + BAOBAB_SETTINGS_TOOLBAR_VISIBLE, + baobab.toolbar, "visible", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind (baobab.ui_settings, + BAOBAB_SETTINGS_TOOLBAR_VISIBLE, + GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_tb")), "active", + G_SETTINGS_BIND_DEFAULT); - baobab_set_toolbar_visible (visible); } static void @@ -775,36 +716,37 @@ baobab_create_statusbar (void) return; } - visible = mateconf_client_get_bool (baobab.mateconf_client, - BAOBAB_STATUSBAR_VISIBLE_KEY, - NULL); - - baobab_set_statusbar_visible (visible); + g_settings_bind (baobab.ui_settings, + BAOBAB_SETTINGS_STATUSBAR_VISIBLE, + baobab.statusbar, "visible", + G_SETTINGS_BIND_DEFAULT); + g_settings_bind (baobab.ui_settings, + BAOBAB_SETTINGS_STATUSBAR_VISIBLE, + GTK_TOGGLE_ACTION (gtk_builder_get_object (baobab.main_ui, "view_sb")), "active", + G_SETTINGS_BIND_DEFAULT); } -static void -baobab_subfolderstips_toggled (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +baobab_settings_subfoldertips_changed (GSettings *settings, + const gchar *key, + gpointer user_data) { - baobab_ringschart_set_subfoldertips_enabled (baobab.rings_chart, - mateconf_client_get_bool (baobab.mateconf_client, - BAOBAB_SUBFLSTIPS_VISIBLE_KEY, - NULL)); + gboolean visible; + + visible = g_settings_get_boolean (settings, key); + baobab_ringschart_set_subfoldertips_enabled (baobab.rings_chart, visible); } static void -baobab_set_excluded_locations (GSList *excluded_uris) +baobab_set_excluded_locations (gchar **uris) { - GSList *l; + gint i; g_slist_foreach (baobab.excluded_locations, (GFunc) g_object_unref, NULL); g_slist_free (baobab.excluded_locations); baobab.excluded_locations = NULL; - for (l = excluded_uris; l != NULL; l = l->next) { + for (i = 0; uris[i] != NULL; ++i) { baobab.excluded_locations = g_slist_prepend (baobab.excluded_locations, - g_file_new_for_uri (l->data)); + g_file_new_for_uri (uris[i])); } } @@ -812,22 +754,22 @@ static void store_excluded_locations (void) { GSList *l; + GPtrArray *uris; GSList *uri_list = NULL; - for (l = baobab.excluded_locations; l != NULL; l = l->next) { - GSList *uri_list = NULL; + uris = g_ptr_array_new (); - uri_list = g_slist_prepend (uri_list, g_file_get_uri(l->data)); + for (l = baobab.excluded_locations; l != NULL; l = l->next) { + g_ptr_array_add (uris, g_file_get_uri (l->data)); } - mateconf_client_set_list (baobab.mateconf_client, - BAOBAB_EXCLUDED_DIRS_KEY, - MATECONF_VALUE_STRING, - uri_list, - NULL); + g_ptr_array_add (uris, NULL); + + g_settings_set_strv (baobab.prefs_settings, + BAOBAB_SETTINGS_EXCLUDED_URIS, + (const gchar *const *) uris->pdata); - g_slist_foreach (uri_list, (GFunc) g_free, NULL); - g_slist_free (uri_list); + g_ptr_array_free (uris, TRUE); } static void @@ -836,7 +778,7 @@ sanity_check_excluded_locations (void) GFile *root; GSList *l; - /* Verify if mateconf wrongly contains root dir exclusion, and remove it from mateconf. */ + /* Make sure the root dir is not excluded */ root = g_file_new_for_uri ("file:///"); for (l = baobab.excluded_locations; l != NULL; l = l->next) { @@ -851,20 +793,15 @@ sanity_check_excluded_locations (void) } static void -excluded_locations_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +excluded_uris_changed (GSettings *settings, + const gchar *key, + gpointer user_data) { - GSList *uris; + gchar **uris; - uris = mateconf_client_get_list (client, - BAOBAB_EXCLUDED_DIRS_KEY, - MATECONF_VALUE_STRING, - NULL); + uris = g_settings_get_strv (settings, key); baobab_set_excluded_locations (uris); - g_slist_foreach (uris, (GFunc) g_free, NULL); - g_slist_free (uris); + g_strfreev (uris); baobab_update_filesystem (); @@ -873,16 +810,49 @@ excluded_locations_changed (MateConfClient *client, } static void -baobab_monitor_home_toggled (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, - gpointer user_data) +baobab_setup_excluded_locations (void) +{ + gchar **uris; + + uris = g_settings_get_strv (baobab.prefs_settings, + BAOBAB_SETTINGS_EXCLUDED_URIS); + baobab_set_excluded_locations (uris); + g_strfreev (uris); + + sanity_check_excluded_locations (); + + g_signal_connect (baobab.prefs_settings, + "changed::" BAOBAB_SETTINGS_EXCLUDED_URIS, + G_CALLBACK (excluded_uris_changed), + NULL); +} + +static void +baobab_settings_monitor_home_changed (GSettings *settings, + const gchar *key, + gpointer user_data) { gboolean enable; - enable = mateconf_client_get_bool (baobab.mateconf_client, - BAOBAB_ENABLE_HOME_MONITOR_KEY, - NULL); + enable = g_settings_get_boolean (settings, key); + + monitor_home (enable); +} + +static void +baobab_setup_monitors (void) +{ + gboolean enable; + + monitor_volume (); + + enable = g_settings_get_boolean (baobab.prefs_settings, + BAOBAB_SETTINGS_MONITOR_HOME); + + g_signal_connect (baobab.prefs_settings, + "changed::" BAOBAB_SETTINGS_MONITOR_HOME, + G_CALLBACK (baobab_settings_monitor_home_changed), + NULL); monitor_home (enable); } @@ -890,9 +860,7 @@ baobab_monitor_home_toggled (MateConfClient *client, static void baobab_init (void) { - GSList *uri_list; GError *error = NULL; - gboolean enable; /* FileSystem usage */ baobab_get_filesystem (&baobab.fs); @@ -910,55 +878,33 @@ baobab_init (void) gtk_builder_connect_signals (baobab.main_ui, NULL); + /* Settings */ + baobab.ui_settings = g_settings_new (BAOBAB_UI_SETTINGS_SCHEMA); + baobab.prefs_settings = g_settings_new (BAOBAB_PREFS_SETTINGS_SCHEMA); + /* Misc */ baobab.CONTENTS_CHANGED_DELAYED = FALSE; baobab.STOP_SCANNING = TRUE; baobab.show_allocated = TRUE; baobab.is_local = TRUE; - /* MateConf */ - baobab.mateconf_client = mateconf_client_get_default (); - mateconf_client_add_dir (baobab.mateconf_client, BAOBAB_KEY_DIR, - MATECONF_CLIENT_PRELOAD_NONE, NULL); - mateconf_client_notify_add (baobab.mateconf_client, BAOBAB_EXCLUDED_DIRS_KEY, excluded_locations_changed, - NULL, NULL, NULL); - mateconf_client_notify_add (baobab.mateconf_client, SYSTEM_TOOLBAR_STYLE_KEY, baobab_toolbar_style, - NULL, NULL, NULL); - mateconf_client_notify_add (baobab.mateconf_client, BAOBAB_SUBFLSTIPS_VISIBLE_KEY, baobab_subfolderstips_toggled, - NULL, NULL, NULL); - mateconf_client_notify_add (baobab.mateconf_client, BAOBAB_ENABLE_HOME_MONITOR_KEY, baobab_monitor_home_toggled, - NULL, NULL, NULL); - - uri_list = mateconf_client_get_list (baobab.mateconf_client, - BAOBAB_EXCLUDED_DIRS_KEY, - MATECONF_VALUE_STRING, - NULL); - - baobab_set_excluded_locations (uri_list); - - g_slist_foreach (uri_list, (GFunc) g_free, NULL); - g_slist_free (uri_list); - - sanity_check_excluded_locations (); + baobab_setup_excluded_locations (); baobab_create_toolbar (); - baobab_create_statusbar (); - monitor_volume (); - - enable = mateconf_client_get_bool (baobab.mateconf_client, - BAOBAB_ENABLE_HOME_MONITOR_KEY, - NULL); + baobab_setup_monitors (); - monitor_home (enable); + g_signal_connect (baobab.ui_settings, "changed::" BAOBAB_SETTINGS_SUBFLSTIPS_VISIBLE, + (GCallback) baobab_settings_subfoldertips_changed, NULL); } static void baobab_shutdown (void) { - if (baobab.current_location) + if (baobab.current_location) { g_object_unref (baobab.current_location); + } if (baobab.monitor_vol) { g_object_unref (baobab.monitor_vol); @@ -974,8 +920,12 @@ baobab_shutdown (void) g_slist_foreach (baobab.excluded_locations, (GFunc) g_object_unref, NULL); g_slist_free (baobab.excluded_locations); - if (baobab.mateconf_client) { - g_object_unref (baobab.mateconf_client); + if (baobab.ui_settings) { + g_object_unref (baobab.ui_settings); + } + + if (baobab.prefs_settings) { + g_object_unref (baobab.prefs_settings); } } @@ -1120,20 +1070,70 @@ 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); + + g_settings_set_string (baobab.ui_settings, + BAOBAB_SETTINGS_ACTIVE_CHART, + baobab.current_chart == baobab.rings_chart ? "rings" : "treemap"); + } +} + +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; + gboolean visible; - 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 (); @@ -1141,7 +1141,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", @@ -1170,13 +1169,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 (); @@ -1188,32 +1188,43 @@ initialize_charts (void) COL_H_PERC, COL_H_ELEMENTS, NULL); - baobab_ringschart_set_subfoldertips_enabled (baobab.rings_chart, - mateconf_client_get_bool (baobab.mateconf_client, - BAOBAB_SUBFLSTIPS_VISIBLE_KEY, - NULL)); + + visible = g_settings_get_boolean (baobab.ui_settings, + BAOBAB_SETTINGS_SUBFLSTIPS_VISIBLE); + baobab_ringschart_set_subfoldertips_enabled (baobab.rings_chart, visible); + 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 */ + g_object_ref_sink (baobab.rings_chart); + baobab_chart_freeze_updates (baobab.rings_chart); - baobab.current_chart = baobab.rings_chart; - - g_object_ref_sink (baobab.treemap_chart); - baobab_chart_freeze_updates (baobab.treemap_chart); + saved_chart = g_settings_get_string (baobab.ui_settings, + BAOBAB_SETTINGS_ACTIVE_CHART); - 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); } +void +baobab_quit () +{ + baobab_stop_scan (); + gtk_main_quit (); +} + static gboolean start_proc_on_command_line (GFile *file) { @@ -1315,7 +1326,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 bab9b8bb..eb7c4a58 100644 --- a/baobab/src/baobab.h +++ b/baobab/src/baobab.h @@ -28,22 +28,18 @@ #include #include #include -#include -typedef struct _baobab_fs baobab_fs; struct BaobabSearchOpt; -#define BAOBAB_UI_FILE PKGDATADIR "/baobab-main-window.ui" -#define BAOBAB_DIALOG_SCAN_UI_FILE PKGDATADIR "/baobab-dialog-scan-props.ui" - /* Settings */ -#define BAOBAB_KEY_DIR "/apps/baobab" -#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_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/mate/interface/toolbar_style" +#define BAOBAB_UI_SETTINGS_SCHEMA "org.mate.disk-usage-analyzer.ui" +#define BAOBAB_PREFS_SETTINGS_SCHEMA "org.mate.disk-usage-analyzer.preferences" +#define BAOBAB_SETTINGS_TOOLBAR_VISIBLE "toolbar-visible" +#define BAOBAB_SETTINGS_STATUSBAR_VISIBLE "statusbar-visible" +#define BAOBAB_SETTINGS_SUBFLSTIPS_VISIBLE "subfoldertips-visible" +#define BAOBAB_SETTINGS_ACTIVE_CHART "active-chart" +#define BAOBAB_SETTINGS_MONITOR_HOME "monitor-home" +#define BAOBAB_SETTINGS_EXCLUDED_URIS "excluded-uris" typedef struct _BaobabChartMenu BaobabChartMenu; @@ -73,6 +69,7 @@ struct _BaobabApplication { GtkBuilder *main_ui; GtkWidget *window; GtkWidget *tree_view; + GtkWidget *chart_frame; GtkWidget *rings_chart; GtkWidget *treemap_chart; GtkWidget *current_chart; @@ -95,8 +92,10 @@ struct _BaobabApplication { GVolumeMonitor *monitor_vol; GFileMonitor *monitor_home; - MateConfClient *mateconf_client; gint model_max_depth; + + GSettings *ui_settings; + GSettings *prefs_settings; }; /* Application singleton */ @@ -124,5 +123,6 @@ gboolean baobab_is_excluded_location (GFile *); void baobab_set_toolbar_visible (gboolean visible); void baobab_set_statusbar_visible (gboolean visible); void baobab_set_statusbar (const gchar *); +void baobab_quit (void); #endif /* __BAOBAB_H_ */ diff --git a/baobab/src/callbacks.c b/baobab/src/callbacks.c index 3dc8ede4..72894222 100644 --- a/baobab/src/callbacks.c +++ b/baobab/src/callbacks.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "baobab.h" @@ -38,6 +37,12 @@ #include "baobab-remote-connect-dialog.h" #include "baobab-chart.h" +void +on_quit_activate (GtkMenuItem *menuitem, gpointer user_data) +{ + baobab_quit (); +} + void on_menuscanhome_activate (GtkMenuItem *menuitem, gpointer user_data) { @@ -57,15 +62,9 @@ on_menuscandir_activate (GtkMenuItem *menuitem, gpointer user_data) } void -on_esci1_activate (GtkObject *menuitem, gpointer user_data) -{ - baobab_stop_scan (); - gtk_main_quit (); -} - -void on_about_activate(GtkMenuItem* menuitem, gpointer user_data) +on_about_activate (GtkMenuItem *menuitem, gpointer user_data) { - const gchar* const authors[] = { + const gchar * const authors[] = { "Fabio Marzocca ", "Paolo Borelli ", "BenoƮt Dejean ", @@ -185,7 +184,7 @@ gboolean on_delete_activate (GtkWidget *widget, GdkEvent *event, gpointer user_data) { - on_esci1_activate (NULL, NULL); + baobab_quit (); return TRUE; } @@ -264,36 +263,6 @@ on_ck_allocated_activate (GtkToggleAction *action, baobab_set_statusbar (_("Ready")); } -void -on_view_tb_activate (GtkToggleAction *action, - gpointer user_data) -{ - gboolean visible; - - visible = gtk_toggle_action_get_active (action); - baobab_set_toolbar_visible (visible); - - mateconf_client_set_bool (baobab.mateconf_client, - BAOBAB_TOOLBAR_VISIBLE_KEY, - visible, - NULL); -} - -void -on_view_sb_activate (GtkToggleAction *action, - gpointer user_data) -{ - gboolean visible; - - visible = gtk_toggle_action_get_active (action); - baobab_set_statusbar_visible (visible); - - mateconf_client_set_bool (baobab.mateconf_client, - BAOBAB_STATUSBAR_VISIBLE_KEY, - visible, - NULL); -} - void on_helpcontents_activate (GtkAction *a, gpointer user_data) { @@ -359,36 +328,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 93e70fbc..0f517968 100644 --- a/baobab/src/callbacks.h +++ b/baobab/src/callbacks.h @@ -26,6 +26,7 @@ #include #include "baobab-chart.h" +void on_quit_activate (GtkMenuItem *menuitem, gpointer user_data); void on_about_activate (GtkMenuItem *menuitem, gpointer user_data); void on_menuscanhome_activate (GtkMenuItem *menuitem, gpointer user_data); void on_menuallfs_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -39,7 +40,6 @@ void on_tbstop_clicked (GtkToolButton *toolbutton, gpointer user_data); void on_tbrescan_clicked (GtkToolButton *toolbutton, gpointer user_data); void on_radio_allfs_clicked (GtkButton *button, gpointer user_data); void on_radio_dir_clicked (GtkButton *button, gpointer user_data); -void on_esci1_activate (GtkObject *object, gpointer user_data); gboolean on_delete_activate (GtkWidget *widget, GdkEvent *event, gpointer user_data); void open_file_cb (GtkMenuItem *pmenu, gpointer dummy); void scan_folder_cb (GtkMenuItem *pmenu, gpointer dummy); @@ -48,8 +48,6 @@ void list_all_cb (GtkMenuItem *pmenu, gpointer dummy); void on_pref_menu (GtkAction *a, gpointer user_data); void on_tb_scan_remote_clicked (GtkToolButton *toolbutton, gpointer user_data); void on_menu_scan_rem_activate (GtkMenuItem *menuitem, gpointer user_data); -void on_view_tb_activate (GtkToggleAction *action, gpointer user_data); -void on_view_sb_activate (GtkToggleAction *action, gpointer user_data); void on_ck_allocated_activate (GtkToggleAction *action, gpointer user_data); void on_helpcontents_activate (GtkAction *a, gpointer user_data); void on_tv_selection_changed (GtkTreeSelection *selection, gpointer user_data); @@ -57,6 +55,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__ */ -- cgit v1.2.1