Use gtk to detect dpi.

This commit is contained in:
Marco Pesenti Gritti
2007-04-07 03:42:51 +02:00
parent e3cf7aa1d3
commit 4828870afd
7 changed files with 6 additions and 140 deletions
-5
View File
@@ -32,11 +32,6 @@ class Activity(Window, gtk.Container):
def __init__(self, handle):
Window.__init__(self)
# FIXME: This will work only for activities in python. We need a xsetting.
display = gtk.gdk.display_manager_get().get_default_display()
screen = display.get_default_screen()
screen.set_resolution(_sugar.get_screen_dpi())
self.connect('destroy', self._destroy_cb)
self._shared = False
+3 -4
View File
@@ -61,19 +61,18 @@ units to device units.
import gtk
import _sugar
_MAX_ZOOM_FACTOR = 2.0
_ZOOM_CONSTANT = 650.0
def _compute_zoom_factor():
screen_width = gtk.gdk.screen_width()
if _sugar.get_screen_dpi() == 201.0 and screen_width == 1200:
if _screen_dpi == 201.0 and screen_width == 1200:
return 1.0
else:
return min(_MAX_ZOOM_FACTOR, screen_width / _ZOOM_CONSTANT)
_screen_dpi = float(_sugar.get_screen_dpi())
_gtk_xft_dpi = gtk.settings_get_default().get_property('gtk-xft-dpi')
_screen_dpi = float(_gtk_xft_dpi / 1024)
_dpi_factor = _screen_dpi / 201.0
_zoom_factor = _compute_zoom_factor()