[gnome-shell] st: Add high dpi support



commit d868e6bfaff4e1174220ae6158cd7a0a02904ffc
Author: Adel Gadllah <adel gadllah gmail com>
Date:   Wed Feb 12 17:29:08 2014 +0100

    st: Add high dpi support
    
    Add a scale_factor property to StThemeContext that can
    be used to enable (integer) scaling of pixel values.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=705410

 src/st/st-theme-context.c |   79 +++++++++++++++++++++++++++++++++++++++++++++
 src/st/st-theme-node.c    |    5 ++-
 2 files changed, 83 insertions(+), 1 deletions(-)
---
diff --git a/src/st/st-theme-context.c b/src/st/st-theme-context.c
index 399a858..34ac295 100644
--- a/src/st/st-theme-context.c
+++ b/src/st/st-theme-context.c
@@ -34,6 +34,8 @@ struct _StThemeContext {
 
   /* set of StThemeNode */
   GHashTable *nodes;
+
+  int scale_factor;
 };
 
 struct _StThemeContextClass {
@@ -44,6 +46,12 @@ struct _StThemeContextClass {
 
 enum
 {
+  PROP_0,
+  PROP_SCALE_FACTOR
+};
+
+enum
+{
   CHANGED,
 
   LAST_SIGNAL
@@ -57,6 +65,15 @@ static void on_icon_theme_changed (StTextureCache *cache,
                                    StThemeContext *context);
 static void st_theme_context_changed (StThemeContext *context);
 
+static void st_theme_context_set_property (GObject      *object,
+                                           guint         prop_id,
+                                           const GValue *value,
+                                           GParamSpec   *pspec);
+static void st_theme_context_get_property (GObject      *object,
+                                           guint         prop_id,
+                                           GValue       *value,
+                                           GParamSpec   *pspec);
+
 static void
 st_theme_context_finalize (GObject *object)
 {
@@ -86,8 +103,23 @@ st_theme_context_class_init (StThemeContextClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
+  object_class->set_property = st_theme_context_set_property;
+  object_class->get_property = st_theme_context_get_property;
   object_class->finalize = st_theme_context_finalize;
 
+  /**
+   * StThemeContext:scale-factor:
+   *
+   * The scaling factor used or high dpi scaling.
+   */
+  g_object_class_install_property (object_class,
+                                   PROP_SCALE_FACTOR,
+                                   g_param_spec_int ("scale-factor",
+                                                     "Scale factor",
+                                                     "Integer scale factor used for high dpi scaling",
+                                                     0, G_MAXINT, 1,
+                                                     G_PARAM_READABLE | G_PARAM_WRITABLE));
+
   signals[CHANGED] =
     g_signal_new ("changed",
                   G_TYPE_FROM_CLASS (klass),
@@ -114,6 +146,53 @@ st_theme_context_init (StThemeContext *context)
   context->nodes = g_hash_table_new_full ((GHashFunc) st_theme_node_hash,
                                           (GEqualFunc) st_theme_node_equal,
                                           g_object_unref, NULL);
+  context->scale_factor = 1;
+}
+
+static void
+st_theme_context_set_property (GObject      *object,
+                               guint         prop_id,
+                               const GValue *value,
+                               GParamSpec   *pspec)
+{
+  StThemeContext *context = ST_THEME_CONTEXT (object);
+
+  switch (prop_id)
+    {
+    case PROP_SCALE_FACTOR:
+      {
+        int scale_factor = g_value_get_int (value);
+        if (scale_factor != context->scale_factor)
+          {
+            context->scale_factor = scale_factor;
+            st_theme_context_changed (context);
+          }
+
+        break;
+      }
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+st_theme_context_get_property (GObject    *object,
+                               guint       prop_id,
+                               GValue     *value,
+                               GParamSpec *pspec)
+{
+  StThemeContext *context = ST_THEME_CONTEXT (object);
+
+  switch (prop_id)
+    {
+    case PROP_SCALE_FACTOR:
+      g_value_set_int (value, context->scale_factor);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
 }
 
 /**
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 22b3833..68aea17 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -1015,6 +1015,9 @@ get_length_from_term (StThemeNode *node,
   } type = ABSOLUTE;
 
   double multiplier = 1.0;
+  int scale_factor;
+
+  g_object_get (node->context, "scale-factor", &scale_factor, NULL);
 
   if (term->type != TERM_NUMBER)
     {
@@ -1028,7 +1031,7 @@ get_length_from_term (StThemeNode *node,
     {
     case NUM_LENGTH_PX:
       type = ABSOLUTE;
-      multiplier = 1;
+      multiplier = 1 * scale_factor;
       break;
     case NUM_LENGTH_PT:
       type = POINTS;


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