diff options
author | Marco Pesenti Gritti <marco@gnome.org> | 2003-11-05 05:43:09 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <marco@src.gnome.org> | 2003-11-05 05:43:09 +0800 |
commit | 8180308e57e97c0c4e69331aac409e49e6a38876 (patch) | |
tree | f507f2923ead34164153f2825eea87f8199d3e5d /embed | |
parent | f077672b83507d7ae5dedad6c7d82105e5d5d42f (diff) | |
download | gsoc2013-epiphany-8180308e57e97c0c4e69331aac409e49e6a38876.tar gsoc2013-epiphany-8180308e57e97c0c4e69331aac409e49e6a38876.tar.gz gsoc2013-epiphany-8180308e57e97c0c4e69331aac409e49e6a38876.tar.bz2 gsoc2013-epiphany-8180308e57e97c0c4e69331aac409e49e6a38876.tar.lz gsoc2013-epiphany-8180308e57e97c0c4e69331aac409e49e6a38876.tar.xz gsoc2013-epiphany-8180308e57e97c0c4e69331aac409e49e6a38876.tar.zst gsoc2013-epiphany-8180308e57e97c0c4e69331aac409e49e6a38876.zip |
Resync with eel.
2003-11-04 Marco Pesenti Gritti <marco@gnome.org>
* lib/eel-gconf-extensions.c: (global_client_free),
(eel_gconf_client_get_global), (eel_gconf_handle_error),
(eel_gconf_set_string), (eel_gconf_is_default),
(eel_gconf_key_is_writable), (eel_gconf_monitor_add),
(eel_gconf_monitor_remove), (eel_gconf_preload_cache),
(eel_gconf_get_default_value), (eel_strcmp), (eel_str_is_equal),
(simple_value_is_equal), (eel_gconf_value_is_equal),
(eel_gconf_value_get_string_list),
(eel_gconf_value_set_string_list), (eel_gconf_set_float),
(eel_gconf_get_float):
* lib/eel-gconf-extensions.h:
Resync with eel.
* lib/ephy-prefs.h:
* lib/widgets/ephy-spinner.c:
* embed/ephy-embed-prefs.h:
* embed/mozilla/mozilla-notifiers.cpp:
Migrate old font size settings. This will screw things
for 1.1 users, not much we can do about it now.
Diffstat (limited to 'embed')
-rw-r--r-- | embed/ephy-embed-prefs.h | 11 | ||||
-rw-r--r-- | embed/mozilla/mozilla-notifiers.cpp | 114 |
2 files changed, 116 insertions, 9 deletions
diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h index 50e63bdb7..71cba6166 100644 --- a/embed/ephy-embed-prefs.h +++ b/embed/ephy-embed-prefs.h @@ -1,8 +1,8 @@ #define CONF_NETWORK_CACHE_SIZE "/apps/epiphany/web/cache_size" #define CONF_RENDERING_FONT "/apps/epiphany/web/font" -#define CONF_RENDERING_FONT_VAR_SIZE "/apps/epiphany/web/font_var_size" -#define CONF_RENDERING_FONT_FIXED_SIZE "/apps/epiphany/web/font_fixed_size" -#define CONF_RENDERING_FONT_MIN_SIZE "/apps/epiphany/web/font_min_size" +#define CONF_RENDERING_FONT_VAR_SIZE "/apps/epiphany/web/font_var_size_pt" +#define CONF_RENDERING_FONT_FIXED_SIZE "/apps/epiphany/web/font_fixed_size_pt" +#define CONF_RENDERING_FONT_MIN_SIZE "/apps/epiphany/web/font_min_size_pt" #define CONF_RENDERING_LANGUAGE "/apps/epiphany/web/language" #define CONF_RENDERING_USE_OWN_COLORS "/apps/epiphany/web/use_own_colors" #define CONF_RENDERING_USE_OWN_FONTS "/apps/epiphany/web/use_own_fonts" @@ -26,3 +26,8 @@ #define CONF_NETWORK_SOCKS_PROXY_PORT "/system/proxy/socks_port" #define CONF_NETWORK_PROXY_AUTO_URL "/system/proxy/autoconfig_url" #define CONF_NETWORK_PROXY_IGNORE_HOSTS "/system/http_proxy/ignore_hosts" + +/* Deprecated, we migrate them */ +#define CONF_RENDERING_FONT_VAR_SIZE_OLD "/apps/epiphany/web/font_var_size" +#define CONF_RENDERING_FONT_FIXED_SIZE_OLD "/apps/epiphany/web/font_fixed_size" +#define CONF_RENDERING_FONT_MIN_SIZE_OLD "/apps/epiphany/web/font_min_size" diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp index 7dde69462..da68ebbc0 100644 --- a/embed/mozilla/mozilla-notifiers.cpp +++ b/embed/mozilla/mozilla-notifiers.cpp @@ -35,11 +35,13 @@ #include <locale.h> #include <libgnome/gnome-i18n.h> #include <stdlib.h> -#include "nsCOMPtr.h" -#include "nsIPrefService.h" -#include "nsIServiceManager.h" +#include <gdk/gdkx.h> +#include <nsCOMPtr.h> +#include <nsIPrefService.h> +#include <nsIServiceManager.h> #define MOZILLA_PREF_NO_PROXIES "network.proxy.no_proxies_on" +#define MIGRATE_PIXEL_SIZE static void mozilla_cache_size_notifier (GConfClient *client, @@ -382,14 +384,81 @@ add_notification_and_notify (GConfClient *client, gconf_client_notify (client, key); } +#ifdef MIGRATE_PIXEL_SIZE + +#define INT_ROUND(a) gint((a) + 0.5f) + +/** + * This function gets the dpi in the same way that mozilla gets the dpi, + * this allows us to convert from pixels to points easily + */ +static gint +mozilla_get_dpi () +{ + GtkSettings* settings = gtk_settings_get_default (); + gint dpi = 0; + + /* Use the gdk-xft-dpi setting if it is set */ + if (g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (settings)), + "gtk-xft-dpi")) + { + g_object_get (G_OBJECT (settings), "gtk-xft-dpi", &dpi, NULL); + if (dpi) return INT_ROUND (dpi / PANGO_SCALE); + } + + /* Fall back to what xft thinks it is */ + char *val = XGetDefault (GDK_DISPLAY (), "Xft", "dpi"); + if (val) + { + char *e; + double d = strtod(val, &e); + if (e != val) return INT_ROUND (d); + } + + /* Fall back to calculating manually from the gdk screen settings */ + float screenWidthIn = float (gdk_screen_width_mm()) / 25.4f; + return INT_ROUND (gdk_screen_width() / screenWidthIn); +} + +static void +mozilla_migrate_font_gconf_key (const char *pixel_key, const char *point_key) +{ + int size; + + size = eel_gconf_get_integer (pixel_key); + + if (size > 0) + { + /* Use doubles to get more accurate arithmetic */ + double dpi = (double)mozilla_get_dpi (); + double value = (double)eel_gconf_get_integer (pixel_key); + gint point = INT_ROUND ((value * 72) / dpi); + + eel_gconf_set_integer (point_key, point); + } +} + +#endif + void -mozilla_notifiers_init(EphyEmbedSingle *single) +mozilla_notifiers_init (EphyEmbedSingle *single) { GConfClient *client = eel_gconf_client_get_global (); guint i; const EphyFontsLanguageInfo *font_languages; guint n_font_languages; +#ifdef MIGRATE_PIXEL_SIZE + gboolean migrate_size; + + migrate_size = (eel_gconf_get_integer (CONF_SCHEMA_VERSION) + < EPIPHANY_SCHEMA_VERSION); + if (migrate_size) + { + eel_gconf_set_integer (CONF_SCHEMA_VERSION, EPIPHANY_SCHEMA_VERSION); + } +#endif + for (i = 0; conversion_table[i].gconf_key != NULL; i++) { GConfClientNotifyFunc func = NULL; @@ -436,6 +505,9 @@ mozilla_notifiers_init(EphyEmbedSingle *single) char *types [] = { "variable", "monospace" }; char key[255]; char *info; +#ifdef MIGRATE_PIXEL_SIZE + char old_key[255]; +#endif for (k = 0; k < G_N_ELEMENTS (types); k++) { @@ -456,6 +528,15 @@ mozilla_notifiers_init(EphyEmbedSingle *single) info); font_infos = g_list_prepend (font_infos, info); +#ifdef MIGRATE_PIXEL_SIZE + if (migrate_size) + { + g_snprintf (old_key, 255, "%s_%s", + CONF_RENDERING_FONT_MIN_SIZE_OLD, code); + mozilla_migrate_font_gconf_key (old_key, key); + } +#endif + g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_FIXED_SIZE, code); info = g_strconcat ("size.fixed", ".", code, NULL); add_notification_and_notify (client, key, @@ -463,19 +544,40 @@ mozilla_notifiers_init(EphyEmbedSingle *single) info); font_infos = g_list_prepend (font_infos, info); +#ifdef MIGRATE_PIXEL_SIZE + if (migrate_size) + { + g_snprintf (old_key, 255, "%s_%s", + CONF_RENDERING_FONT_FIXED_SIZE_OLD, code); + mozilla_migrate_font_gconf_key (old_key, key); + } +#endif + g_snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_VAR_SIZE, code); info = g_strconcat ("size.variable", ".", code, NULL); add_notification_and_notify (client, key, (GConfClientNotifyFunc)mozilla_font_size_notifier, info); - font_infos = g_list_prepend (font_infos, info); + font_infos = g_list_prepend (font_infos, info); + +#ifdef MIGRATE_PIXEL_SIZE + if (migrate_size) + { + g_snprintf (old_key, 255, "%s_%s", + CONF_RENDERING_FONT_VAR_SIZE_OLD, code); + mozilla_migrate_font_gconf_key (old_key, key); + } +#endif } } void mozilla_notifiers_free (void) { - ephy_notification_remove (&mozilla_notifiers); + g_list_foreach (mozilla_notifiers, + (GFunc)eel_gconf_notification_remove, + NULL); + g_list_free(mozilla_notifiers); g_list_foreach (font_infos, (GFunc) g_free, NULL); g_list_free (font_infos); |