void NotebookApplicationAddin::on_note_added(const Note::Ptr & note)
{
    note->signal_tag_added().connect(
        sigc::mem_fun(*this, &NotebookApplicationAddin::on_tag_added));
    note->signal_tag_removed().connect(
        sigc::mem_fun(*this, &NotebookApplicationAddin::on_tag_removed));
}
Example #2
0
// BEGIN Notebook::get_template_note()
Note::Ptr Notebook::get_template_note() const {
    std::cout << "Notebook:: get template note()";
    NoteManager & noteManager = Gnote::obj().default_note_manager();
    Note::Ptr note = noteManager.find (m_template_note_title);
    std::cout << "Notebook:: find note";
    if (!note) {
    std::cout << "Notebook:: no note";
      // FIXME: need to get a unique name as well as uuid
      // we should have a default create() function which fills all this junk in...
      note = noteManager.create_new_note("New Note", "");
      //note = noteManager.create (m_template_note_title,
       //                     NoteManager::get_note_template_content (
        //                      m_template_note_title));
          
      // Flag this as a template note
    //qDebug() << "Notebook:: get or create sys tag 2";
      Tag::Ptr tag = TagManager::obj().get_or_create_system_tag (TagManager::TEMPLATE_NOTE_SYSTEM_TAG);
      note->add_tag (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.
    //qDebug() << "Notebook:: get or create sys tag 3";
      tag = TagManager::obj().get_or_create_system_tag (NOTEBOOK_TAG_PREFIX + get_name());
      note->add_tag (tag);
        
      //note->queue_save (Note::CONTENT_CHANGED);
    }
    else
      std::cout << "Notebook:: note found";

    return note;
} // END Notebook::get_template_note()
Example #3
0
    /// <summary>
    /// Place the specified note into the specified notebook.  If the
    /// note already belongs to a notebook, it will be removed from that
    /// notebook first.
    /// </summary>
    /// <param name="note">
    /// A <see cref="Note"/>
    /// </param>
    /// <param name="notebook">
    /// A <see cref="Notebook"/>.  If Notebook is null, the note will
    /// be removed from its current notebook.
    /// </param>
    /// <returns>True if the note was successfully moved.</returns>
    bool NotebookManager::move_note_to_notebook (const Note::Ptr & note, 
                                                 const Notebook::Ptr & notebook)
    {
      if (!note) {
        return false;
      }

      // NOTE: In the future we may want to allow notes
      // to exist in multiple notebooks.  For now, to
      // alleviate the confusion, only allow a note to
      // exist in one notebook at a time.

      Notebook::Ptr currentNotebook = get_notebook_from_note (note);
      if (currentNotebook == notebook)
        return true; // It's already there.

      if(currentNotebook) {
        note->remove_tag (currentNotebook->get_tag());
        m_note_removed_from_notebook(*note, currentNotebook);
      }

      // Only attempt to add the notebook tag when this
      // menu item is not the "No notebook" menu item.
      if(notebook) {
        note->add_tag(notebook->get_tag());
        m_note_added_to_notebook(*note, notebook);
      }

      return true;
    }
Example #4
0
 std::string RemoteControl::GetNoteTitle(const std::string& uri)
 {
   Note::Ptr note;
   note = m_manager.find_by_uri (uri);
   if (!note)
     return "";
   return note->get_title();
 }
Example #5
0
 int32_t RemoteControl::GetNoteCreateDate(const std::string& uri)
 {
   Note::Ptr note;
   note = m_manager.find_by_uri (uri);
   if (!note)
     return -1;
   return note->create_date().sec();
 }
Example #6
0
 std::string RemoteControl::GetNoteContentsXml(const std::string& uri)
 {
   Note::Ptr note;
   note = m_manager.find_by_uri (uri);
   if (!note)
     return "";
   return note->xml_content();
 }
Example #7
0
  std::string RemoteControl::GetNoteCompleteXml(const std::string& uri)
  {
    Note::Ptr note;
    note = m_manager.find_by_uri (uri);
    if (!note)
      return "";
    return note->get_complete_note_xml();

  }
Example #8
0
 bool RemoteControl::AddTagToNote(const std::string& uri, const std::string& tag_name)
 {
   Note::Ptr note = m_manager.find_by_uri (uri);
   if (!note) {
     return false;
   }
   Tag::Ptr tag = TagManager::obj().get_or_create_tag (tag_name);
   note->add_tag (tag);
   return true;
 }
Example #9
0
bool RemoteControl::HideNote(const std::string& uri)
{
  Note::Ptr note;
  note = m_manager.find_by_uri (uri);
  if (!note)
    return false;

  note->get_window()->hide();
  return true;
}
Example #10
0
bool RemoteControl::SetNoteContentsXml(const std::string& uri, 
                                       const std::string& xml_contents)
{
  Note::Ptr note;
  note = m_manager.find_by_uri(uri);
  if(!note) {
    return false;
  }
  note->set_xml_content(xml_contents);
  return true;
}
Example #11
0
 std::string RemoteControl::CreateNote()
 {
   try {
     Note::Ptr note = m_manager.create ();
     return note->uri();
   } 
   catch(...)
   {
   }
   return "";
 }
Example #12
0
bool RemoteControl::SetNoteCompleteXml(const std::string& uri, 
                                       const std::string& xml_contents)
{
  Note::Ptr note;
  note = m_manager.find_by_uri(uri);
  if(!note) {
    return false;
  }
    
  note->load_foreign_note_xml(xml_contents, CONTENT_CHANGED);
  return true;
}
Example #13
0
bool RemoteControl::RemoveTagFromNote(const std::string& uri, 
                                      const std::string& tag_name)
{
  Note::Ptr note = m_manager.find_by_uri (uri);
  if (!note)
    return false;
  Tag::Ptr tag = TagManager::obj().get_tag (tag_name);
  if (tag) {
    note->remove_tag (tag);
  }
  return true;
}
Example #14
0
  bool RemoteControl::DisplayNote(const std::string& uri)
  {
    Note::Ptr note;

    note = m_manager.find_by_uri (uri);
    if (!note) {
      return false;
    }

    note->get_window()->present();
    return true;
  }
Example #15
0
  std::vector< std::string > RemoteControl::GetTagsForNote(const std::string& uri)
  {
    Note::Ptr note;
    note = m_manager.find_by_uri (uri);
    if (!note)
      return std::vector< std::string >();

    std::vector< std::string > tags;
    std::list<Tag::Ptr> l;
    note->get_tags(l);
    for (std::list<Tag::Ptr>::const_iterator iter = l.begin();
         iter != l.end(); ++iter) {
      tags.push_back((*iter)->normalized_name());
    }
    return tags;
  }
Example #16
0
  std::string RemoteControl::CreateNamedNote(const std::string& linked_title)
  {
    Note::Ptr note;

    note = m_manager.find (linked_title);
    if (note)
      return "";

    try {
      note = m_manager.create (linked_title);
      return note->uri();
    } 
    catch (const std::exception & e) {
      ERR_OUT("create throw: %s", e.what());
    }
    return "";
  }
Example #17
0
    Notebook::Ptr NotebookManager::get_or_create_notebook(const std::string & notebookName)
    {
      if (notebookName.empty())
        throw sharp::Exception ("NotebookManager.GetNotebook () called with a null name.");
      
      Notebook::Ptr notebook = get_notebook (notebookName);
      if (notebook) {
        return notebook;
      }
      
      Gtk::TreeIter iter;
//      lock (locker) {
        notebook = get_notebook (notebookName);
        if (notebook)
          return notebook;
        
        try {
          m_adding_notebook = true;
          notebook = Notebook::Ptr(new Notebook (notebookName));
        } 
        catch(...)
        {
          // set flag to fast and rethrow
          m_adding_notebook = false;
          throw;
        }
        m_adding_notebook = false;
        iter = m_notebooks->append ();
        iter->set_value(0, notebook);
        m_notebookMap [notebook->get_normalized_name()] = iter;
        
        // Create the template note so the system tag
        // that represents the notebook actually gets
        // saved to a note (and persisted after Tomboy
        // is shut down).
        Note::Ptr templateNote = notebook->get_template_note ();
        
        // Make sure the template note has the notebook tag.
        // Since it's possible for the template note to already
        // exist, we need to make sure it gets tagged.
        templateNote->add_tag (notebook->get_tag());
        m_note_added_to_notebook (*templateNote, notebook);
//      }

      return notebook;
    }
Example #18
0
 /// <summary>
 /// Returns true when the specified note exists in the notebook
 /// </summary>
 /// <param name="note">
 /// A <see cref="Note"/>
 /// </param>
 /// <returns>
 /// A <see cref="System.Boolean"/>
 /// </returns>
 bool Notebook::contains_note(const Note::Ptr & note, bool include_system)
 {
   bool contains = note->contains_tag(m_tag);
   if(!contains || include_system) {
     return contains;
   }
   return !is_template_note(note);
 }
Example #19
0
  bool RemoteControl::DisplayNoteWithSearch(const std::string& uri, const std::string& search)
  {
    Note::Ptr note;

    note = m_manager.find_by_uri (uri);
    if (!note) {
      return false;
    }

    note->get_window()->present();

    // Pop open the find-bar
    NoteFindBar & findbar = note->get_window()->get_find_bar();
    findbar.show_all ();
    findbar.property_visible() = true;
    findbar.set_search_text(search);

    return true;
  }
Example #20
0
  bool NoteUpdate::basically_equal_to(const Note::Ptr & existing_note)
  {
    // NOTE: This would be so much easier if NoteUpdate
    //       was not just a container for a big XML string
    sharp::XmlReader xml;
    xml.load_buffer(m_xml_content);
    NoteData *data = new NoteData(m_uuid);
    NoteArchiver::obj().read(xml, *data);
    std::auto_ptr<NoteData> update_data(data);
    xml.close();

    // NOTE: Mostly a hack to ignore missing version attributes
    std::string existing_inner_content = get_inner_content(existing_note->data().text());
    std::string update_inner_content = get_inner_content(update_data->text());

    return existing_inner_content == update_inner_content &&
           existing_note->data().title() == update_data->title() &&
           compare_tags(existing_note->data().tags(), update_data->tags());
           // TODO: Compare open-on-startup, pinned
  }
Example #21
0
 /// <summary>
 /// Returns the Notebook associated with this note or null
 /// if no notebook exists.
 /// </summary>
 /// <param name="note">
 /// A <see cref="Note"/>
 /// </param>
 /// <returns>
 /// A <see cref="Notebook"/>
 /// </returns>
 Notebook::Ptr NotebookManager::get_notebook_from_note(const Note::Ptr & note)
 {
   std::list<Tag::Ptr> tags;
   note->get_tags(tags);
   for(std::list<Tag::Ptr>::const_iterator iter = tags.begin();
       iter != tags.end(); ++iter) {
     Notebook::Ptr notebook = get_notebook_from_tag (*iter);
     if (notebook)
       return notebook;
   }
   
   return Notebook::Ptr();
 }
Example #22
0
 void SilentUI::note_conflict_detected(NoteManager & manager,
                                       const Note::Ptr & localConflictNote,
                                       NoteUpdate remoteNote,
                                       const std::list<std::string> &)
 {
   DBG_OUT("note conflict detected, overwriting without a care");
   // TODO: At least respect conflict prefs
   // TODO: Implement more useful conflict handling
   if(localConflictNote->id() != remoteNote.m_uuid) {
     manager.delete_note(localConflictNote);
   }
   SyncManager::obj().resolve_conflict(OVERWRITE_EXISTING);
 }
Example #23
0
bool Search::check_note_has_match(const Note::Ptr & note,
                                  const std::vector<std::string> & encoded_words,
                                  bool match_case)
{
    std::string note_text = note->xml_content();
    if (!match_case) {
        note_text = sharp::string_to_lower(note_text);
    }

    for(std::vector<std::string>::const_iterator iter = encoded_words.begin();
            iter != encoded_words.end(); ++iter) {
        if (sharp::string_contains(note_text, *iter) ) {
            continue;
        }
        else {
            return false;
        }
    }

    return true;
}
Example #24
0
  /// <summary>
  /// Returns true when the specified note exists in the notebook
  /// </summary>
  /// <param name="note">
  /// A <see cref="Note"/>
  /// </param>
  /// <returns>
  /// A <see cref="System.Boolean"/>
  /// </returns>
  bool Notebook::contains_note(const Note::Ptr & note)
  {
	// FIXME: IMPLEMENT
//	return true;
    return note->contains_tag (m_tag);
  }
Example #25
0
 std::string RemoteControl::FindNote(const std::string& linked_title)
 {
   Note::Ptr note = m_manager.find (linked_title);
   return (!note) ? "" : note->uri();
 }
Example #26
0
 std::string RemoteControl::FindStartHereNote()
 {
   Note::Ptr note = m_manager.find_by_uri (m_manager.start_note_uri());
   return (!note) ? "" : note->uri();
 }
Example #27
0
void RemoteControl::on_note_added(const Note::Ptr & note)
{
  if(note) {
    NoteAdded(note->uri());
  }
}
Example #28
0
void RemoteControl::on_note_saved(const Note::Ptr & note)
{
  if(note) {
    NoteSaved(note->uri());
  }
}
Example #29
0
void RemoteControl::on_note_deleted(const Note::Ptr & note)
{
  if(note) {
    NoteDeleted(note->uri(), note->get_title());
  }
}