[gnote] Do not use singleton gnote in notebooks
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Do not use singleton gnote in notebooks
- Date: Sun, 15 Dec 2019 12:11:00 +0000 (UTC)
commit 10acafb72c806d01e4f47ec06d98206869ce4ff5
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Dec 15 14:09:54 2019 +0200
Do not use singleton gnote in notebooks
src/notebooks/notebookmenuitem.cpp | 6 +++---
src/notebooks/notebookmenuitem.hpp | 8 ++++++--
src/notebooks/notebooknewnotemenuitem.cpp | 9 +++++----
src/notebooks/notebooknewnotemenuitem.hpp | 5 ++++-
4 files changed, 18 insertions(+), 10 deletions(-)
---
diff --git a/src/notebooks/notebookmenuitem.cpp b/src/notebooks/notebookmenuitem.cpp
index 9a645830..6dc70bae 100644
--- a/src/notebooks/notebookmenuitem.cpp
+++ b/src/notebooks/notebookmenuitem.cpp
@@ -24,17 +24,17 @@
#include "notebooks/notebookmenuitem.hpp"
#include "notebooks/notebookmanager.hpp"
-#include "ignote.hpp"
namespace gnote {
namespace notebooks {
- NotebookMenuItem::NotebookMenuItem(const Note::Ptr & note, const Notebook::Ptr & notebook)
+ NotebookMenuItem::NotebookMenuItem(const Note::Ptr & note, const Notebook::Ptr & notebook,
NotebookManager & manager)
: Gtk::CheckMenuItem(notebook ? notebook->get_name() : _("No notebook"))
, m_note(note)
, m_notebook(notebook)
+ , m_notebook_manager(manager)
{
signal_activate().connect(sigc::mem_fun(*this, &NotebookMenuItem::on_activated));
}
@@ -46,7 +46,7 @@ namespace gnote {
return;
}
- IGnote::obj().notebook_manager().move_note_to_notebook(m_note, m_notebook);
+ m_notebook_manager.move_note_to_notebook(m_note, m_notebook);
}
// the menu item is comparable.
diff --git a/src/notebooks/notebookmenuitem.hpp b/src/notebooks/notebookmenuitem.hpp
index 34c0b65b..62275761 100644
--- a/src/notebooks/notebookmenuitem.hpp
+++ b/src/notebooks/notebookmenuitem.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2015 Aurimas Cernius
+ * Copyright (C) 2015,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -33,11 +33,14 @@
namespace gnote {
namespace notebooks {
+ class NotebookManager;
+
+
class NotebookMenuItem
: public Gtk::CheckMenuItem
{
public:
- NotebookMenuItem(const Note::Ptr &, const Notebook::Ptr &);
+ NotebookMenuItem(const Note::Ptr &, const Notebook::Ptr &, NotebookManager &);
const Note::Ptr & get_note() const
{
@@ -56,6 +59,7 @@ namespace gnote {
Note::Ptr m_note;
Notebook::Ptr m_notebook;
+ NotebookManager & m_notebook_manager;
};
}
diff --git a/src/notebooks/notebooknewnotemenuitem.cpp b/src/notebooks/notebooknewnotemenuitem.cpp
index 04a6047f..126d5fea 100644
--- a/src/notebooks/notebooknewnotemenuitem.cpp
+++ b/src/notebooks/notebooknewnotemenuitem.cpp
@@ -36,12 +36,13 @@
namespace gnote {
namespace notebooks {
- NotebookNewNoteMenuItem::NotebookNewNoteMenuItem(const Notebook::Ptr & notebook)
+ NotebookNewNoteMenuItem::NotebookNewNoteMenuItem(const Notebook::Ptr & notebook, IGnote & g)
// TRANSLATORS: %1: format placeholder for the notebook name
: Gtk::ImageMenuItem(Glib::ustring::compose(_("New \"%1\" Note"), notebook->get_name()))
, m_notebook(notebook)
+ , m_gnote(g)
{
- set_image(*manage(new Gtk::Image(IGnote::obj().icon_manager().get_icon(IconManager::NOTE_NEW, 16))));
+ set_image(*manage(new Gtk::Image(g.icon_manager().get_icon(IconManager::NOTE_NEW, 16))));
signal_activate().connect(sigc::mem_fun(*this, &NotebookNewNoteMenuItem::on_activated));
}
@@ -55,8 +56,8 @@ namespace gnote {
// Look for the template note and create a new note
Note::Ptr note = m_notebook->create_notebook_note ();
- MainWindow::present_in_new_window(IGnote::obj(), note,
- IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
+ MainWindow::present_in_new_window(m_gnote, note,
+ m_gnote.preferences().get_schema_settings(Preferences::SCHEMA_GNOTE)->get_boolean(
Preferences::ENABLE_CLOSE_NOTE_ON_ESCAPE));
}
diff --git a/src/notebooks/notebooknewnotemenuitem.hpp b/src/notebooks/notebooknewnotemenuitem.hpp
index 1b73e153..f554e722 100644
--- a/src/notebooks/notebooknewnotemenuitem.hpp
+++ b/src/notebooks/notebooknewnotemenuitem.hpp
@@ -29,6 +29,8 @@
#include "notebooks/notebook.hpp"
namespace gnote {
+ class IGnote;
+
namespace notebooks {
class NotebookMenuItem;
@@ -37,7 +39,7 @@ class NotebookNewNoteMenuItem
: public Gtk::ImageMenuItem
{
public:
- NotebookNewNoteMenuItem(const Notebook::Ptr &);
+ NotebookNewNoteMenuItem(const Notebook::Ptr &, IGnote &);
void on_activated();
Notebook::Ptr get_notebook() const
{
@@ -49,6 +51,7 @@ public:
bool operator>(const NotebookMenuItem &);
private:
Notebook::Ptr m_notebook;
+ IGnote & m_gnote;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]