summaryrefslogtreecommitdiff
path: root/plugins/housekeeping
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/housekeeping')
-rw-r--r--plugins/housekeeping/msd-disk-space.c11
-rw-r--r--plugins/housekeeping/msd-disk-space.h1
-rw-r--r--plugins/housekeeping/msd-housekeeping-manager.c94
-rw-r--r--plugins/housekeeping/msd-housekeeping-manager.h36
-rw-r--r--plugins/housekeeping/msd-housekeeping-plugin.c1
-rw-r--r--plugins/housekeeping/msd-housekeeping-plugin.h1
-rw-r--r--plugins/housekeeping/msd-ldsm-dialog.c6
-rw-r--r--plugins/housekeeping/msd-ldsm-dialog.h1
-rw-r--r--plugins/housekeeping/msd-ldsm-trash-empty.c1
-rw-r--r--plugins/housekeeping/msd-ldsm-trash-empty.h1
10 files changed, 77 insertions, 76 deletions
diff --git a/plugins/housekeeping/msd-disk-space.c b/plugins/housekeeping/msd-disk-space.c
index 22b196c..91738e0 100644
--- a/plugins/housekeeping/msd-disk-space.c
+++ b/plugins/housekeeping/msd-disk-space.c
@@ -2,6 +2,7 @@
* vim: set et sw=8 ts=8:
*
* Copyright (c) 2008, Novell, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
*
* Authors: Vincent Untz <[email protected]>
*
@@ -40,7 +41,6 @@
#include "msd-ldsm-dialog.h"
#include "msd-ldsm-trash-empty.h"
-
#define GIGABYTE 1024 * 1024 * 1024
#define CHECK_EVERY_X_SECONDS 60
@@ -279,7 +279,6 @@ ldsm_mount_is_user_ignore (const gchar *path)
return FALSE;
}
-
static gboolean
is_in (const gchar *value, const gchar *set[])
{
@@ -612,8 +611,7 @@ msd_ldsm_get_config (void)
SETTINGS_MIN_NOTIFY_PERIOD);
if (ignore_paths != NULL) {
- g_slist_foreach (ignore_paths, (GFunc) g_free, NULL);
- g_slist_free (ignore_paths);
+ g_slist_free_full (ignore_paths, g_free);
ignore_paths = NULL;
}
@@ -636,7 +634,7 @@ msd_ldsm_get_config (void)
}
static void
-msd_ldsm_update_config (GSettings *settings G_GNUC_UNUSED,
+msd_ldsm_update_config (GSettings *gsettings G_GNUC_UNUSED,
gchar *key G_GNUC_UNUSED,
gpointer user_data G_GNUC_UNUSED)
{
@@ -696,8 +694,7 @@ msd_ldsm_clean (void)
}
if (ignore_paths) {
- g_slist_foreach (ignore_paths, (GFunc) g_free, NULL);
- g_slist_free (ignore_paths);
+ g_slist_free_full (ignore_paths, g_free);
}
}
diff --git a/plugins/housekeeping/msd-disk-space.h b/plugins/housekeeping/msd-disk-space.h
index 13d4aa4..ff84a41 100644
--- a/plugins/housekeeping/msd-disk-space.h
+++ b/plugins/housekeeping/msd-disk-space.h
@@ -4,6 +4,7 @@
* Copyright (c) 2008, Novell, Inc.
*
* Authors: Vincent Untz <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/plugins/housekeeping/msd-housekeeping-manager.c b/plugins/housekeeping/msd-housekeeping-manager.c
index 4a76241..367cbb1 100644
--- a/plugins/housekeeping/msd-housekeeping-manager.c
+++ b/plugins/housekeeping/msd-housekeeping-manager.c
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2008 Michael J. Chudobiak <[email protected]>
* Copyright (C) 2012 Jasmine Hassan <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,7 +29,6 @@
#include "msd-housekeeping-manager.h"
#include "msd-disk-space.h"
-
/* General */
#define INTERVAL_ONCE_A_DAY 24*60*60
#define INTERVAL_TWO_MINUTES 2*60
@@ -38,17 +38,19 @@
#define THUMB_CACHE_KEY_AGE "maximum-age"
#define THUMB_CACHE_KEY_SIZE "maximum-size"
-struct MsdHousekeepingManagerPrivate {
- guint long_term_cb;
- guint short_term_cb;
+struct _MsdHousekeepingManager {
+ GObject parent;
+
+ guint long_term_cb;
+ guint short_term_cb;
GSettings *settings;
+ gulong config_listener_id;
};
-G_DEFINE_TYPE_WITH_PRIVATE (MsdHousekeepingManager, msd_housekeeping_manager, G_TYPE_OBJECT)
+G_DEFINE_TYPE (MsdHousekeepingManager, msd_housekeeping_manager, G_TYPE_OBJECT)
static gpointer manager_object = NULL;
-
typedef struct {
GDateTime *now;
GTimeSpan max_age;
@@ -56,14 +58,12 @@ typedef struct {
goffset max_size;
} PurgeData;
-
typedef struct {
GDateTime *mtime;
char *path;
glong size;
} ThumbData;
-
static void
thumb_data_free (gpointer data)
{
@@ -155,8 +155,8 @@ purge_thumbnail_cache (MsdHousekeepingManager *manager)
g_debug ("housekeeping: checking thumbnail cache size and freshness");
- purge_data.max_age = g_settings_get_int (manager->priv->settings, THUMB_CACHE_KEY_AGE) * G_TIME_SPAN_DAY;
- purge_data.max_size = g_settings_get_int (manager->priv->settings, THUMB_CACHE_KEY_SIZE) * 1024 * 1024;
+ purge_data.max_age = g_settings_get_int (manager->settings, THUMB_CACHE_KEY_AGE) * G_TIME_SPAN_DAY;
+ purge_data.max_size = g_settings_get_int (manager->settings, THUMB_CACHE_KEY_SIZE) * 1024 * 1024;
/* if both are set to -1, we don't need to read anything */
if ((purge_data.max_age < 0) && (purge_data.max_size < 0))
@@ -200,8 +200,7 @@ purge_thumbnail_cache (MsdHousekeepingManager *manager)
}
}
- g_list_foreach (files, (GFunc) thumb_data_free, NULL);
- g_list_free (files);
+ g_list_free_full (files, thumb_data_free);
g_date_time_unref (purge_data.now);
}
@@ -216,16 +215,16 @@ static gboolean
do_cleanup_once (MsdHousekeepingManager *manager)
{
do_cleanup (manager);
- manager->priv->short_term_cb = 0;
+ manager->short_term_cb = 0;
return FALSE;
}
static void
do_cleanup_soon (MsdHousekeepingManager *manager)
{
- if (manager->priv->short_term_cb == 0) {
+ if (manager->short_term_cb == 0) {
g_debug ("housekeeping: will tidy up in 2 minutes");
- manager->priv->short_term_cb = g_timeout_add_seconds (INTERVAL_TWO_MINUTES,
+ manager->short_term_cb = g_timeout_add_seconds (INTERVAL_TWO_MINUTES,
(GSourceFunc) do_cleanup_once,
manager);
}
@@ -246,18 +245,11 @@ msd_housekeeping_manager_start (MsdHousekeepingManager *manager,
g_debug ("Starting housekeeping manager");
mate_settings_profile_start (NULL);
- msd_ldsm_setup (FALSE);
-
- manager->priv->settings = g_settings_new (THUMB_CACHE_SCHEMA);
-
- g_signal_connect (manager->priv->settings, "changed",
- G_CALLBACK (settings_changed_callback), manager);
-
/* Clean once, a few minutes after start-up */
do_cleanup_soon (manager);
/* Clean periodically, on a daily basis. */
- manager->priv->long_term_cb = g_timeout_add_seconds (INTERVAL_ONCE_A_DAY,
+ manager->long_term_cb = g_timeout_add_seconds (INTERVAL_ONCE_A_DAY,
(GSourceFunc) do_cleanup,
manager);
mate_settings_profile_end (NULL);
@@ -265,46 +257,70 @@ msd_housekeeping_manager_start (MsdHousekeepingManager *manager,
return TRUE;
}
+static void
+msd_housekeeping_manager_finalize (GObject *object)
+{
+ MsdHousekeepingManager *manager = MSD_HOUSEKEEPING_MANAGER (object);
+ msd_housekeeping_manager_stop (manager);
+#if GLIB_CHECK_VERSION(2,62,0)
+ g_clear_signal_handler (&manager->config_listener_id,
+ manager->settings);
+#else
+ if (manager->config_listener_id != 0) {
+ g_signal_handler_disconnect (manager->settings,
+ manager->config_listener_id);
+ manager->config_listener_id = 0;
+ }
+#endif
+ g_object_unref (manager->settings);
+ manager->settings = NULL;
+
+ msd_ldsm_clean ();
+
+ G_OBJECT_CLASS (msd_housekeeping_manager_parent_class)->finalize (object);
+}
+
void
msd_housekeeping_manager_stop (MsdHousekeepingManager *manager)
{
- MsdHousekeepingManagerPrivate *p = manager->priv;
-
g_debug ("Stopping housekeeping manager");
- if (p->short_term_cb) {
- g_source_remove (p->short_term_cb);
- p->short_term_cb = 0;
+ if (manager->short_term_cb) {
+ g_source_remove (manager->short_term_cb);
+ manager->short_term_cb = 0;
}
- if (p->long_term_cb) {
- g_source_remove (p->long_term_cb);
- p->long_term_cb = 0;
+ if (manager->long_term_cb) {
+ g_source_remove (manager->long_term_cb);
+ manager->long_term_cb = 0;
/* Do a clean-up on shutdown if and only if the size or age
* limits have been set to a paranoid level of cleaning (zero)
*/
- if ((g_settings_get_int (p->settings, THUMB_CACHE_KEY_AGE) == 0) ||
- (g_settings_get_int (p->settings, THUMB_CACHE_KEY_SIZE) == 0)) {
+ if ((g_settings_get_int (manager->settings, THUMB_CACHE_KEY_AGE) == 0) ||
+ (g_settings_get_int (manager->settings, THUMB_CACHE_KEY_SIZE) == 0)) {
do_cleanup (manager);
}
}
-
- g_object_unref (p->settings);
- p->settings = NULL;
-
- msd_ldsm_clean ();
}
static void
msd_housekeeping_manager_class_init (MsdHousekeepingManagerClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = msd_housekeeping_manager_finalize;
}
static void
msd_housekeeping_manager_init (MsdHousekeepingManager *manager)
{
- manager->priv = msd_housekeeping_manager_get_instance_private (manager);
+ msd_ldsm_setup (FALSE);
+
+ manager->settings = g_settings_new (THUMB_CACHE_SCHEMA);
+ manager->config_listener_id = g_signal_connect (manager->settings, "changed",
+ G_CALLBACK (settings_changed_callback),
+ manager);
}
MsdHousekeepingManager *
diff --git a/plugins/housekeeping/msd-housekeeping-manager.h b/plugins/housekeeping/msd-housekeeping-manager.h
index a336fad..40ed061 100644
--- a/plugins/housekeeping/msd-housekeeping-manager.h
+++ b/plugins/housekeeping/msd-housekeeping-manager.h
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Michael J. Chudobiak <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,42 +19,23 @@
*
*/
-#ifndef __MSD_HOUSEKEEPING_MANAGER_H
-#define __MSD_HOUSEKEEPING_MANAGER_H
+#ifndef MSD_HOUSEKEEPING_MANAGER_H
+#define MSD_HOUSEKEEPING_MANAGER_H
#include <glib-object.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+G_BEGIN_DECLS
-#define MSD_TYPE_HOUSEKEEPING_MANAGER (msd_housekeeping_manager_get_type ())
-#define MSD_HOUSEKEEPING_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_TYPE_HOUSEKEEPING_MANAGER, MsdHousekeepingManager))
-#define MSD_HOUSEKEEPING_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MSD_TYPE_HOUSEKEEPING_MANAGER, MsdHousekeepingManagerClass))
-#define MSD_IS_HOUSEKEEPING_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MSD_TYPE_HOUSEKEEPING_MANAGER))
-#define MSD_IS_HOUSEKEEPING_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MSD_TYPE_HOUSEKEEPING_MANAGER))
-#define MSD_HOUSEKEEPING_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MSD_TYPE_HOUSEKEEPING_MANAGER, MsdHousekeepingManagerClass))
+#define MSD_TYPE_HOUSEKEEPING_MANAGER (msd_housekeeping_manager_get_type ())
-typedef struct MsdHousekeepingManagerPrivate MsdHousekeepingManagerPrivate;
-
-typedef struct {
- GObject parent;
- MsdHousekeepingManagerPrivate *priv;
-} MsdHousekeepingManager;
-
-typedef struct {
- GObjectClass parent_class;
-} MsdHousekeepingManagerClass;
-
-GType msd_housekeeping_manager_get_type (void);
+G_DECLARE_FINAL_TYPE (MsdHousekeepingManager, msd_housekeeping_manager,
+ MSD, HOUSEKEEPING_MANAGER, GObject)
MsdHousekeepingManager * msd_housekeeping_manager_new (void);
gboolean msd_housekeeping_manager_start (MsdHousekeepingManager *manager,
GError **error);
void msd_housekeeping_manager_stop (MsdHousekeepingManager *manager);
-#ifdef __cplusplus
-}
-#endif
+G_END_DECLS
-#endif /* __MSD_HOUSEKEEPING_MANAGER_H */
+#endif /* MSD_HOUSEKEEPING_MANAGER_H */
diff --git a/plugins/housekeeping/msd-housekeeping-plugin.c b/plugins/housekeeping/msd-housekeeping-plugin.c
index 8a829fe..3d2b7ed 100644
--- a/plugins/housekeeping/msd-housekeeping-plugin.c
+++ b/plugins/housekeeping/msd-housekeeping-plugin.c
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Michael J. Chudobiak <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/plugins/housekeeping/msd-housekeeping-plugin.h b/plugins/housekeeping/msd-housekeeping-plugin.h
index 15be276..7fb155a 100644
--- a/plugins/housekeeping/msd-housekeeping-plugin.h
+++ b/plugins/housekeeping/msd-housekeeping-plugin.h
@@ -1,6 +1,7 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2008 Michael J. Chudobiak <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/plugins/housekeeping/msd-ldsm-dialog.c b/plugins/housekeeping/msd-ldsm-dialog.c
index 74ff606..3b06d09 100644
--- a/plugins/housekeeping/msd-ldsm-dialog.c
+++ b/plugins/housekeeping/msd-ldsm-dialog.c
@@ -2,6 +2,7 @@
*
* msd-ldsm-dialog.c
* Copyright (C) Chris Coulson 2009 <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* msd-ldsm-dialog.c is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -182,8 +183,7 @@ ignore_check_button_toggled_cb (GtkToggleButton *button,
g_ptr_array_free (array, FALSE);
}
- g_slist_foreach (ignore_paths, (GFunc) g_free, NULL);
- g_slist_free (ignore_paths);
+ g_slist_free_full (ignore_paths, g_free);
g_object_unref (settings);
}
@@ -450,7 +450,7 @@ msd_ldsm_dialog_new (gboolean other_usable_partitions,
button_ignore = gtk_dialog_add_button (GTK_DIALOG (dialog),
_("Ignore"),
GTK_RESPONSE_CANCEL);
- ignore_image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON);
+ ignore_image = gtk_image_new_from_icon_name ("process-stop", GTK_ICON_SIZE_BUTTON);
gtk_button_set_image (GTK_BUTTON (button_ignore), ignore_image);
gtk_widget_grab_default (button_ignore);
diff --git a/plugins/housekeeping/msd-ldsm-dialog.h b/plugins/housekeeping/msd-ldsm-dialog.h
index 8b95fb9..7b59c80 100644
--- a/plugins/housekeeping/msd-ldsm-dialog.h
+++ b/plugins/housekeeping/msd-ldsm-dialog.h
@@ -2,6 +2,7 @@
*
* msd-ldsm-dialog.c
* Copyright (C) Chris Coulson 2009 <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* msd-ldsm-dialog.c is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
diff --git a/plugins/housekeeping/msd-ldsm-trash-empty.c b/plugins/housekeeping/msd-ldsm-trash-empty.c
index 301b6dc..e331dda 100644
--- a/plugins/housekeeping/msd-ldsm-trash-empty.c
+++ b/plugins/housekeeping/msd-ldsm-trash-empty.c
@@ -3,6 +3,7 @@
* msd-ldsm-trash-empty.c
* Copyright (C) Chris Coulson 2009 <[email protected]>
* (C) Ryan Lortie 2008
+ * Copyright (C) 2012-2021 MATE Developers
*
* msd-ldsm-trash-empty.c is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
diff --git a/plugins/housekeeping/msd-ldsm-trash-empty.h b/plugins/housekeeping/msd-ldsm-trash-empty.h
index 478f0a7..52daa95 100644
--- a/plugins/housekeeping/msd-ldsm-trash-empty.h
+++ b/plugins/housekeeping/msd-ldsm-trash-empty.h
@@ -2,6 +2,7 @@
*
* msd-ldsm-trash-empty.h
* Copyright (C) Chris Coulson 2009 <[email protected]>
+ * Copyright (C) 2012-2021 MATE Developers
*
* msd-ldsm-trash-empty.h is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the