[gnote] Only connect a single callback for format and make format static
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Only connect a single callback for format and make format static
- Date: Tue, 5 Jan 2021 18:51:43 +0000 (UTC)
commit 6af9833ef6862e6eb930c8a3998f35453a3f0a69
Author: Aurimas Černius <aurisc4 gmail com>
Date: Tue Jan 5 20:51:31 2021 +0200
Only connect a single callback for format and make format static
src/addins/inserttimestamp/inserttimestampnoteaddin.cpp | 14 ++++++++------
src/addins/inserttimestamp/inserttimestampnoteaddin.hpp | 10 ++++++----
2 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
b/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
index a7965169..5c7ef4ba 100644
--- a/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
+++ b/src/addins/inserttimestamp/inserttimestampnoteaddin.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2013,2016-2017,2019-2020 Aurimas Cernius
+ * Copyright (C) 2010-2013,2016-2017,2019-2021 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -55,9 +55,11 @@ namespace inserttimestamp {
register_main_window_action_callback("inserttimestamp-insert",
sigc::mem_fun(*this, &InsertTimestampNoteAddin::on_menu_item_activated));
- InsertTimestampPreferences::settings()->signal_changed(INSERT_TIMESTAMP_FORMAT).connect(
- sigc::mem_fun(*this, &InsertTimestampNoteAddin::on_format_setting_changed));
- m_date_format = InsertTimestampPreferences::settings()->get_string(INSERT_TIMESTAMP_FORMAT);
+ if(s_on_format_setting_changed_cid.empty()) {
+ s_on_format_setting_changed_cid =
InsertTimestampPreferences::settings()->signal_changed(INSERT_TIMESTAMP_FORMAT)
+ .connect(sigc::ptr_fun(InsertTimestampNoteAddin::on_format_setting_changed));
+ s_date_format = InsertTimestampPreferences::settings()->get_string(INSERT_TIMESTAMP_FORMAT);
+ }
}
@@ -72,7 +74,7 @@ namespace inserttimestamp {
void InsertTimestampNoteAddin::on_menu_item_activated(const Glib::VariantBase&)
{
- Glib::ustring text = sharp::date_time_to_string(Glib::DateTime::create_now_local(), m_date_format);
+ Glib::ustring text = sharp::date_time_to_string(Glib::DateTime::create_now_local(), s_date_format);
Gtk::TextIter cursor = get_buffer()->get_iter_at_mark (get_buffer()->get_insert());
std::vector<Glib::ustring> names;
names.push_back("datetime");
@@ -82,7 +84,7 @@ namespace inserttimestamp {
void InsertTimestampNoteAddin::on_format_setting_changed(const Glib::ustring &)
{
- m_date_format = InsertTimestampPreferences::settings()->get_string(INSERT_TIMESTAMP_FORMAT);
+ s_date_format = InsertTimestampPreferences::settings()->get_string(INSERT_TIMESTAMP_FORMAT);
}
}
diff --git a/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
b/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
index a8891182..26814182 100644
--- a/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
+++ b/src/addins/inserttimestamp/inserttimestampnoteaddin.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010,2013,2016-2017,2019 Aurimas Cernius
+ * Copyright (C) 2010,2013,2016-2017,2019,2021 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -54,10 +54,12 @@ public:
virtual void on_note_opened() override;
virtual std::vector<gnote::PopoverWidget> get_actions_popover_widgets() const override;
private:
- void on_menu_item_activated(const Glib::VariantBase&);
- void on_format_setting_changed(const Glib::ustring & key);
+ static void on_format_setting_changed(const Glib::ustring & key);
+
+ static Glib::ustring s_date_format;
+ static sigc::connection s_on_format_setting_changed_cid;
- Glib::ustring m_date_format;
+ void on_menu_item_activated(const Glib::VariantBase&);
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]