[gnote] Replace std::string by Glib::ustring in noteoftheday
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Replace std::string by Glib::ustring in noteoftheday
- Date: Sat, 4 Feb 2017 18:03:08 +0000 (UTC)
commit e9c0a4ee7519a1146c6f48c69403fc7165f7725f
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Feb 4 19:37:32 2017 +0200
Replace std::string by Glib::ustring in noteoftheday
src/addins/noteoftheday/noteoftheday.cpp | 32 +++++++++++++----------------
src/addins/noteoftheday/noteoftheday.hpp | 16 ++++----------
2 files changed, 19 insertions(+), 29 deletions(-)
---
diff --git a/src/addins/noteoftheday/noteoftheday.cpp b/src/addins/noteoftheday/noteoftheday.cpp
index bafe6c5..1073c9a 100644
--- a/src/addins/noteoftheday/noteoftheday.cpp
+++ b/src/addins/noteoftheday/noteoftheday.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2013-2014 Aurimas Cernius
+ * Copyright (C) 2013-2014,2017 Aurimas Cernius
* Copyright (C) 2009-2010 Debarshi Ray
*
* This program is free software: you can redistribute it and/or modify
@@ -37,8 +37,8 @@ const Glib::ustring NoteOfTheDay::s_title_prefix
gnote::NoteBase::Ptr NoteOfTheDay::create(gnote::NoteManager & manager,
const Glib::Date & date)
{
- const std::string title = get_title(date);
- const std::string xml = get_content(date, manager);
+ const Glib::ustring title = get_title(date);
+ const Glib::ustring xml = get_content(date, manager);
gnote::NoteBase::Ptr notd;
try {
@@ -88,17 +88,15 @@ void NoteOfTheDay::cleanup_old(gnote::NoteManager & manager)
}
}
-std::string NoteOfTheDay::get_content(
- const Glib::Date & date,
- const gnote::NoteManager & manager)
+Glib::ustring NoteOfTheDay::get_content(const Glib::Date & date, const gnote::NoteManager & manager)
{
- const std::string title = get_title(date);
+ const Glib::ustring title = get_title(date);
// Attempt to load content from template
const gnote::NoteBase::Ptr template_note = manager.find(s_template_title);
if (0 != template_note) {
- std::string xml_content = template_note->xml_content();
+ Glib::ustring xml_content = template_note->xml_content();
return xml_content.replace(xml_content.find(s_template_title, 0),
s_template_title.length(),
title);
@@ -108,15 +106,14 @@ std::string NoteOfTheDay::get_content(
}
}
-std::string NoteOfTheDay::get_content_without_title(
- const std::string & content)
+Glib::ustring NoteOfTheDay::get_content_without_title(const Glib::ustring & content)
{
- const std::string::size_type nl = content.find("\n");
+ const Glib::ustring::size_type nl = content.find("\n");
- if (std::string::npos != nl)
- return std::string(content, nl, std::string::npos);
+ if (Glib::ustring::npos != nl)
+ return Glib::ustring(content, nl, Glib::ustring::npos);
else
- return std::string();
+ return Glib::ustring();
}
gnote::NoteBase::Ptr NoteOfTheDay::get_note_by_date(
@@ -142,8 +139,7 @@ gnote::NoteBase::Ptr NoteOfTheDay::get_note_by_date(
return gnote::Note::Ptr();
}
-std::string NoteOfTheDay::get_template_content(
- const std::string & title)
+Glib::ustring NoteOfTheDay::get_template_content(const Glib::ustring & title)
{
return Glib::ustring::compose(
"<note-content xmlns:size=\"http://beatniksoftware.com/tomboy/size\">"
@@ -156,7 +152,7 @@ std::string NoteOfTheDay::get_template_content(
_("Appointments"));
}
-std::string NoteOfTheDay::get_title(const Glib::Date & date)
+Glib::ustring NoteOfTheDay::get_title(const Glib::Date & date)
{
// Format: "Today: Friday, July 01 2005"
return s_title_prefix + date.format_string(_("%A, %B %d %Y"));
@@ -165,7 +161,7 @@ std::string NoteOfTheDay::get_title(const Glib::Date & date)
bool NoteOfTheDay::has_changed(const gnote::NoteBase::Ptr & note)
{
const sharp::DateTime & date_time = note->create_date();
- const std::string original_xml
+ const Glib::ustring original_xml
= get_content(Glib::Date(
date_time.day(),
static_cast<Glib::Date::Month>(date_time.month()),
diff --git a/src/addins/noteoftheday/noteoftheday.hpp b/src/addins/noteoftheday/noteoftheday.hpp
index 1fe261c..9d28375 100644
--- a/src/addins/noteoftheday/noteoftheday.hpp
+++ b/src/addins/noteoftheday/noteoftheday.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2014 Aurimas Cernius
+ * Copyright (C) 2014,2017 Aurimas Cernius
* Copyright (C) 2009 Debarshi Ray
*
* This program is free software: you can redistribute it and/or modify
@@ -21,10 +21,6 @@
#ifndef __NOTE_OF_THE_DAY_HPP_
#define __NOTE_OF_THE_DAY_HPP_
-#include <string>
-
-#include <glibmm.h>
-
#include "sharp/dynamicmodule.hpp"
#include "applicationaddin.hpp"
#include "note.hpp"
@@ -44,22 +40,20 @@ public:
static gnote::NoteBase::Ptr create(gnote::NoteManager & manager,
const Glib::Date & date);
static void cleanup_old(gnote::NoteManager & manager);
- static std::string get_content(const Glib::Date & date,
+ static Glib::ustring get_content(const Glib::Date & date,
const gnote::NoteManager & manager);
static gnote::NoteBase::Ptr get_note_by_date(
gnote::NoteManager & manager,
const Glib::Date & date);
- static std::string get_template_content(
- const std::string & title);
- static std::string get_title(const Glib::Date & date);
+ static Glib::ustring get_template_content(const Glib::ustring & title);
+ static Glib::ustring get_title(const Glib::Date & date);
static bool has_changed(const gnote::NoteBase::Ptr & note);
static const Glib::ustring s_template_title;
private:
- static std::string get_content_without_title(
- const std::string & content);
+ static Glib::ustring get_content_without_title(const Glib::ustring & content);
static const Glib::ustring s_title_prefix;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]