[gnote] Do not access singleton IGnote in pretty_print_date



commit 0f7f3499b3948379bb8138d61c480d8ab357e6eb
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Dec 8 18:46:33 2019 +0200

    Do not access singleton IGnote in pretty_print_date

 src/searchnoteswidget.cpp | 5 ++---
 src/utils.cpp             | 6 ++----
 src/utils.hpp             | 6 +++++-
 3 files changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/src/searchnoteswidget.cpp b/src/searchnoteswidget.cpp
index c7ab2ba4..561d6eda 100644
--- a/src/searchnoteswidget.cpp
+++ b/src/searchnoteswidget.cpp
@@ -514,7 +514,7 @@ void SearchNotesWidget::update_results()
 
   for(const NoteBase::Ptr & note_iter : m_manager.get_notes()) {
     Note::Ptr note(std::static_pointer_cast<Note>(note_iter));
-    Glib::ustring nice_date = utils::get_pretty_print_date(note->change_date(), true);
+    Glib::ustring nice_date = utils::get_pretty_print_date(note->change_date(), true, m_gnote.preferences());
 
     Gtk::TreeIter iter = m_store->append();
     iter->set_value(0, get_note_icon(m_gnote.icon_manager()));  /* icon */
@@ -1189,8 +1189,7 @@ void SearchNotesWidget::delete_note(const Note::Ptr & note)
 
 void SearchNotesWidget::add_note(const Note::Ptr & note)
 {
-  Glib::ustring nice_date =
-    utils::get_pretty_print_date(note->change_date(), true);
+  Glib::ustring nice_date = utils::get_pretty_print_date(note->change_date(), true, m_gnote.preferences());
   Gtk::TreeIter iter = m_store->append();
   iter->set_value(m_column_types.icon, get_note_icon(m_gnote.icon_manager()));
   iter->set_value(m_column_types.title, note->get_title());
diff --git a/src/utils.cpp b/src/utils.cpp
index 190c9602..cf76e25b 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -42,7 +42,6 @@
 #include "sharp/string.hpp"
 #include "sharp/uri.hpp"
 #include "sharp/datetime.hpp"
-#include "ignote.hpp"
 #include "preferences.hpp"
 #include "note.hpp"
 #include "utils.hpp"
@@ -183,12 +182,11 @@ namespace gnote {
       dialog.run ();
     }
 
-    Glib::ustring get_pretty_print_date(const sharp::DateTime & date, bool show_time)
+    Glib::ustring get_pretty_print_date(const sharp::DateTime & date, bool show_time, Preferences & 
preferences)
     {
       bool use_12h = false;
       if(show_time) {
-        use_12h = IGnote::obj().preferences().get_schema_settings(
-          Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE)->get_string(
+        use_12h = preferences.get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE)->get_string(
             Preferences::DESKTOP_GNOME_CLOCK_FORMAT) == "12h";
       }
       return get_pretty_print_date(date, show_time, use_12h);
diff --git a/src/utils.hpp b/src/utils.hpp
index 93e90d35..a0cb3047 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -46,6 +46,10 @@ namespace sharp {
 }
 
 namespace gnote {
+
+class Preferences;
+
+
   namespace utils {
 
     void popup_menu(Gtk::Menu &menu, const GdkEventButton *);
@@ -55,7 +59,7 @@ namespace gnote {
     void show_opening_location_error(Gtk::Window * parent,
                                      const Glib::ustring & url,
                                      const Glib::ustring & error);
-    Glib::ustring get_pretty_print_date(const sharp::DateTime &, bool show_time);
+    Glib::ustring get_pretty_print_date(const sharp::DateTime &, bool show_time, Preferences & preferences);
     Glib::ustring get_pretty_print_date(const sharp::DateTime &, bool show_time, bool use_12h);
 
     void main_context_invoke(const sigc::slot<void> & slot);


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