[Xfce4-commits] <midori:master> Implement Always use my font choices preference

Christian Dywan noreply at xfce.org
Wed Oct 26 23:14:02 CEST 2011


Updating branch refs/heads/master
         to 968c9675924d8d84fc9b2e74e06d0edfa315728a (commit)
       from 0388f2fa39666a2228d20ab7a1867bf3caa0d9f6 (commit)

commit 968c9675924d8d84fc9b2e74e06d0edfa315728a
Author: Christian Dywan <christian at twotoasts.de>
Date:   Wed Oct 26 21:11:50 2011 +0200

    Implement Always use my font choices preference
    
    Patch based on input from Peter Hatina.
    
    Fixes: https://bugs.launchpad.net/midori/+bug/826441

 midori/midori-preferences.c |    2 ++
 midori/midori-websettings.c |   35 ++++++++++++++++++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index 682e91c..1dc9f9e 100644
--- a/midori/midori-preferences.c
+++ b/midori/midori-preferences.c
@@ -351,6 +351,8 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
     entry = katze_property_proxy (settings, "minimum-font-size", NULL);
     gtk_widget_set_tooltip_text (entry, _("The minimum font size used to display text"));
     SPANNED_ADD (entry);
+    button = katze_property_proxy (settings, "enforce-font-family", NULL);
+    INDENTED_ADD (button);
     #endif
     label = katze_property_label (settings, "preferred-encoding");
     INDENTED_ADD (label);
diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c
index 7c04da1..8467163 100644
--- a/midori/midori-websettings.c
+++ b/midori/midori-websettings.c
@@ -92,6 +92,7 @@ struct _MidoriWebSettings
     gboolean enable_dns_prefetching;
     #endif
     gboolean strip_referer;
+    gboolean enforce_font_family;
     gboolean flash_window_on_bg_tabs;
     GHashTable* user_stylesheets;
 };
@@ -175,6 +176,7 @@ enum
     PROP_CLEAR_DATA,
     PROP_ENABLE_DNS_PREFETCHING,
     PROP_STRIP_REFERER,
+    PROP_ENFORCE_FONT_FAMILY,
 };
 
 GType
@@ -1052,7 +1054,21 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
         _("Whether the \"Referer\" header should be shortened to the hostname"),
                                      FALSE,
                                      flags));
-
+    /**
+     * MidoriWebSettings:enforc-font-family:
+     *
+     * Whether to enforce user font preferences with an internal stylesheet.
+     *
+     * Since: 0.4.2
+     */
+    g_object_class_install_property (gobject_class,
+                                     PROP_ENFORCE_FONT_FAMILY,
+                                     g_param_spec_boolean (
+                                     "enforce-font-family",
+                                     _("Always use my font choices"),
+                                     _("Override fonts picked by websites with user preferences"),
+                                     FALSE,
+                                     flags));
 }
 
 static void
@@ -1453,6 +1469,20 @@ midori_web_settings_set_property (GObject*      object,
     case PROP_STRIP_REFERER:
         web_settings->strip_referer = g_value_get_boolean (value);
         break;
+    case PROP_ENFORCE_FONT_FAMILY:
+        if ((web_settings->enforce_font_family = g_value_get_boolean (value)))
+        {
+            gchar* font_family = katze_object_get_string (web_settings,
+                                                          "default-font-family");
+            gchar* css = g_strdup_printf ("* { font-family: %s !important; }",
+                                          font_family);
+            midori_web_settings_add_style (web_settings, "enforce-font-family", css);
+            g_free (font_family);
+            g_free (css);
+        }
+        else
+            midori_web_settings_remove_style (web_settings, "enforce-font-family");
+        break;
     case PROP_FLASH_WINDOW_ON_BG_TABS:
         web_settings->flash_window_on_bg_tabs = g_value_get_boolean (value);
         break;
@@ -1711,6 +1741,9 @@ midori_web_settings_get_property (GObject*    object,
     case PROP_STRIP_REFERER:
         g_value_set_boolean (value, web_settings->strip_referer);
         break;
+    case PROP_ENFORCE_FONT_FAMILY:
+        g_value_set_boolean (value, web_settings->enforce_font_family);
+        break;
     case PROP_FLASH_WINDOW_ON_BG_TABS:
         g_value_set_boolean (value, web_settings->flash_window_on_bg_tabs);
         break;


More information about the Xfce4-commits mailing list