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); }
void GnoteSyncClient::note_deleted_handler(const NoteBase::Ptr & deletedNote) { m_deleted_notes[deletedNote->id()] = deletedNote->get_title(); m_file_revisions.erase(deletedNote->id()); write(m_local_manifest_file_path); }
Glib::ustring RemoteControl::CreateNote() { try { NoteBase::Ptr note = m_manager.create (); return note->uri(); } catch(...) { } return ""; }
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); }
Glib::ustring RemoteControl::CreateNamedNote(const Glib::ustring& linked_title) { NoteBase::Ptr 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(_("Exception thrown when creating note: %s"), e.what()); } return ""; }
void NotebooksTreeView::on_drag_data_received( const Glib::RefPtr<Gdk::DragContext> & context, int x, int y, const Gtk::SelectionData & selectionData, guint , guint time_) { utils::UriList uriList(selectionData); if (uriList.size() == 0) { context->drag_finish (false, false, time_); return; } Gtk::TreePath treepath; Gtk::TreeViewDropPosition pos; if (get_dest_row_at_pos (x, y, treepath, pos) == false) { context->drag_finish (false, false, time_); return; } Gtk::TreeIter iter = get_model()->get_iter(treepath); if (!iter) { context->drag_finish (false, false, time_); return; } Notebook::Ptr destNotebook; iter->get_value(0, destNotebook); if(std::dynamic_pointer_cast<AllNotesNotebook>(destNotebook)) { context->drag_finish (false, false, time_); return; } for(utils::UriList::const_iterator uri_iter = uriList.begin(); uri_iter != uriList.end(); ++uri_iter) { const sharp::Uri & uri(*uri_iter); NoteBase::Ptr note = m_note_manager.find_by_uri(uri.to_string()); if (!note) continue; DBG_OUT ("Dropped into notebook: %s", note->get_title().c_str()); destNotebook->add_note(std::static_pointer_cast<Note>(note)); } context->drag_finish (true, false, time_); }
int GnoteSyncClient::get_revision(const NoteBase::Ptr & note) { std::string note_guid = note->id(); std::map<std::string, int>::const_iterator iter = m_file_revisions.find(note_guid); if(iter != m_file_revisions.end()) { return iter->second; } else { return -1; } }
void ModelFiller::operator()(const NoteBase::Ptr & note) { if (!note) return; ModelColumnRecord model_column_record; const Gtk::TreeModel::iterator iter = m_list_store->append(); Gtk::TreeModel::Row row = *iter; row[model_column_record.get_column_selected()] = true; row[model_column_record.get_column_title()] = note->get_title(); row[model_column_record.get_column_note()] = note; }
/// <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 NoteBase::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(); }
NoteRenameDialog::NoteRenameDialog(const NoteBase::List & notes, const std::string & old_title, const NoteBase::Ptr & renamed_note) : Gtk::Dialog(_("Rename Note Links?"), *dynamic_cast<Gtk::Window*>(static_pointer_cast<Note>(renamed_note)->get_window()->host()), false) , m_notes_model(Gtk::ListStore::create(m_model_column_record)) , m_dont_rename_button(_("_Don't Rename Links"), true) , m_rename_button(_("_Rename Links"), true) , m_select_all_button(_("Select All")) , m_select_none_button(_("Select None")) , m_always_show_dlg_radio(_("Always show this _window"), true) , m_always_rename_radio(_("Alwa_ys rename links"), true) , m_never_rename_radio(_("Never rename _links"), true) { set_default_response(Gtk::RESPONSE_CANCEL); set_border_width(10); Gtk::Box * const vbox = get_vbox(); add_action_widget(m_rename_button, Gtk::RESPONSE_YES); add_action_widget(m_dont_rename_button, Gtk::RESPONSE_NO); std::for_each(notes.begin(), notes.end(), ModelFiller(m_notes_model)); Gtk::Label * const label = Gtk::manage(new Gtk::Label()); label->set_use_markup(true); label->set_markup( Glib::ustring::compose( _("Rename links in other notes from " "\"<span underline=\"single\">%1</span>\" to " "\"<span underline=\"single\">%2</span>\"?\n\n" "If you do not rename the links, they will no longer link to " "anything."), old_title, renamed_note->get_title())); label->set_line_wrap(true); vbox->pack_start(*label, false, true, 5); Gtk::TreeView * const notes_view = Gtk::manage( new Gtk::TreeView( m_notes_model)); notes_view->set_size_request(-1, 200); notes_view->signal_row_activated().connect( sigc::bind( sigc::mem_fun(*this, &NoteRenameDialog::on_notes_view_row_activated), old_title)); ModelColumnRecord model_column_record; Gtk::CellRendererToggle * const toggle_cell = Gtk::manage( new Gtk::CellRendererToggle); toggle_cell->set_activatable(true); toggle_cell->signal_toggled().connect( sigc::mem_fun(*this, &NoteRenameDialog::on_toggle_cell_toggled)); { Gtk::TreeViewColumn * const column = Gtk::manage( new Gtk::TreeViewColumn( _("Rename Links"), *toggle_cell)); column->add_attribute(*toggle_cell, "active", model_column_record.get_column_selected()); column->set_sort_column( model_column_record.get_column_selected()); column->set_resizable(true); notes_view->append_column(*column); } { Gtk::TreeViewColumn * const column = Gtk::manage( new Gtk::TreeViewColumn( _("Note Title"), model_column_record.get_column_title())); column->set_sort_column(model_column_record.get_column_title()); column->set_resizable(true); notes_view->append_column(*column); } m_select_all_button.signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &NoteRenameDialog::on_select_all_button_clicked), true)); m_select_none_button.signal_clicked().connect( sigc::bind( sigc::mem_fun(*this, &NoteRenameDialog::on_select_all_button_clicked), false)); Gtk::Grid * const notes_button_box = manage(new Gtk::Grid); notes_button_box->set_column_spacing(5); notes_button_box->attach(m_select_none_button, 0, 0, 1, 1); notes_button_box->attach(m_select_all_button, 1, 0, 1, 1); notes_button_box->set_hexpand(true); Gtk::ScrolledWindow * const notes_scroll = Gtk::manage( new Gtk::ScrolledWindow()); notes_scroll->add(*notes_view); notes_scroll->set_hexpand(true); notes_scroll->set_vexpand(true); m_notes_box.attach(*notes_scroll, 0, 0, 1, 1); m_notes_box.attach(*notes_button_box, 0, 1, 1, 1); Gtk::Expander * const advanced_expander = Gtk::manage(new Gtk::Expander( _("Ad_vanced"), true)); Gtk::Grid * const expand_box = Gtk::manage(new Gtk::Grid); expand_box->attach(m_notes_box, 0, 0, 1, 1); m_always_show_dlg_radio.signal_clicked().connect( sigc::mem_fun(*this, &NoteRenameDialog::on_always_show_dlg_clicked)); Gtk::RadioButton::Group group = m_always_show_dlg_radio.get_group(); m_never_rename_radio.set_group(group); m_never_rename_radio.signal_clicked().connect( sigc::mem_fun(*this, &NoteRenameDialog::on_never_rename_clicked)); m_always_rename_radio.set_group(group); m_always_rename_radio.signal_clicked().connect( sigc::mem_fun(*this, &NoteRenameDialog::on_always_rename_clicked)); expand_box->attach(m_always_show_dlg_radio, 0, 1, 1, 1); expand_box->attach(m_never_rename_radio, 0, 2, 1, 1); expand_box->attach(m_always_rename_radio, 0, 3, 1, 1); advanced_expander->add(*expand_box); vbox->pack_start(*advanced_expander, true, true, 5); advanced_expander->property_expanded().signal_changed().connect( sigc::bind( sigc::mem_fun(*this, &NoteRenameDialog::on_advanced_expander_changed), advanced_expander->property_expanded().get_value())); set_focus(m_dont_rename_button); vbox->show_all(); }
Glib::ustring RemoteControl::FindStartHereNote() { NoteBase::Ptr note = m_manager.find_by_uri(m_manager.start_note_uri()); return (!note) ? "" : note->uri(); }
Glib::ustring RemoteControl::FindNote(const Glib::ustring& linked_title) { NoteBase::Ptr note = m_manager.find(linked_title); return (!note) ? "" : note->uri(); }
void GnoteSyncClient::set_revision(const NoteBase::Ptr & note, int revision) { m_file_revisions[note->id()] = revision; // TODO: Should we write on each of these or no? write(m_local_manifest_file_path); }