[epiphany/wip/sync: 6/22] sync-service: Connect the GSettings signal to handle changed sync frequency
- From: Gabriel Ivașcu <gabrielivascu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/sync: 6/22] sync-service: Connect the GSettings signal to handle changed sync frequency
- Date: Sat, 10 Jun 2017 17:30:21 +0000 (UTC)
commit cfa90194a27b315a38e02194236f181788b65a03
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date: Tue May 16 18:00:50 2017 +0300
sync-service: Connect the GSettings signal to handle changed sync frequency
We don't need to trigger the signal when closing the preferences dialog
because we don't really care if the sync is rescheduled with the same
frequency.
lib/sync/ephy-sync-service.c | 28 +++++++++++-----------------
src/prefs-dialog.c | 9 +--------
2 files changed, 12 insertions(+), 25 deletions(-)
---
diff --git a/lib/sync/ephy-sync-service.c b/lib/sync/ephy-sync-service.c
index e21123b..ad321d8 100644
--- a/lib/sync/ephy-sync-service.c
+++ b/lib/sync/ephy-sync-service.c
@@ -107,7 +107,6 @@ static GParamSpec *obj_properties[LAST_PROP];
enum {
STORE_FINISHED,
SIGN_IN_ERROR,
- SYNC_FREQUENCY_CHANGED,
SYNC_FINISHED,
LAST_SIGNAL
};
@@ -1438,18 +1437,20 @@ ephy_sync_service_stop_periodical_sync (EphySyncService *self)
static void
ephy_sync_service_schedule_periodical_sync (EphySyncService *self)
{
+ guint seconds;
+
g_assert (EPHY_IS_SYNC_SERVICE (self));
- self->source_id = g_timeout_add_seconds (g_settings_get_uint (EPHY_SETTINGS_SYNC,
- EPHY_PREFS_SYNC_FREQUENCY) * 60,
- ephy_sync_service_sync,
- self);
- LOG ("Scheduled new sync with frequency %u mins",
- g_settings_get_uint (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_FREQUENCY));
+ seconds = g_settings_get_uint (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_FREQUENCY) * 60;
+ self->source_id = g_timeout_add_seconds (seconds, ephy_sync_service_sync, self);
+
+ LOG ("Scheduled new sync with frequency %u minutes", seconds / 60);
}
static void
-sync_frequency_changed_cb (EphySyncService *self)
+sync_frequency_changed_cb (GSettings *settings,
+ char *key,
+ EphySyncService *self)
{
g_assert (EPHY_IS_SYNC_SERVICE (self));
@@ -1665,8 +1666,8 @@ ephy_sync_service_constructed (GObject *object)
user_agent = webkit_settings_get_user_agent (settings);
g_object_set (self->session, "user-agent", user_agent, NULL);
- g_signal_connect (self, "sync-frequency-changed",
- G_CALLBACK (sync_frequency_changed_cb), NULL);
+ g_signal_connect (EPHY_SETTINGS_SYNC, "changed::"EPHY_PREFS_SYNC_FREQUENCY,
+ G_CALLBACK (sync_frequency_changed_cb), self);
}
}
@@ -1723,13 +1724,6 @@ ephy_sync_service_class_init (EphySyncServiceClass *klass)
G_TYPE_NONE, 1,
G_TYPE_STRING);
- signals[SYNC_FREQUENCY_CHANGED] =
- g_signal_new ("sync-frequency-changed",
- EPHY_TYPE_SYNC_SERVICE,
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 0);
-
signals[SYNC_FINISHED] =
g_signal_new ("sync-finished",
EPHY_TYPE_SYNC_SERVICE,
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index dfb7e0a..69e9557 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -127,7 +127,6 @@ struct _PrefsDialog {
GtkWidget *sync_frequency_30_min_radiobutton;
GtkWidget *sync_frequency_60_min_radiobutton;
GtkWidget *sync_now_button;
- guint32 sync_frequency;
gboolean sync_was_signed_in;
WebKitWebView *fxa_web_view;
@@ -166,11 +165,8 @@ prefs_dialog_finalize (GObject *object)
g_object_unref (dialog->fxa_manager);
}
- if (ephy_sync_service_is_signed_in (dialog->sync_service) && !dialog->sync_was_signed_in) {
+ if (ephy_sync_service_is_signed_in (dialog->sync_service) && !dialog->sync_was_signed_in)
ephy_sync_service_start_periodical_sync (dialog->sync_service);
- } else if (dialog->sync_frequency != g_settings_get_uint (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_FREQUENCY)) {
- g_signal_emit_by_name (dialog->sync_service, "sync-frequency-changed");
- }
G_OBJECT_CLASS (prefs_dialog_parent_class)->finalize (object);
}
@@ -1736,9 +1732,6 @@ setup_sync_page (PrefsDialog *dialog)
sync_frequency_set_mapping,
GINT_TO_POINTER (60),
NULL);
-
- dialog->sync_frequency = g_settings_get_uint (EPHY_SETTINGS_SYNC,
- EPHY_PREFS_SYNC_FREQUENCY);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]