[gnote] Make GnoteCommandLine have pointer to NoteManager



commit 3f479b47f943e3788572d89622dc66d0937eb59e
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Oct 6 21:29:56 2019 +0300

    Make GnoteCommandLine have pointer to NoteManager

 src/gnote.cpp | 29 +++++++++++++++++------------
 src/gnote.hpp |  7 ++++++-
 2 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 057ff655..a8a6b50a 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -87,8 +87,8 @@ namespace gnote {
     }
 
     if(handle) {
-      cmd_line.parse(argc, argv);
-      cmd_line.immediate_execute();
+      m_cmd_line.parse(argc, argv);
+      m_cmd_line.immediate_execute();
       return 0;
     }
 
@@ -113,19 +113,22 @@ namespace gnote {
     int argc = 0;
     char **argv = command_line->get_arguments(argc);
     GnoteCommandLine passed_cmd_line;
-    GnoteCommandLine &cmdline = m_manager ? passed_cmd_line : cmd_line;
+    GnoteCommandLine &cmdline = m_manager ? passed_cmd_line : m_cmd_line;
     cmdline.parse(argc, argv);
     m_is_background = cmdline.background();
-    m_is_shell_search = cmd_line.shell_search();
+    m_is_shell_search = m_cmd_line.shell_search();
     if(!m_manager) {
       common_init();
       register_object();
     }
-    else if(cmdline.needs_execute()) {
-      cmdline.execute();
-    }
-    else if(!(cmdline.background() || cmdline.shell_search())) {
-      new_main_window().present();
+    else {
+      cmdline.set_note_manager(*m_manager);
+      if(cmdline.needs_execute()) {
+        cmdline.execute();
+      }
+      else if(!(cmdline.background() || cmdline.shell_search())) {
+        new_main_window().present();
+      }
     }
 
     g_strfreev(argv);
@@ -135,7 +138,7 @@ namespace gnote {
 
   void Gnote::common_init()
   {
-    Glib::ustring note_path = get_note_path(cmd_line.note_path());
+    Glib::ustring note_path = get_note_path(m_cmd_line.note_path());
 
     //create singleton objects
     new TagManager;
@@ -151,8 +154,9 @@ namespace gnote {
 
   void Gnote::end_main(bool bus_acquired, bool name_acquired)
   {
-    if(cmd_line.needs_execute()) {
-      cmd_line.execute();
+    m_cmd_line.set_note_manager(*m_manager);
+    if(m_cmd_line.needs_execute()) {
+      m_cmd_line.execute();
     }
 
     if(bus_acquired) {
@@ -491,6 +495,7 @@ namespace gnote {
 
   GnoteCommandLine::GnoteCommandLine()
     : m_context(g_option_context_new("Foobar"))
+    , m_manager(NULL)
     , m_use_panel(false)
     , m_background(false)
     , m_shell_search(false)
diff --git a/src/gnote.hpp b/src/gnote.hpp
index 86f848bc..cae59ee1 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -46,6 +46,10 @@ class GnoteCommandLine
 public:
   GnoteCommandLine();
   ~GnoteCommandLine();
+  void set_note_manager(NoteManagerBase & manager)
+    {
+      m_manager = &manager;
+    }
   int execute();
   int immediate_execute();
 
@@ -78,6 +82,7 @@ private:
 
   GOptionContext *m_context;
 
+  NoteManagerBase *m_manager;
   bool        m_use_panel;
   bool        m_background;
   bool        m_shell_search;
@@ -164,7 +169,7 @@ private:
   bool m_is_background;
   bool m_is_shell_search;
   PreferencesDialog *m_prefsdlg;
-  GnoteCommandLine cmd_line;
+  GnoteCommandLine m_cmd_line;
   sync::SyncDialog::Ptr m_sync_dlg;
 };
 


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