mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
inspector: Add a button for rtl flipping
Nice to have a quick way of testing this everywhere. The implementation is not quite perfect: due to the way text direction works in GTK+, widgets that appear in the inspector window while we are flipped will inherit the flipped direction instead of the fixed direction of the inspector window.
This commit is contained in:
parent
a089ccf5f0
commit
be532bc196
@ -50,6 +50,40 @@ on_graphic_updates_toggled (GtkToggleButton *button,
|
||||
gdk_window_set_debug_updates (gtk_toggle_button_get_active (button));
|
||||
}
|
||||
|
||||
static void
|
||||
fix_direction_recurse (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GtkTextDirection dir = GPOINTER_TO_INT (data);
|
||||
|
||||
g_object_ref (widget);
|
||||
|
||||
gtk_widget_set_direction (widget, dir);
|
||||
if (GTK_IS_CONTAINER (widget))
|
||||
gtk_container_forall (GTK_CONTAINER (widget), fix_direction_recurse, data);
|
||||
|
||||
g_object_unref (widget);
|
||||
}
|
||||
|
||||
static GtkTextDirection initial_direction;
|
||||
|
||||
static void
|
||||
fix_direction (GtkInspectorWindow *iw)
|
||||
{
|
||||
fix_direction_recurse (GTK_WIDGET (iw), GINT_TO_POINTER (initial_direction));
|
||||
}
|
||||
|
||||
static void
|
||||
on_flip (GtkButton *button,
|
||||
GtkInspectorWindow *iw)
|
||||
{
|
||||
fix_direction (iw);
|
||||
|
||||
if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_LTR)
|
||||
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
|
||||
else
|
||||
gtk_widget_set_default_direction (GTK_TEXT_DIR_LTR);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_widget_tree_button_press (GtkInspectorWidgetTree *wt,
|
||||
GdkEventButton *event,
|
||||
@ -126,6 +160,8 @@ gtk_inspector_window_init (GtkInspectorWindow *iw)
|
||||
g_signal_connect (G_OBJECT (iw->widget_tree), "button-press-event",
|
||||
G_CALLBACK (on_widget_tree_button_press), iw);
|
||||
}
|
||||
|
||||
initial_direction = gtk_widget_get_default_direction ();
|
||||
}
|
||||
|
||||
static void
|
||||
@ -182,6 +218,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_inspect);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_graphic_updates_toggled);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_flip);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_widget_tree_selection_changed);
|
||||
gtk_widget_class_bind_template_callback (widget_class, on_send_widget_to_shell_activate);
|
||||
}
|
||||
|
@ -1,13 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface domain="gtk30">
|
||||
<object class="GtkImage" id="inspect_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">edit-find</property>
|
||||
<property name="icon-size">4</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="update_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">view-refresh</property>
|
||||
<property name="icon-size">4</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="inspect_image">
|
||||
<object class="GtkImage" id="flip_image">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">edit-find</property>
|
||||
<property name="icon-name">object-flip-horizontal</property>
|
||||
<property name="icon-size">4</property>
|
||||
</object>
|
||||
<object class="GtkMenu" id="widget_popup">
|
||||
@ -49,6 +54,14 @@
|
||||
<signal name="toggled" handler="on_graphic_updates_toggled"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="image">flip_image</property>
|
||||
<property name="tooltip-text" translatable="yes">Change Text Direction</property>
|
||||
<signal name="clicked" handler="on_flip"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="pack-type">start</property>
|
||||
|
Loading…
Reference in New Issue
Block a user