[gnome-shell] st: Remove our own font DPI resolution implementation



commit de8a66d4ce5758d8e34cc7a4684ee280d2dafe9b
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Mon Mar 26 11:14:31 2012 -0300

    st: Remove our own font DPI resolution implementation
    
    Clutter has had clutter_backend_get_resolution for a little while.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672807

 src/shell-global.c        |   36 -------------------------
 src/st/st-theme-context.c |   63 ---------------------------------------------
 src/st/st-theme-context.h |    4 ---
 src/st/st-theme-node.c    |    8 +++---
 src/st/test-theme.c       |    1 -
 5 files changed, 4 insertions(+), 108 deletions(-)
---
diff --git a/src/shell-global.c b/src/shell-global.c
index 0a5ce86..be14fa3 100644
--- a/src/shell-global.c
+++ b/src/shell-global.c
@@ -806,37 +806,8 @@ global_stage_after_paint (ClutterStage *stage,
 }
 
 static void
-update_font_options (GtkSettings  *settings,
-                     ClutterStage *stage)
-{
-  StThemeContext *context;
-  gint dpi;
-
-  g_object_get (settings,
-                "gtk-xft-dpi", &dpi,
-                NULL);
-
-  context = st_theme_context_get_for_stage (stage);
-
-  if (dpi != -1)
-    /* GTK stores resolution as 1024 * dots/inch */
-    st_theme_context_set_resolution (context, dpi / 1024);
-  else
-    st_theme_context_set_default_resolution (context);
-}
-
-static void
-settings_notify_cb (GtkSettings *settings,
-                    GParamSpec  *pspec,
-                    gpointer     data)
-{
-  update_font_options (settings, CLUTTER_STAGE (data));
-}
-
-static void
 shell_fonts_init (ClutterStage *stage)
 {
-  GtkSettings *settings;
   CoglPangoFontMap *fontmap;
 
   /* Disable text mipmapping; it causes problems on pre-GEM Intel
@@ -846,13 +817,6 @@ shell_fonts_init (ClutterStage *stage)
    */
   fontmap = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
   cogl_pango_font_map_set_use_mipmapping (fontmap, FALSE);
-
-  settings = gtk_settings_get_default ();
-  g_object_connect (settings,
-                    "signal::notify::gtk-xft-dpi",
-                    G_CALLBACK (settings_notify_cb), stage,
-                    NULL);
-  update_font_options (settings, stage);
 }
 
 /* This is an IBus workaround. The flow of events with IBus is that every time
diff --git a/src/st/st-theme-context.c b/src/st/st-theme-context.c
index 7b676b7..a73679e 100644
--- a/src/st/st-theme-context.c
+++ b/src/st/st-theme-context.c
@@ -28,7 +28,6 @@
 struct _StThemeContext {
   GObject parent;
 
-  double resolution;
   PangoFontDescription *font;
   StThemeNode *root_node;
   StTheme *theme;
@@ -38,7 +37,6 @@ struct _StThemeContextClass {
   GObjectClass parent_class;
 };
 
-#define DEFAULT_RESOLUTION 96.
 #define DEFAULT_FONT "sans-serif 10"
 
 enum
@@ -93,7 +91,6 @@ st_theme_context_class_init (StThemeContextClass *klass)
 static void
 st_theme_context_init (StThemeContext *context)
 {
-  context->resolution = DEFAULT_RESOLUTION;
   context->font = pango_font_description_from_string (DEFAULT_FONT);
 
   g_signal_connect (st_texture_cache_get_default (),
@@ -233,66 +230,6 @@ st_theme_context_get_theme (StThemeContext *context)
 }
 
 /**
- * st_theme_context_set_resolution:
- * @context: a #StThemeContext
- * @resolution: resolution of the context (number of pixels in an "inch")
- *
- * Sets the resolution of the theme context. This is the scale factor
- * used to convert between points and the length units pt, in, and cm.
- * This does not necessarily need to correspond to the actual number
- * resolution of the device. A value of 72. means that points and
- * pixels are identical. The default value is 96.
- */
-void
-st_theme_context_set_resolution (StThemeContext *context,
-                                 double          resolution)
-{
-  g_return_if_fail (ST_IS_THEME_CONTEXT (context));
-
-  if (resolution == context->resolution)
-    return;
-
-  context->resolution = resolution;
-  st_theme_context_changed (context);
-}
-
-/**
- * st_theme_context_set_default_resolution:
- * @context: a #StThemeContext
- *
- * Sets the resolution of the theme context to the default value of 96.
- * See st_theme_context_set_resolution().
- */
-void
-st_theme_context_set_default_resolution (StThemeContext *context)
-{
-  g_return_if_fail (ST_IS_THEME_CONTEXT (context));
-
-  if (context->resolution == DEFAULT_RESOLUTION)
-    return;
-
-  context->resolution = DEFAULT_RESOLUTION;
-  st_theme_context_changed (context);
-}
-
-/**
- * st_theme_context_get_resolution:
- * @context: a #StThemeContext
- *
- * Gets the current resolution of the theme context.
- * See st_theme_context_set_resolution().
- *
- * Return value: the resolution (in dots-per-"inch")
- */
-double
-st_theme_context_get_resolution (StThemeContext *context)
-{
-  g_return_val_if_fail (ST_IS_THEME_CONTEXT (context), DEFAULT_RESOLUTION);
-
-  return context->resolution;
-}
-
-/**
  * st_theme_context_set_font:
  * @context: a #StThemeContext
  * @font: the default font for theme context
diff --git a/src/st/st-theme-context.h b/src/st/st-theme-context.h
index 8805fb1..a0b73d9 100644
--- a/src/st/st-theme-context.h
+++ b/src/st/st-theme-context.h
@@ -56,10 +56,6 @@ void                        st_theme_context_set_theme      (StThemeContext
                                                              StTheme                    *theme);
 StTheme *                   st_theme_context_get_theme      (StThemeContext             *context);
 
-void                        st_theme_context_set_resolution (StThemeContext             *context,
-                                                             gdouble                     resolution);
-void                        st_theme_context_set_default_resolution (StThemeContext *context);
-double                      st_theme_context_get_resolution (StThemeContext             *context);
 void                        st_theme_context_set_font       (StThemeContext             *context,
                                                              const PangoFontDescription *font);
 const PangoFontDescription *st_theme_context_get_font       (StThemeContext             *context);
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 47b117c..765a3ee 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -820,7 +820,7 @@ get_length_from_term (StThemeNode *node,
       break;
     case POINTS:
       {
-        double resolution = st_theme_context_get_resolution (node->context);
+        double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
         *length = num->val * multiplier * (resolution / 72.);
       }
       break;
@@ -842,7 +842,7 @@ get_length_from_term (StThemeNode *node,
           }
         else
           {
-            double resolution = st_theme_context_get_resolution (node->context);
+            double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
             *length = num->val * multiplier * (resolution / 72.) * font_size;
           }
       }
@@ -2139,7 +2139,7 @@ font_size_from_term (StThemeNode *node,
 {
   if (term->type == TERM_IDENT)
     {
-      double resolution = st_theme_context_get_resolution (node->context);
+      double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
       /* We work in integers to avoid double comparisons when converting back
        * from a size in pixels to a logical size.
        */
@@ -2346,7 +2346,7 @@ st_theme_node_get_font (StThemeNode *node)
   parent_size = pango_font_description_get_size (node->font_desc);
   if (!pango_font_description_get_size_is_absolute (node->font_desc))
     {
-      double resolution = st_theme_context_get_resolution (node->context);
+      double resolution = clutter_backend_get_resolution (clutter_get_default_backend ());
       parent_size *= (resolution / 72.);
     }
 
diff --git a/src/st/test-theme.c b/src/st/test-theme.c
index d6a8f7b..fa85ebe 100644
--- a/src/st/test-theme.c
+++ b/src/st/test-theme.c
@@ -435,7 +435,6 @@ main (int argc, char **argv)
   stage = clutter_stage_new ();
   context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
   st_theme_context_set_theme (context, theme);
-  st_theme_context_set_resolution (context, 96.);
   st_theme_context_set_font (context,
 				pango_font_description_from_string ("sans-serif 12"));
 



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