[evolution/wip/webkit-composer: 86/262] Remove option to set spell-checking color
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip/webkit-composer: 86/262] Remove option to set spell-checking color
- Date: Thu, 16 Jan 2014 09:55:06 +0000 (UTC)
commit 53f5acabb1d446e04be4cb393a1b42b76ab9f1d2
Author: Dan Vrátil <dvratil redhat com>
Date: Mon Nov 5 20:30:20 2012 +0100
Remove option to set spell-checking color
This was a special feature supported by GtkHTML, however
WebKit does not seem to support it. It should use whatever
is set as sytem default.
data/org.gnome.evolution.mail.gschema.xml.in | 5 -
mail/mail-config.ui | 41 ------
modules/mail/em-composer-prefs.c | 56 --------
modules/settings/e-settings-web-view.c | 189 ++++++++++++++++++++++++--
4 files changed, 180 insertions(+), 111 deletions(-)
---
diff --git a/data/org.gnome.evolution.mail.gschema.xml.in b/data/org.gnome.evolution.mail.gschema.xml.in
index 0055c08..523f553 100644
--- a/data/org.gnome.evolution.mail.gschema.xml.in
+++ b/data/org.gnome.evolution.mail.gschema.xml.in
@@ -95,11 +95,6 @@
<_summary>Send HTML mail by default</_summary>
<_description>Send HTML mail by default.</_description>
</key>
- <key name="composer-spell-color" type="s">
- <default>'#FFFF00000000'</default>
- <_summary>Spell checking color</_summary>
- <_description>Underline color for misspelled words when using inline spelling.</_description>
- </key>
<key name="composer-spell-languages" type="as">
<default>[]</default>
<_summary>Spell checking languages</_summary>
diff --git a/mail/mail-config.ui b/mail/mail-config.ui
index 97c836d..f4984a1 100644
--- a/mail/mail-config.ui
+++ b/mail/mail-config.ui
@@ -781,47 +781,6 @@
<property name="position">0</property>
</packing>
</child>
- <child>
- <object class="GtkHBox" id="hboxSpellCheckColor">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="lblSpellCheckColor">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Color for _misspelled words:</property>
- <property name="use_underline">True</property>
- <property name="justify">center</property>
- <property name="mnemonic_widget">colorButtonSpellCheckColor</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkColorButton" id="colorButtonSpellCheckColor">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="title" translatable="yes">Pick a color</property>
- <property name="color">#000000000000</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
</object>
</child>
</object>
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index 1d758a9..1d62a43 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -52,53 +52,6 @@ G_DEFINE_TYPE (
em_composer_prefs,
GTK_TYPE_VBOX)
-static gboolean
-composer_prefs_map_string_to_color (GValue *value,
- GVariant *variant,
- gpointer user_data)
-{
- GdkColor color;
- const gchar *string;
- gboolean success = FALSE;
-
- string = g_variant_get_string (variant, NULL);
- if (gdk_color_parse (string, &color)) {
- g_value_set_boxed (value, &color);
- success = TRUE;
- }
-
- return success;
-}
-
-static GVariant *
-composer_prefs_map_color_to_string (const GValue *value,
- const GVariantType *expected_type,
- gpointer user_data)
-{
- GVariant *variant;
- const GdkColor *color;
-
- color = g_value_get_boxed (value);
- if (color == NULL) {
- variant = g_variant_new_string ("");
- } else {
- gchar *string;
-
- /* Encode the color manually because CSS styles expect
- * color codes as #rrggbb, whereas gdk_color_to_string()
- * returns color codes as #rrrrggggbbbb. */
- string = g_strdup_printf (
- "#%02x%02x%02x",
- (gint) color->red * 256 / 65536,
- (gint) color->green * 256 / 65536,
- (gint) color->blue * 256 / 65536);
- variant = g_variant_new_string (string);
- g_free (string);
- }
-
- return variant;
-}
-
static void
composer_prefs_dispose (GObject *object)
{
@@ -1206,15 +1159,6 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
GTK_IMAGE (info_pixmap),
GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON);
- widget = e_builder_get_widget (prefs->builder, "colorButtonSpellCheckColor");
- g_settings_bind_with_mapping (
- settings, "composer-spell-color",
- widget, "color",
- G_SETTINGS_BIND_DEFAULT,
- composer_prefs_map_string_to_color,
- composer_prefs_map_color_to_string,
- NULL, (GDestroyNotify) NULL);
-
spell_setup (prefs);
/* Forwards and Replies */
diff --git a/modules/settings/e-settings-web-view.c b/modules/settings/e-settings-web-view.c
index 0867b3c..ff804f3 100644
--- a/modules/settings/e-settings-web-view.c
+++ b/modules/settings/e-settings-web-view.c
@@ -31,7 +31,8 @@
((obj), E_TYPE_SETTINGS_WEB_VIEW, ESettingsWebViewPrivate))
struct _ESettingsWebViewPrivate {
- gint placeholder;
+ GtkCssProvider *css_provider;
+ GSettings *settings;
};
G_DEFINE_DYNAMIC_TYPE (
@@ -39,32 +40,194 @@ G_DEFINE_DYNAMIC_TYPE (
e_settings_web_view,
E_TYPE_EXTENSION)
+/* replaces content of color string */
static void
-settings_web_view_constructed (GObject *object)
+settings_web_view_fix_color_string (gchar *color_string)
{
- GSettings *settings;
+ GdkColor color;
+
+ if (color_string == NULL)
+ return;
+
+ if (strlen (color_string) < 13)
+ return;
+
+ if (!gdk_color_parse (color_string, &color))
+ return;
+
+ sprintf (
+ color_string, "#%02x%02x%02x",
+ (gint) color.red * 256 / 65536,
+ (gint) color.green * 256 / 65536,
+ (gint) color.blue * 256 / 65536);
+}
+
+static void
+settings_web_view_load_style (ESettingsWebView *extension)
+{
+ GString *buffer;
+ gchar *citation_color;
+ gchar *monospace_font;
+ gchar *variable_font;
+ gboolean custom_fonts;
+ gboolean mark_citations;
EExtensible *extensible;
+ GtkStyleContext *style_context;
+ GSettings *settings;
+ GError *error = NULL;
- extensible = e_extension_get_extensible (E_EXTENSION (object));
+ /* Some of our mail and composer preferences are passed down to
+ * GtkHtml through style properties, unfortunately. This builds
+ * a style sheet for the EWebView using values from GSettings. */
- settings = g_settings_new ("org.gnome.evolution.mail");
+ settings = extension->priv->settings;
+
+ custom_fonts =
+ g_settings_get_boolean (settings, "use-custom-font");
+ monospace_font =
+ g_settings_get_string (settings, "monospace-font");
+ variable_font =
+ g_settings_get_string (settings, "variable-width-font");
+ mark_citations =
+ g_settings_get_boolean (settings, "mark-citations");
+ citation_color =
+ g_settings_get_string (settings, "citation-color");
+
+ buffer = g_string_new ("EWebViewGtkHTML {\n");
+
+ settings_web_view_fix_color_string (citation_color);
+
+ if (custom_fonts && variable_font != NULL)
+ g_string_append_printf (
+ buffer, " font: %s;\n", variable_font);
+
+ if (custom_fonts && monospace_font != NULL)
+ g_string_append_printf (
+ buffer, " -GtkHTML-fixed-font-name: '%s';\n",
+ monospace_font);
+
+ if (mark_citations && citation_color != NULL)
+ g_string_append_printf (
+ buffer, " -GtkHTML-cite-color: %s;\n",
+ citation_color);
+
+ g_string_append (buffer, "}\n");
+
+ gtk_css_provider_load_from_data (
+ extension->priv->css_provider,
+ buffer->str, buffer->len, &error);
+
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_error_free (error);
+ }
+
+ g_string_free (buffer, TRUE);
+
+ g_free (monospace_font);
+ g_free (variable_font);
+ g_free (citation_color);
+
+ extensible = e_extension_get_extensible (E_EXTENSION (extension));
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (extensible));
+ gtk_style_context_invalidate (style_context);
+}
+
+static void
+settings_web_view_changed_cb (GSettings *settings,
+ const gchar *key,
+ ESettingsWebView *extension)
+{
+ settings_web_view_load_style (extension);
+}
+
+static void
+settings_web_view_realize (GtkWidget *widget,
+ ESettingsWebView *extension)
+{
+ GSettings *settings;
+
+ settings = extension->priv->settings;
g_settings_bind (
settings, "composer-inline-spelling",
- extensible, "inline-spelling",
+ widget, "inline-spelling",
G_SETTINGS_BIND_GET);
g_settings_bind (
settings, "composer-magic-links",
- extensible, "magic-links",
+ widget, "magic-links",
G_SETTINGS_BIND_GET);
g_settings_bind (
settings, "composer-magic-smileys",
- extensible, "magic-smileys",
+ widget, "magic-smileys",
G_SETTINGS_BIND_GET);
- g_object_unref (settings);
+ gtk_style_context_add_provider (
+ gtk_widget_get_style_context (widget),
+ GTK_STYLE_PROVIDER (extension->priv->css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+ settings_web_view_load_style (extension);
+
+ /* Reload the style sheet when certain settings change. */
+
+ g_signal_connect (
+ settings, "changed::use-custom-font",
+ G_CALLBACK (settings_web_view_changed_cb), extension);
+
+ g_signal_connect (
+ settings, "changed::monospace-font",
+ G_CALLBACK (settings_web_view_changed_cb), extension);
+
+ g_signal_connect (
+ settings, "changed::variable-width-font",
+ G_CALLBACK (settings_web_view_changed_cb), extension);
+
+ g_signal_connect (
+ settings, "changed::mark-citations",
+ G_CALLBACK (settings_web_view_changed_cb), extension);
+
+ g_signal_connect (
+ settings, "changed::citation-color",
+ G_CALLBACK (settings_web_view_changed_cb), extension);
+}
+
+static void
+settings_web_view_dispose (GObject *object)
+{
+ ESettingsWebViewPrivate *priv;
+
+ priv = E_SETTINGS_WEB_VIEW_GET_PRIVATE (object);
+
+ if (priv->settings != NULL) {
+ g_signal_handlers_disconnect_by_func (
+ priv->settings,
+ settings_web_view_changed_cb, object);
+ }
+
+ g_clear_object (&priv->css_provider);
+ g_clear_object (&priv->settings);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_settings_web_view_parent_class)->dispose (object);
+}
+
+static void
+settings_web_view_constructed (GObject *object)
+{
+ EExtensible *extensible;
+
+ extensible = e_extension_get_extensible (E_EXTENSION (object));
+
+ /* Wait to bind settings until the EWebView is realized so
+ * GtkhtmlEditor has a chance to install a GtkHTMLEditorAPI.
+ * Otherwise our settings will have no effect. */
+
+ g_signal_connect (
+ extensible, "realize",
+ G_CALLBACK (settings_web_view_realize), object);
/* Chain up to parent's constructed() method. */
G_OBJECT_CLASS (e_settings_web_view_parent_class)->
@@ -80,6 +243,7 @@ e_settings_web_view_class_init (ESettingsWebViewClass *class)
g_type_class_add_private (class, sizeof (ESettingsWebViewPrivate));
object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = settings_web_view_dispose;
object_class->constructed = settings_web_view_constructed;
extension_class = E_EXTENSION_CLASS (class);
@@ -94,7 +258,14 @@ e_settings_web_view_class_finalize (ESettingsWebViewClass *class)
static void
e_settings_web_view_init (ESettingsWebView *extension)
{
+ GSettings *settings;
+
extension->priv = E_SETTINGS_WEB_VIEW_GET_PRIVATE (extension);
+
+ extension->priv->css_provider = gtk_css_provider_new ();
+
+ settings = g_settings_new ("org.gnome.evolution.mail");
+ extension->priv->settings = settings;
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]