[gnote] Make IconManager non-singleton
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Make IconManager non-singleton
- Date: Sun, 29 Sep 2019 12:53:01 +0000 (UTC)
commit b06441fc845e5e64e1597c557da1809a7cbbc5f7
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sun Sep 29 15:47:54 2019 +0300
Make IconManager non-singleton
src/dbus/searchprovider.cpp | 2 +-
src/gnote.cpp | 3 +--
src/gnote.hpp | 6 ++++++
src/iconmanager.cpp | 5 +----
src/iconmanager.hpp | 7 +------
src/ignote.hpp | 8 +++++++-
src/notebooks/createnotebookdialog.cpp | 5 +++--
src/notebooks/notebooknewnotemenuitem.cpp | 5 +++--
src/notebooks/specialnotebooks.cpp | 9 +++++----
src/notewindow.cpp | 5 +++--
src/searchnoteswidget.cpp | 5 +++--
src/sharp/addinstreemodel.cpp | 5 +++--
src/synchronization/syncdialog.cpp | 2 +-
13 files changed, 38 insertions(+), 29 deletions(-)
---
diff --git a/src/dbus/searchprovider.cpp b/src/dbus/searchprovider.cpp
index 59072a84..1fc5c082 100644
--- a/src/dbus/searchprovider.cpp
+++ b/src/dbus/searchprovider.cpp
@@ -233,7 +233,7 @@ Glib::VariantContainerBase SearchProvider::LaunchSearch_stub(const Glib::Variant
gchar *SearchProvider::get_icon()
{
if(!m_note_icon) {
- Gtk::IconInfo info = gnote::IconManager::obj().lookup_icon(gnote::IconManager::NOTE, 48);
+ Gtk::IconInfo info = gnote::IGnote::obj().icon_manager().lookup_icon(gnote::IconManager::NOTE, 48);
m_note_icon = Gio::Icon::create(info.get_filename());
}
diff --git a/src/gnote.cpp b/src/gnote.cpp
index bc647123..150227ed 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2018 Aurimas Cernius
+ * Copyright (C) 2010-2019 Aurimas Cernius
* Copyright (C) 2010 Debarshi Ray
* Copyright (C) 2009 Hubert Figuiere
*
@@ -41,7 +41,6 @@
#include "addinmanager.hpp"
#include "applicationaddin.hpp"
#include "debug.hpp"
-#include "iconmanager.hpp"
#include "notemanager.hpp"
#include "notewindow.hpp"
#include "preferencesdialog.hpp"
diff --git a/src/gnote.hpp b/src/gnote.hpp
index 9f52583f..86f848bc 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -30,6 +30,7 @@
#include <gtkmm/statusicon.h>
#include "actionmanager.hpp"
+#include "iconmanager.hpp"
#include "ignote.hpp"
#include "remotecontrolproxy.hpp"
#include "synchronization/syncdialog.hpp"
@@ -114,6 +115,10 @@ public:
{
return *m_manager;
}
+ virtual IconManager & icon_manager() override
+ {
+ return m_icon_manager;
+ }
void on_preferences_response(int res);
void on_show_preferences_action(const Glib::VariantBase&);
@@ -154,6 +159,7 @@ private:
void register_object();
NoteManager *m_manager;
+ IconManager m_icon_manager;
Glib::RefPtr<Gtk::IconTheme> m_icon_theme;
bool m_is_background;
bool m_is_shell_search;
diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp
index 198ffdc6..0fb94a10 100644
--- a/src/iconmanager.cpp
+++ b/src/iconmanager.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012-2013,2017 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017,2019 Aurimas Cernius
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -43,9 +43,6 @@ const char *IconManager::PIN_UP = "pin-up";
const char *IconManager::ACTIVE_NOTES = "active-notes";
const char *IconManager::SPECIAL_NOTES = "special-notes";
-//instance
-IconManager IconManager::s_obj;
-
Glib::RefPtr<Gdk::Pixbuf> IconManager::get_icon(const Glib::ustring & name, int size)
{
diff --git a/src/iconmanager.hpp b/src/iconmanager.hpp
index e67e78a5..420c8b80 100644
--- a/src/iconmanager.hpp
+++ b/src/iconmanager.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012-2013,2017 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017,2019 Aurimas Cernius
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,13 +23,10 @@
#include <glibmm/refptr.h>
#include <gtkmm/iconinfo.h>
-#include "base/singleton.hpp"
-
namespace gnote {
class IconManager
- : public base::Singleton<IconManager>
{
public:
static const char *BUG;
@@ -54,8 +51,6 @@ private:
typedef std::map<IconDef, Glib::RefPtr<Gdk::Pixbuf> > IconMap;
IconMap m_icons;
-
- static IconManager s_obj;
};
}
diff --git a/src/ignote.hpp b/src/ignote.hpp
index e2a27998..71f82e80 100644
--- a/src/ignote.hpp
+++ b/src/ignote.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2013,2016-2017 Aurimas Cernius
+ * Copyright (C) 2013,2016-2017,2019 Aurimas Cernius
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -25,6 +25,9 @@
namespace gnote {
+class IconManager;
+
+
class IGnote
: public base::Singleton<IGnote>
{
@@ -35,6 +38,9 @@ public:
static Glib::ustring old_note_dir();
virtual ~IGnote();
+
+ virtual IconManager & icon_manager() = 0;
+
virtual MainWindow & get_main_window() = 0;
virtual MainWindow & get_window_for_note() = 0;
virtual MainWindow & new_main_window() = 0;
diff --git a/src/notebooks/createnotebookdialog.cpp b/src/notebooks/createnotebookdialog.cpp
index 511038bc..b53395b2 100644
--- a/src/notebooks/createnotebookdialog.cpp
+++ b/src/notebooks/createnotebookdialog.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2012-2013,2017 Aurimas Cernius
+ * Copyright (C) 2012-2013,2017,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -28,6 +28,7 @@
#include "notebooks/createnotebookdialog.hpp"
#include "notebooks/notebookmanager.hpp"
#include "iconmanager.hpp"
+#include "ignote.hpp"
#include "utils.hpp"
namespace gnote {
@@ -63,7 +64,7 @@ namespace gnote {
set_extra_widget(table);
add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL, false);
- add_button (IconManager::obj().get_icon(IconManager::NOTEBOOK_NEW, 16),
+ add_button (IGnote::obj().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);
diff --git a/src/notebooks/notebooknewnotemenuitem.cpp b/src/notebooks/notebooknewnotemenuitem.cpp
index 94028e92..b4b01d6c 100644
--- a/src/notebooks/notebooknewnotemenuitem.cpp
+++ b/src/notebooks/notebooknewnotemenuitem.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010,2012-2013,2017 Aurimas Cernius
+ * Copyright (C) 2010,2012-2013,2017,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -25,6 +25,7 @@
#include "sharp/string.hpp"
#include "iconmanager.hpp"
+#include "ignote.hpp"
#include "mainwindow.hpp"
#include "note.hpp"
#include "notemanager.hpp"
@@ -40,7 +41,7 @@ namespace gnote {
: Gtk::ImageMenuItem(Glib::ustring::compose(_("New \"%1\" Note"), notebook->get_name()))
, m_notebook(notebook)
{
- set_image(*manage(new Gtk::Image(IconManager::obj().get_icon(IconManager::NOTE_NEW, 16))));
+ set_image(*manage(new Gtk::Image(IGnote::obj().icon_manager().get_icon(IconManager::NOTE_NEW, 16))));
signal_activate().connect(sigc::mem_fun(*this, &NotebookNewNoteMenuItem::on_activated));
}
diff --git a/src/notebooks/specialnotebooks.cpp b/src/notebooks/specialnotebooks.cpp
index 25a28f7a..8ffed7f0 100644
--- a/src/notebooks/specialnotebooks.cpp
+++ b/src/notebooks/specialnotebooks.cpp
@@ -22,6 +22,7 @@
#include <glibmm/i18n.h>
#include "iconmanager.hpp"
+#include "ignote.hpp"
#include "notemanager.hpp"
#include "notebookmanager.hpp"
#include "specialnotebooks.hpp"
@@ -67,7 +68,7 @@ bool AllNotesNotebook::add_note(const Note::Ptr &)
Glib::RefPtr<Gdk::Pixbuf> AllNotesNotebook::get_icon()
{
- return IconManager::obj().get_icon(IconManager::FILTER_NOTE_ALL, 22);
+ return IGnote::obj().icon_manager().get_icon(IconManager::FILTER_NOTE_ALL, 22);
}
@@ -98,7 +99,7 @@ bool UnfiledNotesNotebook::add_note(const Note::Ptr & note)
Glib::RefPtr<Gdk::Pixbuf> UnfiledNotesNotebook::get_icon()
{
- return IconManager::obj().get_icon(IconManager::FILTER_NOTE_UNFILED, 22);
+ return IGnote::obj().icon_manager().get_icon(IconManager::FILTER_NOTE_UNFILED, 22);
}
@@ -125,7 +126,7 @@ bool PinnedNotesNotebook::add_note(const Note::Ptr & note)
Glib::RefPtr<Gdk::Pixbuf> PinnedNotesNotebook::get_icon()
{
- return IconManager::obj().get_icon(IconManager::PIN_DOWN, 22);
+ return IGnote::obj().icon_manager().get_icon(IconManager::PIN_DOWN, 22);
}
@@ -161,7 +162,7 @@ bool ActiveNotesNotebook::add_note(const Note::Ptr & note)
Glib::RefPtr<Gdk::Pixbuf> ActiveNotesNotebook::get_icon()
{
- return IconManager::obj().get_icon(IconManager::ACTIVE_NOTES, 22);
+ return IGnote::obj().icon_manager().get_icon(IconManager::ACTIVE_NOTES, 22);
}
void ActiveNotesNotebook::on_note_deleted(const NoteBase::Ptr & note)
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 0b7e87cf..2eb530d0 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -34,6 +34,7 @@
#include "debug.hpp"
#include "addinmanager.hpp"
#include "iconmanager.hpp"
+#include "ignote.hpp"
#include "mainwindow.hpp"
#include "note.hpp"
#include "notewindow.hpp"
@@ -53,12 +54,12 @@ namespace gnote {
Glib::RefPtr<Gio::Icon> NoteWindow::get_icon_pin_active()
{
- return IconManager::obj().get_icon(IconManager::PIN_ACTIVE, 22);
+ return IGnote::obj().icon_manager().get_icon(IconManager::PIN_ACTIVE, 22);
}
Glib::RefPtr<Gio::Icon> NoteWindow::get_icon_pin_down()
{
- return IconManager::obj().get_icon(IconManager::PIN_DOWN, 22);
+ return IGnote::obj().icon_manager().get_icon(IconManager::PIN_DOWN, 22);
}
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index e83c0984..c1d3150a 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -30,6 +30,7 @@
#include "debug.hpp"
#include "iactionmanager.hpp"
#include "iconmanager.hpp"
+#include "ignote.hpp"
#include "mainwindow.hpp"
#include "notemanager.hpp"
#include "notewindow.hpp"
@@ -47,7 +48,7 @@ namespace gnote {
Glib::RefPtr<Gdk::Pixbuf> SearchNotesWidget::get_note_icon()
{
- return IconManager::obj().get_icon(IconManager::NOTE, 22);
+ return IGnote::obj().icon_manager().get_icon(IconManager::NOTE, 22);
}
@@ -301,7 +302,7 @@ void SearchNotesWidget::notebook_pixbuf_cell_data_func(Gtk::CellRenderer * rende
crp->property_pixbuf() = special_nb->get_icon();
}
else {
- crp->property_pixbuf() = IconManager::obj().get_icon(IconManager::NOTEBOOK, 22);
+ crp->property_pixbuf() = IGnote::obj().icon_manager().get_icon(IconManager::NOTEBOOK, 22);
}
}
diff --git a/src/sharp/addinstreemodel.cpp b/src/sharp/addinstreemodel.cpp
index 1baaa1bf..5b727c15 100644
--- a/src/sharp/addinstreemodel.cpp
+++ b/src/sharp/addinstreemodel.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010,2012-2013,2017 Aurimas Cernius
+ * Copyright (C) 2010,2012-2013,2017,2019 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -30,6 +30,7 @@
#include "sharp/addinstreemodel.hpp"
#include "abstractaddin.hpp"
#include "iconmanager.hpp"
+#include "ignote.hpp"
namespace sharp {
@@ -98,7 +99,7 @@ namespace sharp {
Gtk::CellRendererPixbuf *icon_renderer = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
Glib::RefPtr<Gdk::Pixbuf> icon;
if(get_module_id(iter) != "") {
- icon = gnote::IconManager::obj().get_icon(gnote::IconManager::EMBLEM_PACKAGE, 22);
+ icon = gnote::IGnote::obj().icon_manager().get_icon(gnote::IconManager::EMBLEM_PACKAGE, 22);
}
icon_renderer->property_pixbuf() = icon;
}
diff --git a/src/synchronization/syncdialog.cpp b/src/synchronization/syncdialog.cpp
index 2382aedc..14fca1e2 100644
--- a/src/synchronization/syncdialog.cpp
+++ b/src/synchronization/syncdialog.cpp
@@ -245,7 +245,7 @@ SyncDialog::SyncDialog(NoteManagerBase & manager)
hbox->show();
outerVBox->attach(*hbox, 0, outerVBoxRow++, 1, 1);
- m_image = manage(new Gtk::Image(IconManager::obj().get_icon(IconManager::GNOTE, 48)));
+ m_image = manage(new Gtk::Image(IGnote::obj().icon_manager().get_icon(IconManager::GNOTE, 48)));
m_image->set_alignment(0, 0);
m_image->show();
hbox->attach(*m_image, 0, 0, 1, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]