[gtk+/wip/window-scales] GtkStyleContext: Add gtk_style_context_get/set_scale



commit 03bde76dffcaa4f08a2db21bac780534aecfd8b2
Author: Alexander Larsson <alexl redhat com>
Date:   Thu Jun 27 18:21:41 2013 +0200

    GtkStyleContext: Add gtk_style_context_get/set_scale

 gtk/gtkstylecontext.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkstylecontext.h |    6 ++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 1f26ce6..2113da6 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -364,6 +364,7 @@ struct _GtkStyleContextPrivate
   GtkWidgetPath *widget_path;
   GHashTable *style_data;
   GtkStyleInfo *info;
+  gint scale;
 
   GdkFrameClock *frame_clock;
   guint frame_clock_update_id;
@@ -997,6 +998,7 @@ build_properties (GtkStyleContext      *context,
 
   _gtk_css_lookup_resolve (lookup, 
                            GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
+                          priv->scale,
                            values,
                            priv->parent ? style_data_lookup (priv->parent)->store : NULL);
 
@@ -1528,6 +1530,47 @@ gtk_style_context_get_state (GtkStyleContext *context)
 }
 
 /**
+ * gtk_style_context_set_scale:
+ * @context: a #GtkStyleContext
+ * @scale: scale
+ *
+ * Sets the scale to use when getting image assets for the style .
+ *
+ * Since: 3.10
+ **/
+void
+gtk_style_context_set_scale (GtkStyleContext *context,
+                             gint             scale)
+{
+  g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+
+  if (context->priv->scale == scale)
+    return;
+
+  context->priv->scale = scale;
+
+  gtk_style_context_queue_invalidate_internal (context, GTK_CSS_CHANGE_SOURCE);
+}
+
+/**
+ * gtk_style_context_get_scale:
+ * @context: a #GtkStyleContext
+ *
+ * Returns the scale used for assets.
+ *
+ * Returns: the scale
+ *
+ * Since: 3.10
+ **/
+gint
+gtk_style_context_get_scale (GtkStyleContext *context)
+{
+  g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), 0);
+
+  return context->priv->scale;
+}
+
+/**
  * gtk_style_context_state_is_running:
  * @context: a #GtkStyleContext
  * @state: a widget state
diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h
index f3ca674..3ea52d8 100644
--- a/gtk/gtkstylecontext.h
+++ b/gtk/gtkstylecontext.h
@@ -817,6 +817,12 @@ void          gtk_style_context_set_state    (GtkStyleContext *context,
 GDK_AVAILABLE_IN_ALL
 GtkStateFlags gtk_style_context_get_state    (GtkStyleContext *context);
 
+GDK_AVAILABLE_IN_3_10
+void          gtk_style_context_set_scale    (GtkStyleContext *context,
+                                              gint             scale);
+GDK_AVAILABLE_IN_3_10
+gint          gtk_style_context_get_scale    (GtkStyleContext *context);
+
 GDK_DEPRECATED_IN_3_6
 gboolean      gtk_style_context_state_is_running (GtkStyleContext *context,
                                                   GtkStateType     state,


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