summaryrefslogtreecommitdiff
path: root/gtk/a11y/gtkatspitextbuffer.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2022-04-26 13:43:19 -0500
committerFederico Mena Quintero <federico@gnome.org>2022-04-26 13:43:19 -0500
commit737854aa0d203de7bdab2b282a51691c9056dadc (patch)
treea67e99977d54b8fab69a129774159e1f6bf09529 /gtk/a11y/gtkatspitextbuffer.c
parent3af4d53945dd92b955ba1fee45d9a2957b6af8c4 (diff)
downloadgtk+-737854aa0d203de7bdab2b282a51691c9056dadc.tar.gz
Don't cast GtkWrapMode to the incompatible enum PangoWrapMode
The enum values are not compatible, and moreover, there is an extra GTK_WRAP_NONE that PangoWrapMode doesn't have - thus, pango_wrap_mode_to_string() will assert. As far as I can tell, Orca does not read the wrap-mode key in the dictionary for text attributes, anyway. Fixes: #4869
Diffstat (limited to 'gtk/a11y/gtkatspitextbuffer.c')
-rw-r--r--gtk/a11y/gtkatspitextbuffer.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/gtk/a11y/gtkatspitextbuffer.c b/gtk/a11y/gtkatspitextbuffer.c
index 61e240fb0d..40fd05fa1f 100644
--- a/gtk/a11y/gtkatspitextbuffer.c
+++ b/gtk/a11y/gtkatspitextbuffer.c
@@ -55,6 +55,27 @@ gtk_text_direction_to_string (GtkTextDirection direction)
}
}
+static const char *
+gtk_wrap_mode_to_string (GtkWrapMode wrap_mode)
+{
+ /* Keep these in sync with pango_wrap_mode_to_string(); note that
+ * here we have an extra case for NONE.
+ */
+ switch (wrap_mode)
+ {
+ case GTK_WRAP_NONE:
+ return "none";
+ case GTK_WRAP_CHAR:
+ return "char";
+ case GTK_WRAP_WORD:
+ return "word";
+ case GTK_WRAP_WORD_CHAR:
+ return "word-char";
+ default:
+ g_assert_not_reached ();
+ }
+}
+
void
gtk_text_view_add_default_attributes (GtkTextView *view,
GVariantBuilder *builder)
@@ -75,7 +96,7 @@ gtk_text_view_add_default_attributes (GtkTextView *view,
g_variant_builder_add (builder, "{ss}", "direction",
gtk_text_direction_to_string (text_attrs->direction));
g_variant_builder_add (builder, "{ss}", "wrap-mode",
- pango_wrap_mode_to_string ((PangoWrapMode)text_attrs->wrap_mode));
+ gtk_wrap_mode_to_string (text_attrs->wrap_mode));
g_variant_builder_add (builder, "{ss}", "editable",
text_attrs->editable ? "true" : "false");
g_variant_builder_add (builder, "{ss}", "invisible",
@@ -256,7 +277,7 @@ gtk_text_buffer_get_run_attributes (GtkTextBuffer *buffer,
"wrap-mode", &wrap_mode,
NULL);
if (val_set)
- g_variant_builder_add (builder, "{ss}", "wrap-mode", pango_wrap_mode_to_string ((PangoWrapMode)wrap_mode));
+ g_variant_builder_add (builder, "{ss}", "wrap-mode", gtk_wrap_mode_to_string (wrap_mode));
temp_tags = temp_tags->next;
}
val_set = FALSE;