[gnote] Do not statically access IGnote in export to html
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Do not statically access IGnote in export to html
- Date: Sat, 26 Oct 2019 19:53:07 +0000 (UTC)
commit 928b964c75678c08ffd5e2bae9da8362d27eecd5
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Oct 26 22:52:51 2019 +0300
Do not statically access IGnote in export to html
src/addins/exporttohtml/exporttohtmldialog.cpp | 7 ++++---
src/addins/exporttohtml/exporttohtmldialog.hpp | 10 ++++++++--
src/addins/exporttohtml/exporttohtmlnoteaddin.cpp | 4 ++--
3 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/src/addins/exporttohtml/exporttohtmldialog.cpp b/src/addins/exporttohtml/exporttohtmldialog.cpp
index 68e4fc36..bb707490 100644
--- a/src/addins/exporttohtml/exporttohtmldialog.cpp
+++ b/src/addins/exporttohtml/exporttohtmldialog.cpp
@@ -38,9 +38,10 @@ const char * EXPORTHTML_EXPORT_LINKED = "export-linked";
const char * EXPORTHTML_EXPORT_LINKED_ALL = "export-linked-all";
-ExportToHtmlDialog::ExportToHtmlDialog(const Glib::ustring & default_file)
+ExportToHtmlDialog::ExportToHtmlDialog(gnote::IGnote & ignote, const Glib::ustring & default_file)
: Gtk::FileChooserDialog(_("Destination for HTML Export"),
Gtk::FILE_CHOOSER_ACTION_SAVE)
+ , m_gnote(ignote)
, m_export_linked(_("Export linked notes"))
, m_export_linked_all(_("Include all other linked notes"))
{
@@ -95,7 +96,7 @@ void ExportToHtmlDialog::set_export_linked_all(bool value)
void ExportToHtmlDialog::save_preferences()
{
Glib::ustring dir = sharp::file_dirname(get_filename());
- Glib::RefPtr<Gio::Settings> settings =
gnote::IGnote::obj().preferences().get_schema_settings(SCHEMA_EXPORTHTML);
+ Glib::RefPtr<Gio::Settings> settings = m_gnote.preferences().get_schema_settings(SCHEMA_EXPORTHTML);
settings->set_string(EXPORTHTML_LAST_DIRECTORY, dir);
settings->set_boolean(EXPORTHTML_EXPORT_LINKED, get_export_linked());
settings->set_boolean(EXPORTHTML_EXPORT_LINKED_ALL, get_export_linked_all());
@@ -104,7 +105,7 @@ void ExportToHtmlDialog::save_preferences()
void ExportToHtmlDialog::load_preferences(const Glib::ustring & default_file)
{
- Glib::RefPtr<Gio::Settings> settings =
gnote::IGnote::obj().preferences().get_schema_settings(SCHEMA_EXPORTHTML);
+ Glib::RefPtr<Gio::Settings> settings = m_gnote.preferences().get_schema_settings(SCHEMA_EXPORTHTML);
Glib::ustring last_dir = settings->get_string(EXPORTHTML_LAST_DIRECTORY);
if (last_dir.empty()) {
last_dir = Glib::get_home_dir();
diff --git a/src/addins/exporttohtml/exporttohtmldialog.hpp b/src/addins/exporttohtml/exporttohtmldialog.hpp
index a8bb0348..4aea1d33 100644
--- a/src/addins/exporttohtml/exporttohtmldialog.hpp
+++ b/src/addins/exporttohtml/exporttohtmldialog.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
@@ -26,13 +26,18 @@
#include <gtkmm/filechooserdialog.h>
+namespace gnote {
+ class IGnote;
+}
+
+
namespace exporttohtml {
class ExportToHtmlDialog
: public Gtk::FileChooserDialog
{
public:
- ExportToHtmlDialog(const Glib::ustring &);
+ ExportToHtmlDialog(gnote::IGnote & ignote, const Glib::ustring &);
void save_preferences();
bool get_export_linked() const;
@@ -43,6 +48,7 @@ public:
private:
void on_export_linked_toggled();
void load_preferences(const Glib::ustring & );
+ gnote::IGnote & m_gnote;
Gtk::CheckButton m_export_linked;
Gtk::CheckButton m_export_linked_all;
};
diff --git a/src/addins/exporttohtml/exporttohtmlnoteaddin.cpp
b/src/addins/exporttohtml/exporttohtmlnoteaddin.cpp
index 7c758c81..a0360fab 100644
--- a/src/addins/exporttohtml/exporttohtmlnoteaddin.cpp
+++ b/src/addins/exporttohtml/exporttohtmlnoteaddin.cpp
@@ -87,7 +87,7 @@ std::vector<gnote::PopoverWidget> ExportToHtmlNoteAddin::get_actions_popover_wid
void ExportToHtmlNoteAddin::export_button_clicked(const Glib::VariantBase&)
{
- ExportToHtmlDialog dialog(get_note()->get_title() + ".html");
+ ExportToHtmlDialog dialog(ignote(), get_note()->get_title() + ".html");
int response = dialog.run();
Glib::ustring output_path = dialog.get_filename();
@@ -234,7 +234,7 @@ void ExportToHtmlNoteAddin::write_html_for_note (sharp::StreamWriter & writer,
args.add_param ("export-linked-all", "", export_linked_all);
args.add_param ("root-note", "", gnote::utils::XmlEncoder::encode(note->get_title()));
- Glib::RefPtr<Gio::Settings> settings =
gnote::IGnote::obj().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
+ Glib::RefPtr<Gio::Settings> settings =
ignote().preferences().get_schema_settings(Preferences::SCHEMA_GNOTE);
if (settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) {
Glib::ustring font_face = settings->get_string(Preferences::CUSTOM_FONT_FACE);
Pango::FontDescription font_desc (font_face);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]