Example #1
0
  Note::Ptr Notebook::get_template_note() const
  {
    NoteBase::Ptr note = find_template_note();

    if (!note) {
      std::string title = m_default_template_note_title;
      if(m_note_manager.find(title)) {
        std::list<NoteBase*> tag_notes;
        m_tag->get_notes(tag_notes);
        title = m_note_manager.get_unique_name(title);
      }
      note = m_note_manager.create(title, NoteManager::get_note_template_content (title));
          
      // Select the initial text
      NoteBuffer::Ptr buffer = static_pointer_cast<Note>(note)->get_buffer();
      buffer->select_note_body();

      // Flag this as a template note
      Tag::Ptr templ_tag = template_tag();
      note->add_tag(templ_tag);

      // Add on the notebook system tag so Tomboy
      // will persist the tag/notebook across sessions
      // if no other notes are added to the notebook.
      Tag::Ptr notebook_tag = ITagManager::obj().get_or_create_system_tag(NOTEBOOK_TAG_PREFIX + get_name());
      note->add_tag (notebook_tag);
        
      note->queue_save (CONTENT_CHANGED);
    }

    return static_pointer_cast<Note>(note);
  }
Example #2
0
  Note::Ptr Notebook::create_notebook_note()
  {
    Glib::ustring temp_title;
    Note::Ptr note_template = get_template_note();

    temp_title = m_note_manager.get_unique_name(_("New Note"));
    NoteBase::Ptr note = m_note_manager.create_note_from_template(temp_title, note_template);

    // Add the notebook tag
    note->add_tag(m_tag);

    return static_pointer_cast<Note>(note);
  }