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); }
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; }
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_); }
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(); }