forked from AuroraMiddleware/gtk
inspector: Give the font scale an entry
This matches what Matt did for the slowdown.
This commit is contained in:
parent
b3dc473057
commit
e6c408c08a
@ -53,12 +53,12 @@ struct _GtkInspectorVisualPrivate
|
||||
GtkWidget *font_button;
|
||||
GtkWidget *hidpi_spin;
|
||||
GtkWidget *animation_switch;
|
||||
GtkWidget *font_scale_scale;
|
||||
GtkWidget *font_scale_entry;
|
||||
GtkAdjustment *font_scale_adjustment;
|
||||
GtkAdjustment *scale_adjustment;
|
||||
GtkAdjustment *slowdown_adjustment;
|
||||
GtkWidget *slowdown_entry;
|
||||
GtkAdjustment *cursor_size_adjustment;
|
||||
GtkAdjustment *font_scale_adjustment;
|
||||
|
||||
GtkWidget *debug_box;
|
||||
GtkWidget *rendering_mode_combo;
|
||||
@ -140,13 +140,46 @@ redraw_everything (void)
|
||||
}
|
||||
|
||||
static void
|
||||
font_scale_changed (GtkAdjustment *adjustment)
|
||||
update_font_scale (GtkInspectorVisual *vis,
|
||||
gdouble factor,
|
||||
gboolean update_adjustment,
|
||||
gboolean update_entry)
|
||||
{
|
||||
g_object_set (gtk_settings_get_default (), "gtk-xft-dpi",
|
||||
(gint)(factor * 96 * 1024), NULL);
|
||||
|
||||
if (update_adjustment)
|
||||
gtk_adjustment_set_value (vis->priv->font_scale_adjustment, factor);
|
||||
|
||||
if (update_entry)
|
||||
{
|
||||
gchar *str = g_strdup_printf ("%0.2f", factor);
|
||||
|
||||
gtk_entry_set_text (GTK_ENTRY (vis->priv->font_scale_entry), str);
|
||||
g_free (str);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
font_scale_adjustment_changed (GtkAdjustment *adjustment,
|
||||
GtkInspectorVisual *vis)
|
||||
{
|
||||
gdouble factor;
|
||||
|
||||
factor = gtk_adjustment_get_value (adjustment);
|
||||
g_object_set (gtk_settings_get_default (), "gtk-xft-dpi",
|
||||
(gint)(factor * 96 * 1024), NULL);
|
||||
update_font_scale (vis, factor, FALSE, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
font_scale_entry_activated (GtkEntry *entry,
|
||||
GtkInspectorVisual *vis)
|
||||
{
|
||||
gdouble factor;
|
||||
gchar *err = NULL;
|
||||
|
||||
factor = g_strtod (gtk_entry_get_text (entry), &err);
|
||||
if (err != NULL)
|
||||
update_font_scale (vis, factor, TRUE, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -513,11 +546,12 @@ init_font (GtkInspectorVisual *vis)
|
||||
static void
|
||||
init_font_scale (GtkInspectorVisual *vis)
|
||||
{
|
||||
gtk_scale_add_mark (GTK_SCALE (vis->priv->font_scale_scale), 1.0, GTK_POS_TOP, NULL);
|
||||
/* There is no backend agnostic way to get the default value, so use 1.0 */
|
||||
gtk_adjustment_set_value (vis->priv->font_scale_adjustment, 1.0);
|
||||
update_font_scale (vis, 1.0, TRUE, TRUE);
|
||||
g_signal_connect (vis->priv->font_scale_adjustment, "value-changed",
|
||||
G_CALLBACK (font_scale_changed), NULL);
|
||||
G_CALLBACK (font_scale_adjustment_changed), vis);
|
||||
g_signal_connect (vis->priv->font_scale_entry, "activate",
|
||||
G_CALLBACK (font_scale_entry_activated), vis);
|
||||
}
|
||||
|
||||
#if defined (GDK_WINDOWING_X11)
|
||||
@ -860,7 +894,7 @@ gtk_inspector_visual_class_init (GtkInspectorVisualClass *klass)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, software_gl_switch);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, software_surface_switch);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, texture_rectangle_switch);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_scale);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_entry);
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorVisual, font_scale_adjustment);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, updates_activate);
|
||||
|
@ -256,7 +256,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<property name="margin">10</property>
|
||||
<property name="spacing">40</property>
|
||||
<property name="spacing">20</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="font_scale_label">
|
||||
<property name="visible">True</property>
|
||||
@ -269,15 +269,26 @@
|
||||
<child>
|
||||
<object class="GtkScale" id="font_scale_scale">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="digits">2</property>
|
||||
<property name="adjustment">font_scale_adjustment</property>
|
||||
<property name="draw_value">0</property>
|
||||
<marks>
|
||||
<mark value="1.0" position="top"/>
|
||||
</marks>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="font_scale_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="width-chars">4</property>
|
||||
<property name="input-purpose">number</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@ -876,7 +887,6 @@
|
||||
<widget name="icon_combo"/>
|
||||
<widget name="cursor_combo"/>
|
||||
<widget name="font_button"/>
|
||||
<widget name="font_scale_scale"/>
|
||||
<widget name="direction_combo"/>
|
||||
<widget name="rendering_mode_combo"/>
|
||||
<widget name="gl_combo"/>
|
||||
|
Loading…
Reference in New Issue
Block a user