summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-05-10 20:55:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2021-05-10 20:55:43 -0400
commita723baec4b57532e1bcdb0f30930873f281cd644 (patch)
tree1a367acdf7f8238cc6a8f50ea4d0cbc924e9c44b
parent6120519e8e0307156b4dbfe4b93275463d57f3ca (diff)
downloadgtk+-a723baec4b57532e1bcdb0f30930873f281cd644.tar.gz
inspector: Show text direction
This is not a property, so show it on the misc tab.
-rw-r--r--gtk/inspector/misc-info.c36
-rw-r--r--gtk/inspector/misc-info.ui31
2 files changed, 65 insertions, 2 deletions
diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c
index 8d969d996f..df61d1ea00 100644
--- a/gtk/inspector/misc-info.c
+++ b/gtk/inspector/misc-info.c
@@ -47,6 +47,8 @@ struct _GtkInspectorMiscInfo
GtkWidget *refcount;
GtkWidget *state_row;
GtkWidget *state;
+ GtkWidget *direction_row;
+ GtkWidget *direction;
GtkWidget *buildable_id_row;
GtkWidget *buildable_id;
GtkWidget *mnemonic_label_row;
@@ -296,6 +298,30 @@ update_frame_clock (GtkInspectorMiscInfo *sl)
}
}
+static void
+update_direction (GtkInspectorMiscInfo *sl)
+{
+ GtkWidget *widget = GTK_WIDGET (sl->object);
+
+ switch (widget->priv->direction)
+ {
+ case GTK_TEXT_DIR_LTR:
+ gtk_label_set_label (GTK_LABEL (sl->direction), "Left-to-Right");
+ break;
+ case GTK_TEXT_DIR_RTL:
+ gtk_label_set_label (GTK_LABEL (sl->direction), "Right-to-Left");
+ break;
+ case GTK_TEXT_DIR_NONE:
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ gtk_label_set_label (GTK_LABEL (sl->direction), "Left-to-Right (inherited)");
+ else
+ gtk_label_set_label (GTK_LABEL (sl->direction), "Right-to-Left (inherited)");
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+}
+
static gboolean
update_info (gpointer data)
{
@@ -325,8 +351,10 @@ update_info (gpointer data)
GtkWidget *child;
GList *list, *l;
- while ((child = gtk_widget_get_first_child (sl->mnemonic_label)))
- gtk_box_remove (GTK_BOX (sl->mnemonic_label), child);
+ update_direction (sl);
+
+ while ((child = gtk_widget_get_first_child (sl->mnemonic_label)))
+ gtk_box_remove (GTK_BOX (sl->mnemonic_label), child);
list = gtk_widget_list_mnemonic_labels (GTK_WIDGET (sl->object));
for (l = list; l; l = l->next)
@@ -418,6 +446,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
{
gtk_widget_show (sl->refcount_row);
gtk_widget_show (sl->state_row);
+ gtk_widget_show (sl->direction_row);
gtk_widget_show (sl->request_mode_row);
gtk_widget_show (sl->allocated_size_row);
gtk_widget_show (sl->baseline_row);
@@ -437,6 +466,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
else
{
gtk_widget_hide (sl->state_row);
+ gtk_widget_hide (sl->direction_row);
gtk_widget_hide (sl->request_mode_row);
gtk_widget_hide (sl->mnemonic_label_row);
gtk_widget_hide (sl->allocated_size_row);
@@ -534,6 +564,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, refcount);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, state_row);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, state);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, direction_row);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, direction);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, buildable_id_row);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, buildable_id);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, mnemonic_label_row);
diff --git a/gtk/inspector/misc-info.ui b/gtk/inspector/misc-info.ui
index ca7fbc9639..8313e5a6e3 100644
--- a/gtk/inspector/misc-info.ui
+++ b/gtk/inspector/misc-info.ui
@@ -137,6 +137,36 @@
</object>
</child>
<child>
+ <object class="GtkListBoxRow" id="direction_row">
+ <property name="activatable">0</property>
+ <child>
+ <object class="GtkBox">
+ <property name="margin-start">10</property>
+ <property name="margin-end">10</property>
+ <property name="margin-top">10</property>
+ <property name="margin-bottom">10</property>
+ <property name="spacing">40</property>
+ <child>
+ <object class="GtkLabel" id="direction_label">
+ <property name="label" translatable="yes">Direction</property>
+ <property name="halign">start</property>
+ <property name="valign">baseline</property>
+ <property name="xalign">0.0</property>
+ <property name="hexpand">1</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="direction">
+ <property name="selectable">1</property>
+ <property name="halign">end</property>
+ <property name="valign">baseline</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkListBoxRow" id="buildable_id_row">
<property name="activatable">0</property>
<child>
@@ -621,6 +651,7 @@
<widget name="address_label"/>
<widget name="refcount_label"/>
<widget name="state_label"/>
+ <widget name="direction_label"/>
<widget name="buildable_id_label"/>
<widget name="surface_label"/>
<widget name="renderer_label"/>