[evince/outline_search_improvements: 27/28] convert utf8 fullwidth numbers to halfwidth
- From: Germán Poo-Caamaño <gpoo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince/outline_search_improvements: 27/28] convert utf8 fullwidth numbers to halfwidth
- Date: Thu, 25 Aug 2022 15:31:11 +0000 (UTC)
commit 3e82d46b438beda234770dc962ba2d1c285f70d8
Author: Nelson Benítez León <nbenitezl gmail com>
Date: Fri Jun 24 17:47:44 2022 +0100
convert utf8 fullwidth numbers to halfwidth
when entering a page number in the EvPageActionWidget
with an input source like eg. Japanese which
by default uses fullwidth numbers.
We introduce a private function to determine
when the EvPageActionWidget is in "search outline"
mode or in "entering page number" mode.
Fixes #1518
libmisc/ev-page-action-widget.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
---
diff --git a/libmisc/ev-page-action-widget.c b/libmisc/ev-page-action-widget.c
index d7db2a28d..e32b1daca 100644
--- a/libmisc/ev-page-action-widget.c
+++ b/libmisc/ev-page-action-widget.c
@@ -33,6 +33,7 @@
/* Widget we pass back */
static void ev_page_action_widget_init (EvPageActionWidget *action_widget);
static void ev_page_action_widget_class_init (EvPageActionWidgetClass *action_widget);
+static gboolean ev_page_action_widget_completion_search_is_enabled (EvPageActionWidget *proxy);
enum
{
@@ -178,6 +179,7 @@ activate_cb (EvPageActionWidget *action_widget)
EvLinkAction *link_action;
EvLink *link;
gchar *link_text;
+ gchar *new_text;
gint current_page;
model = action_widget->doc_model;
@@ -185,6 +187,15 @@ activate_cb (EvPageActionWidget *action_widget)
text = gtk_entry_get_text (GTK_ENTRY (action_widget->entry));
+ /* If we are not in search mode, i.e. we are entering a page number */
+ if (!ev_page_action_widget_completion_search_is_enabled (action_widget)) {
+ /* Convert utf8 fullwidth numbers (eg. japanese) to halfwidth - fixes #1518 */
+ new_text = g_utf8_normalize (text, -1, G_NORMALIZE_ALL);
+ gtk_entry_set_text (GTK_ENTRY (action_widget->entry), new_text);
+ text = gtk_entry_get_text (GTK_ENTRY (action_widget->entry));
+ g_free (new_text);
+ }
+
link_dest = ev_link_dest_new_page_label (text);
link_action = ev_link_action_new_dest (link_dest);
link_text = g_strdup_printf (_("Page %s"), text);
@@ -636,4 +647,11 @@ ev_page_action_widget_enable_completion_search (EvPageActionWidget *proxy, gbool
{
GtkEntryCompletion *completion = enable ? proxy->completion : NULL;
gtk_entry_set_completion (GTK_ENTRY (proxy->entry), completion);
+}
+
+/* Returns whether the completion search is enabled in @proxy */
+static gboolean
+ev_page_action_widget_completion_search_is_enabled (EvPageActionWidget *proxy)
+{
+ return gtk_entry_get_completion (GTK_ENTRY (proxy->entry)) != NULL;
}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]