[metacity/wip/gtk-theme: 16/52] 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/wip/gtk-theme: 16/52] frames: Use title style to set up title layout
- Date: Wed, 7 Jan 2015 12:35:46 +0000 (UTC)
commit 08a50706b57c9f44892c691ff81be5582e188c47
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 in way it does not break existing themes.
src/ui/frames.c | 23 +++++++++++++++--------
src/ui/theme.c | 26 ++++++++++++++++++++++++++
src/ui/theme.h | 8 ++++++++
src/ui/ui.c | 41 +++++++++++++++++++++++++++++------------
4 files changed, 78 insertions(+), 20 deletions(-)
---
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 9ea60a9..e38b583 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -525,22 +525,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 (g_getenv ("USE_METACITY_THEME") != NULL)
+ {
+ 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 9baee78..d8415ee 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -54,6 +54,7 @@
#include "frames.h" /* for META_TYPE_FRAMES */
#include "theme.h"
#include "theme-parser.h"
+#include "prefs.h" /* for meta_prefs_get_titlebar_font */
#include "util.h"
#include "gradient.h"
#include <gtk/gtk.h>
@@ -4519,6 +4520,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,
@@ -5601,6 +5611,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 57e8d10..df85576 100644
--- a/src/ui/theme.h
+++ b/src/ui/theme.h
@@ -1027,6 +1027,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);
+
MetaShadowProperties* meta_frame_style_get_shadow_properties (MetaFrameStyle *style);
MetaInvisibleGrabAreaProperties* meta_frame_style_get_invisible_grab_area_properties (MetaFrameStyle *style);
@@ -1067,6 +1070,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 88fc883..ca06058 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -675,7 +675,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 ())
@@ -687,16 +686,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 (g_getenv ("USE_METACITY_THEME") != NULL)
+ {
+ 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;
}
@@ -713,9 +733,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]