diff options
author | monsta <[email protected]> | 2017-01-06 18:02:30 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2017-01-06 18:02:30 +0300 |
commit | 5759a070c1b02cc9f07b4a1670cecca34d25e2b0 (patch) | |
tree | df5472c712e1a6aa4c9aa72d148c8b2a397bbc1f /src/ui/theme-viewer.c | |
parent | 1cdde13577525fda5609ed2a494f743e979f6e10 (diff) | |
download | marco-5759a070c1b02cc9f07b4a1670cecca34d25e2b0.tar.bz2 marco-5759a070c1b02cc9f07b4a1670cecca34d25e2b0.tar.xz |
theme-viewer: use GtkStyleContext
picked from upstream:
https://git.gnome.org/browse/metacity/commit/src/ui/theme-viewer.c?id=238e83a98cf014c9b1082d21541e63f102d441d6
https://git.gnome.org/browse/metacity/commit/src/ui/theme-viewer.c?id=c9099b4a90932a22c86b960c8b4dc7cd1458defe
Diffstat (limited to 'src/ui/theme-viewer.c')
-rw-r--r-- | src/ui/theme-viewer.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c index 879e39ab..dae993ec 100644 --- a/src/ui/theme-viewer.c +++ b/src/ui/theme-viewer.c @@ -465,7 +465,7 @@ get_window_flags (MetaFrameType type) static GtkWidget* preview_collection (int font_size, - PangoFontDescription *base_desc) + const PangoFontDescription *base_desc) { GtkWidget *box; GtkWidget *sw; @@ -560,7 +560,7 @@ preview_collection (int font_size, pango_font_description_set_size (font_desc, MAX (pango_font_description_get_size (base_desc) * scale, 1)); - gtk_widget_modify_font (preview, font_desc); + gtk_widget_override_font (preview, font_desc); pango_font_description_free (font_desc); } @@ -777,7 +777,8 @@ main (int argc, char **argv) { GtkWidget *window; GtkWidget *collection; - GtkStyle *style; + GtkStyleContext *style; + PangoFontDescription *font_desc; GError *err; clock_t start, end; GtkWidget *notebook; @@ -847,28 +848,29 @@ main (int argc, char **argv) G_CALLBACK (gtk_main_quit), NULL); gtk_widget_realize (window); - style = gtk_widget_get_style (window); + style = gtk_widget_get_style_context (window); + gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &font_desc, NULL); g_assert (style); - g_assert (style->font_desc); + g_assert (font_desc); notebook = gtk_notebook_new (); gtk_container_add (GTK_CONTAINER (window), notebook); collection = preview_collection (FONT_SIZE_NORMAL, - style->font_desc); + font_desc); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), collection, gtk_label_new (_("Normal Title Font"))); collection = preview_collection (FONT_SIZE_SMALL, - style->font_desc); + font_desc); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), collection, gtk_label_new (_("Small Title Font"))); collection = preview_collection (FONT_SIZE_LARGE, - style->font_desc); + font_desc); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), collection, gtk_label_new (_("Large Title Font"))); @@ -883,6 +885,8 @@ main (int argc, char **argv) collection, gtk_label_new (_("Benchmark"))); + pango_font_description_free (font_desc); + i = 0; while (i < (int) G_N_ELEMENTS (previews)) { @@ -919,8 +923,16 @@ get_flags (GtkWidget *widget) static int get_text_height (GtkWidget *widget) { - return meta_pango_font_desc_get_text_height (gtk_widget_get_style (widget)->font_desc, - gtk_widget_get_pango_context (widget)); + GtkStyleContext *style; + PangoFontDescription *font_desc; + int text_height; + + style = gtk_widget_get_style_context (widget); + gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &font_desc, NULL); + text_height = meta_pango_font_desc_get_text_height (font_desc, gtk_widget_get_pango_context (widget)); + pango_font_description_free (font_desc); + + return text_height; } static PangoLayout* |