[metacity] libmetacity: don't expose meta_theme_create_title_layout



commit cc5c53f9adc7fafe37dbb43f3a32026022bfe202
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Jun 7 13:59:23 2016 +0300

    libmetacity: don't expose meta_theme_create_title_layout

 libmetacity/meta-theme.c           |   94 ++++++++++++++++-------------------
 libmetacity/meta-theme.h           |    8 +---
 src/ui/frames.c                    |   51 +-------------------
 src/ui/frames.h                    |    2 -
 theme-viewer/theme-viewer-window.c |   24 +--------
 5 files changed, 47 insertions(+), 132 deletions(-)
---
diff --git a/libmetacity/meta-theme.c b/libmetacity/meta-theme.c
index 70ab57b..8e86ec7 100644
--- a/libmetacity/meta-theme.c
+++ b/libmetacity/meta-theme.c
@@ -225,6 +225,33 @@ get_title_height (MetaTheme      *theme,
   return title_height;
 }
 
+static PangoLayout *
+create_title_layout (MetaTheme      *theme,
+                     const gchar    *variant,
+                     MetaFrameType   type,
+                     MetaFrameFlags  flags,
+                     const gchar    *title)
+{
+  PangoLayout *layout;
+  PangoFontDescription *font_desc;
+
+  ensure_pango_context (theme);
+
+  layout = pango_layout_new (theme->context);
+
+  if (title)
+    pango_layout_set_text (layout, title, -1);
+
+  pango_layout_set_auto_dir (layout, FALSE);
+  pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
+  pango_layout_set_single_paragraph_mode (layout, TRUE);
+
+  font_desc = get_title_font_desc (theme, variant, type, flags);
+  pango_layout_set_font_description (layout, font_desc);
+
+  return layout;
+}
+
 static void
 meta_theme_constructed (GObject *object)
 {
@@ -515,45 +542,6 @@ meta_theme_get_frame_style (MetaTheme      *theme,
   return style;
 }
 
-/**
- * meta_theme_create_title_layout:
- * @theme: a #MetaTheme
- * @variant: (nullable): theme variant
- * @type: frame type
- * @flags: frame flags
- * @title: (nullable): text to set on the layout
- *
- * Use this function to create #PangoLayout for use in meta_theme_draw_frame.
- *
- * Returns: (transfer full): the new #PangoLayout
- */
-PangoLayout *
-meta_theme_create_title_layout (MetaTheme      *theme,
-                                const gchar    *variant,
-                                MetaFrameType   type,
-                                MetaFrameFlags  flags,
-                                const gchar    *title)
-{
-  PangoLayout *layout;
-  PangoFontDescription *font_desc;
-
-  ensure_pango_context (theme);
-
-  layout = pango_layout_new (theme->context);
-
-  if (title)
-    pango_layout_set_text (layout, title, -1);
-
-  pango_layout_set_auto_dir (layout, FALSE);
-  pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);
-  pango_layout_set_single_paragraph_mode (layout, TRUE);
-
-  font_desc = get_title_font_desc (theme, variant, type, flags);
-  pango_layout_set_font_description (layout, font_desc);
-
-  return layout;
-}
-
 MetaFrameType
 meta_frame_type_from_string (const gchar *str)
 {
@@ -577,7 +565,7 @@ meta_frame_type_from_string (const gchar *str)
 
 void
 meta_theme_get_frame_borders (MetaTheme        *theme,
-                              const gchar      *theme_variant,
+                              const gchar      *variant,
                               MetaFrameType     type,
                               MetaFrameFlags    flags,
                               MetaFrameBorders *borders)
@@ -598,8 +586,8 @@ meta_theme_get_frame_borders (MetaTheme        *theme,
     return;
 
   impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
-  style_info = meta_theme_get_style_info (theme, theme_variant);
-  title_height = get_title_height (theme, theme_variant, type, flags);
+  style_info = meta_theme_get_style_info (theme, variant);
+  title_height = get_title_height (theme, variant, type, flags);
 
   impl_class->get_frame_borders (theme->impl, style->layout, style_info,
                                  title_height, flags, type, borders);
@@ -607,7 +595,7 @@ meta_theme_get_frame_borders (MetaTheme        *theme,
 
 void
 meta_theme_calc_geometry (MetaTheme              *theme,
-                          const gchar            *theme_variant,
+                          const gchar            *variant,
                           MetaFrameType           type,
                           MetaFrameFlags          flags,
                           gint                    client_width,
@@ -629,8 +617,8 @@ meta_theme_calc_geometry (MetaTheme              *theme,
     return;
 
   impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
-  style_info = meta_theme_get_style_info (theme, theme_variant);
-  title_height = get_title_height (theme, theme_variant, type, flags);
+  style_info = meta_theme_get_style_info (theme, variant);
+  title_height = get_title_height (theme, variant, type, flags);
 
   impl_class->calc_geometry (theme->impl, style->layout, style_info,
                              title_height, flags, client_width, client_height,
@@ -639,13 +627,13 @@ meta_theme_calc_geometry (MetaTheme              *theme,
 
 void
 meta_theme_draw_frame (MetaTheme              *theme,
-                       const gchar            *theme_variant,
+                       const gchar            *variant,
                        cairo_t                *cr,
                        MetaFrameType           type,
                        MetaFrameFlags          flags,
-                       int                     client_width,
-                       int                     client_height,
-                       PangoLayout            *title_layout,
+                       gint                    client_width,
+                       gint                    client_height,
+                       const gchar            *title,
                        const MetaButtonLayout *button_layout,
                        MetaButtonState         button_states[META_BUTTON_TYPE_LAST],
                        GdkPixbuf              *mini_icon,
@@ -655,6 +643,7 @@ meta_theme_draw_frame (MetaTheme              *theme,
   MetaThemeImplClass *impl_class;
   MetaStyleInfo *style_info;
   gint title_height;
+  PangoLayout *title_layout;
   MetaFrameGeometry fgeom;
 
   g_return_if_fail (type < META_FRAME_TYPE_LAST);
@@ -666,8 +655,9 @@ meta_theme_draw_frame (MetaTheme              *theme,
     return;
 
   impl_class = META_THEME_IMPL_GET_CLASS (theme->impl);
-  style_info = meta_theme_get_style_info (theme, theme_variant);
-  title_height = get_title_height (theme, theme_variant, type, flags);
+  style_info = meta_theme_get_style_info (theme, variant);
+  title_height = get_title_height (theme, variant, type, flags);
+  title_layout = create_title_layout (theme, variant, type, flags, title);
 
   impl_class->calc_geometry (theme->impl, style->layout, style_info,
                              title_height, flags, client_width, client_height,
@@ -675,4 +665,6 @@ meta_theme_draw_frame (MetaTheme              *theme,
 
   impl_class->draw_frame (theme->impl, style, style_info, cr, &fgeom,
                           title_layout, flags, button_states, mini_icon, icon);
+
+  g_object_unref (title_layout);
 }
diff --git a/libmetacity/meta-theme.h b/libmetacity/meta-theme.h
index 8a36efb..fad7465 100644
--- a/libmetacity/meta-theme.h
+++ b/libmetacity/meta-theme.h
@@ -165,12 +165,6 @@ MetaFrameStyle *meta_theme_get_frame_style     (MetaTheme                   *the
                                                 MetaFrameType                type,
                                                 MetaFrameFlags               flags);
 
-PangoLayout    *meta_theme_create_title_layout (MetaTheme                   *theme,
-                                                const gchar                 *variant,
-                                                MetaFrameType                type,
-                                                MetaFrameFlags               flags,
-                                                const gchar                 *title);
-
 MetaFrameType   meta_frame_type_from_string    (const gchar                 *str);
 
 void            meta_theme_get_frame_borders   (MetaTheme                   *theme,
@@ -195,7 +189,7 @@ void            meta_theme_draw_frame          (MetaTheme                   *the
                                                 MetaFrameFlags               flags,
                                                 gint                         client_width,
                                                 gint                         client_height,
-                                                PangoLayout                 *title_layout,
+                                                const gchar                 *title,
                                                 const MetaButtonLayout      *button_layout,
                                                 MetaButtonState              
button_states[META_BUTTON_TYPE_LAST],
                                                 GdkPixbuf                   *mini_icon,
diff --git a/src/ui/frames.c b/src/ui/frames.c
index 88737fb..f950cb5 100644
--- a/src/ui/frames.c
+++ b/src/ui/frames.c
@@ -75,9 +75,6 @@ static void meta_frames_calc_geometry (MetaFrames        *frames,
                                        MetaUIFrame         *frame,
                                        MetaFrameGeometry *fgeom);
 
-static void meta_frames_ensure_layout (MetaFrames      *frames,
-                                       MetaUIFrame     *frame);
-
 static MetaUIFrame* meta_frames_lookup_window (MetaFrames *frames,
                                                Window      xwindow);
 
@@ -325,8 +322,6 @@ queue_recalc_func (gpointer key, gpointer value, gpointer data)
   invalidate_whole_window (frames, frame);
   meta_core_queue_frame_resize (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                                 frame->xwindow);
-
-  g_clear_object (&frame->text_layout);
 }
 
 static void
@@ -403,37 +398,6 @@ meta_frames_style_updated (GtkWidget *widget)
 }
 
 static void
-meta_frames_ensure_layout (MetaFrames  *frames,
-                           MetaUIFrame *frame)
-{
-  MetaFrameFlags flags;
-  MetaFrameType type;
-  MetaTheme *theme;
-  MetaFrameStyle *style;
-
-  meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
-                 META_CORE_GET_FRAME_FLAGS, &flags,
-                 META_CORE_GET_FRAME_TYPE, &type,
-                 META_CORE_GET_END);
-
-  theme = meta_ui_get_theme ();
-  style = meta_theme_get_frame_style (theme, type, flags);
-
-  if (style != frame->cache_style)
-    g_clear_object (&frame->text_layout);
-
-  frame->cache_style = style;
-
-  if (frame->text_layout == NULL)
-    {
-      frame->text_layout = meta_theme_create_title_layout (theme,
-                                                           frame->theme_variant,
-                                                           type, flags,
-                                                           frame->title);
-    }
-}
-
-static void
 meta_frames_calc_geometry (MetaFrames        *frames,
                            MetaUIFrame       *frame,
                            MetaFrameGeometry *fgeom)
@@ -450,8 +414,6 @@ meta_frames_calc_geometry (MetaFrames        *frames,
                  META_CORE_GET_FRAME_TYPE, &type,
                  META_CORE_GET_END);
 
-  meta_frames_ensure_layout (frames, frame);
-
   meta_prefs_get_button_layout (&button_layout);
 
   meta_theme_calc_geometry (meta_ui_get_theme (), frame->theme_variant,
@@ -549,8 +511,6 @@ meta_frames_manage_window (MetaFrames *frames,
   /* Don't set event mask here, it's in frame.c */
 
   frame->xwindow = xwindow;
-  frame->cache_style = NULL;
-  frame->text_layout = NULL;
   frame->title = NULL;
   frame->expose_delayed = FALSE;
   frame->shape_applied = FALSE;
@@ -594,9 +554,6 @@ meta_frames_unmanage_window (MetaFrames *frames,
 
       gdk_window_destroy (frame->window);
 
-      if (frame->text_layout)
-        g_object_unref (G_OBJECT (frame->text_layout));
-
       if (frame->title)
         g_free (frame->title);
 
@@ -632,8 +589,6 @@ meta_ui_frame_get_borders (MetaFrames       *frames,
 
   g_return_if_fail (type < META_FRAME_TYPE_LAST);
 
-  meta_frames_ensure_layout (frames, frame);
-
   /* We can't get the full geometry, because that depends on
    * the client window size and probably we're being called
    * by the core move/resize code to decide on the client
@@ -1050,8 +1005,6 @@ meta_frames_set_title (MetaFrames *frames,
   g_free (frame->title);
   frame->title = g_strdup (title);
 
-  g_clear_object (&frame->text_layout);
-
   invalidate_whole_window (frames, frame);
 }
 
@@ -2498,12 +2451,10 @@ meta_frames_paint (MetaFrames   *frames,
                  META_CORE_GET_CLIENT_HEIGHT, &h,
                  META_CORE_GET_END);
 
-  meta_frames_ensure_layout (frames, frame);
-
   meta_prefs_get_button_layout (&button_layout);
 
   meta_theme_draw_frame (meta_ui_get_theme (), frame->theme_variant,
-                         cr, type, flags, w, h, frame->text_layout,
+                         cr, type, flags, w, h, frame->title,
                          &button_layout, button_states, mini_icon, icon);
 }
 
diff --git a/src/ui/frames.h b/src/ui/frames.h
index ee9c92a..9b55510 100644
--- a/src/ui/frames.h
+++ b/src/ui/frames.h
@@ -68,8 +68,6 @@ struct _MetaUIFrame
   Window xwindow;
   GdkWindow *window;
   gchar *theme_variant;
-  MetaFrameStyle *cache_style;
-  PangoLayout *text_layout;
   gchar *title;
   guint expose_delayed : 1;
   guint shape_applied : 1;
diff --git a/theme-viewer/theme-viewer-window.c b/theme-viewer/theme-viewer-window.c
index a0d4a03..82bc329 100644
--- a/theme-viewer/theme-viewer-window.c
+++ b/theme-viewer/theme-viewer-window.c
@@ -60,8 +60,6 @@ struct _ThemeViewerWindow
   MetaFrameType     frame_type;
   MetaFrameFlags    frame_flags;
 
-  PangoLayout      *title_layout;
-
   MetaFrameBorders  borders;
 
   MetaButtonLayout  button_layout;
@@ -187,7 +185,7 @@ benchmark_draw_time (ThemeViewerWindow *window,
 
         meta_theme_draw_frame (theme, window->theme_variant, cr,
                                window->frame_type, window->frame_flags,
-                               width, height, window->title_layout,
+                               width, height, "Benchmark",
                                &window->button_layout, window->button_states,
                                window->mini_icon, window->icon);
 
@@ -418,21 +416,6 @@ update_button_layout (ThemeViewerWindow *window)
 }
 
 static void
-update_title_layout (ThemeViewerWindow *window)
-{
-  PangoLayout *layout;
-
-  layout = meta_theme_create_title_layout (window->theme, window->theme_variant,
-                                           window->frame_type, window->frame_flags,
-                                           "Metacity Theme Viewer");
-
-  if (window->title_layout)
-    g_object_unref (window->title_layout);
-
-  window->title_layout = layout;
-}
-
-static void
 update_frame_borders (ThemeViewerWindow *window)
 {
   meta_theme_get_frame_borders (window->theme, window->theme_variant,
@@ -474,9 +457,7 @@ update_frame_flags (ThemeViewerWindow *window)
 
   window->frame_flags = flags;
 
-  update_title_layout (window);
   update_frame_borders (window);
-
   update_frame_flags_sensitivity (window);
 }
 
@@ -642,7 +623,6 @@ theme_viewer_window_dispose (GObject *object)
   window = THEME_VIEWER_WINDOW (object);
 
   g_clear_object (&window->theme);
-  g_clear_object (&window->title_layout);
   g_clear_object (&window->mini_icon);
   g_clear_object (&window->icon);
 
@@ -794,7 +774,7 @@ theme_box_draw_cb (GtkWidget         *widget,
   cairo_translate (cr, PADDING, PADDING);
   meta_theme_draw_frame (window->theme, window->theme_variant, cr,
                          window->frame_type, window->frame_flags,
-                         client_width, client_height, window->title_layout,
+                         client_width, client_height, "Metacity Theme Viewer",
                          &window->button_layout, window->button_states,
                          window->mini_icon, window->icon);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]