[epiphany/wip/ephy-sync] Have a global sync service



commit 17bb83e6a2479927665ba983f305bdf46f81bfef
Author: Gabriel Ivascu <ivascu gabriel59 gmail com>
Date:   Mon Jun 20 13:09:45 2016 +0300

    Have a global sync service

 src/ephy-shell.c       |   33 +++++++++++++++++++++++++--------
 src/ephy-shell.h       |    2 ++
 src/ephy-sync-crypto.h |    4 ++--
 src/ephy-sync-window.c |    1 -
 src/window-commands.c  |    2 +-
 5 files changed, 30 insertions(+), 12 deletions(-)
---
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 239bdac..09565e8 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -51,6 +51,7 @@ struct _EphyShell {
   EphyEmbedShell parent_instance;
 
   EphySession *session;
+  EphySyncService *global_sync_service;
   GList *windows;
   GObject *lockdown;
   EphyBookmarks *bookmarks;
@@ -191,7 +192,7 @@ show_sync (GSimpleAction *action,
 {
   GtkWindow *window;
 
-  printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   window = gtk_application_get_active_window (GTK_APPLICATION (ephy_shell));
 
@@ -782,6 +783,26 @@ ephy_shell_get_bookmarks_editor (EphyShell *shell)
 }
 
 /**
+ * ephy_shell_get_global_sync_service:
+ *
+ * Return value: (transfer none):
+ **/
+GObject *
+ephy_shell_get_global_sync_service (EphyShell *shell)
+{
+  g_return_val_if_fail (EPHY_IS_SHELL (shell), NULL);
+
+  if (shell->global_sync_service == NULL) {
+LOG ("%s:%d", __func__, __LINE__);
+    shell->global_sync_service = ephy_sync_service_new ();
+    g_return_val_if_fail (shell->global_sync_service, NULL);
+  }
+
+LOG ("%s:%d", __func__, __LINE__);
+  return G_OBJECT (shell->global_sync_service);
+}
+
+/**
  * ephy_shell_get_history_window:
  *
  * Return value: (transfer none):
@@ -810,16 +831,11 @@ ephy_shell_get_history_window (EphyShell *shell)
 GtkWidget *
 ephy_shell_get_sync_window (EphyShell *shell)
 {
-  EphyEmbedShell *embed_shell;
   EphySyncService *sync_service;
 
-  printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
-
-  embed_shell = ephy_embed_shell_get_default ();
-  embed_shell = embed_shell; // suppress warnings
-
   if (shell->sync_window == NULL) {
-    sync_service = ephy_sync_service_new ();
+LOG ("%s:%d", __func__, __LINE__);
+    sync_service = EPHY_SYNC_SERVICE (ephy_shell_get_global_sync_service (shell));
     shell->sync_window = ephy_sync_window_new (sync_service);
     g_signal_connect (shell->sync_window,
                       "destroy",
@@ -827,6 +843,7 @@ ephy_shell_get_sync_window (EphyShell *shell)
                       &shell->sync_window);
   }
 
+LOG ("%s:%d", __func__, __LINE__);
   return shell->sync_window;
 }
 
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 1e1f139..b51e8ce 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -102,6 +102,8 @@ EphyBookmarks   *ephy_shell_get_bookmarks                (EphyShell *shell);
 
 GtkWidget       *ephy_shell_get_bookmarks_editor         (EphyShell *shell);
 
+GObject         *ephy_shell_get_global_sync_service      (EphyShell *shell);
+
 GtkWidget       *ephy_shell_get_history_window           (EphyShell *shell);
 
 GtkWidget       *ephy_shell_get_sync_window              (EphyShell *shell);
diff --git a/src/ephy-sync-crypto.h b/src/ephy-sync-crypto.h
index 7b4cb06..cb83395 100644
--- a/src/ephy-sync-crypto.h
+++ b/src/ephy-sync-crypto.h
@@ -16,8 +16,8 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef EPHY_EMBED_UTILS_H
-#define EPHY_EMBED_UTILS_H
+#ifndef EPHY_SYNC_CRYPTO_H
+#define EPHY_SYNC_CRYPTO_H
 
 #include <glib-object.h>
 
diff --git a/src/ephy-sync-window.c b/src/ephy-sync-window.c
index 7c6a257..51dc2be 100644
--- a/src/ephy-sync-window.c
+++ b/src/ephy-sync-window.c
@@ -19,7 +19,6 @@
 #include "ephy-debug.h"
 #include "ephy-gui.h"
 #include "ephy-sync-crypto.h"
-#include "ephy-sync-service.h"
 #include "ephy-sync-window.h"
 
 #include <gtk/gtk.h>
diff --git a/src/window-commands.c b/src/window-commands.c
index 78bebf2..11eb993 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -1088,7 +1088,7 @@ window_cmd_edit_sync (GtkAction  *action,
 {
   GtkWidget *swindow;
 
-  printf ("[%s:%d, %s]\n", __FILE__, __LINE__, __func__);
+LOG ("%s:%d", __func__, __LINE__);
 
   swindow = ephy_shell_get_sync_window (ephy_shell_get_default ());
 


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