[epiphany/wip/sync: 14/22] sync: Disable sync in app mode and incognito mode



commit 6375f2ed30e3a92cfc7a4dcbc0624134d83165ad
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Fri Jun 2 18:20:09 2017 +0300

    sync: Disable sync in app mode and incognito mode

 src/ephy-shell.c                  |   35 ++++++++++++++++++++++-------------
 src/prefs-dialog.c                |   16 +++++++++++++---
 src/resources/gtk/prefs-dialog.ui |    2 +-
 3 files changed, 36 insertions(+), 17 deletions(-)
---
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 894a017..886f639 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -313,6 +313,8 @@ static void
 ephy_shell_startup (GApplication *application)
 {
   EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (application);
+  EphyShell *shell = EPHY_SHELL (application);
+  EphySynchronizableManager *manager;
   EphyEmbedShellMode mode;
   GtkBuilder *builder;
 
@@ -339,25 +341,29 @@ ephy_shell_startup (GApplication *application)
       g_action_map_add_action_entries (G_ACTION_MAP (application),
                                        app_normal_mode_entries, G_N_ELEMENTS (app_normal_mode_entries),
                                        application);
-      g_object_bind_property (G_OBJECT (ephy_shell_get_session (EPHY_SHELL (application))),
+      g_object_bind_property (G_OBJECT (ephy_shell_get_session (shell)),
                               "can-undo-tab-closed",
                               g_action_map_lookup_action (G_ACTION_MAP (application),
                                                           "reopen-closed-tab"),
                               "enabled",
                               G_BINDING_SYNC_CREATE);
-    }
 
-    /* Create the sync service and register synchronizable managers. */
-    ephy_shell->sync_service = ephy_sync_service_new (TRUE);
-    if (g_settings_get_boolean (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_BOOKMARKS_ENABLED))
-      ephy_sync_service_register_manager (ephy_shell->sync_service,
-                                          EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_bookmarks_manager 
(ephy_shell)));
-    if (g_settings_get_boolean (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_PASSWORDS_ENABLED))
-      ephy_sync_service_register_manager (ephy_shell->sync_service,
-                                          EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_password_manager 
(ephy_shell)));
-    if (g_settings_get_boolean (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_HISTORY_ENABLED))
-      ephy_sync_service_register_manager (ephy_shell->sync_service,
-                                          EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_history_manager 
(ephy_shell)));
+      /* Register the synchronizable managers. */
+      if (g_settings_get_boolean (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_BOOKMARKS_ENABLED)) {
+        manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_bookmarks_manager (shell));
+        ephy_sync_service_register_manager (ephy_shell_get_sync_service (shell), manager);
+      }
+
+      if (g_settings_get_boolean (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_PASSWORDS_ENABLED)) {
+        manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_password_manager (shell));
+        ephy_sync_service_register_manager (ephy_shell_get_sync_service (shell), manager);
+      }
+
+      if (g_settings_get_boolean (EPHY_SETTINGS_SYNC, EPHY_PREFS_SYNC_HISTORY_ENABLED)) {
+        manager = EPHY_SYNCHRONIZABLE_MANAGER (ephy_shell_get_history_manager (shell));
+        ephy_sync_service_register_manager (ephy_shell_get_sync_service (shell), manager);
+      }
+    }
 
     gtk_application_set_app_menu (GTK_APPLICATION (application),
                                   G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
@@ -793,6 +799,9 @@ ephy_shell_get_sync_service (EphyShell *shell)
 {
   g_return_val_if_fail (EPHY_IS_SHELL (shell), NULL);
 
+  if (shell->sync_service == NULL)
+    shell->sync_service = ephy_sync_service_new (TRUE);
+
   return shell->sync_service;
 }
 
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 78d5b6e..75fce2a 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -62,6 +62,8 @@ enum {
 struct _PrefsDialog {
   GtkDialog parent_instance;
 
+  GtkWidget *notebook;
+
   /* general */
   GtkWidget *homepage_box;
   GtkWidget *new_tab_homepage_radiobutton;
@@ -166,8 +168,10 @@ 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)
-    ephy_sync_service_start_periodical_sync (dialog->sync_service);
+  if (dialog->sync_service != NULL) {
+    if (ephy_sync_service_is_signed_in (dialog->sync_service) && !dialog->sync_was_signed_in)
+      ephy_sync_service_start_periodical_sync (dialog->sync_service);
+  }
 
   G_OBJECT_CLASS (prefs_dialog_parent_class)->finalize (object);
 }
@@ -597,6 +601,9 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class,
                                                "/org/gnome/epiphany/gtk/prefs-dialog.ui");
+
+  gtk_widget_class_bind_template_child (widget_class, PrefsDialog, notebook);
+
   /* general */
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, homepage_box);
   gtk_widget_class_bind_template_child (widget_class, PrefsDialog, new_tab_homepage_radiobutton);
@@ -1797,7 +1804,10 @@ prefs_dialog_init (PrefsDialog *dialog)
   setup_fonts_page (dialog);
   setup_stored_data_page (dialog);
   setup_language_page (dialog);
-  if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION)
+
+  if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION || mode == EPHY_EMBED_SHELL_MODE_INCOGNITO)
+    gtk_notebook_remove_page (GTK_NOTEBOOK (dialog->notebook), -1);
+  else
     setup_sync_page (dialog);
 
   ephy_gui_ensure_window_group (GTK_WINDOW (dialog));
diff --git a/src/resources/gtk/prefs-dialog.ui b/src/resources/gtk/prefs-dialog.ui
index db6911f..1db23d1 100644
--- a/src/resources/gtk/prefs-dialog.ui
+++ b/src/resources/gtk/prefs-dialog.ui
@@ -21,7 +21,7 @@
         <property name="spacing">2</property>
         <property name="border_width">0</property>
         <child>
-          <object class="GtkNotebook">
+          <object class="GtkNotebook" id="notebook">
             <property name="visible">True</property>
             <property name="show_border">False</property>
             <child>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]