[gnome-applets] sticky-notes: remove save timeout on dispose
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] sticky-notes: remove save timeout on dispose
- Date: Sun, 2 Oct 2022 14:30:48 +0000 (UTC)
commit 131e6c5cb0e066a67b96da5cb1bb4209ff755ea8
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sun Oct 2 17:29:15 2022 +0300
sticky-notes: remove save timeout on dispose
gnome-applets/sticky-notes/sticky-notes-applet.c | 6 ++++++
gnome-applets/sticky-notes/sticky-notes-applet.h | 2 +-
gnome-applets/sticky-notes/sticky-notes.c | 15 +++++++--------
3 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/gnome-applets/sticky-notes/sticky-notes-applet.c
b/gnome-applets/sticky-notes/sticky-notes-applet.c
index adc0f11a4..0a1887729 100644
--- a/gnome-applets/sticky-notes/sticky-notes-applet.c
+++ b/gnome-applets/sticky-notes/sticky-notes-applet.c
@@ -250,6 +250,12 @@ sticky_notes_applet_dispose (GObject *object)
self = STICKY_NOTES_APPLET (object);
+ if (self->save_timeout_id != 0)
+ {
+ g_source_remove (self->save_timeout_id);
+ self->save_timeout_id = 0;
+ }
+
if (self->notes != NULL)
{
stickynotes_save_now (self);
diff --git a/gnome-applets/sticky-notes/sticky-notes-applet.h
b/gnome-applets/sticky-notes/sticky-notes-applet.h
index d838f6c59..95ccd43ce 100644
--- a/gnome-applets/sticky-notes/sticky-notes-applet.h
+++ b/gnome-applets/sticky-notes/sticky-notes-applet.h
@@ -52,7 +52,7 @@ struct _StickyNotesApplet
GtkWidget *w_prefs;
- gboolean save_scheduled;
+ guint save_timeout_id;
GList *notes;
diff --git a/gnome-applets/sticky-notes/sticky-notes.c b/gnome-applets/sticky-notes/sticky-notes.c
index 820cc95c8..00556bf7b 100644
--- a/gnome-applets/sticky-notes/sticky-notes.c
+++ b/gnome-applets/sticky-notes/sticky-notes.c
@@ -1165,8 +1165,6 @@ stickynotes_save_now (StickyNotesApplet *applet)
if (applet->notes == NULL) {
g_unlink (notes_file);
g_free (notes_file);
-
- applet->save_scheduled = FALSE;
return;
}
@@ -1273,8 +1271,6 @@ stickynotes_save_now (StickyNotesApplet *applet)
g_free (notes_file);
xmlFreeDoc(doc);
-
- applet->save_scheduled = FALSE;
}
static gboolean
@@ -1283,6 +1279,7 @@ stickynotes_save_cb (gpointer user_data)
StickyNotesApplet *applet;
applet = STICKY_NOTES_APPLET (user_data);
+ applet->save_timeout_id = 0;
stickynotes_save_now (applet);
@@ -1293,10 +1290,12 @@ void
stickynotes_save (StickyNotesApplet *applet)
{
/* If a save isn't already schedules, save everything a minute from now. */
- if (!applet->save_scheduled) {
- g_timeout_add_seconds (60, stickynotes_save_cb, applet);
- applet->save_scheduled = TRUE;
- }
+ if (applet->save_timeout_id != 0)
+ return;
+
+ applet->save_timeout_id = g_timeout_add_seconds (60,
+ stickynotes_save_cb,
+ applet);
}
static char *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]