[metacity] frames: Use title style to set up title layout
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity] frames: Use title style to set up title layout
- Date: Thu, 19 Feb 2015 21:21:37 +0000 (UTC)
commit dce01fa7e380f20edd4f14bfde723aa9031c797b
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.
https://bugzilla.gnome.org/show_bug.cgi?id=741917
NOTE: Updated for metacity.
src/ui/frames.c | 23 +++++++++++++++--------
src/ui/theme.c | 25 +++++++++++++++++++++++++
src/ui/theme.h | 8 ++++++++
src/ui/ui.c | 41 +++++++++++++++++++++++++++++------------
4 files changed, 77 insertions(+), 20 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index d45f997..68daa61 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -508,22 +508,29 @@ 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 ());
+ if (meta_prefs_get_theme ())
+ {
+ double scale;
+
+ scale = meta_theme_get_title_scale (meta_theme_get_current (),
+ type, flags);
+
+ font_desc = meta_gtk_widget_get_font_desc (widget, scale,
+ meta_prefs_get_titlebar_font ());
+ }
+ else
+ {
+ 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.c b/src/ui/theme.c
index 3ee5d04..8269a20 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -4488,6 +4488,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,
@@ -5562,6 +5571,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,
diff --git a/src/ui/theme.h b/src/ui/theme.h
index da7ffe8..f83a57e 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -967,6 +967,9 @@ 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,
GError **error);
@@ -1004,6 +1007,11 @@ 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_style_info_set_flags (MetaStyleInfo *style_info,
+ MetaFrameFlags flags);
+
void meta_theme_draw_frame (MetaTheme *theme,
MetaStyleInfo *style_info,
cairo_t *cr,
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 14a9602..9a7f255 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -671,7 +671,6 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
int text_height;
PangoContext *context;
const PangoFontDescription *font_desc;
- GtkStyleContext *style = NULL;
PangoFontDescription *free_font_desc = NULL;
if (meta_ui_have_a_theme ())
@@ -683,16 +682,37 @@ 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);
+ if (meta_prefs_get_theme ())
+ {
+ GtkStyleContext *style = NULL;
+ 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);
+
+ if (style != NULL)
+ g_object_unref (style);
+ }
+ else
+ {
+ MetaStyleInfo *style_info = NULL;
+
+ style_info = meta_theme_create_style_info (screen, NULL);
+ free_font_desc = meta_style_info_create_font_desc (style_info);
+
+ if (style_info != NULL)
+ meta_style_info_unref (style_info);
+ }
- gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
font_desc = (const PangoFontDescription *) free_font_desc;
}
@@ -709,9 +729,6 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
{
meta_frame_borders_clear (borders);
}
-
- if (style != NULL)
- g_object_unref (style);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]