gnome-settings-daemon r472 - in trunk: . plugins/a11y-keyboard
- From: mccann svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r472 - in trunk: . plugins/a11y-keyboard
- Date: Tue, 26 Aug 2008 15:54:22 +0000 (UTC)
Author: mccann
Date: Tue Aug 26 15:54:22 2008
New Revision: 472
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=472&view=rev
Log:
2008-08-26 William Jon McCann <jmccann redhat com>
* plugins/a11y-keyboard/Makefile.am:
* plugins/a11y-keyboard/gsd-a11y-preferences-dialog.c
(dpi_from_pixels_and_mm), (get_dpi_from_x_server),
(config_get_large_print), (config_set_large_print):
* plugins/a11y-keyboard/test-a11y-preferences-dialog.c
(test_window), (main):
Use a scale factor instead of a fixed DPI. Add a test
program.
Added:
trunk/plugins/a11y-keyboard/test-a11y-preferences-dialog.c
Modified:
trunk/ChangeLog
trunk/plugins/a11y-keyboard/Makefile.am
trunk/plugins/a11y-keyboard/gsd-a11y-preferences-dialog.c
Modified: trunk/plugins/a11y-keyboard/Makefile.am
==============================================================================
--- trunk/plugins/a11y-keyboard/Makefile.am (original)
+++ trunk/plugins/a11y-keyboard/Makefile.am Tue Aug 26 15:54:22 2008
@@ -5,6 +5,32 @@
gsd-a11y-preferences-dialog.glade \
$(NULL)
+noinst_PROGRAMS = \
+ test-a11y-preferences-dialog \
+ $(NULL)
+
+test_a11y_preferences_dialog_SOURCES = \
+ gsd-a11y-preferences-dialog.c \
+ gsd-a11y-preferences-dialog.h \
+ test-a11y-preferences-dialog.c \
+ $(NULL)
+
+test_a11y_preferences_dialog_CPPFLAGS = \
+ -I$(top_srcdir)/gnome-settings-daemon \
+ -DPIXMAPDIR=\""$(pkgdatadir)"\" \
+ -DGLADEDIR=\""$(pkgdatadir)"\" \
+ -DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
+ $(AM_CPPFLAGS)
+
+test_a11y_preferences_dialog_CFLAGS = \
+ $(SETTINGS_PLUGIN_CFLAGS) \
+ $(AM_CFLAGS)
+
+test_a11y_preferences_dialog_LDADD = \
+ $(SETTINGS_DAEMON_LIBS) \
+ $(SETTINGS_PLUGIN_LIBS) \
+ $(NULL)
+
plugin_LTLIBRARIES = \
liba11y-keyboard.la \
$(NULL)
Modified: trunk/plugins/a11y-keyboard/gsd-a11y-preferences-dialog.c
==============================================================================
--- trunk/plugins/a11y-keyboard/gsd-a11y-preferences-dialog.c (original)
+++ trunk/plugins/a11y-keyboard/gsd-a11y-preferences-dialog.c Tue Aug 26 15:54:22 2008
@@ -72,10 +72,10 @@
#define DPI_LOW_REASONABLE_VALUE 50
#define DPI_HIGH_REASONABLE_VALUE 500
-#define DPI_LARGE_FONT 120
-#define DPI_LARGER_FONT 144
-#define DPI_LARGEST_FONT 192
-#define DPI_DEFAULT 96
+#define DPI_FACTOR_LARGE 1.25
+#define DPI_FACTOR_LARGER 1.5
+#define DPI_FACTOR_LARGEST 2.0
+#define DPI_DEFAULT 96
#define KEY_GTK_THEME "/desktop/gnome/interface/gtk_theme"
#define KEY_COLOR_SCHEME "/desktop/gnome/interface/gtk_color_scheme"
@@ -226,6 +226,21 @@
}
static double
+dpi_from_pixels_and_mm (int pixels,
+ int mm)
+{
+ double dpi;
+
+ if (mm >= 1) {
+ dpi = pixels / (mm / 25.4);
+ } else {
+ dpi = 0;
+ }
+
+ return dpi;
+}
+
+static double
get_dpi_from_x_server (void)
{
GdkScreen *screen;
@@ -233,10 +248,20 @@
screen = gdk_screen_get_default ();
if (screen != NULL) {
- dpi = gdk_screen_get_resolution (screen);
- if (dpi < DPI_LOW_REASONABLE_VALUE || dpi > DPI_HIGH_REASONABLE_VALUE ||
- dpi < DPI_LOW_REASONABLE_VALUE || dpi > DPI_HIGH_REASONABLE_VALUE) {
+ double width_dpi;
+ double height_dpi;
+
+ width_dpi = dpi_from_pixels_and_mm (gdk_screen_get_width (screen),
+ gdk_screen_get_width_mm (screen));
+ height_dpi = dpi_from_pixels_and_mm (gdk_screen_get_height (screen),
+ gdk_screen_get_height_mm (screen));
+ if (width_dpi < DPI_LOW_REASONABLE_VALUE
+ || width_dpi > DPI_HIGH_REASONABLE_VALUE
+ || height_dpi < DPI_LOW_REASONABLE_VALUE
+ || height_dpi > DPI_HIGH_REASONABLE_VALUE) {
dpi = DPI_DEFAULT;
+ } else {
+ dpi = (width_dpi + height_dpi) / 2.0;
}
} else {
/* Huh!? No screen? */
@@ -252,25 +277,26 @@
gboolean ret;
GConfClient *client;
GConfValue *value;
- gdouble dpi;
+ gdouble x_dpi;
+ gdouble u_dpi;
client = gconf_client_get_default ();
value = gconf_client_get_without_default (client, KEY_FONT_DPI, NULL);
if (value != NULL) {
- dpi = gconf_value_get_float (value);
+ u_dpi = gconf_value_get_float (value);
gconf_value_free (value);
} else {
- dpi = get_dpi_from_x_server ();
+ u_dpi = DPI_DEFAULT;
}
- if (dpi < DPI_LOW_REASONABLE_VALUE) {
- dpi = DPI_LOW_REASONABLE_VALUE;
- }
+ x_dpi = get_dpi_from_x_server ();
g_object_unref (client);
- ret = (dpi > DPI_DEFAULT);
+ g_debug ("GsdA11yPreferences: got x-dpi=%f user-dpi=%f", x_dpi, u_dpi);
+
+ ret = (((double)DPI_FACTOR_LARGE * x_dpi) < u_dpi);
return ret;
}
@@ -283,7 +309,15 @@
client = gconf_client_get_default ();
if (enabled) {
- gconf_client_set_float (client, KEY_FONT_DPI, DPI_LARGER_FONT, NULL);
+ gdouble x_dpi;
+ gdouble u_dpi;
+
+ x_dpi = get_dpi_from_x_server ();
+ u_dpi = (double)DPI_FACTOR_LARGER * x_dpi;
+
+ g_debug ("GsdA11yPreferences: setting x-dpi=%f user-dpi=%f", x_dpi, u_dpi);
+
+ gconf_client_set_float (client, KEY_FONT_DPI, u_dpi, NULL);
} else {
gconf_client_unset (client, KEY_FONT_DPI, NULL);
}
Added: trunk/plugins/a11y-keyboard/test-a11y-preferences-dialog.c
==============================================================================
--- (empty file)
+++ trunk/plugins/a11y-keyboard/test-a11y-preferences-dialog.c Tue Aug 26 15:54:22 2008
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 William Jon McCann <mccann jhu edu>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ *
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "gsd-a11y-preferences-dialog.h"
+
+static void
+test_window (void)
+{
+ GtkWidget *window;
+
+ window = gsd_a11y_preferences_dialog_new ();
+ gtk_dialog_run (GTK_DIALOG (window));
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ GError *error = NULL;
+
+#ifdef ENABLE_NLS
+ bindtextdomain (GETTEXT_PACKAGE, GNOME_SETTINGS_LOCALEDIR);
+# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+# endif
+ textdomain (GETTEXT_PACKAGE);
+#endif
+
+ if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error)) {
+ fprintf (stderr, "%s", error->message);
+ g_error_free (error);
+ exit (1);
+ }
+
+ test_window ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]