[mutter/wip/gtk-theming: 5/20] frames: Use title style to set up title layout
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/gtk-theming: 5/20] frames: Use title style to set up title layout
- Date: Mon, 22 Dec 2014 23:25:10 +0000 (UTC)
commit 282de4c0df92d414155a2f12d807fb1c923ab129
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Sep 25 06:44:45 2014 +0200
frames: Use title style to set up title layout
Sounds obvious, doesn't it?
After this change when titlebar-uses-system-font is set, the "system
font" used will not be a generic one, but match what GTK+ uses in
client-side decorations.
src/ui/frames.c | 9 ++-------
src/ui/theme-private.h | 7 ++++---
src/ui/theme.c | 48 +++++++++++++++++++++++++-----------------------
src/ui/ui.c | 17 +++++------------
4 files changed, 36 insertions(+), 45 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 41c719f..809b2ee 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -416,21 +416,16 @@ meta_frames_ensure_layout (MetaFrames *frames,
{
gpointer key, value;
PangoFontDescription *font_desc;
- double scale;
int size;
- scale = meta_theme_get_title_scale (meta_theme_get_current (),
- type,
- flags);
-
frame->layout = gtk_widget_create_pango_layout (widget, frame->title);
pango_layout_set_ellipsize (frame->layout, PANGO_ELLIPSIZE_END);
pango_layout_set_auto_dir (frame->layout, FALSE);
pango_layout_set_single_paragraph_mode (frame->layout, TRUE);
- font_desc = meta_gtk_widget_get_font_desc (widget, scale,
- meta_prefs_get_titlebar_font ());
+ font_desc = meta_style_info_create_font_desc (frame->style_info);
+ meta_frame_style_apply_scale (style, font_desc);
size = pango_font_description_get_size (font_desc);
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index bd482ba..04558ef 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -1021,6 +1021,8 @@ MetaFrameStyle* meta_frame_style_new (MetaFrameStyle *parent);
void meta_frame_style_ref (MetaFrameStyle *style);
void meta_frame_style_unref (MetaFrameStyle *style);
+void meta_frame_style_apply_scale (const MetaFrameStyle *style,
+ PangoFontDescription *font_desc);
gboolean meta_frame_style_validate (MetaFrameStyle *style,
guint current_theme_version,
@@ -1051,6 +1053,8 @@ MetaStyleInfo * meta_theme_create_style_info (GdkScreen *screen,
MetaStyleInfo * meta_style_info_ref (MetaStyleInfo *style);
void meta_style_info_unref (MetaStyleInfo *style_info);
+PangoFontDescription * meta_style_info_create_font_desc (MetaStyleInfo *style_info);
+
void meta_theme_draw_frame (MetaTheme *theme,
MetaStyleInfo *style_info,
cairo_t *cr,
@@ -1130,9 +1134,6 @@ gboolean meta_theme_replace_constants (MetaTheme *theme,
/* random stuff */
-PangoFontDescription* meta_gtk_widget_get_font_desc (GtkWidget *widget,
- double scale,
- const PangoFontDescription *override);
int meta_pango_font_desc_get_text_height (const PangoFontDescription *font_desc,
PangoContext *context);
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 894f996..8faa83d 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -4034,6 +4034,15 @@ get_button (MetaFrameStyle *style,
return op_list;
}
+void
+meta_frame_style_apply_scale (const MetaFrameStyle *style,
+ PangoFontDescription *font_desc)
+{
+ int size = pango_font_description_get_size (font_desc);
+ pango_font_description_set_size (font_desc,
+ MAX (size * style->layout->title_scale, 1));
+}
+
gboolean
meta_frame_style_validate (MetaFrameStyle *style,
guint current_theme_version,
@@ -5122,6 +5131,22 @@ meta_style_info_unref (MetaStyleInfo *style_info)
}
}
+PangoFontDescription*
+meta_style_info_create_font_desc (MetaStyleInfo *style_info)
+{
+ PangoFontDescription *font_desc;
+ const PangoFontDescription *override = meta_prefs_get_titlebar_font ();
+
+ gtk_style_context_get (style_info->styles[META_STYLE_ELEMENT_TITLE],
+ GTK_STATE_FLAG_NORMAL,
+ "font", &font_desc, NULL);
+
+ if (override)
+ pango_font_description_merge (font_desc, override, TRUE);
+
+ return font_desc;
+}
+
void
meta_theme_draw_frame (MetaTheme *theme,
MetaStyleInfo *style_info,
@@ -5490,29 +5515,6 @@ meta_theme_lookup_color_constant (MetaTheme *theme,
}
}
-
-PangoFontDescription*
-meta_gtk_widget_get_font_desc (GtkWidget *widget,
- double scale,
- const PangoFontDescription *override)
-{
- GtkStyleContext *style;
- PangoFontDescription *font_desc;
-
- g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
-
- style = gtk_widget_get_style_context (widget);
- gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &font_desc, NULL);
-
- if (override)
- pango_font_description_merge (font_desc, override, TRUE);
-
- pango_font_description_set_size (font_desc,
- MAX (pango_font_description_get_size (font_desc) * scale, 1));
-
- return font_desc;
-}
-
/**
* meta_pango_font_desc_get_text_height:
* @font_desc: the font
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 4381880..e93d764 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -576,7 +576,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
MetaFrameBorders *borders)
{
int text_height;
- GtkStyleContext *style = NULL;
+ MetaStyleInfo *style_info = NULL;
PangoContext *context;
const PangoFontDescription *font_desc;
PangoFontDescription *free_font_desc = NULL;
@@ -590,16 +590,9 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
{
GdkDisplay *display = gdk_x11_lookup_xdisplay (ui->xdisplay);
GdkScreen *screen = gdk_display_get_screen (display, XScreenNumberOfScreen (ui->xscreen));
- GtkWidgetPath *widget_path;
- style = gtk_style_context_new ();
- gtk_style_context_set_screen (style, screen);
- widget_path = gtk_widget_path_new ();
- gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
- gtk_style_context_set_path (style, widget_path);
- gtk_widget_path_free (widget_path);
-
- gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
+ style_info = meta_theme_create_style_info (screen, NULL);
+ free_font_desc = meta_style_info_create_font_desc (style_info);
font_desc = (const PangoFontDescription *) free_font_desc;
}
@@ -617,8 +610,8 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
meta_frame_borders_clear (borders);
}
- if (style != NULL)
- g_object_unref (style);
+ if (style_info != NULL)
+ meta_style_info_unref (style_info);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]