[evolution/webkit-composer: 35/185] Make 'Page Properties' dialog work
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 35/185] Make 'Page Properties' dialog work
- Date: Sat, 13 Apr 2013 15:31:16 +0000 (UTC)
commit 675a8cfd6570b0cd85526ebedac5bcda208620eb
Author: Dan Vrátil <dvratil redhat com>
Date: Mon Aug 13 12:02:39 2012 +0200
Make 'Page Properties' dialog work
The dialog is implemented in EEditorPageDialog class.
Background images for templates were imported from
GtkHTML to /art folder in Evo.
art/Makefile.am | 12 +-
art/confidential-stamp.jpg | Bin 0 -> 5708 bytes
art/draft-paper.png | Bin 0 -> 597 bytes
art/draft-stamp.jpg | Bin 0 -> 4660 bytes
art/midnight-stars.jpg | Bin 0 -> 7190 bytes
art/paper.png | Bin 0 -> 266 bytes
art/rect.png | Bin 0 -> 3795 bytes
art/ribbon.jpg | Bin 0 -> 3193 bytes
art/texture.png | Bin 0 -> 137 bytes
e-util/Makefile.am | 2 +
e-util/e-editor-actions.c | 7 +-
e-util/e-editor-builder.ui | 280 ----------------------
e-util/e-editor-page-dialog.c | 529 ++++++++++++++++++++++++++++++++++++++++++
e-util/e-editor-page-dialog.h | 69 ++++++
e-util/e-editor-private.h | 2 +
e-util/e-editor-widget.c | 183 ++++++++++++++-
e-util/e-editor-widget.h | 3 +-
e-util/e-editor-widgets.h | 14 --
e-util/e-util.h | 1 +
19 files changed, 796 insertions(+), 306 deletions(-)
---
diff --git a/art/Makefile.am b/art/Makefile.am
index 850be7e..276d435 100644
--- a/art/Makefile.am
+++ b/art/Makefile.am
@@ -1,7 +1,15 @@
images_DATA = \
- world_map-960.png \
+ confidential-stamp.jpg \
+ draft-paper.png \
+ draft-stamp.jpg \
+ midnight-stars.jpg \
+ minus.png \
+ paper.png \
plus.png \
- minus.png
+ rect.png \
+ ribbon.jpg \
+ texture.png \
+ world_map-960.png
EXTRA_DIST = \
README \
diff --git a/art/confidential-stamp.jpg b/art/confidential-stamp.jpg
new file mode 100644
index 0000000..0dece7c
Binary files /dev/null and b/art/confidential-stamp.jpg differ
diff --git a/art/draft-paper.png b/art/draft-paper.png
new file mode 100644
index 0000000..177d568
Binary files /dev/null and b/art/draft-paper.png differ
diff --git a/art/draft-stamp.jpg b/art/draft-stamp.jpg
new file mode 100644
index 0000000..623f50e
Binary files /dev/null and b/art/draft-stamp.jpg differ
diff --git a/art/midnight-stars.jpg b/art/midnight-stars.jpg
new file mode 100644
index 0000000..22f01b3
Binary files /dev/null and b/art/midnight-stars.jpg differ
diff --git a/art/paper.png b/art/paper.png
new file mode 100644
index 0000000..bca355b
Binary files /dev/null and b/art/paper.png differ
diff --git a/art/rect.png b/art/rect.png
new file mode 100644
index 0000000..b7e633c
Binary files /dev/null and b/art/rect.png differ
diff --git a/art/ribbon.jpg b/art/ribbon.jpg
new file mode 100644
index 0000000..03ca65e
Binary files /dev/null and b/art/ribbon.jpg differ
diff --git a/art/texture.png b/art/texture.png
new file mode 100644
index 0000000..b0925a6
Binary files /dev/null and b/art/texture.png differ
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index 5f1a66f..cf8dc41 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -183,6 +183,7 @@ eutilinclude_HEADERS = \
e-editor-find-dialog.h \
e-editor-hrule-dialog.h \
e-editor-link-dialog.h \
+ e-editor-page-dialog.h \
e-editor-replace-dialog.h \
e-editor-selection.h \
e-editor-table-dialog.h \
@@ -450,6 +451,7 @@ libeutil_la_SOURCES = \
e-editor-find-dialog.c \
e-editor-hrule-dialog.c \
e-editor-link-dialog.c \
+ e-editor-page-dialog.c \
e-editor-private.h \
e-editor-replace-dialog.c \
e-editor-selection.c \
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 93af22d..298a1e5 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -923,7 +923,12 @@ static void
action_properties_page_cb (GtkAction *action,
EEditor *editor)
{
- gtk_window_present (GTK_WINDOW (WIDGET (PAGE_PROPERTIES_WINDOW)));
+ if (editor->priv->page_dialog == NULL) {
+ editor->priv->page_dialog =
+ e_editor_page_dialog_new (editor);
+ }
+
+ gtk_window_present (GTK_WINDOW (editor->priv->page_dialog));
}
static void
diff --git a/e-util/e-editor-builder.ui b/e-util/e-editor-builder.ui
index cb58225..50e220f 100644
--- a/e-util/e-editor-builder.ui
+++ b/e-util/e-editor-builder.ui
@@ -731,286 +731,6 @@
</object>
</child>
</object>
- <object class="GtkWindow" id="page-properties-window">
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
- <property name="border_width">12</property>
- <property name="title" translatable="yes">Page Properties</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
- <property name="destroy_with_parent">True</property>
- <signal handler="gtkhtml_editor_page_properties_window_realized_cb" name="realize"/>
- <signal handler="gtk_widget_hide_on_delete" name="delete_event"/>
- <child>
- <object class="GtkVBox" id="page-properties-vbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">12</property>
- <child>
- <object class="GtkVBox" id="page-properties-colors-vbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="page-properties-colors-header">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Colors</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="page-properties-colors-alignment">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkTable" id="page-properties-colors-table">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">3</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="page-properties-text-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Text:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="page-properties-link-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Link:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="page-properties-background-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">_Background:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="EColorCombo" id="page-properties-text-color-combo">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="default_color">#000000000000</property>
- <property name="default_label">Automatic</property>
- <signal handler="gtkhtml_editor_page_properties_text_color_changed_cb"
name="changed" object="page-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="EColorCombo" id="page-properties-link-color-combo">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="default_color">#000000000000</property>
- <property name="default_label">_Automatic</property>
- <signal handler="gtkhtml_editor_page_properties_link_color_changed_cb"
name="changed" object="page-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="EColorCombo" id="page-properties-background-color-combo">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="default_color">#000000000000</property>
- <property name="default_label">Automatic</property>
- <signal handler="gtkhtml_editor_page_properties_background_color_changed_cb"
name="changed" object="page-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkVBox" id="page-properties-background-vbox">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="page-properties-background-header">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Background Image</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkAlignment" id="page-properties-background-alignment">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="left_padding">12</property>
- <child>
- <object class="GtkTable" id="page-properties-backgrond-table">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">6</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="page-properties-template-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">T_emplate:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="page-properties-custom-label">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="xalign">1</property>
- <property name="label" translatable="yes">C_ustom:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkFileChooserButton" id="page-properties-custom-file-chooser">
- <property name="width_request">200</property>
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <signal handler="gtkhtml_editor_page_properties_custom_file_changed_cb"
name="selection_changed" object="page-properties-window"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="page-properties-template-combo-box">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <signal handler="gtkhtml_editor_page_properties_template_changed_cb" name="changed"
object="page-properties-window"/>
- <property name="model">model5</property>
- <child>
- <object class="GtkCellRendererText" id="renderer5"/>
- <attributes>
- <attribute name="text">0</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <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>
- <child>
- <object class="GtkHButtonBox" id="page-properties-button-box">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">12</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
- <child>
- <object class="GtkButton" id="page-properties-close-button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="label">gtk-close</property>
- <property name="use_stock">True</property>
- <signal handler="gtk_widget_hide" name="clicked" object="page-properties-window"/>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
<object class="GtkWindow" id="cell-properties-window">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">1</property>
diff --git a/e-util/e-editor-page-dialog.c b/e-util/e-editor-page-dialog.c
new file mode 100644
index 0000000..5c99749
--- /dev/null
+++ b/e-util/e-editor-page-dialog.c
@@ -0,0 +1,529 @@
+/*
+ * e-editor-page-dialog.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "e-editor-page-dialog.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "e-color-combo.h"
+#include "e-misc-utils.h"
+
+G_DEFINE_TYPE (
+ EEditorPageDialog,
+ e_editor_page_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
+struct _EEditorPageDialogPrivate {
+ GtkWidget *text_color_picker;
+ GtkWidget *link_color_picker;
+ GtkWidget *background_color_picker;
+
+ GtkWidget *background_template_combo;
+ GtkWidget *background_image_filechooser;
+
+ GtkWidget *close_button;
+};
+
+typedef struct _Template {
+ const gchar *name;
+ const gchar *filename;
+ GdkRGBA text_color;
+ GdkRGBA link_color;
+ GdkRGBA background_color;
+ gint left_margin;
+} Template;
+
+static const Template templates[] = {
+
+ {
+ N_("None"),
+ NULL,
+ { 0.0, 0.0 , 0.0 , 1 },
+ { 0.3, 0.55, 0.85, 1 },
+ { 1.0, 1.0 , 1.0 , 1 },
+ 0
+ },
+
+ {
+ N_("Perforated Paper"),
+ "paper.png",
+ { 0.0, 0.0, 0.0, 1 },
+ { 0.0, 0.2, 0.4, 1 },
+ { 1.0, 1.0, 1.0, 0 },
+ 30
+ },
+
+ {
+ N_("Blue Ink"),
+ "texture.png",
+ { 0.1, 0.12, 0.56, 1 },
+ { 0.0, 0.0, 1.0, 1 },
+ { 1.0, 1.0, 1.0, 1 },
+ 0
+ },
+
+ {
+ N_("Paper"),
+ "rect.png",
+ { 0, 0, 0, 1 },
+ { 0, 0, 1, 1 },
+ { 1, 1, 1, 1 },
+ 0
+ },
+
+ {
+ N_("Ribbon"),
+ "ribbon.jpg",
+ { 0.0, 0.0, 0.0, 1 },
+ { 0.6, 0.2, 0.4, 1 },
+ { 1.0, 1.0, 1.0, 1 },
+ 70
+ },
+
+ {
+ N_("Midnight"),
+ "midnight-stars.jpg",
+ { 1.0, 1.0, 1.0, 1 },
+ { 1.0, 0.6, 0.0, 1 },
+ { 0.0, 0.0, 0.0, 1 },
+ 0
+ },
+
+ {
+ N_("Confidential"),
+ "confidential-stamp.jpg",
+ { 0.0, 0.0, 0.0, 1 },
+ { 0.0, 0.0, 1.0, 1 },
+ { 1.0, 1.0, 1.0, 1 },
+ 0
+ },
+
+ {
+ N_("Draft"),
+ "draft-stamp.jpg",
+ { 0.0, 0.0, 0.0, 1 },
+ { 0.0, 0.0, 1.0, 1 },
+ { 1.0, 1.0, 1.0, 1 },
+ 0
+ },
+
+ {
+ N_("Graph Paper"),
+ "draft-paper.png",
+ { 0.0 , 0.0 , 0.5, 1 },
+ { 0.88, 0.13, 0.14, 1 },
+ { 1.0 , 1.0 , 1.0 , 1 },
+ 0
+ }
+
+};
+
+static void
+editor_page_dialog_set_text_color (EEditorPageDialog *dialog)
+{
+ EEditor *editor;
+ EEditorWidget *widget;
+ WebKitDOMDocument *document;
+ WebKitDOMHTMLElement *body;
+ GdkRGBA rgba;
+ gchar *color;
+
+ editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ widget = e_editor_get_editor_widget (editor);
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+ body = webkit_dom_document_get_body (document);
+
+ e_color_combo_get_current_color (
+ E_COLOR_COMBO (dialog->priv->text_color_picker), &rgba);
+
+ color = g_strdup_printf("#%06x", e_rgba_to_value (&rgba));
+ webkit_dom_html_body_element_set_text (
+ (WebKitDOMHTMLBodyElement *) body, color);
+
+ g_free (color);
+}
+
+static void
+editor_page_dialog_set_link_color (EEditorPageDialog *dialog)
+{
+ EEditor *editor;
+ EEditorWidget *widget;
+ WebKitDOMDocument *document;
+ WebKitDOMHTMLElement *body;
+ GdkRGBA rgba;
+ gchar *color;
+
+ editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ widget = e_editor_get_editor_widget (editor);
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+ body = webkit_dom_document_get_body (document);
+
+ e_color_combo_get_current_color (
+ E_COLOR_COMBO (dialog->priv->link_color_picker), &rgba);
+
+ color = g_strdup_printf("#%06x", e_rgba_to_value (&rgba));
+ webkit_dom_html_body_element_set_link (
+ (WebKitDOMHTMLBodyElement *) body, color);
+
+ g_free (color);
+}
+
+static void
+editor_page_dialog_set_background_color (EEditorPageDialog *dialog)
+{
+ EEditor *editor;
+ EEditorWidget *widget;
+ WebKitDOMDocument *document;
+ WebKitDOMHTMLElement *body;
+ GdkRGBA rgba;
+ gchar *color;
+
+ editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ widget = e_editor_get_editor_widget (editor);
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+ body = webkit_dom_document_get_body (document);
+
+ e_color_combo_get_current_color (
+ E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba);
+
+ color = g_strdup_printf("#%06x", e_rgba_to_value (&rgba));
+
+ webkit_dom_html_body_element_set_bg_color (
+ (WebKitDOMHTMLBodyElement *) body, color);
+
+ g_free (color);
+}
+
+static void
+editor_page_dialog_set_background_from_template (EEditorPageDialog *dialog)
+{
+ const Template *tmplt;
+
+ tmplt = &templates[
+ gtk_combo_box_get_active (
+ GTK_COMBO_BOX (dialog->priv->background_template_combo))];
+
+
+ /* Special case - 'none' template */
+ if (tmplt->filename == NULL) {
+ gtk_file_chooser_unselect_all (
+ GTK_FILE_CHOOSER (dialog->priv->background_image_filechooser));
+ } else {
+ gchar *filename;
+
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->text_color_picker),
+ &tmplt->text_color);
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->background_color_picker),
+ &tmplt->background_color);
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->link_color_picker),
+ &tmplt->link_color);
+
+ filename = g_build_filename (EVOLUTION_IMAGESDIR, tmplt->filename, NULL);
+
+ gtk_file_chooser_set_filename (
+ GTK_FILE_CHOOSER (dialog->priv->background_image_filechooser),
+ filename);
+ g_free (filename);
+ }
+
+}
+
+static void
+editor_page_dialog_set_background_image (EEditorPageDialog *dialog)
+{
+ EEditor *editor;
+ EEditorWidget *widget;
+ WebKitDOMDocument *document;
+ WebKitDOMHTMLElement *body;
+ const gchar *uri;
+
+ editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ widget = e_editor_get_editor_widget (editor);
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
+ body = webkit_dom_document_get_body (document);
+
+ uri = gtk_file_chooser_get_uri (
+ GTK_FILE_CHOOSER (
+ dialog->priv->background_image_filechooser));
+
+ webkit_dom_html_body_element_set_background (
+ (WebKitDOMHTMLBodyElement *) body, uri ? uri : "");
+}
+
+static void
+editor_page_dialog_close (EEditorPageDialog *dialog)
+{
+ gtk_widget_hide (GTK_WIDGET (dialog));
+}
+
+static void
+editor_page_dialog_show (GtkWidget *widget)
+{
+ EEditor *editor;
+ EEditorWidget *editor_widget;
+ EEditorPageDialog *dialog;
+ WebKitDOMDocument *document;
+ WebKitDOMHTMLElement *body;
+ gchar *tmp;
+ GdkRGBA rgba;
+
+ dialog = E_EDITOR_PAGE_DIALOG (widget);
+ editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
+ editor_widget = e_editor_get_editor_widget (editor);
+
+ document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (editor_widget));
+ body = webkit_dom_document_get_body (document);
+
+ tmp = webkit_dom_html_body_element_get_background (
+ (WebKitDOMHTMLBodyElement *) body);
+ if (tmp && *tmp) {
+ gint ii;
+ gchar *fname = g_filename_from_uri (tmp, NULL, NULL);
+ for (ii = 0; ii < G_N_ELEMENTS (templates); ii++) {
+ const Template *tmplt = &templates[ii];
+
+ if (g_strcmp0 (tmplt->filename, fname) == 0) {
+ gtk_combo_box_set_active (
+ GTK_COMBO_BOX (dialog->priv->background_template_combo),
+ ii);
+ break;
+ }
+ }
+ g_free (fname);
+ } else {
+ gtk_combo_box_set_active (
+ GTK_COMBO_BOX (dialog->priv->background_template_combo), 0);
+ }
+
+ tmp = webkit_dom_html_body_element_get_text (
+ (WebKitDOMHTMLBodyElement *) body);
+ if (!tmp || !*tmp) {
+ GdkColor *color;
+ GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (editor_widget));
+ color = &style->text[GTK_STATE_NORMAL];
+
+ rgba.alpha = 1;
+ rgba.red = ((gdouble) color->red) / G_MAXUINT16;
+ rgba.green = ((gdouble) color->green) / G_MAXUINT16;
+ rgba.blue = ((gdouble) color->blue) / G_MAXUINT16;
+ } else {
+ gdk_rgba_parse (&rgba, tmp);
+ g_free (tmp);
+ }
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->text_color_picker), &rgba);
+
+ tmp = webkit_dom_html_body_element_get_link (
+ (WebKitDOMHTMLBodyElement *) body);
+ if (!tmp || !*tmp) {
+ GdkColor color;
+ gtk_widget_style_get (
+ GTK_WIDGET (editor_widget), "link-color", &color, NULL);
+
+ rgba.alpha = 1;
+ rgba.red = ((gdouble) color.red) / G_MAXUINT16;
+ rgba.green = ((gdouble) color.green) / G_MAXUINT16;
+ rgba.blue = ((gdouble) color.blue) / G_MAXUINT16;
+ } else {
+ gdk_rgba_parse (&rgba, tmp);
+ g_free (tmp);
+ }
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->link_color_picker), &rgba);
+
+ tmp = webkit_dom_html_body_element_get_bg_color (
+ (WebKitDOMHTMLBodyElement *) body);
+ if (!tmp || !*tmp) {
+ GdkColor *color;
+ GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (editor_widget));
+ color = &style->base[GTK_STATE_NORMAL];
+
+ rgba.alpha = 1;
+ rgba.red = ((gdouble) color->red) / G_MAXUINT16;
+ rgba.green = ((gdouble) color->green) / G_MAXUINT16;
+ rgba.blue = ((gdouble) color->blue) / G_MAXUINT16;
+
+ } else {
+ gdk_rgba_parse (&rgba, tmp);
+ g_free (tmp);
+ }
+ e_color_combo_set_current_color (
+ E_COLOR_COMBO (dialog->priv->background_color_picker), &rgba);
+
+
+ GTK_WIDGET_CLASS (e_editor_page_dialog_parent_class)->show (widget);
+}
+
+static void
+e_editor_page_dialog_class_init (EEditorPageDialogClass *klass)
+{
+ GtkWidgetClass *widget_class;
+
+ e_editor_page_dialog_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (EEditorPageDialogPrivate));
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class->show = editor_page_dialog_show;
+}
+
+static void
+e_editor_page_dialog_init (EEditorPageDialog *dialog)
+{
+ GtkBox *main_layout;
+ GtkGrid *grid;
+ GtkWidget *widget;
+ gint ii;
+
+ dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ dialog, E_TYPE_EDITOR_PAGE_DIALOG, EEditorPageDialogPrivate);
+
+ main_layout = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 5));
+ gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (main_layout));
+ gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);
+
+ /* == Colors == */
+ widget = gtk_label_new ("");
+ gtk_label_set_markup (GTK_LABEL (widget), _("<b>Colors</b>"));
+ gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
+ gtk_box_pack_start (main_layout, widget, TRUE, TRUE, 5);
+
+ grid = GTK_GRID (gtk_grid_new ());
+ gtk_grid_set_row_spacing (grid, 5);
+ gtk_grid_set_column_spacing (grid, 5);
+ gtk_box_pack_start (main_layout, GTK_WIDGET (grid), TRUE, TRUE, 0);
+ gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);
+
+ /* Text */
+ widget = e_color_combo_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ g_signal_connect_swapped (
+ widget, "notify::current-color",
+ G_CALLBACK (editor_page_dialog_set_text_color), dialog);
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ dialog->priv->text_color_picker = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Text:"));
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->text_color_picker);
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+
+ /* Link */
+ widget = e_color_combo_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ g_signal_connect_swapped (
+ widget, "notify::current-color",
+ G_CALLBACK (editor_page_dialog_set_link_color), dialog);
+ gtk_grid_attach (grid, widget, 1, 1, 1, 1);
+ dialog->priv->link_color_picker = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Link:"));
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->link_color_picker);
+ gtk_grid_attach (grid, widget, 0, 1, 1, 1);
+
+ /* Background */
+ widget = e_color_combo_new ();
+ gtk_widget_set_hexpand (widget, TRUE);
+ g_signal_connect_swapped (
+ widget, "notify::current-color",
+ G_CALLBACK (editor_page_dialog_set_background_color), dialog);
+ gtk_grid_attach (grid, widget, 1, 2, 1, 1);
+ dialog->priv->background_color_picker = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Background:"));
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->background_color_picker);
+ gtk_grid_attach (grid, widget, 0, 2, 1, 1);
+
+ /* == Background Image == */
+ widget = gtk_label_new ("");
+ gtk_label_set_markup (GTK_LABEL (widget), _("<b>Background Image</b>"));
+ gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
+ gtk_box_pack_start (main_layout, widget, TRUE, TRUE, 5);
+
+ grid = GTK_GRID (gtk_grid_new ());
+ gtk_grid_set_row_spacing (grid, 5);
+ gtk_grid_set_column_spacing (grid, 5);
+ gtk_box_pack_start (main_layout, GTK_WIDGET (grid), TRUE, TRUE, 0);
+ gtk_widget_set_margin_left (GTK_WIDGET (grid), 10);
+
+ /* Template */
+ widget = gtk_combo_box_text_new ();
+ for (ii = 0; ii < G_N_ELEMENTS (templates); ii++) {
+ gtk_combo_box_text_append_text (
+ GTK_COMBO_BOX_TEXT (widget), templates[ii].name);
+ }
+ g_signal_connect_swapped (
+ widget, "changed",
+ G_CALLBACK (editor_page_dialog_set_background_from_template), dialog);
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ dialog->priv->background_template_combo = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Template:"));
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->background_template_combo);
+ gtk_grid_attach (grid, widget, 0, 0, 1, 1);
+
+ /* Custom image */
+ widget = gtk_file_chooser_button_new (
+ _("Selection a file"), GTK_FILE_CHOOSER_ACTION_OPEN);
+ g_signal_connect_swapped (
+ widget, "selection-changed",
+ G_CALLBACK (editor_page_dialog_set_background_image), dialog);
+ gtk_grid_attach (grid, widget, 1, 1, 1, 1);
+ dialog->priv->background_image_filechooser = widget;
+
+ widget = gtk_label_new_with_mnemonic (_("Custom:"));
+ gtk_label_set_mnemonic_widget (
+ GTK_LABEL (widget), dialog->priv->background_image_filechooser);
+ gtk_grid_attach (grid, widget, 0, 1, 1, 1);
+
+
+ /* == Button box == */
+ widget = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
+ g_signal_connect_swapped (
+ widget, "clicked",
+ G_CALLBACK (editor_page_dialog_close), dialog);
+ dialog->priv->close_button = widget;
+
+ widget = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_button_box_set_layout (GTK_BUTTON_BOX (widget), GTK_BUTTONBOX_END);
+ gtk_box_pack_start (main_layout, widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (widget), dialog->priv->close_button, FALSE, FALSE, 5);
+
+ gtk_widget_show_all (GTK_WIDGET (main_layout));
+}
+
+
+GtkWidget *
+e_editor_page_dialog_new (EEditor *editor)
+{
+ return GTK_WIDGET (
+ g_object_new (
+ E_TYPE_EDITOR_PAGE_DIALOG,
+ "editor", editor,
+ "title", N_("Page Properties"),
+ NULL));
+}
diff --git a/e-util/e-editor-page-dialog.h b/e-util/e-editor-page-dialog.h
new file mode 100644
index 0000000..21a6399
--- /dev/null
+++ b/e-util/e-editor-page-dialog.h
@@ -0,0 +1,69 @@
+/*
+ * e-editor-page-dialog.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
+#error "Only <e-util/e-util.h> should be included directly."
+#endif
+
+#ifndef E_EDITOR_PAGE_DIALOG_H
+#define E_EDITOR_PAGE_DIALOG_H
+
+#include <e-util/e-editor-dialog.h>
+
+/* Standard GObject macros */
+#define E_TYPE_EDITOR_PAGE_DIALOG \
+ (e_editor_page_dialog_get_type ())
+#define E_EDITOR_PAGE_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_EDITOR_PAGE_DIALOG, EEditorPageDialog))
+#define E_EDITOR_PAGE_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_EDITOR_PAGE_DIALOG, EEditorPageDialogClass))
+#define E_IS_EDITOR_PAGE_DIALOG(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_EDITOR_PAGE_DIALOG))
+#define E_IS_EDITOR_PAGE_DIALOG_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_EDITOR_PAGE_DIALOG))
+#define E_EDITOR_PAGE_DIALOG_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_EDITOR_PAGE_DIALOG, EEditorPageDialogClass))
+
+G_BEGIN_DECLS
+
+typedef struct _EEditorPageDialog EEditorPageDialog;
+typedef struct _EEditorPageDialogClass EEditorPageDialogClass;
+typedef struct _EEditorPageDialogPrivate EEditorPageDialogPrivate;
+
+struct _EEditorPageDialog {
+ EEditorDialog parent;
+
+ EEditorPageDialogPrivate *priv;
+};
+
+struct _EEditorPageDialogClass {
+ EEditorDialogClass parent_class;
+};
+
+GType e_editor_page_dialog_get_type (void);
+
+GtkWidget* e_editor_page_dialog_new (EEditor *editor);
+
+G_END_DECLS
+
+#endif /* E_EDITOR_PAGE_DIALOG_H */
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index 2c5b476..00d10c2 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -29,6 +29,7 @@
#include <e-editor-link-dialog.h>
#include <e-editor-hrule-dialog.h>
#include <e-editor-table-dialog.h>
+#include <e-editor-page-dialog.h>
#ifdef HAVE_XFREE
#include <X11/XF86keysym.h>
@@ -62,6 +63,7 @@ struct _EEditorPrivate {
GtkWidget *link_dialog;
GtkWidget *hrule_dialog;
GtkWidget *table_dialog;
+ GtkWidget *page_dialog;
GtkWidget *color_combo_box;
GtkWidget *mode_combo_box;
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index 5cbe9ec..6b648c0 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -24,6 +24,7 @@
#include "e-editor.h"
#include "e-emoticon-chooser.h"
+#include <e-util/e-util.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdkkeysyms.h>
@@ -44,6 +45,9 @@ struct _EEditorWidgetPrivate {
/* FIXME WEBKIT Is this in widget's competence? */
GList *spelling_langs;
+
+ GSettings *font_settings;
+ GSettings *aliasing_settings;
};
G_DEFINE_TYPE (
@@ -589,7 +593,7 @@ e_editor_widget_init (EEditorWidget *editor)
WebKitWebSettings *settings;
WebKitDOMDocument *document;
GSettings *g_settings;
- gboolean enable_spellchecking;
+ GSettingsSchema *settings_schema;
editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (
editor, E_TYPE_EDITOR_WIDGET, EEditorWidgetPrivate);
@@ -597,22 +601,15 @@ e_editor_widget_init (EEditorWidget *editor)
webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor), TRUE);
settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (editor));
- g_settings = g_settings_new ("org.gnome.evolution.mail");
- enable_spellchecking = g_settings_get_boolean (
- g_settings, "composer-inline-spelling");
-
g_object_set (
G_OBJECT (settings),
"enable-developer-extras", TRUE,
"enable-dom-paste", TRUE,
"enable-file-access-from-file-uris", TRUE,
"enable-plugins", FALSE,
- "enable-spell-checking", enable_spellchecking,
"enable-scripts", FALSE,
NULL);
- g_object_unref(g_settings);
-
webkit_web_view_set_settings (WEBKIT_WEB_VIEW (editor), settings);
/* Don't use CSS when possible to preserve compatibility with older
@@ -629,6 +626,29 @@ e_editor_widget_init (EEditorWidget *editor)
editor->priv->selection = e_editor_selection_new (
WEBKIT_WEB_VIEW (editor));
+ g_settings = g_settings_new ("org.gnome.desktop.interface");
+ g_signal_connect_swapped (
+ g_settings, "changed::font-name",
+ G_CALLBACK (e_editor_widget_update_fonts), editor);
+ g_signal_connect_swapped (
+ g_settings, "changed::monospace-font-name",
+ G_CALLBACK (e_editor_widget_update_fonts), editor);
+ editor->priv->font_settings = g_settings;
+
+ /* This schema is optional. Use if available. */
+ settings_schema = g_settings_schema_source_lookup (
+ g_settings_schema_source_get_default (),
+ "org.gnome.settings-daemon.plugins.xsettings", FALSE);
+ if (settings_schema != NULL) {
+ g_settings = g_settings_new ("org.gnome.settings-daemon.plugins.xsettings");
+ g_signal_connect_swapped (
+ settings, "changed::antialiasing",
+ G_CALLBACK (e_editor_widget_update_fonts), editor);
+ editor->priv->aliasing_settings = g_settings;
+ }
+
+ e_editor_widget_update_fonts (editor);
+
/* Make WebKit think we are displaying a local file, so that it
* does not block loading resources from file:// protocol */
@@ -835,3 +855,150 @@ e_editor_widget_paste_clipboard_quoted (EEditorWidget *widget)
klass->paste_clipboard_quoted (widget);
}
+
+void
+e_editor_widget_update_fonts (EEditorWidget *widget)
+{
+ GString *stylesheet;
+ gchar *base64;
+ gchar *aa = NULL;
+ WebKitWebSettings *settings;
+ PangoFontDescription *min_size, *ms, *vw;
+ const gchar *styles[] = { "normal", "oblique", "italic" };
+ const gchar *smoothing = NULL;
+ GtkStyleContext *context;
+ GdkColor *link = NULL;
+ GdkColor *visited = NULL;
+
+ ms = NULL;
+ vw = NULL;
+
+
+ if (ms == NULL) {
+ gchar *font;
+
+ font = g_settings_get_string (
+ widget->priv->font_settings,
+ "monospace-font-name");
+
+ ms = pango_font_description_from_string (
+ font ? font : "monospace 10");
+
+ g_free (font);
+ }
+
+ if (vw == NULL) {
+ gchar *font;
+
+ font = g_settings_get_string (
+ widget->priv->font_settings,
+ "font-name");
+
+ vw = pango_font_description_from_string (
+ font ? font : "serif 10");
+
+ g_free (font);
+ }
+
+ if (pango_font_description_get_size (ms) < pango_font_description_get_size (vw)) {
+ min_size = ms;
+ } else {
+ min_size = vw;
+ }
+
+ stylesheet = g_string_new ("");
+ g_string_append_printf (stylesheet,
+ "body {\n"
+ " font-family: '%s';\n"
+ " font-size: %dpt;\n"
+ " font-weight: %d;\n"
+ " font-style: %s;\n",
+ pango_font_description_get_family (vw),
+ pango_font_description_get_size (vw) / PANGO_SCALE,
+ pango_font_description_get_weight (vw),
+ styles[pango_font_description_get_style (vw)]);
+
+ if (widget->priv->aliasing_settings != NULL)
+ aa = g_settings_get_string (
+ widget->priv->aliasing_settings, "antialiasing");
+
+ if (g_strcmp0 (aa, "none") == 0)
+ smoothing = "none";
+ else if (g_strcmp0 (aa, "grayscale") == 0)
+ smoothing = "antialiased";
+ else if (g_strcmp0 (aa, "rgba") == 0)
+ smoothing = "subpixel-antialiased";
+
+ if (smoothing != NULL)
+ g_string_append_printf (
+ stylesheet,
+ " -webkit-font-smoothing: %s;\n",
+ smoothing);
+
+ g_free (aa);
+
+ g_string_append (stylesheet, "}\n");
+
+ g_string_append_printf (stylesheet,
+ "pre,code,.pre {\n"
+ " font-family: '%s';\n"
+ " font-size: %dpt;\n"
+ " font-weight: %d;\n"
+ " font-style: %s;\n"
+ "}",
+ pango_font_description_get_family (ms),
+ pango_font_description_get_size (ms) / PANGO_SCALE,
+ pango_font_description_get_weight (ms),
+ styles[pango_font_description_get_style (ms)]);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (widget));
+ gtk_style_context_get_style (context,
+ "link-color", &link,
+ "visited-link-color", &visited,
+ NULL);
+
+ if (link == NULL) {
+ link = g_slice_new0 (GdkColor);
+ link->blue = G_MAXINT16;
+ }
+
+ if (visited == NULL) {
+ visited = g_slice_new0 (GdkColor);
+ visited->red = G_MAXINT16;
+ }
+
+ g_string_append_printf (stylesheet,
+ "a {\n"
+ " color: #%06x;\n"
+ "}\n"
+ "a:visited {\n"
+ " color: #%06x;\n"
+ "}\n",
+ e_color_to_value (link),
+ e_color_to_value (visited));
+
+ gdk_color_free (link);
+ gdk_color_free (visited);
+
+ base64 = g_base64_encode ((guchar *) stylesheet->str, stylesheet->len);
+ g_string_free (stylesheet, TRUE);
+
+ stylesheet = g_string_new ("data:text/css;charset=utf-8;base64,");
+ g_string_append (stylesheet, base64);
+ g_free (base64);
+
+ settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (widget));
+ g_object_set (G_OBJECT (settings),
+ "default-font-size", pango_font_description_get_size (vw) / PANGO_SCALE,
+ "default-font-family", pango_font_description_get_family (vw),
+ "monospace-font-family", pango_font_description_get_family (ms),
+ "default-monospace-font-size", (pango_font_description_get_size (ms) / PANGO_SCALE),
+ "minimum-font-size", (pango_font_description_get_size (min_size) / PANGO_SCALE),
+ "user-stylesheet-uri", stylesheet->str,
+ NULL);
+
+ g_string_free (stylesheet, TRUE);
+
+ pango_font_description_free (ms);
+ pango_font_description_free (vw);
+}
diff --git a/e-util/e-editor-widget.h b/e-util/e-editor-widget.h
index 1144129..487c1a0 100644
--- a/e-util/e-editor-widget.h
+++ b/e-util/e-editor-widget.h
@@ -121,7 +121,8 @@ void e_editor_widget_set_text_html (EEditorWidget *widget,
void e_editor_widget_paste_clipboard_quoted
(EEditorWidget *widget);
+void e_editor_widget_update_fonts (EEditorWidget *widget);
+
G_END_DECLS
#endif /* E_EDITOR_WIDGET_H */
-
diff --git a/e-util/e-editor-widgets.h b/e-util/e-editor-widgets.h
index ee8f818..6088c7b 100644
--- a/e-util/e-editor-widgets.h
+++ b/e-util/e-editor-widgets.h
@@ -87,20 +87,6 @@
#define E_EDITOR_WIDGETS_IMAGE_PROPERTIES_Y_PADDING_SPIN_BUTTON(editor) \
E_EDITOR_WIDGETS ((editor), "image-properties-y-padding-spin-button")
-/* Page Properties Window */
-#define E_EDITOR_WIDGETS_PAGE_PROPERTIES_BACKGROUND_COLOR_COMBO(editor) \
- E_EDITOR_WIDGETS ((editor), "page-properties-background-color-combo")
-#define E_EDITOR_WIDGETS_PAGE_PROPERTIES_CUSTOM_FILE_CHOOSER(editor) \
- E_EDITOR_WIDGETS ((editor), "page-properties-custom-file-chooser")
-#define E_EDITOR_WIDGETS_PAGE_PROPERTIES_LINK_COLOR_COMBO(editor) \
- E_EDITOR_WIDGETS ((editor), "page-properties-link-color-combo")
-#define E_EDITOR_WIDGETS_PAGE_PROPERTIES_TEMPLATE_COMBO_BOX(editor) \
- E_EDITOR_WIDGETS ((editor), "page-properties-template-combo-box")
-#define E_EDITOR_WIDGETS_PAGE_PROPERTIES_TEXT_COLOR_COMBO(editor) \
- E_EDITOR_WIDGETS ((editor), "page-properties-text-color-combo")
-#define E_EDITOR_WIDGETS_PAGE_PROPERTIES_WINDOW(editor) \
- E_EDITOR_WIDGETS ((editor), "page-properties-window")
-
/* Paragraph Properties Window */
#define E_EDITOR_WIDGETS_PARAGRAPH_PROPERTIES_CENTER_BUTTON(editor) \
E_EDITOR_WIDGETS ((editor), "paragraph-properties-center-button")
diff --git a/e-util/e-util.h b/e-util/e-util.h
index 625d0b0..59ea63f 100644
--- a/e-util/e-util.h
+++ b/e-util/e-util.h
@@ -97,6 +97,7 @@
#include <e-util/e-editor-find-dialog.h>
#include <e-util/e-editor-hrule-dialog.h>
#include <e-util/e-editor-link-dialog.h>
+#include <e-util/e-editor-page-dialog.h>
#include <e-util/e-editor-replace-dialog.h>
#include <e-util/e-editor-selection.h>
#include <e-util/e-editor-table-dialog.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]