mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 22:41:43 +00:00
inspector: Use GtkFontDialogButton
A small step towards respecting our own deprecations. While we are at it, make the control only select the font family, since that is the intention of the font setting. Font style and size are under the control of the css, and we have a font scale slider right below to influence font size globally.
This commit is contained in:
parent
7f48b5a05c
commit
c8c56f8d42
@ -866,13 +866,50 @@ init_cursor_size (GtkInspectorVisual *vis)
|
||||
G_CALLBACK (cursor_size_changed), vis);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
name_to_desc (GBinding *binding,
|
||||
const GValue *from_value,
|
||||
GValue *to_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
const char *name;
|
||||
PangoFontDescription *desc;
|
||||
|
||||
name = g_value_get_string (from_value);
|
||||
desc = pango_font_description_from_string (name);
|
||||
|
||||
g_value_take_boxed (to_value, desc);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
name_from_desc (GBinding *binding,
|
||||
const GValue *from_value,
|
||||
GValue *to_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
const char *name;
|
||||
PangoFontDescription *desc;
|
||||
|
||||
desc = g_value_get_boxed (from_value);
|
||||
name = pango_font_description_get_family (desc);
|
||||
|
||||
g_value_set_string (to_value, name);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
init_font (GtkInspectorVisual *vis)
|
||||
{
|
||||
g_object_bind_property (gtk_settings_get_for_display (vis->display),
|
||||
"gtk-font-name",
|
||||
vis->font_button, "font",
|
||||
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property_full (gtk_settings_get_for_display (vis->display),
|
||||
"gtk-font-name",
|
||||
vis->font_button, "font-desc",
|
||||
G_BINDING_BIDIRECTIONAL|G_BINDING_SYNC_CREATE,
|
||||
name_to_desc,
|
||||
name_from_desc,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -173,7 +173,12 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFontButton" id="font_button">
|
||||
<object class="GtkFontDialogButton" id="font_button">
|
||||
<property name="level">family</property>
|
||||
<property name="dialog">
|
||||
<object class="GtkFontDialog">
|
||||
</object>
|
||||
</property>
|
||||
<property name="halign">end</property>
|
||||
<property name="valign">baseline</property>
|
||||
<property name="hexpand">1</property>
|
||||
|
Loading…
Reference in New Issue
Block a user