[balsa] Remember cursor position when adding or changing signature
- From: Peter Bloomfield <PeterB src gnome org>
- To: svn-commits-list gnome org
- Subject: [balsa] Remember cursor position when adding or changing signature
- Date: Sun, 7 Jun 2009 12:04:32 -0400 (EDT)
commit b1ac2fedfd8ac01e50b86d9db953a83deeb81696
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Jun 7 11:37:45 2009 -0400
Remember cursor position when adding or changing signature
---
ChangeLog | 6 +++++
src/sendmsg-window.c | 51 ++++++++++++++++++++++++++++---------------------
2 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 69650c3..a055000 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-06-07 Peter Bloomfield
+
+ * src/sendmsg-window.c (repl_identity_signature),
+ (insert_initial_sig): remember cursor position when adding or
+ changing signature.
+
2009-06-03 Peter Bloomfield
Build with threads disabled
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 0e75ff7..a4764f7 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1282,7 +1282,13 @@ repl_identity_signature(BalsaSendmsg* bsmsg, LibBalsaIdentity* new_ident,
GtkTextBuffer *buffer =
gtk_text_view_get_buffer(GTK_TEXT_VIEW(bsmsg->text));
GtkTextIter ins, end;
+ GtkTextMark *mark;
+ /* Save cursor */
+ gtk_text_buffer_get_iter_at_mark(buffer, &ins,
+ gtk_text_buffer_get_insert(buffer));
+ mark = gtk_text_buffer_create_mark(buffer, NULL, &ins, TRUE);
+
gtk_text_buffer_get_iter_at_offset(buffer, &ins,
*replace_offset);
gtk_text_buffer_get_iter_at_offset(buffer, &end,
@@ -1293,26 +1299,30 @@ repl_identity_signature(BalsaSendmsg* bsmsg, LibBalsaIdentity* new_ident,
/* check to see if this is a reply or forward and compare identity
* settings to determine whether to add signature */
- if ((reply_type && !new_ident->sig_whenreply) ||
- (forward_type && !new_ident->sig_whenforward)) {
- return;
- }
-
- /* see if sig location is probably going to be the same */
- if (new_ident->sig_prepend == old_ident->sig_prepend) {
- /* account for sig length difference in replacement offset */
- *replace_offset += newsiglen - siglen;
- } else if (new_ident->sig_prepend) {
- /* sig location not the same between idents, take a WAG and
- * put it at the start of the message */
- gtk_text_buffer_get_start_iter(buffer, &ins);
- *replace_offset += newsiglen;
- } else {
- /* put it at the end of the message */
- gtk_text_buffer_get_end_iter(buffer, &ins);
+ if ((reply_type && new_ident->sig_whenreply) ||
+ (forward_type && new_ident->sig_whenforward)) {
+
+ /* see if sig location is probably going to be the same */
+ if (new_ident->sig_prepend == old_ident->sig_prepend) {
+ /* account for sig length difference in replacement offset */
+ *replace_offset += newsiglen - siglen;
+ } else if (new_ident->sig_prepend) {
+ /* sig location not the same between idents, take a WAG and
+ * put it at the start of the message */
+ gtk_text_buffer_get_start_iter(buffer, &ins);
+ *replace_offset += newsiglen;
+ } else {
+ /* put it at the end of the message */
+ gtk_text_buffer_get_end_iter(buffer, &ins);
+ }
+ gtk_text_buffer_place_cursor(buffer, &ins);
+ gtk_text_buffer_insert_at_cursor(buffer, new_sig, -1);
}
+
+ /* Restore cursor */
+ gtk_text_buffer_get_iter_at_mark(buffer, &ins, mark);
gtk_text_buffer_place_cursor(buffer, &ins);
- gtk_text_buffer_insert_at_cursor(buffer, new_sig, -1);
+ gtk_text_buffer_delete_mark(buffer, mark);
}
/*
@@ -4608,18 +4618,15 @@ insert_initial_sig(BalsaSendmsg *bsmsg)
GtkTextIter sig_pos;
GtkTextBuffer *buffer =
gtk_text_view_get_buffer(GTK_TEXT_VIEW(bsmsg->text));
- GtkTextMark *m;
if(bsmsg->ident->sig_prepend)
gtk_text_buffer_get_start_iter(buffer, &sig_pos);
else
gtk_text_buffer_get_end_iter(buffer, &sig_pos);
- m = gtk_text_buffer_create_mark (buffer, "pos", &sig_pos, TRUE);
gtk_text_buffer_insert(buffer, &sig_pos, "\n", 1);
insert_signature_cb(NULL, bsmsg);
- gtk_text_buffer_get_iter_at_mark(buffer, &sig_pos, m);
+ gtk_text_buffer_get_start_iter(buffer, &sig_pos);
gtk_text_buffer_place_cursor(buffer, &sig_pos);
- gtk_text_buffer_delete_mark(buffer, m);
}
BalsaSendmsg*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]