[gnumeric] GUI: Fix cursor position after Ctrl-;
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Fix cursor position after Ctrl-;
- Date: Fri, 5 Jun 2020 23:07:29 +0000 (UTC)
commit baf0a739240a0604a6256981fa9989c02049831e
Author: Morten Welinder <terra gnome org>
Date: Fri Jun 5 19:06:56 2020 -0400
GUI: Fix cursor position after Ctrl-;
Place cursor after the inserted date.
NEWS | 1 +
src/wbc-gtk-actions.c | 11 +++++++++--
2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/NEWS b/NEWS
index 577ee5e81..56d0eb3ff 100644
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,7 @@ Morten:
* Fix performance issue with sample_datasource. [#491]
* Fix partial-line issue with sample_datasource.
* Fix load of in-place graph data with extra ()s. [#492]
+ * Fix Ctrl-; cursor position. [#494]
--------------------------------------------------------------------------
Gnumeric 1.12.47
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index 433b90a17..dc9704ccc 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -788,6 +788,7 @@ insert_date_time_common (WBCGtk *wbcg, gboolean do_date, gboolean do_time)
char *txt;
char *dtxt = NULL;
char *ttxt = NULL;
+ GtkEntry *entry;
if (do_date) {
GOFormat *fmt = gnm_format_for_date_editing (cell);
@@ -800,6 +801,8 @@ insert_date_time_common (WBCGtk *wbcg, gboolean do_date, gboolean do_time)
ttxt = format_value (fmt, v, -1, date_conv);
}
+ value_release (v);
+
if (do_date && do_time) {
txt = g_strconcat (dtxt, " ", ttxt, NULL);
g_free (dtxt);
@@ -810,9 +813,13 @@ insert_date_time_common (WBCGtk *wbcg, gboolean do_date, gboolean do_time)
txt = ttxt;
wb_control_edit_line_set (wbc, txt);
-
- value_release (v);
g_free (txt);
+
+ // Explicitly place cursor at end. Otherwise the cursor
+ // position depends on whether the new contents matches
+ // the old which is weird.
+ entry = wbcg_get_entry (wbcg);
+ gtk_editable_set_position (GTK_EDITABLE (entry), -1);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]