diff options
Diffstat (limited to 'baobab')
-rw-r--r-- | baobab/README | 12 | ||||
-rw-r--r-- | baobab/data/Makefile.am | 19 | ||||
-rw-r--r-- | baobab/data/baobab-main-window.ui | 14 | ||||
-rw-r--r-- | baobab/data/baobab.schemas.in | 70 | ||||
-rw-r--r-- | baobab/data/org.mate.disk-usage-analyzer.gschema.xml.in | 40 | ||||
-rw-r--r-- | baobab/src/Makefile.am | 8 | ||||
-rw-r--r-- | baobab/src/baobab-prefs.c | 69 | ||||
-rw-r--r-- | baobab/src/baobab-utils.c | 11 | ||||
-rw-r--r-- | baobab/src/baobab-utils.h | 1 | ||||
-rw-r--r-- | baobab/src/baobab.c | 366 | ||||
-rw-r--r-- | baobab/src/baobab.h | 26 | ||||
-rw-r--r-- | baobab/src/callbacks.c | 82 | ||||
-rw-r--r-- | baobab/src/callbacks.h | 5 |
13 files changed, 303 insertions, 420 deletions
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 @@ <accelerator key="R" modifiers="GDK_CONTROL_MASK"/> </child> <child> - <object class="GtkAction" id="esci1"> + <object class="GtkAction" id="menuquit"> <property name="stock_id">gtk-quit</property> - <property name="name">esci1</property> - <signal handler="on_esci1_activate" last_modification_time="Tue, 05 Jul 2005 08:47:26 GMT" name="activate"/> + <property name="name">menuquit</property> + <signal handler="on_quit_activate" last_modification_time="Tue, 05 Jul 2005 08:47:26 GMT" name="activate"/> </object> </child> <child> @@ -106,7 +106,6 @@ <property name="active">True</property> <property name="name">view_tb</property> <property name="label" translatable="yes">_Toolbar</property> - <signal handler="on_view_tb_activate" last_modification_time="Wed, 19 Apr 2006 12:10:25 GMT" name="activate"/> </object> </child> <child> @@ -114,7 +113,6 @@ <property name="active">True</property> <property name="name">view_sb</property> <property name="label" translatable="yes">St_atusbar</property> - <signal handler="on_view_sb_activate" last_modification_time="Wed, 19 Apr 2006 12:45:08 GMT" name="activate"/> </object> </child> <child> @@ -160,7 +158,7 @@ <menuitem action="menustop"/> <menuitem action="menurescan"/> <separator/> - <menuitem action="esci1"/> + <menuitem action="menuquit"/> </menu> <menu action="edit1"> <menuitem action="expand_all"/> @@ -197,7 +195,6 @@ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> <property name="urgency_hint">False</property> - <signal handler="on_esci1_activate" last_modification_time="Sun, 31 Jul 2005 16:47:41 GMT" name="destroy"/> <signal handler="on_delete_activate" last_modification_time="Sun, 31 Jul 2005 16:53:49 GMT" name="delete_event"/> <child> <object class="GtkVBox" id="vbox1"> @@ -233,8 +230,7 @@ <property name="visible_vertical">True</property> <property name="is_important">True</property> <accessibility> - - </accessibility> + </accessibility> <signal handler="on_tbscanhome_clicked" last_modification_time="Wed, 23 Aug 2006 12:30:03 GMT" name="clicked"/> <child internal-child="accessible"> <object class="AtkObject" id="a11y-tbscanhome1"> 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 @@ -<mateconfschemafile> - <schemalist> - <schema> - <key>/schemas/apps/baobab/ui/toolbar_visible</key> - <applyto>/apps/baobab/ui/toolbar_visible</applyto> - <owner>baobab</owner> - <type>bool</type> - <default>TRUE</default> - <locale name="C"> - <short>Toolbar is Visible</short> - <long>Whether the toolbar should be visible in main window.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/baobab/ui/statusbar_visible</key> - <applyto>/apps/baobab/ui/statusbar_visible</applyto> - <owner>baobab</owner> - <type>bool</type> - <default>FALSE</default> - <locale name="C"> - <short>Status Bar is Visible</short> - <long>Whether the status bar at the bottom of main window - should be visible.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/baobab/properties/enable_home_monitor</key> - <applyto>/apps/baobab/properties/enable_home_monitor</applyto> - <owner>baobab</owner> - <type>bool</type> - <default>FALSE</default> - <locale name="C"> - <short>Enable monitoring of home directory</short> - <long>Whether any change to the home directory should - be monitored.</long> - </locale> - </schema> - - - <schema> - <key>/schemas/apps/baobab/properties/skip_scan_uri_list</key> - <applyto>/apps/baobab/properties/skip_scan_uri_list</applyto> - <owner>baobab</owner> - <type>list</type> - <list_type>string</list_type> - <default>[]</default> - <locale name="C"> - <short>Excluded partitions URIs</short> - <long>A list of URIs for partitions to be excluded from scanning.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/baobab/ui/baobab_subfoldertips_visible</key> - <applyto>/apps/baobab/ui/baobab_subfoldertips_visible</applyto> - <owner>baobab</owner> - <type>bool</type> - <default>TRUE</default> - <locale name="C"> - <short>Subfolders tooltips visible</short> - <long>Whether the subfolder tooltips of the selected folder - are drawn.</long> - </locale> - </schema> - - </schemalist> -</mateconfschemafile> - 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 @@ +<schemalist> + <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.disk-usage-analyzer" path="/org/mate/disk-usage-analyzer/"> + <child name="preferences" schema="org.mate.disk-usage-analyzer.preferences"/> + <child name="ui" schema="org.mate.disk-usage-analyzer.ui"/> + </schema> + <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.disk-usage-analyzer.preferences" path="/org/mate/disk-usage-analyzer/preferences/"> + <key name="monitor-home" type="b"> + <default>false</default> + <_summary>Monitor Home</_summary> + <_description>Whether any change to the home directory should be monitored.</_description> + </key> + <key name="excluded-uris" type="as"> + <default>[]</default> + <_summary>Excluded partitions URIs</_summary> + <_description>A list of URIs for partitions to be excluded from scanning.</_description> + </key> + </schema> + <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.mate.disk-usage-analyzer.ui" path="/org/mate/disk-usage-analyzer/ui/"> + <key name="toolbar-visible" type="b"> + <default>true</default> + <_summary>Toolbar is Visible</_summary> + <_description>Whether the toolbar should be visible in main window.</_description> + </key> + <key name="statusbar-visible" type="b"> + <default>false</default> + <_summary>Statusbar is Visible</_summary> + <_description>Whether the status bar at the bottom of main window should be visible.</_description> + </key> + <key name="subfoldertips-visible" type="b"> + <default>true</default> + <_summary>Subfolder tips visible</_summary> + <_description>Whether the subfolder tooltips of the selected folder are drawn.</_description> + </key> + <key name="active-chart" type="s"> + <default>'rings'</default> + <_summary>Active Chart</_summary> + <_description>Which type of chart should be displayed.</_description> + </key> + </schema> +</schemalist> 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 <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); 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 <gtk/gtk.h> #include <glib/gi18n.h> #include <gio/gio.h> -#include <mateconf/mateconf-client.h> #include <glibtop.h> #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); @@ -630,36 +631,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) { gtk_statusbar_pop (GTK_STATUSBAR (baobab.statusbar), 1); @@ -691,38 +662,6 @@ toolbar_reconfigured_cb (GtkToolItem *item, } 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) { GtkWidget *toolbar; @@ -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); } } @@ -1121,19 +1071,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); + + 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 <glib.h> #include <gtk/gtk.h> #include <gio/gio.h> -#include <mateconf/mateconf-client.h> -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 <string.h> #include <gtk/gtk.h> #include <glib/gi18n.h> -#include <mateconf/mateconf-client.h> #include <gio/gio.h> #include "baobab.h" @@ -39,6 +38,12 @@ #include "baobab-chart.h" void +on_quit_activate (GtkMenuItem *menuitem, gpointer user_data) +{ + baobab_quit (); +} + +void on_menuscanhome_activate (GtkMenuItem *menuitem, gpointer user_data) { baobab_scan_home (); @@ -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 <[email protected]>", "Paolo Borelli <[email protected]>", "BenoƮt Dejean <[email protected]>", @@ -185,7 +184,7 @@ gboolean on_delete_activate (GtkWidget *widget, GdkEvent *event, gpointer user_data) { - on_esci1_activate (NULL, NULL); + baobab_quit (); return TRUE; } @@ -265,36 +264,6 @@ on_ck_allocated_activate (GtkToggleAction *action, } 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) { baobab_help_display (GTK_WINDOW (baobab.window), "baobab", NULL); @@ -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 <gtk/gtk.h> #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__ */ |