[mutter] ui: Don't use deprecated GtkStyleContext API



commit 4e21d5d61010b0aa5ddc3acccd9598384c3e8f01
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Dec 16 18:41:42 2012 -0500

    ui: Don't use deprecated GtkStyleContext API
    
    Update for deprecations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690593

 src/ui/theme-viewer.c |   19 ++++++++++++-------
 src/ui/theme.c        |    2 +-
 src/ui/ui.c           |    7 ++++++-
 3 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index a931899..32cb27d 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -777,7 +777,7 @@ int
 main (int argc, char **argv)
 {
   GtkStyleContext *style;
-  const PangoFontDescription *font_desc;
+  PangoFontDescription *font_desc;
   GtkWidget *window;
   GtkWidget *collection;
   GError *err;
@@ -855,7 +855,7 @@ main (int argc, char **argv)
 
   gtk_widget_realize (window);
   style = gtk_widget_get_style_context (window);
-  font_desc = gtk_style_context_get_font (style, 0);
+  gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &font_desc, NULL);
 
   g_assert (style);
   g_assert (font_desc);
@@ -890,7 +890,9 @@ main (int argc, char **argv)
   gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
                             collection,
                             gtk_label_new (_("Benchmark")));
-  
+
+  pango_font_description_free (font_desc);
+
   i = 0;
   while (i < (int) G_N_ELEMENTS (previews))
     {
@@ -928,12 +930,15 @@ static int
 get_text_height (GtkWidget *widget)
 {
   GtkStyleContext *style;
-  const PangoFontDescription *font_desc;
+  PangoFontDescription *font_desc;
+  int text_height;
 
   style = gtk_widget_get_style_context (widget);
-  font_desc = gtk_style_context_get_font (style, 0);
-  return meta_pango_font_desc_get_text_height (font_desc,
-                                               gtk_widget_get_pango_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*
diff --git a/src/ui/theme.c b/src/ui/theme.c
index a394517..d53794c 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -5841,7 +5841,7 @@ meta_gtk_widget_get_font_desc (GtkWidget *widget,
   g_return_val_if_fail (gtk_widget_get_realized (widget), NULL);
 
   style = gtk_widget_get_style_context (widget);
-  font_desc = pango_font_description_copy (gtk_style_context_get_font (style, 0));
+  gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &font_desc, NULL);
 
   if (override)
     pango_font_description_merge (font_desc, override, TRUE);
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 2e7dd4a..ce108a7 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -735,6 +735,7 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
   GtkStyleContext *style = NULL;
   PangoContext *context;
   const PangoFontDescription *font_desc;
+  PangoFontDescription *free_font_desc = NULL;
 
   if (meta_ui_have_a_theme ())
     {
@@ -744,7 +745,8 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
       if (!font_desc)
         {
           style = gtk_style_context_new ();
-          font_desc = gtk_style_context_get_font (style, 0);
+          gtk_style_context_get (style, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
+          font_desc = (const PangoFontDescription *) free_font_desc;
         }
 
       text_height = meta_pango_font_desc_get_text_height (font_desc, context);
@@ -752,6 +754,9 @@ meta_ui_theme_get_frame_borders (MetaUI *ui,
       meta_theme_get_frame_borders (meta_theme_get_current (),
                                     type, text_height, flags,
                                     borders);
+
+      if (free_font_desc)
+        pango_font_description_free (free_font_desc);
     }
   else
     {



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