[gnome-settings-daemon/wip/benzea/cleanups-and-small-fixes: 23/51] housekeeping: Use G_DECLARE_FINAL_TYPE for GsdHousekeepingManager
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/benzea/cleanups-and-small-fixes: 23/51] housekeeping: Use G_DECLARE_FINAL_TYPE for GsdHousekeepingManager
- Date: Tue, 26 Feb 2019 10:53:36 +0000 (UTC)
commit f2018c49f6ad17c2e66d7c73ac2ae8ee961b2060
Author: Benjamin Berg <bberg redhat com>
Date: Wed Feb 20 16:24:09 2019 +0100
housekeeping: Use G_DECLARE_FINAL_TYPE for GsdHousekeepingManager
plugins/housekeeping/gsd-housekeeping-manager.c | 75 ++++++++++++-------------
plugins/housekeeping/gsd-housekeeping-manager.h | 18 +-----
2 files changed, 36 insertions(+), 57 deletions(-)
---
diff --git a/plugins/housekeeping/gsd-housekeeping-manager.c b/plugins/housekeeping/gsd-housekeeping-manager.c
index 5ace4179..adc41ede 100644
--- a/plugins/housekeeping/gsd-housekeeping-manager.c
+++ b/plugins/housekeeping/gsd-housekeeping-manager.c
@@ -48,7 +48,9 @@ static const gchar introspection_xml[] =
" </interface>"
"</node>";
-struct GsdHousekeepingManagerPrivate {
+struct _GsdHousekeepingManager {
+ GObject parent;
+
GSettings *settings;
guint long_term_cb;
guint short_term_cb;
@@ -59,8 +61,6 @@ struct GsdHousekeepingManagerPrivate {
guint name_id;
};
-#define GSD_HOUSEKEEPING_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o),
GSD_TYPE_HOUSEKEEPING_MANAGER, GsdHousekeepingManagerPrivate))
-
static void gsd_housekeeping_manager_class_init (GsdHousekeepingManagerClass *klass);
static void gsd_housekeeping_manager_init (GsdHousekeepingManager *housekeeping_manager);
@@ -226,8 +226,8 @@ purge_thumbnail_cache (GsdHousekeepingManager *manager)
g_debug ("housekeeping: checking thumbnail cache size and freshness");
- purge_data.max_age = (glong) g_settings_get_int (manager->priv->settings, THUMB_AGE_KEY) * 24 * 60 *
60;
- purge_data.max_size = (goffset) g_settings_get_int (manager->priv->settings, THUMB_SIZE_KEY) * 1024
* 1024;
+ purge_data.max_age = (glong) g_settings_get_int (manager->settings, THUMB_AGE_KEY) * 24 * 60 * 60;
+ purge_data.max_size = (goffset) g_settings_get_int (manager->settings, THUMB_SIZE_KEY) * 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))
@@ -272,19 +272,19 @@ static gboolean
do_cleanup_once (GsdHousekeepingManager *manager)
{
do_cleanup (manager);
- manager->priv->short_term_cb = 0;
+ manager->short_term_cb = 0;
return FALSE;
}
static void
do_cleanup_soon (GsdHousekeepingManager *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);
- g_source_set_name_by_id (manager->priv->short_term_cb, "[gnome-settings-daemon]
do_cleanup_once");
+ g_source_set_name_by_id (manager->short_term_cb, "[gnome-settings-daemon] do_cleanup_once");
}
}
@@ -343,9 +343,9 @@ on_bus_gotten (GObject *source_object,
g_error_free (error);
return;
}
- manager->priv->connection = connection;
+ manager->connection = connection;
- infos = manager->priv->introspection_data->interfaces;
+ infos = manager->introspection_data->interfaces;
for (i = 0; infos[i] != NULL; i++) {
g_dbus_connection_register_object (connection,
GSD_HOUSEKEEPING_DBUS_PATH,
@@ -356,7 +356,7 @@ on_bus_gotten (GObject *source_object,
NULL);
}
- manager->priv->name_id = g_bus_own_name_on_connection (connection,
+ manager->name_id = g_bus_own_name_on_connection (connection,
"org.gnome.SettingsDaemon.Housekeeping",
G_BUS_NAME_OWNER_FLAGS_NONE,
NULL,
@@ -368,12 +368,12 @@ on_bus_gotten (GObject *source_object,
static void
register_manager_dbus (GsdHousekeepingManager *manager)
{
- manager->priv->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
- g_assert (manager->priv->introspection_data != NULL);
- manager->priv->bus_cancellable = g_cancellable_new ();
+ manager->introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
+ g_assert (manager->introspection_data != NULL);
+ manager->bus_cancellable = g_cancellable_new ();
g_bus_get (G_BUS_TYPE_SESSION,
- manager->priv->bus_cancellable,
+ manager->bus_cancellable,
(GAsyncReadyCallback) on_bus_gotten,
manager);
}
@@ -398,18 +398,18 @@ gsd_housekeeping_manager_start (GsdHousekeepingManager *manager,
gsd_ldsm_setup (FALSE);
- manager->priv->settings = g_settings_new (THUMB_PREFIX);
- g_signal_connect (G_OBJECT (manager->priv->settings), "changed",
+ manager->settings = g_settings_new (THUMB_PREFIX);
+ g_signal_connect (G_OBJECT (manager->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);
- g_source_set_name_by_id (manager->priv->long_term_cb, "[gnome-settings-daemon] do_cleanup");
+ g_source_set_name_by_id (manager->long_term_cb, "[gnome-settings-daemon] do_cleanup");
gnome_settings_profile_end (NULL);
@@ -419,38 +419,36 @@ gsd_housekeeping_manager_start (GsdHousekeepingManager *manager,
void
gsd_housekeeping_manager_stop (GsdHousekeepingManager *manager)
{
- GsdHousekeepingManagerPrivate *p = manager->priv;
-
g_debug ("Stopping housekeeping manager");
- if (manager->priv->name_id != 0) {
- g_bus_unown_name (manager->priv->name_id);
- manager->priv->name_id = 0;
+ if (manager->name_id != 0) {
+ g_bus_unown_name (manager->name_id);
+ manager->name_id = 0;
}
- g_clear_object (&p->bus_cancellable);
- g_clear_pointer (&p->introspection_data, g_dbus_node_info_unref);
- g_clear_object (&p->connection);
+ g_clear_object (&manager->bus_cancellable);
+ g_clear_pointer (&manager->introspection_data, g_dbus_node_info_unref);
+ g_clear_object (&manager->connection);
- 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 paranoid levels (zero) */
- if ((g_settings_get_int (p->settings, THUMB_AGE_KEY) == 0) ||
- (g_settings_get_int (p->settings, THUMB_SIZE_KEY) == 0)) {
+ if ((g_settings_get_int (manager->settings, THUMB_AGE_KEY) == 0) ||
+ (g_settings_get_int (manager->settings, THUMB_SIZE_KEY) == 0)) {
do_cleanup (manager);
}
}
- g_clear_object (&p->settings);
+ g_clear_object (&manager->settings);
gsd_ldsm_clean ();
}
@@ -470,14 +468,11 @@ gsd_housekeeping_manager_class_init (GsdHousekeepingManagerClass *klass)
object_class->finalize = gsd_housekeeping_manager_finalize;
notify_init ("gnome-settings-daemon");
-
- g_type_class_add_private (klass, sizeof (GsdHousekeepingManagerPrivate));
}
static void
gsd_housekeeping_manager_init (GsdHousekeepingManager *manager)
{
- manager->priv = GSD_HOUSEKEEPING_MANAGER_GET_PRIVATE (manager);
}
GsdHousekeepingManager *
diff --git a/plugins/housekeeping/gsd-housekeeping-manager.h b/plugins/housekeeping/gsd-housekeeping-manager.h
index 69d50b1c..8b5f8405 100644
--- a/plugins/housekeeping/gsd-housekeeping-manager.h
+++ b/plugins/housekeeping/gsd-housekeeping-manager.h
@@ -25,24 +25,8 @@
G_BEGIN_DECLS
#define GSD_TYPE_HOUSEKEEPING_MANAGER (gsd_housekeeping_manager_get_type ())
-#define GSD_HOUSEKEEPING_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
GSD_TYPE_HOUSEKEEPING_MANAGER, GsdHousekeepingManager))
-#define GSD_HOUSEKEEPING_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_HOUSEKEEPING_MANAGER,
GsdHousekeepingManagerClass))
-#define GSD_IS_HOUSEKEEPING_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
GSD_TYPE_HOUSEKEEPING_MANAGER))
-#define GSD_IS_HOUSEKEEPING_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_HOUSEKEEPING_MANAGER))
-#define GSD_HOUSEKEEPING_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
GSD_TYPE_HOUSEKEEPING_MANAGER, GsdHousekeepingManagerClass))
-typedef struct GsdHousekeepingManagerPrivate GsdHousekeepingManagerPrivate;
-
-typedef struct {
- GObject parent;
- GsdHousekeepingManagerPrivate *priv;
-} GsdHousekeepingManager;
-
-typedef struct {
- GObjectClass parent_class;
-} GsdHousekeepingManagerClass;
-
-GType gsd_housekeeping_manager_get_type (void);
+G_DECLARE_FINAL_TYPE (GsdHousekeepingManager, gsd_housekeeping_manager, GSD, HOUSEKEEPING_MANAGER, GObject)
GsdHousekeepingManager * gsd_housekeeping_manager_new (void);
gboolean gsd_housekeeping_manager_start (GsdHousekeepingManager *manager,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]