diff --git a/lib/python/_sugar.defs b/lib/python/_sugar.defs index b09d0eb5..e59c9852 100644 --- a/lib/python/_sugar.defs +++ b/lib/python/_sugar.defs @@ -199,11 +199,4 @@ ) ) -;; From sugar-utils.h - -(define-function get_screen_dpi - (c-name "sugar_get_screen_dpi") - (return-type "gint") -) - (include "gtkmozembed.defs") diff --git a/lib/src/Makefile.am b/lib/src/Makefile.am index 88e863a4..504c2119 100644 --- a/lib/src/Makefile.am +++ b/lib/src/Makefile.am @@ -37,9 +37,7 @@ libsugarprivate_la_SOURCES = \ sugar-download.h \ sugar-download.c \ sugar-download-manager.h \ - sugar-download-manager.c \ - sugar-utils.c \ - sugar-utils.h + sugar-download-manager.c BUILT_SOURCES = \ sugar-marshal.c \ diff --git a/lib/src/sugar-utils.c b/lib/src/sugar-utils.c deleted file mode 100644 index 6cc59462..00000000 --- a/lib/src/sugar-utils.c +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2006, Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include - -#include "sugar-utils.h" - -/* Ported from mozilla nsDeviceContextGTK.cpp */ - -static gint -get_gtk_settings_dpi(void) -{ - GtkSettings *settings = gtk_settings_get_default(); - GParamSpec *spec; - gint dpi = 0; - - spec = g_object_class_find_property( - G_OBJECT_GET_CLASS(G_OBJECT(settings)), "gtk-xft-dpi"); - - if (spec) { - g_object_get(G_OBJECT(settings), - "gtk-xft-dpi", &dpi, - NULL); - } - - return (int)(dpi / 1024.0 + 0.5); -} - -static gint -get_xft_dpi(void) -{ - char *val = XGetDefault(GDK_DISPLAY(), "Xft", "dpi"); - if (val) { - char *e; - double d = strtod(val, &e); - - if (e != val) - return (int)(d + 0.5); - } - - return 0; -} - -static int -get_dpi_from_physical_resolution(void) -{ - float screen_width_in; - - screen_width_in = (float)(gdk_screen_width_mm()) / 25.4f; - - return (int)((float)(gdk_screen_width()) / screen_width_in + 0.5); -} - -gint -sugar_get_screen_dpi(void) -{ - int dpi; - - dpi = get_gtk_settings_dpi(); - - if (dpi == 0) { - dpi = get_xft_dpi(); - } - - if (dpi == 0) { - dpi = get_dpi_from_physical_resolution(); - } - - return dpi; -} diff --git a/lib/src/sugar-utils.h b/lib/src/sugar-utils.h deleted file mode 100644 index 1b45d25a..00000000 --- a/lib/src/sugar-utils.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (C) 2006, Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __SUGAR_UTILS_H__ -#define __SUGAR_UTILS_H__ - -#include - -G_BEGIN_DECLS - -gint sugar_get_screen_dpi (void); - -G_END_DECLS - -#endif /* __SUGAR_UTILS_H__ */ diff --git a/sugar-emulator b/sugar-emulator index 88061623..3f1df1bb 100755 --- a/sugar-emulator +++ b/sugar-emulator @@ -88,7 +88,8 @@ else: width = 1200 height = 900 -_start_xephyr(width, height, min(_sugar.get_screen_dpi(), 96)) +_gtk_xft_dpi = float(gtk.settings_get_default().get_property('gtk-xft-dpi')) +_start_xephyr(width, height, _gtk_xft_dpi / 1024) os.environ['GTK2_RC_FILES'] = env.get_data_path('gtkrc') diff --git a/sugar/activity/activity.py b/sugar/activity/activity.py index 937d6864..fc291042 100644 --- a/sugar/activity/activity.py +++ b/sugar/activity/activity.py @@ -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 diff --git a/sugar/graphics/units.py b/sugar/graphics/units.py index 2417255e..0e415e23 100644 --- a/sugar/graphics/units.py +++ b/sugar/graphics/units.py @@ -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()