aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <descalante@igalia.com>2010-12-08 02:51:11 +0800
committerDiego Escalante Urrelo <descalante@igalia.com>2010-12-08 23:56:12 +0800
commit4015281028a036ee859360bb7feb3a6aeb8f56cb (patch)
treef9d8b7f71a4229d8b44d1180698e8f892635e880
parentbc03f56a7483e499274cf1632975dfbb7e09e9ec (diff)
downloadgsoc2013-epiphany-4015281028a036ee859360bb7feb3a6aeb8f56cb.tar
gsoc2013-epiphany-4015281028a036ee859360bb7feb3a6aeb8f56cb.tar.gz
gsoc2013-epiphany-4015281028a036ee859360bb7feb3a6aeb8f56cb.tar.bz2
gsoc2013-epiphany-4015281028a036ee859360bb7feb3a6aeb8f56cb.tar.lz
gsoc2013-epiphany-4015281028a036ee859360bb7feb3a6aeb8f56cb.tar.xz
gsoc2013-epiphany-4015281028a036ee859360bb7feb3a6aeb8f56cb.tar.zst
gsoc2013-epiphany-4015281028a036ee859360bb7feb3a6aeb8f56cb.zip
prefs-dialog: new custom font selection UI
Allow users to set custom sans, serif and monospace fonts if they don't want the defaults, which are the desktop wide settings in the org.gnome.desktop.interface schema. Bug #636761
-rw-r--r--data/glade/prefs-dialog.ui86
-rw-r--r--data/org.gnome.epiphany.gschema.xml.in20
-rw-r--r--embed/ephy-embed-prefs.c107
-rw-r--r--lib/ephy-prefs.h4
-rw-r--r--src/prefs-dialog.c35
5 files changed, 240 insertions, 12 deletions
diff --git a/data/glade/prefs-dialog.ui b/data/glade/prefs-dialog.ui
index e2c385731..b98558566 100644
--- a/data/glade/prefs-dialog.ui
+++ b/data/glade/prefs-dialog.ui
@@ -272,7 +272,7 @@
<object class="GtkLabel" id="label1312">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">_Minimum size:</property>
+ <property name="label" translatable="yes">_Minimum font size:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">min_size_spinbutton</property>
</object>
@@ -301,6 +301,84 @@
</packing>
</child>
<child>
+ <object class="GtkVBox" id="vbox1">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkCheckButton" id="use_gnome_fonts_checkbutton">
+ <property name="label" translatable="yes">_Use system fonts</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_underline">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkVBox" id="custom_fonts_vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkFontButton" id="sans_fontbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_font">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFontButton" id="serif_fontbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="font_name">Serif 12</property>
+ <property name="use_font">True</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFontButton" id="mono_fontbutton">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="font_name">Monospace 12</property>
+ <property name="use_font">True</property>
+ </object>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="use_fonts_checkbutton">
<property name="label" translatable="yes">Let web pages specify their own _fonts</property>
<property name="visible">True</property>
@@ -312,7 +390,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -327,7 +405,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -376,7 +454,7 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
</object>
diff --git a/data/org.gnome.epiphany.gschema.xml.in b/data/org.gnome.epiphany.gschema.xml.in
index 587a5ebcb..eb7a1fe2d 100644
--- a/data/org.gnome.epiphany.gschema.xml.in
+++ b/data/org.gnome.epiphany.gschema.xml.in
@@ -92,6 +92,26 @@
<default>7</default>
<summary>Minimum font size</summary>
</key>
+ <key type="b" name="use-gnome-fonts">
+ <default>true</default>
+ <summary>Use GNOME fonts</summary>
+ <description>Use GNOME desktop wide font configuration.</description>
+ </key>
+ <key type="s" name="sans-serif-font">
+ <default>'Sans 10'</default>
+ <summary>Custom sans-serif font</summary>
+ <description>A value to be used to override sans-serif desktop font when use-gnome-fonts is set.</description>
+ </key>
+ <key type="s" name="serif-font">
+ <default>'Serif 10'</default>
+ <summary>Custom serif font</summary>
+ <description>A value to be used to override serif desktop font when use-gnome-fonts is set.</description>
+ </key>
+ <key type="s" name="monospace-font">
+ <default>'Monospace 10'</default>
+ <summary>Custom monospace font</summary>
+ <description>A value to be used to override monospace desktop font when use-gnome-fonts is set.</description>
+ </key>
<key type="b" name="use-own-colors">
<default>false</default>
<summary>Use own colors</summary>
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index e2a279dc4..daea9fb8e 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -151,6 +151,19 @@ webkit_pref_callback_font_size (GSettings *settings,
char *value = NULL;
int size = 9; /* FIXME: What to use here? */
+ char *schema = NULL;
+ g_object_get (settings, "schema", &schema, NULL);
+
+ /* If we are changing a GNOME font value and we are not using GNOME fonts in
+ * Epiphany, return. */
+ if (g_strcmp0 (schema, EPHY_PREFS_WEB_SCHEMA) != 0 &&
+ g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE)
+ {
+ g_free (schema);
+ return;
+ }
+ g_free (schema);
+
value = g_settings_get_string (settings, key);
if (value) {
@@ -175,6 +188,19 @@ webkit_pref_callback_font_family (GSettings *settings,
char *webkit_pref = data;
char *value = NULL;
+ char *schema = NULL;
+ g_object_get (settings, "schema", &schema, NULL);
+
+ /* If we are changing a GNOME font value and we are not using GNOME fonts in
+ * Epiphany, return. */
+ if (g_strcmp0 (schema, EPHY_PREFS_WEB_SCHEMA) != 0 &&
+ g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_USE_GNOME_FONTS) != TRUE)
+ {
+ g_free (schema);
+ return;
+ }
+ g_free (schema);
+
value = g_settings_get_string (settings, key);
if (value) {
@@ -323,13 +349,62 @@ webkit_pref_callback_cookie_accept_policy (GSettings *settings,
g_free (value);
}
+static void
+webkit_pref_callback_gnome_fonts (GSettings *ephy_settings,
+ char *key,
+ gpointer data)
+{
+ GSettings *settings;
+
+ if (g_settings_get_boolean (ephy_settings, key)) {
+ settings = ephy_settings_get ("org.gnome.desktop.interface");
+
+ webkit_pref_callback_font_size (settings, "font-name",
+ "default-font-size");
+ webkit_pref_callback_font_size (settings, "monospace-font-name",
+ "default-monospace-font-size");
+
+ webkit_pref_callback_font_family (settings, "font-name",
+ "default-font-family");
+ webkit_pref_callback_font_family (settings, "font-name",
+ "sans-serif-font-family");
+
+ webkit_pref_callback_font_family (settings, "monospace-font-name",
+ "monospace-font-family");
+ } else {
+ /* Sync with Epiphany values */
+ settings = ephy_settings;
+
+ webkit_pref_callback_font_size (settings, EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ "default-font-size");
+ webkit_pref_callback_font_size (settings, EPHY_PREFS_WEB_MONOSPACE_FONT,
+ "default-monospace-font-size");
+
+ webkit_pref_callback_font_family (settings, EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ "default-font-family");
+ webkit_pref_callback_font_family (settings, EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ "sans-serif-font-family");
+
+ webkit_pref_callback_font_family (settings, EPHY_PREFS_WEB_MONOSPACE_FONT,
+ "monospace-font-family");
+
+ webkit_pref_callback_font_family (settings, EPHY_PREFS_WEB_SERIF_FONT,
+ "serif-font-family");
+ }
+}
+
static const PrefData webkit_pref_entries[] =
{
+ /* GNOME font settings */
{ "org.gnome.desktop.interface",
"font-name",
"default-font-size",
webkit_pref_callback_font_size },
{ "org.gnome.desktop.interface",
+ "monospace-font-name",
+ "default-monospace-font-size",
+ webkit_pref_callback_font_size },
+ { "org.gnome.desktop.interface",
"font-name",
"default-font-family",
webkit_pref_callback_font_family },
@@ -339,13 +414,41 @@ static const PrefData webkit_pref_entries[] =
webkit_pref_callback_font_family },
{ "org.gnome.desktop.interface",
"monospace-font-name",
+ "monospace-font-family",
+ webkit_pref_callback_font_family },
+
+ /* Epiphany font settings */
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ "default-font-size",
+ webkit_pref_callback_font_size },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_MONOSPACE_FONT,
"default-monospace-font-size",
webkit_pref_callback_font_size },
- { "org.gnome.desktop.interface",
- "monospace-font-name",
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ "default-font-family",
+ webkit_pref_callback_font_family },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ "sans-serif-font-family",
+ webkit_pref_callback_font_family },
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_MONOSPACE_FONT,
"monospace-font-family",
webkit_pref_callback_font_family },
{ EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_SERIF_FONT,
+ "serif-font-family",
+ webkit_pref_callback_font_family },
+
+ { EPHY_PREFS_WEB_SCHEMA,
+ EPHY_PREFS_WEB_USE_GNOME_FONTS,
+ NULL,
+ webkit_pref_callback_gnome_fonts },
+
+ { EPHY_PREFS_WEB_SCHEMA,
EPHY_PREFS_WEB_ENABLE_USER_CSS,
"user-stylesheet-uri",
webkit_pref_callback_user_stylesheet },
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 5ae1c6912..d4a9755c8 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -76,6 +76,10 @@ typedef enum
#define EPHY_PREFS_WEB_FONT_MIN_SIZE "min-font-size"
#define EPHY_PREFS_WEB_LANGUAGE "language"
#define EPHY_PREFS_WEB_USE_OWN_FONTS "use-own-fonts"
+#define EPHY_PREFS_WEB_USE_GNOME_FONTS "use-gnome-fonts"
+#define EPHY_PREFS_WEB_SANS_SERIF_FONT "sans-serif-font"
+#define EPHY_PREFS_WEB_SERIF_FONT "serif-font"
+#define EPHY_PREFS_WEB_MONOSPACE_FONT "monospace-font"
#define EPHY_PREFS_WEB_USE_OWN_COLORS "use-own-colors"
#define EPHY_PREFS_WEB_ENABLE_USER_CSS "enable-user-css"
#define EPHY_PREFS_WEB_ENABLE_POPUPS "enable-popups"
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index ce9466a08..44946c6fb 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -1038,6 +1038,9 @@ static const PrefsDialogPreference preferences[] =
{ "disk_cache_spinbutton", "value",
EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_CACHE_SIZE,
G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "use_gnome_fonts_checkbutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_USE_GNOME_FONTS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
{ "use_fonts_checkbutton", "active",
EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_USE_OWN_FONTS,
G_SETTINGS_BIND_DEFAULT, NULL, NULL },
@@ -1061,6 +1064,21 @@ static const PrefsDialogPreference preferences[] =
G_SETTINGS_BIND_DEFAULT, NULL, NULL },
{ "css_edit_button", "sensitive",
EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_ENABLE_USER_CSS,
+ G_SETTINGS_BIND_GET, NULL, NULL },
+
+ /* Font buttons */
+ { "custom_fonts_vbox", "sensitive",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_USE_GNOME_FONTS,
+ G_SETTINGS_BIND_GET | G_SETTINGS_BIND_INVERT_BOOLEAN, NULL, NULL },
+
+ { "sans_fontbutton", "font-name",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_SANS_SERIF_FONT,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "serif_fontbutton", "font-name",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_SERIF_FONT,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "mono_fontbutton", "font-name",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_MONOSPACE_FONT,
G_SETTINGS_BIND_DEFAULT, NULL, NULL },
/* Has mapping */
@@ -1102,12 +1120,17 @@ prefs_dialog_init (PrefsDialog *pd)
settings = ephy_settings_get (pref.schema);
widget = ephy_dialog_get_control (dialog, pref.obj);
- g_settings_bind_with_mapping (settings, pref.key,
- widget, pref.prop,
- pref.flags,
- pref.get_mapping,
- pref.set_mapping,
- widget, NULL);
+ if (pref.set_mapping != NULL || pref.get_mapping != NULL)
+ g_settings_bind_with_mapping (settings, pref.key,
+ widget, pref.prop,
+ pref.flags,
+ pref.get_mapping,
+ pref.set_mapping,
+ widget, NULL);
+ else
+ g_settings_bind (settings, pref.key,
+ widget, pref.prop,
+ pref.flags);
}
ephy_dialog_get_controls (dialog,