summaryrefslogtreecommitdiff
path: root/baobab/src/baobab-prefs.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2012-11-18 10:26:47 -0800
committerStefano Karapetsas <[email protected]>2012-11-18 10:26:47 -0800
commit4bf85370cb70b15e8401a2477a6734528a88d257 (patch)
tree12d8fac0a43fda29116866a7b131960fb5d27c49 /baobab/src/baobab-prefs.c
parent266894647388df80ab6bc6d3b38201db863a9488 (diff)
parent507090e64e66315d6dad960791489a477dced017 (diff)
downloadmate-utils-4bf85370cb70b15e8401a2477a6734528a88d257.tar.bz2
mate-utils-4bf85370cb70b15e8401a2477a6734528a88d257.tar.xz
Merge pull request #9 from bhull2010/master
Port disk-usage-analyzer to Gsettings
Diffstat (limited to 'baobab/src/baobab-prefs.c')
-rw-r--r--baobab/src/baobab-prefs.c69
1 files changed, 29 insertions, 40 deletions
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 <gtk/gtk.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
-#include <mateconf/mateconf-client.h>
#include <glibtop/mountlist.h>
#include <glibtop/fsusage.h>
#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);