[gnote] Do not use singleton IGnote in CreateNotebookDialog



commit a038b609b5bbdd972e4fbc807c94caac947d1b6f
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Mon Dec 9 22:40:53 2019 +0200

    Do not use singleton IGnote in CreateNotebookDialog

 src/notebooks/createnotebookdialog.cpp | 7 ++++---
 src/notebooks/createnotebookdialog.hpp | 8 ++++++--
 src/notebooks/notebookmanager.cpp      | 4 +---
 3 files changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/src/notebooks/createnotebookdialog.cpp b/src/notebooks/createnotebookdialog.cpp
index c882a9df..737ca1fc 100644
--- a/src/notebooks/createnotebookdialog.cpp
+++ b/src/notebooks/createnotebookdialog.cpp
@@ -34,8 +34,9 @@
 namespace gnote {
   namespace notebooks {
 
-    CreateNotebookDialog::CreateNotebookDialog(Gtk::Window *parent, GtkDialogFlags f)
+    CreateNotebookDialog::CreateNotebookDialog(Gtk::Window *parent, GtkDialogFlags f, IGnote & g)
       : utils::HIGMessageDialog(parent, f, Gtk::MESSAGE_OTHER, Gtk::BUTTONS_NONE)
+      , m_gnote(g)
     {
       set_title(_("Create Notebook"));
       Gtk::Table *table = manage(new Gtk::Table (2, 2, false));
@@ -64,7 +65,7 @@ namespace gnote {
       set_extra_widget(table);
       
       add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL, false);
-      add_button (IGnote::obj().icon_manager().get_icon(IconManager::NOTEBOOK_NEW, 16),
+      add_button (m_gnote.icon_manager().get_icon(IconManager::NOTEBOOK_NEW, 16),
                   // Translation note: This is the Create button in the Create
                   // New Note Dialog.
                   _("C_reate"), Gtk::RESPONSE_OK, true);
@@ -92,7 +93,7 @@ namespace gnote {
     void CreateNotebookDialog::on_name_entry_changed()
     {
       bool nameTaken = false;
-      if(IGnote::obj().notebook_manager().notebook_exists(get_notebook_name())) {
+      if(m_gnote.notebook_manager().notebook_exists(get_notebook_name())) {
         m_errorLabel.show ();
         nameTaken = true;
       } 
diff --git a/src/notebooks/createnotebookdialog.hpp b/src/notebooks/createnotebookdialog.hpp
index b0e62080..2c4964e0 100644
--- a/src/notebooks/createnotebookdialog.hpp
+++ b/src/notebooks/createnotebookdialog.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2017 Aurimas Cernius
+ * Copyright (C) 2017,2019 Aurimas Cernius
  * Copyright (C) 2009 Hubert Figuiere
  *
  * This program is free software: you can redistribute it and/or modify
@@ -31,6 +31,9 @@
 #include "utils.hpp"
 
 namespace gnote {
+
+class IGnote;
+
   namespace notebooks {
 
 
@@ -38,13 +41,14 @@ class CreateNotebookDialog
   : public utils::HIGMessageDialog
 {
 public:
-  CreateNotebookDialog(Gtk::Window *parent, GtkDialogFlags f);
+  CreateNotebookDialog(Gtk::Window *parent, GtkDialogFlags f, IGnote & g);
 
   Glib::ustring get_notebook_name();
   void set_notebook_name(const Glib::ustring &);
 
 private:
   void on_name_entry_changed();
+  IGnote &                  m_gnote;
   Gtk::Entry                m_nameEntry;
   Gtk::Label                m_errorLabel;
   Glib::RefPtr<Gdk::Pixbuf> m_newNotebookIcon;
diff --git a/src/notebooks/notebookmanager.cpp b/src/notebooks/notebookmanager.cpp
index 0b0d1f2f..d88e2230 100644
--- a/src/notebooks/notebookmanager.cpp
+++ b/src/notebooks/notebookmanager.cpp
@@ -315,9 +315,7 @@ namespace gnote {
                                                               const Note::List & notesToAdd)
     {
       // Prompt the user for the name of a new notebook
-      CreateNotebookDialog dialog(parent,
-                                  (GtkDialogFlags)(GTK_DIALOG_MODAL
-                                                   | GTK_DIALOG_DESTROY_WITH_PARENT));
+      CreateNotebookDialog dialog(parent, (GtkDialogFlags)(GTK_DIALOG_MODAL | 
GTK_DIALOG_DESTROY_WITH_PARENT), IGnote::obj());
       
       
       int response = dialog.run ();


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