[gnote/gnome-3-6] Fix remembered selection with replacing selected text
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote/gnome-3-6] Fix remembered selection with replacing selected text
- Date: Sat, 22 Dec 2012 17:51:59 +0000 (UTC)
commit ea99184907b8e5e194e9e8aa13422a6b2579b2cd
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Wed Dec 19 23:11:17 2012 +0200
Fix remembered selection with replacing selected text
When selected text is replaced by typing, mark-set signal is not emitted.
Handle selection loss in mark-deleted signal.
src/note.cpp | 14 ++++++++++++++
src/note.hpp | 1 +
2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/note.cpp b/src/note.cpp
index ef4daec..addad72 100644
--- a/src/note.cpp
+++ b/src/note.cpp
@@ -464,6 +464,18 @@ namespace gnote {
queue_save(NO_CHANGE);
}
+ void Note::on_buffer_mark_deleted(const Glib::RefPtr<Gtk::TextBuffer::Mark> &)
+ {
+ Gtk::TextIter start, end;
+ if(m_data.data().selection_bound_position() != m_data.data().cursor_position()
+ && !m_buffer->get_selection_bounds(start, end)) {
+ DBG_OUT("selection removed");
+ m_data.data().set_cursor_position(m_buffer->get_insert()->get_iter().get_offset());
+ m_data.data().set_selection_bound_position(NoteData::s_noPosition);
+ queue_save(NO_CHANGE);
+ }
+ }
+
bool Note::on_window_configure(GdkEventConfigure * /*ev*/)
{
@@ -1015,6 +1027,8 @@ namespace gnote {
sigc::mem_fun(*this, &Note::on_buffer_tag_removed));
m_buffer->signal_mark_set().connect(
sigc::mem_fun(*this, &Note::on_buffer_mark_set));
+ m_buffer->signal_mark_deleted().connect(
+ sigc::mem_fun(*this, &Note::on_buffer_mark_deleted));
}
return m_buffer;
}
diff --git a/src/note.hpp b/src/note.hpp
index f69a36a..d408ae7 100644
--- a/src/note.hpp
+++ b/src/note.hpp
@@ -377,6 +377,7 @@ private:
void on_buffer_mark_set(const Gtk::TextBuffer::iterator & iter,
const Glib::RefPtr<Gtk::TextBuffer::Mark> & insert);
bool on_window_configure(GdkEventConfigure *ev);
+ void on_buffer_mark_deleted(const Glib::RefPtr<Gtk::TextBuffer::Mark> & mark);
bool on_window_destroyed(GdkEventAny *ev);
void on_save_timeout();
void process_child_widget_queue();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]