diff options
Diffstat (limited to 'endless')
-rw-r--r-- | endless/eoswindow.c | 53 | ||||
-rw-r--r-- | endless/eoswindow.h | 37 |
2 files changed, 67 insertions, 23 deletions
diff --git a/endless/eoswindow.c b/endless/eoswindow.c index bbe2422..7b89312 100644 --- a/endless/eoswindow.c +++ b/endless/eoswindow.c @@ -49,11 +49,15 @@ * The default minimum font size under which a font will never scale can be set * by #EosWindow:font-scaling-min-font-size. * + * The calculated minimum font size by which children widgets will scale and can + * be retrieved by #EosWindow:font-scaling-calculated-font-size. This property is + * only readable and is only set by #EosWindow internally. + * * For instance, supose we have a default font size of 12px, a default window size - * of 720px, and a window allocation of 360px. The calculated base pixel size + * of 720px, and a window allocation of 360px. The calculated font pixel size * will be 12px * (360px / 720px) = 6px. A corresponding CSS font-size of 1em will * be equivalent to 6 px. A CSS font-size of 0.5em will be equivalent to 3px. If the - * window is resized to a height of 720px, then the calculated base pixel size will + * window is resized to a height of 720px, then the calculated pixel size will * be 12px, and the CSS font-size of 1em will be equivalent to 12px. A CSS * font-size of 0.5em will be equivalent to 6px. If the minimum font size is set * to 12px, then the font-size will be forced to 12px, ignoring the calculated font @@ -103,6 +107,7 @@ typedef struct { gint font_scaling_default_size; gint font_scaling_default_window_size; gint font_scaling_min_font_size; + gdouble font_scaling_calculated_font_size; /* For keeping track of what to display alongside the current page */ GtkWidget *current_page; @@ -122,6 +127,7 @@ enum PROP_FONT_SCALING_DEFAULT_SIZE, PROP_FONT_SCALING_DEFAULT_WINDOW_SIZE, PROP_FONT_SCALING_MIN_FONT_SIZE, + PROP_FONT_SCALING_CALCULATED_FONT_SIZE, NPROPS }; @@ -429,6 +435,10 @@ eos_window_get_property (GObject *object, g_value_set_int (value, priv->font_scaling_min_font_size); break; + case PROP_FONT_SCALING_CALCULATED_FONT_SIZE: + g_value_set_double (value, priv->font_scaling_calculated_font_size); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } @@ -581,15 +591,15 @@ eos_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) if (priv->font_scaling_active) { GtkStyleProvider *provider = GTK_STYLE_PROVIDER (priv->font_size_provider); - gdouble base_pixel_size = (gdouble) priv->font_scaling_default_size * + priv->font_scaling_calculated_font_size = (gdouble) priv->font_scaling_default_size * ((gdouble) allocation->height / (gdouble) priv->font_scaling_default_window_size); - if (base_pixel_size < priv->font_scaling_min_font_size) - base_pixel_size = priv->font_scaling_min_font_size; + if (priv->font_scaling_calculated_font_size < priv->font_scaling_min_font_size) + priv->font_scaling_calculated_font_size = priv->font_scaling_min_font_size; GError *error = NULL; - gchar *font_size_css = g_strdup_printf (FONT_SIZE_TEMPLATE, base_pixel_size); + gchar *font_size_css = g_strdup_printf (FONT_SIZE_TEMPLATE, priv->font_scaling_calculated_font_size); GdkScreen *screen = gdk_screen_get_default (); gtk_style_context_remove_provider_for_screen (screen, provider); @@ -700,6 +710,19 @@ eos_window_class_init (EosWindowClass *klass) 8, G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS); + /** + * EosWindow:font-scaling-calculated-font-size: + * + * The calculated font-size by which children widgets scale. Units are in pixels. + */ + eos_window_props[PROP_FONT_SCALING_CALCULATED_FONT_SIZE] = + g_param_spec_double ("font-scaling-calculated-font-size", "Font scaling calculated size", + "This is the calculated font-size by which children widgets scale", + 1, + G_MAXDOUBLE, + 12, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties (object_class, NPROPS, eos_window_props); } @@ -1057,3 +1080,21 @@ eos_window_set_font_scaling_min_font_size (EosWindow *self, EosWindowPrivate *priv = eos_window_get_instance_private (self); priv->font_scaling_min_font_size = new_min_font_size; } + +/** + * eos_window_get_font_scaling_calculated_font_size: + * @self: the window + * + * See #EosWindow:font-scaling-calculated-font-size for details. + * + * Returns: the calculated font size by which the font size of children widgets + * will scale. + */ +gdouble +eos_window_get_font_scaling_calculated_font_size (EosWindow *self) +{ + g_return_val_if_fail (self != NULL && EOS_IS_WINDOW (self), -1); + EosWindowPrivate *priv = eos_window_get_instance_private (self); + + return priv->font_scaling_calculated_font_size; +} diff --git a/endless/eoswindow.h b/endless/eoswindow.h index 317f0c5..af39160 100644 --- a/endless/eoswindow.h +++ b/endless/eoswindow.h @@ -59,45 +59,48 @@ struct _EosWindowClass }; EOS_SDK_ALL_API_VERSIONS -GType eos_window_get_type (void) G_GNUC_CONST; +GType eos_window_get_type (void) G_GNUC_CONST; EOS_SDK_ALL_API_VERSIONS -GtkWidget *eos_window_new (EosApplication *application); +GtkWidget *eos_window_new (EosApplication *application); EOS_SDK_ALL_API_VERSIONS -EosPageManager *eos_window_get_page_manager (EosWindow *self); +EosPageManager *eos_window_get_page_manager (EosWindow *self); EOS_SDK_ALL_API_VERSIONS -void eos_window_set_page_manager (EosWindow *self, - EosPageManager *page_manager); +void eos_window_set_page_manager (EosWindow *self, + EosPageManager *page_manager); EOS_SDK_ALL_API_VERSIONS -gboolean eos_window_get_font_scaling_active (EosWindow *self); +gboolean eos_window_get_font_scaling_active (EosWindow *self); EOS_SDK_ALL_API_VERSIONS -void eos_window_set_font_scaling_active (EosWindow *self, - gboolean is_scaling); +void eos_window_set_font_scaling_active (EosWindow *self, + gboolean is_scaling); EOS_SDK_ALL_API_VERSIONS -gint eos_window_get_font_scaling_default_size (EosWindow *self); +gint eos_window_get_font_scaling_default_size (EosWindow *self); EOS_SDK_ALL_API_VERSIONS -void eos_window_set_font_scaling_default_size (EosWindow *self, - gint new_default_font_size); +void eos_window_set_font_scaling_default_size (EosWindow *self, + gint new_default_font_size); EOS_SDK_ALL_API_VERSIONS -gint eos_window_get_font_scaling_default_window_size (EosWindow *self); +gint eos_window_get_font_scaling_default_window_size (EosWindow *self); EOS_SDK_ALL_API_VERSIONS -void eos_window_set_font_scaling_default_window_size (EosWindow *self, - gint new_default_window_size); +void eos_window_set_font_scaling_default_window_size (EosWindow *self, + gint new_default_window_size); EOS_SDK_ALL_API_VERSIONS -gint eos_window_get_font_scaling_min_font_size (EosWindow *self); +gint eos_window_get_font_scaling_min_font_size (EosWindow *self); EOS_SDK_ALL_API_VERSIONS -void eos_window_set_font_scaling_min_font_size (EosWindow *self, - gint new_min_font_size); +void eos_window_set_font_scaling_min_font_size (EosWindow *self, + gint new_min_font_size); + +EOS_SDK_ALL_API_VERSIONS +gdouble eos_window_get_font_scaling_calculated_font_size (EosWindow *self); G_END_DECLS |