mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-14 14:20:21 +00:00
gtkmain: add support for GTK_DEBUG=invert-text-dir
This allows inverting the default text-direction in an application for debugging, testing, and QA purposes. IDEs such as Builder may automate this to encourage more application developers to test with a text-direction different than their own.
This commit is contained in:
parent
56a1cbe217
commit
8f1db27b6b
@ -82,6 +82,7 @@ typedef enum {
|
|||||||
GTK_DEBUG_BUILDER_OBJECTS = 1 << 16,
|
GTK_DEBUG_BUILDER_OBJECTS = 1 << 16,
|
||||||
GTK_DEBUG_A11Y = 1 << 17,
|
GTK_DEBUG_A11Y = 1 << 17,
|
||||||
GTK_DEBUG_ICONFALLBACK = 1 << 18,
|
GTK_DEBUG_ICONFALLBACK = 1 << 18,
|
||||||
|
GTK_DEBUG_INVERT_TEXT_DIR = 1 << 19,
|
||||||
} GtkDebugFlags;
|
} GtkDebugFlags;
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
|
@ -203,6 +203,7 @@ static const GdkDebugKey gtk_debug_keys[] = {
|
|||||||
{ "snapshot", GTK_DEBUG_SNAPSHOT, "Generate debug render nodes" },
|
{ "snapshot", GTK_DEBUG_SNAPSHOT, "Generate debug render nodes" },
|
||||||
{ "accessibility", GTK_DEBUG_A11Y, "Information about accessibility state changes" },
|
{ "accessibility", GTK_DEBUG_A11Y, "Information about accessibility state changes" },
|
||||||
{ "iconfallback", GTK_DEBUG_ICONFALLBACK, "Information about icon fallback" },
|
{ "iconfallback", GTK_DEBUG_ICONFALLBACK, "Information about icon fallback" },
|
||||||
|
{ "invert-text-dir", GTK_DEBUG_INVERT_TEXT_DIR, "Invert the default text direction" },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This checks to see if the process is running suid or sgid
|
/* This checks to see if the process is running suid or sgid
|
||||||
@ -523,6 +524,7 @@ static void
|
|||||||
do_post_parse_initialization (void)
|
do_post_parse_initialization (void)
|
||||||
{
|
{
|
||||||
GdkDisplayManager *display_manager;
|
GdkDisplayManager *display_manager;
|
||||||
|
GtkTextDirection text_dir;
|
||||||
gint64 before G_GNUC_UNUSED;
|
gint64 before G_GNUC_UNUSED;
|
||||||
|
|
||||||
if (gtk_initialized)
|
if (gtk_initialized)
|
||||||
@ -536,7 +538,16 @@ do_post_parse_initialization (void)
|
|||||||
signal (SIGPIPE, SIG_IGN);
|
signal (SIGPIPE, SIG_IGN);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gtk_widget_set_default_direction (gtk_get_locale_direction ());
|
text_dir = gtk_get_locale_direction ();
|
||||||
|
|
||||||
|
/* We always allow inverting the text direction, even in
|
||||||
|
* production builds, as SDK/IDE tooling may provide the
|
||||||
|
* ability for developers to test rtl/ltr inverted.
|
||||||
|
*/
|
||||||
|
if (gtk_get_debug_flags () & GTK_DEBUG_INVERT_TEXT_DIR)
|
||||||
|
text_dir = (text_dir == GTK_TEXT_DIR_LTR) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR;
|
||||||
|
|
||||||
|
gtk_widget_set_default_direction (text_dir);
|
||||||
|
|
||||||
gdk_event_init_types ();
|
gdk_event_init_types ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user