[epiphany/mcatanzaro/ephy-session: 16/19] session: rename save_idle to save_timeout
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/ephy-session: 16/19] session: rename save_idle to save_timeout
- Date: Mon, 8 Mar 2021 18:56:02 +0000 (UTC)
commit 6a9f81600d04def4d01025b032abe4847524c6b5
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Wed Feb 24 11:23:56 2021 -0600
session: rename save_idle to save_timeout
It's a timeout, not an idle callback.
Also, add a comment to explain why the timeout should not be removed.
Also, let's avoid calling the timeout's callback directly.
src/ephy-session.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index fb38a9122..dfa2ed40a 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -77,7 +77,7 @@ enum {
static GParamSpec *obj_properties[LAST_PROP];
-static gboolean ephy_session_save_idle_cb (EphySession *session);
+static void ephy_session_save_now (EphySession *session);
G_DEFINE_TYPE (EphySession, ephy_session, G_TYPE_OBJECT)
@@ -527,7 +527,7 @@ ephy_session_close (EphySession *session)
policy = g_settings_get_enum (EPHY_SETTINGS_MAIN, EPHY_PREFS_RESTORE_SESSION_POLICY);
if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_ALWAYS) {
- ephy_session_save_idle_cb (session);
+ ephy_session_save_now (session);
} else {
session_delete (session);
}
@@ -974,21 +974,21 @@ out:
}
static EphySession *
-ephy_session_save_idle_started (EphySession *session)
+ephy_session_save_timeout_started (EphySession *session)
{
g_application_hold (G_APPLICATION (ephy_shell_get_default ()));
return g_object_ref (session);
}
static void
-ephy_session_save_idle_finished (EphySession *session)
+ephy_session_save_timeout_finished (EphySession *session)
{
g_application_release (G_APPLICATION (ephy_shell_get_default ()));
g_object_unref (session);
}
static gboolean
-ephy_session_save_idle_cb (EphySession *session)
+ephy_session_save_timeout_cb (EphySession *session)
{
EphyShell *shell = ephy_shell_get_default ();
SaveData *data;
@@ -1043,10 +1043,19 @@ ephy_session_save (EphySession *session)
if (policy == EPHY_PREFS_RESTORE_SESSION_POLICY_NEVER)
return;
+ /* Schedule the save to occur one second in the future to ensure we don't
+ * repeatedly write to disk when opening or closing many tabs at once.
+ */
session->save_source_id = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 1,
- (GSourceFunc)ephy_session_save_idle_cb,
- ephy_session_save_idle_started (session),
- (GDestroyNotify)ephy_session_save_idle_finished);
+ (GSourceFunc)ephy_session_save_timeout_cb,
+ ephy_session_save_timeout_started (session),
+ (GDestroyNotify)ephy_session_save_timeout_finished);
+}
+
+static void
+ephy_session_save_now (EphySession *session)
+{
+ ephy_session_save_timeout_cb (session);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]