css: Add -gtk-dpi CSS property hack

This property is necessary to ensure widgets automatically update after
the text scale factor is changed desktop-wide.

And if I'm already doing a property like this, I can make it
overridable. So now you can override the dpi per-widget with CSS like
GtkSwitch {
  -gtk-dpi: 48;
}
if you want to debug things.

Long-term, we want to get rid of this property and insist on dpi being
96 everywhere and people can change the font size to get larger fonts.
This commit is contained in:
Benjamin Otte
2015-02-05 18:52:59 +01:00
parent 7eecb16404
commit 89f635fee1
4 changed files with 37 additions and 3 deletions

View File

@ -23,6 +23,7 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtksettingsprivate.h"
#include "gtkstyleproviderprivate.h"
struct _GtkCssValue {
@ -49,6 +50,18 @@ gtk_css_value_initial_compute (GtkCssValue *value,
switch (property_id)
{
case GTK_CSS_PROPERTY_DPI:
settings = _gtk_style_provider_private_get_settings (provider);
if (settings)
{
GdkScreen *screen = _gtk_settings_get_screen (settings);
double resolution = gdk_screen_get_resolution (screen);
if (resolution > 0.0)
return _gtk_css_number_value_new (resolution, GTK_CSS_NUMBER);
}
break;
case GTK_CSS_PROPERTY_FONT_FAMILY:
settings = _gtk_style_provider_private_get_settings (provider);
if (settings)