[evolution/webkit-composer: 106/231] Coding style and whitespace cleanup.
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 106/231] Coding style and whitespace cleanup.
- Date: Fri, 13 Sep 2013 14:14:54 +0000 (UTC)
commit a5bae05df17399faa39f8a3312afb7ead9fd90ca
Author: Matthew Barnes <mbarnes redhat com>
Date: Thu Jan 10 11:21:28 2013 -0500
Coding style and whitespace cleanup.
composer/e-composer-actions.c | 9 +-
composer/e-composer-activity.c | 4 +-
composer/e-composer-private.c | 100 ++--
composer/e-msg-composer.c | 422 ++++------
composer/e-msg-composer.h | 2 -
e-util/e-color-chooser-widget.c | 46 +-
e-util/e-color-chooser-widget.h | 6 +-
e-util/e-color-combo.c | 246 +++---
e-util/e-color-combo.h | 11 +-
e-util/e-editor-actions.c | 92 ++-
e-util/e-editor-actions.h | 1 +
e-util/e-editor-cell-dialog.c | 103 ++--
e-util/e-editor-cell-dialog.h | 7 +-
e-util/e-editor-dialog.c | 64 +-
e-util/e-editor-dialog.h | 6 +-
e-util/e-editor-find-dialog.c | 28 +-
e-util/e-editor-find-dialog.h | 7 +-
e-util/e-editor-hrule-dialog.c | 33 +-
e-util/e-editor-hrule-dialog.h | 6 +-
e-util/e-editor-image-dialog.c | 50 +-
e-util/e-editor-image-dialog.h | 7 +-
e-util/e-editor-link-dialog.c | 22 +-
e-util/e-editor-link-dialog.h | 6 +-
e-util/e-editor-page-dialog.c | 40 +-
e-util/e-editor-page-dialog.h | 6 +-
e-util/e-editor-paragraph-dialog.c | 15 +-
e-util/e-editor-paragraph-dialog.h | 7 +-
e-util/e-editor-private.h | 3 +-
e-util/e-editor-replace-dialog.c | 17 +-
e-util/e-editor-replace-dialog.h | 7 +-
e-util/e-editor-selection.c | 742 +++++++++--------
e-util/e-editor-selection.h | 211 +++---
e-util/e-editor-spell-check-dialog.c | 201 +++--
e-util/e-editor-spell-check-dialog.h | 13 +-
e-util/e-editor-table-dialog.c | 42 +-
e-util/e-editor-table-dialog.h | 6 +-
e-util/e-editor-text-dialog.c | 34 +-
e-util/e-editor-text-dialog.h | 6 +-
e-util/e-editor-utils.c | 4 +-
e-util/e-editor-utils.h | 18 +-
e-util/e-editor-widget.c | 912 +++++++++++----------
e-util/e-editor-widget.h | 25 +-
e-util/e-editor-window.c | 54 +-
e-util/e-editor-window.h | 8 +-
e-util/e-editor.c | 248 +++---
e-util/e-editor.h | 14 +-
e-util/e-emoticon-action.c | 113 +--
e-util/e-emoticon-action.h | 2 +-
e-util/e-emoticon-chooser-menu.c | 76 +--
e-util/e-emoticon-chooser-menu.h | 5 +-
e-util/e-emoticon-chooser.c | 59 +-
e-util/e-emoticon-chooser.h | 14 +-
e-util/e-emoticon-tool-button.c | 111 +--
e-util/e-emoticon-tool-button.h | 6 +-
e-util/e-emoticon.c | 4 +-
e-util/e-emoticon.h | 3 +-
e-util/e-image-chooser-dialog.c | 20 +-
e-util/e-mail-signature-editor.c | 9 +-
e-util/e-mail-signature-manager.c | 2 +-
e-util/e-name-selector-entry.c | 6 +-
e-util/e-spell-checker.c | 220 +++---
e-util/e-spell-checker.h | 51 +-
e-util/e-spell-dictionary.c | 311 ++++----
e-util/e-spell-dictionary.h | 78 +-
e-util/e-spell-entry.c | 53 +-
e-util/test-editor.c | 32 +-
mail/em-composer-utils.c | 6 +-
mail/em-utils.c | 2 +-
modules/mail/e-mail-shell-backend.c | 12 +-
modules/mail/em-composer-prefs.c | 7 +-
modules/mail/em-composer-prefs.h | 4 +-
plugins/email-custom-header/email-custom-header.c | 1 -
plugins/external-editor/external-editor.c | 21 +-
73 files changed, 2514 insertions(+), 2625 deletions(-)
---
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index f3c3f11..c8def1c 100644
--- a/composer/e-composer-actions.c
+++ b/composer/e-composer-actions.c
@@ -46,9 +46,8 @@ action_charset_cb (GtkRadioAction *action,
{
const gchar *charset;
- if (action != current) {
+ if (action != current)
return;
- }
charset = g_object_get_data (G_OBJECT (action), "charset");
@@ -60,9 +59,8 @@ static void
action_close_cb (GtkAction *action,
EMsgComposer *composer)
{
- if (e_msg_composer_can_close (composer, TRUE)) {
+ if (e_msg_composer_can_close (composer, TRUE))
gtk_widget_destroy (GTK_WIDGET (composer));
- }
}
static void
@@ -225,9 +223,8 @@ action_save_as_cb (GtkAction *action,
response = gtk_dialog_run (GTK_DIALOG (dialog));
- if (response != GTK_RESPONSE_OK) {
+ if (response != GTK_RESPONSE_OK)
goto exit;
- }
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
diff --git a/composer/e-composer-activity.c b/composer/e-composer-activity.c
index fb40a3a..d3a96dc 100644
--- a/composer/e-composer-activity.c
+++ b/composer/e-composer-activity.c
@@ -52,7 +52,7 @@ composer_activity_lock_interface (EComposerActivity *activity)
composer = e_composer_activity_get_composer (activity);
- editor = e_msg_composer_get_editor (composer);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
editable = webkit_web_view_get_editable (WEBKIT_WEB_VIEW (editor_widget));
webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), FALSE);
@@ -74,7 +74,7 @@ composer_activity_unlock_interface (EComposerActivity *activity)
composer = e_composer_activity_get_composer (activity);
editable = activity->priv->saved_editable;
- editor = e_msg_composer_get_editor (composer);
+ editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), editable);
diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c
index 226cb8f..e642bca 100644
--- a/composer/e-composer-private.c
+++ b/composer/e-composer-private.c
@@ -31,7 +31,7 @@
static void
composer_setup_charset_menu (EMsgComposer *composer)
{
- EEditor *editor;
+ EEditor *editor;
GtkUIManager *ui_manager;
const gchar *path;
GList *list;
@@ -87,8 +87,8 @@ composer_update_gallery_visibility (EMsgComposer *composer)
static void
composer_spell_languages_changed (EMsgComposer *composer,
- GParamSpec *pspec,
- EEditorWidget *editor_widget)
+ GParamSpec *pspec,
+ EEditorWidget *editor_widget)
{
GList *languages;
EComposerHeader *header;
@@ -101,7 +101,6 @@ composer_spell_languages_changed (EMsgComposer *composer,
languages = e_editor_widget_get_spell_languages (editor_widget);
header = e_composer_header_table_get_header (table, E_COMPOSER_HEADER_SUBJECT);
e_composer_spell_header_set_languages (E_COMPOSER_SPELL_HEADER (header), languages);
-
g_list_free (languages);
}
@@ -204,12 +203,14 @@ e_composer_private_constructed (EMsgComposer *composer)
e_editor_window_pack_above (E_EDITOR_WINDOW (composer), container);
/* Construct the activity bar. */
+
widget = e_activity_bar_new ();
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
priv->activity_bar = g_object_ref (widget);
/* EActivityBar controls its own visibility. */
/* Construct the alert bar for errors. */
+
widget = e_alert_bar_new ();
gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
priv->alert_bar = g_object_ref (widget);
@@ -271,6 +272,7 @@ e_composer_private_constructed (EMsgComposer *composer)
g_signal_connect_swapped (
editor_widget, "notify::mode",
G_CALLBACK (composer_update_gallery_visibility), composer);
+
g_signal_connect_swapped (
ACTION (PICTURE_GALLERY), "toggled",
G_CALLBACK (composer_update_gallery_visibility), composer);
@@ -420,16 +422,14 @@ e_composer_find_data_file (const gchar *basename)
/* Support running directly from the source tree. */
filename = g_build_filename (".", basename, NULL);
- if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ if (g_file_test (filename, G_FILE_TEST_EXISTS))
return filename;
- }
g_free (filename);
/* XXX This is kinda broken. */
filename = g_build_filename (EVOLUTION_UIDIR, basename, NULL);
- if (g_file_test (filename, G_FILE_TEST_EXISTS)) {
+ if (g_file_test (filename, G_FILE_TEST_EXISTS))
return filename;
- }
g_free (filename);
g_critical ("Could not locate '%s'", basename);
@@ -461,13 +461,11 @@ e_composer_get_default_charset (void)
g_object_unref (settings);
- if (charset == NULL) {
+ if (charset == NULL)
charset = g_strdup (camel_iconv_locale_charset ());
- }
- if (charset == NULL) {
+ if (charset == NULL)
charset = g_strdup ("us-ascii");
- }
return charset;
}
@@ -533,15 +531,13 @@ e_composer_paste_image (EMsgComposer *composer,
}
/* Save the pixbuf as a temporary file in image/png format. */
- if (!gdk_pixbuf_save (pixbuf, filename, "png", &error, NULL)) {
+ if (!gdk_pixbuf_save (pixbuf, filename, "png", &error, NULL))
goto exit;
- }
/* Convert the filename to a URI. */
uri = g_filename_to_uri (filename, NULL, &error);
- if (uri == NULL) {
+ if (uri == NULL)
goto exit;
- }
/* In HTML mode, paste the image into the message body.
* In text mode, add the image to the attachment store. */
@@ -650,9 +646,8 @@ e_composer_selection_is_image_uris (EMsgComposer *composer,
uris = gtk_selection_data_get_uris (selection);
- if (uris == NULL) {
+ if (uris == NULL)
return FALSE;
- }
for (ii = 0; uris[ii] != NULL; ii++) {
GFile *file;
@@ -764,7 +759,7 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
e_mail_signature_combo_box_load_selected_finish (
combo_box, result, &contents, &length, &is_html, &error);
- /* FIXME Use an EAlert here.*/
+ /* FIXME Use an EAlert here. */
if (error != NULL) {
g_warning ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
@@ -772,7 +767,7 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
}
/* "Edit as New Message" sets "priv->is_from_message".
- Always put the signature at the bottom for that case. */
+ * Always put the signature at the bottom for that case. */
top_signature =
use_top_signature (composer) &&
!composer->priv->is_from_message;
@@ -808,8 +803,9 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
g_string_append (html_buffer, "<PRE>\n");
/* The signature dash convention ("-- \n") is specified
- in the "Son of RFC 1036", section 4.3.2.
- http://www.chemie.fu-berlin.de/outerspace/netnews/son-of-1036.html */
+ * in the "Son of RFC 1036", section 4.3.2.
+ * http://www.chemie.fu-berlin.de/outerspace/netnews/son-of-1036.html
+ */
if (add_signature_delimiter (composer)) {
const gchar *delim;
const gchar *delim_nl;
@@ -824,9 +820,9 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
/* Skip the delimiter if the signature already has one. */
if (g_ascii_strncasecmp (contents, delim, strlen (delim)) == 0)
- ; // skip
+ ; /* skip */
else if (e_util_strstrcase (contents, delim_nl) != NULL)
- ; // skip
+ ; /* skip */
else
g_string_append (html_buffer, delim);
}
@@ -844,6 +840,7 @@ composer_load_signature_cb (EMailSignatureComboBox *combo_box,
insert:
/* Remove the old signature and insert the new one. */
+
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
selection = e_editor_widget_get_selection (editor_widget);
@@ -851,14 +848,15 @@ insert:
e_editor_selection_save (selection);
/* This prevents our command before/after callbacks from
- screwing around with the signature as we insert it. */
+ * screwing around with the signature as we insert it. */
composer->priv->in_signature_insert = TRUE;
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (editor_widget));
window = webkit_dom_document_get_default_view (document);
dom_selection = webkit_dom_dom_window_get_selection (window);
- signatures = webkit_dom_document_get_elements_by_class_name (document, "-x-evolution-signature");
+ signatures = webkit_dom_document_get_elements_by_class_name (
+ document, "-x-evolution-signature");
list_length = webkit_dom_node_list_get_length (signatures);
for (ii = 0; ii < list_length; ii++) {
WebKitDOMNode *node;
@@ -868,40 +866,42 @@ insert:
id = webkit_dom_html_element_get_id (WEBKIT_DOM_HTML_ELEMENT (node));
if (id && (strlen (id) == 1) && (*id == '1')) {
- webkit_dom_node_remove_child (
- webkit_dom_node_get_parent_node (node), node, NULL);
- g_free (id);
- break;
+ webkit_dom_node_remove_child (
+ webkit_dom_node_get_parent_node (node),
+ node, NULL);
+ g_free (id);
+ break;
}
g_free (id);
}
if (top_signature) {
- WebKitDOMElement *citation;
-
- citation = webkit_dom_document_get_element_by_id (
- document, "-x-evolution-reply-citation");
- if (!citation) {
- webkit_dom_dom_selection_modify (
- dom_selection, "move", "forward", "documentBoundary");
- } else {
- webkit_dom_dom_selection_set_base_and_extent (
- dom_selection, WEBKIT_DOM_NODE (citation), 0,
- WEBKIT_DOM_NODE (citation), 0, NULL);
- }
+ WebKitDOMElement *citation;
+
+ citation = webkit_dom_document_get_element_by_id (
+ document, "-x-evolution-reply-citation");
+ if (citation == NULL) {
+ webkit_dom_dom_selection_modify (
+ dom_selection, "move", "forward",
+ "documentBoundary");
+ } else {
+ webkit_dom_dom_selection_set_base_and_extent (
+ dom_selection, WEBKIT_DOM_NODE (citation), 0,
+ WEBKIT_DOM_NODE (citation), 0, NULL);
+ }
} else {
- webkit_dom_dom_selection_modify (
- dom_selection, "move", "forward", "documentBoundary");
+ webkit_dom_dom_selection_modify (
+ dom_selection, "move", "forward", "documentBoundary");
}
if (html_buffer != NULL) {
if (*html_buffer->str) {
webkit_dom_document_exec_command (
- document, "insertParagraph", FALSE, "");
+ document, "insertParagraph", FALSE, "");
e_editor_selection_insert_html (selection, html_buffer->str);
webkit_dom_document_exec_command (
- document, "insertParagraph", FALSE, "");
+ document, "insertParagraph", FALSE, "");
}
g_string_free (html_buffer, TRUE);
@@ -930,10 +930,10 @@ e_composer_update_signature (EMsgComposer *composer)
table = e_msg_composer_get_header_table (composer);
combo_box = e_composer_header_table_get_signature_combo_box (table);
- /*XXX Signature files should be local and therefore load quickly,
- so while we do load them asynchronously we don't allow for
- user cancellation and we keep the composer alive until the
- asynchronous loading is complete. */
+ /* XXX Signature files should be local and therefore load quickly,
+ * so while we do load them asynchronously we don't allow for
+ * user cancellation and we keep the composer alive until the
+ * asynchronous loading is complete. */
e_mail_signature_combo_box_load_selected (
combo_box, G_PRIORITY_DEFAULT, NULL,
(GAsyncReadyCallback) composer_load_signature_cb,
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c
index 234d1d4..7e5bf74 100644
--- a/composer/e-msg-composer.c
+++ b/composer/e-msg-composer.c
@@ -44,8 +44,6 @@
#include <em-format/e-mail-parser.h>
#include <em-format/e-mail-formatter-quote.h>
-#include <e-util/e-spell-checker.h>
-
#include <shell/e-shell.h>
typedef struct _AsyncContext AsyncContext;
@@ -240,9 +238,8 @@ emcu_part_to_html (EMsgComposer *composer,
g_object_unref (mem);
text = (gchar *) buf->data;
- if (len) {
+ if (len)
*len = buf->len - 1;
- }
g_byte_array_free (buf, FALSE);
g_object_unref (session);
@@ -256,15 +253,12 @@ emcu_remove_xevolution_headers (CamelMimeMessage *message)
{
struct _camel_header_raw *scan, *list = NULL;
- for (scan = ((CamelMimePart *) message)->headers; scan; scan = scan->next) {
- if (!strncmp (scan->name, "X-Evolution", 11)) {
+ for (scan = ((CamelMimePart *) message)->headers; scan; scan = scan->next)
+ if (!strncmp (scan->name, "X-Evolution", 11))
camel_header_raw_append (&list, scan->name, scan->value, scan->offset);
- }
- }
- for (scan = list; scan; scan = scan->next) {
+ for (scan = list; scan; scan = scan->next)
camel_medium_remove_header ((CamelMedium *) message, scan->name);
- }
return list;
}
@@ -276,13 +270,11 @@ destination_list_to_vector_sized (GList *list,
EDestination **destv;
gint i = 0;
- if (n == -1) {
+ if (n == -1)
n = g_list_length (list);
- }
- if (n == 0) {
+ if (n == 0)
return NULL;
- }
destv = g_new (EDestination *, n + 1);
while (list != NULL && i < n) {
@@ -311,22 +303,18 @@ text_requires_quoted_printable (const gchar *text,
const gchar *p;
gsize pos;
- if (!text) {
+ if (!text)
return FALSE;
- }
- if (len == -1) {
+ if (len == -1)
len = strlen (text);
- }
- if (len >= 5 && strncmp (text, "From ", 5) == 0) {
+ if (len >= 5 && strncmp (text, "From ", 5) == 0)
return TRUE;
- }
for (p = text, pos = 0; pos + 6 <= len; pos++, p++) {
- if (*p == '\n' && strncmp (p + 1, "From ", 5) == 0) {
+ if (*p == '\n' && strncmp (p + 1, "From ", 5) == 0)
return TRUE;
- }
}
return FALSE;
@@ -341,14 +329,12 @@ best_encoding (GByteArray *buf,
gint status, count = 0;
iconv_t cd;
- if (!charset) {
+ if (!charset)
return -1;
- }
cd = camel_iconv_open (charset, "utf-8");
- if (cd == (iconv_t) -1) {
+ if (cd == (iconv_t) -1)
return -1;
- }
in = (gchar *) buf->data;
inlen = buf->len;
@@ -357,26 +343,23 @@ best_encoding (GByteArray *buf,
outlen = sizeof (outbuf);
status = camel_iconv (cd, (const gchar **) &in, &inlen, &out, &outlen);
for (ch = out - 1; ch >= outbuf; ch--) {
- if ((guchar) *ch > 127) {
+ if ((guchar) *ch > 127)
count++;
- }
}
} while (status == (gsize) -1 && errno == E2BIG);
camel_iconv_close (cd);
- if (status == (gsize) -1 || status > 0) {
+ if (status == (gsize) -1 || status > 0)
return -1;
- }
if ((count == 0) && (buf->len < LINE_LEN) &&
!text_requires_quoted_printable (
- (const gchar *) buf->data, buf->len)) {
+ (const gchar *) buf->data, buf->len))
return CAMEL_TRANSFER_ENCODING_7BIT;
- } else if (count <= buf->len * 0.17) {
+ else if (count <= buf->len * 0.17)
return CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE;
- } else {
+ else
return CAMEL_TRANSFER_ENCODING_BASE64;
- }
}
static gchar *
@@ -488,9 +471,8 @@ set_recipients_from_destv (CamelMimeMessage *msg,
seen_hidden_list = TRUE;
}
- if (camel_address_decode (CAMEL_ADDRESS (target), text_addr) <= 0) {
+ if (camel_address_decode (CAMEL_ADDRESS (target), text_addr) <= 0)
camel_internet_address_add (target, "", text_addr);
- }
}
}
@@ -504,26 +486,23 @@ set_recipients_from_destv (CamelMimeMessage *msg,
seen_hidden_list = TRUE;
}
- if (camel_address_decode (CAMEL_ADDRESS (target), text_addr) <= 0) {
+ if (camel_address_decode (CAMEL_ADDRESS (target), text_addr) <= 0)
camel_internet_address_add (target, "", text_addr);
- }
}
}
for (i = 0; bcc_destv != NULL && bcc_destv[i] != NULL; ++i) {
text_addr = e_destination_get_address (bcc_destv[i]);
if (text_addr && *text_addr) {
- if (camel_address_decode (CAMEL_ADDRESS (bcc_addr), text_addr) <= 0) {
+ if (camel_address_decode (CAMEL_ADDRESS (bcc_addr), text_addr) <= 0)
camel_internet_address_add (bcc_addr, "", text_addr);
- }
}
}
- if (redirect) {
+ if (redirect)
header = CAMEL_RECIPIENT_TYPE_RESENT_TO;
- } else {
+ else
header = CAMEL_RECIPIENT_TYPE_TO;
- }
if (camel_address_length (CAMEL_ADDRESS (to_addr)) > 0) {
camel_mime_message_set_recipients (msg, header, to_addr);
@@ -632,9 +611,8 @@ build_message_headers (EMsgComposer *composer,
addr = camel_internet_address_new ();
- if (camel_address_unformat (CAMEL_ADDRESS (addr), reply_to) > 0) {
+ if (camel_address_unformat (CAMEL_ADDRESS (addr), reply_to) > 0)
camel_mime_message_set_reply_to (message, addr);
- }
g_object_unref (addr);
}
@@ -741,9 +719,8 @@ composer_build_message_pgp (AsyncContext *context,
gboolean encrypt_to_self;
/* Return silently if we're not signing or encrypting with PGP. */
- if (!context->pgp_sign && !context->pgp_encrypt) {
+ if (!context->pgp_sign && !context->pgp_encrypt)
return TRUE;
- }
extension_name = E_SOURCE_EXTENSION_OPENPGP;
extension = e_source_get_extension (context->source, extension_name);
@@ -759,18 +736,16 @@ composer_build_message_pgp (AsyncContext *context,
CAMEL_MEDIUM (mime_part),
context->top_level_part);
- if (context->top_level_part == context->text_plain_part) {
+ if (context->top_level_part == context->text_plain_part)
camel_mime_part_set_encoding (
mime_part, context->plain_encoding);
- }
g_object_unref (context->top_level_part);
context->top_level_part = NULL;
- if (pgp_key_id == NULL || *pgp_key_id == '\0') {
+ if (pgp_key_id == NULL || *pgp_key_id == '\0')
camel_internet_address_get (
context->from, 0, NULL, &pgp_key_id);
- }
if (context->pgp_sign) {
CamelMimePart *npart;
@@ -807,11 +782,10 @@ composer_build_message_pgp (AsyncContext *context,
/* Check to see if we should encrypt to self.
* NB: Gets removed immediately after use. */
- if (encrypt_to_self && pgp_key_id != NULL) {
+ if (encrypt_to_self && pgp_key_id != NULL)
g_ptr_array_add (
context->recipients,
g_strdup (pgp_key_id));
- }
cipher = camel_gpg_context_new (context->session);
camel_gpg_context_set_always_trust (
@@ -823,11 +797,10 @@ composer_build_message_pgp (AsyncContext *context,
g_object_unref (cipher);
- if (encrypt_to_self && pgp_key_id != NULL) {
+ if (encrypt_to_self && pgp_key_id != NULL)
g_ptr_array_set_size (
context->recipients,
context->recipients->len - 1);
- }
g_object_unref (mime_part);
@@ -865,9 +838,8 @@ composer_build_message_smime (AsyncContext *context,
gboolean have_encryption_certificate;
/* Return silently if we're not signing or encrypting with S/MIME. */
- if (!context->smime_sign && !context->smime_encrypt) {
+ if (!context->smime_sign && !context->smime_encrypt)
return TRUE;
- }
extension_name = E_SOURCE_EXTENSION_SMIME;
extension = e_source_get_extension (context->source, extension_name);
@@ -916,10 +888,9 @@ composer_build_message_smime (AsyncContext *context,
CAMEL_MEDIUM (mime_part),
context->top_level_part);
- if (context->top_level_part == context->text_plain_part) {
+ if (context->top_level_part == context->text_plain_part)
camel_mime_part_set_encoding (
mime_part, context->plain_encoding);
- }
g_object_unref (context->top_level_part);
context->top_level_part = NULL;
@@ -968,11 +939,10 @@ composer_build_message_smime (AsyncContext *context,
/* Check to see if we should encrypt to self.
* NB: Gets removed immediately after use. */
- if (encrypt_to_self) {
+ if (encrypt_to_self)
g_ptr_array_add (
context->recipients, g_strdup (
encryption_certificate));
- }
cipher = camel_smime_context_new (context->session);
camel_smime_context_set_encrypt_key (
@@ -990,11 +960,10 @@ composer_build_message_smime (AsyncContext *context,
if (!success)
return FALSE;
- if (encrypt_to_self) {
+ if (encrypt_to_self)
g_ptr_array_set_size (
context->recipients,
context->recipients->len - 1);
- }
}
/* we replaced the message directly, we don't want to do reparenting foo */
@@ -1070,27 +1039,22 @@ composer_add_evolution_format_header (CamelMedium *medium,
string = g_string_sized_new (128);
- if (flags & COMPOSER_FLAG_HTML_CONTENT) {
+ if (flags & COMPOSER_FLAG_HTML_CONTENT)
g_string_append (string, "text/html");
- } else {
+ else
g_string_append (string, "text/plain");
- }
- if (flags & COMPOSER_FLAG_PGP_SIGN) {
+ if (flags & COMPOSER_FLAG_PGP_SIGN)
g_string_append (string, ", pgp-sign");
- }
- if (flags & COMPOSER_FLAG_PGP_ENCRYPT) {
+ if (flags & COMPOSER_FLAG_PGP_ENCRYPT)
g_string_append (string, ", pgp-encrypt");
- }
- if (flags & COMPOSER_FLAG_SMIME_SIGN) {
+ if (flags & COMPOSER_FLAG_SMIME_SIGN)
g_string_append (string, ", smime-sign");
- }
- if (flags & COMPOSER_FLAG_SMIME_ENCRYPT) {
+ if (flags & COMPOSER_FLAG_SMIME_ENCRYPT)
g_string_append (string, ", smime-encrypt");
- }
camel_medium_add_header (
medium, "X-Evolution-Format", string->str);
@@ -1145,21 +1109,17 @@ composer_build_message (EMsgComposer *composer,
context->session = e_msg_composer_ref_session (composer);
context->from = e_msg_composer_get_from (composer);
- if (flags & COMPOSER_FLAG_PGP_SIGN) {
+ if (flags & COMPOSER_FLAG_PGP_SIGN)
context->pgp_sign = TRUE;
- }
- if (flags & COMPOSER_FLAG_PGP_ENCRYPT) {
+ if (flags & COMPOSER_FLAG_PGP_ENCRYPT)
context->pgp_encrypt = TRUE;
- }
- if (flags & COMPOSER_FLAG_SMIME_SIGN) {
+ if (flags & COMPOSER_FLAG_SMIME_SIGN)
context->smime_sign = TRUE;
- }
- if (flags & COMPOSER_FLAG_SMIME_ENCRYPT) {
+ if (flags & COMPOSER_FLAG_SMIME_ENCRYPT)
context->smime_encrypt = TRUE;
- }
context->need_thread =
context->pgp_sign || context->pgp_encrypt ||
@@ -1207,22 +1167,19 @@ composer_build_message (EMsgComposer *composer,
const gchar *mdn_address;
mdn_address = e_source_mail_identity_get_reply_to (mi);
- if (mdn_address == NULL) {
+ if (mdn_address == NULL)
mdn_address = e_source_mail_identity_get_address (mi);
- }
- if (mdn_address != NULL) {
+ if (mdn_address != NULL)
camel_medium_add_header (
CAMEL_MEDIUM (context->message),
"Disposition-Notification-To", mdn_address);
- }
}
/* X-Priority */
- if (flags & COMPOSER_FLAG_PRIORITIZE_MESSAGE) {
+ if (flags & COMPOSER_FLAG_PRIORITIZE_MESSAGE)
camel_medium_add_header (
CAMEL_MEDIUM (context->message),
"X-Priority", "1");
- }
/* Organization */
if (organization != NULL && *organization != '\0') {
@@ -1290,14 +1247,12 @@ composer_build_message (EMsgComposer *composer,
g_object_unref (mem_stream);
/* Convert the stream to the appropriate charset. */
- if (iconv_charset && g_ascii_strcasecmp (iconv_charset, "UTF-8") != 0) {
+ if (iconv_charset && g_ascii_strcasecmp (iconv_charset, "UTF-8") != 0)
composer_add_charset_filter (stream, iconv_charset);
- }
/* Encode the stream to quoted-printable if necessary. */
- if (context->plain_encoding == CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE) {
+ if (context->plain_encoding == CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE)
composer_add_quoted_printable_filter (stream);
- }
/* Construct the content object. This does not block since
* we're constructing the data wrapper from a memory stream. */
@@ -1309,9 +1264,8 @@ composer_build_message (EMsgComposer *composer,
context->text_plain_part = g_object_ref (context->top_level_part);
/* Avoid re-encoding the data when adding it to a MIME part. */
- if (context->plain_encoding == CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE) {
+ if (context->plain_encoding == CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE)
context->top_level_part->encoding = context->plain_encoding;
- }
camel_data_wrapper_set_mime_type_field (
context->top_level_part, type);
@@ -1356,9 +1310,8 @@ composer_build_message (EMsgComposer *composer,
stream = camel_stream_filter_new (mem_stream);
g_object_unref (mem_stream);
- if (pre_encode) {
+ if (pre_encode)
composer_add_quoted_printable_filter (stream);
- }
/* Construct the content object. This does not block since
* we're constructing the data wrapper from a memory stream. */
@@ -1371,10 +1324,9 @@ composer_build_message (EMsgComposer *composer,
html, "text/html; charset=utf-8");
/* Avoid re-encoding the data when adding it to a MIME part. */
- if (pre_encode) {
+ if (pre_encode)
html->encoding =
CAMEL_TRANSFER_ENCODING_QUOTEDPRINTABLE;
- }
/* Build the multipart/alternative */
body = camel_multipart_new ();
@@ -1445,10 +1397,9 @@ composer_build_message (EMsgComposer *composer,
camel_medium_set_content (
CAMEL_MEDIUM (part),
context->top_level_part);
- if (context->top_level_part == context->text_plain_part) {
+ if (context->top_level_part == context->text_plain_part)
camel_mime_part_set_encoding (
part, context->plain_encoding);
- }
camel_multipart_add_part (multipart, part);
g_object_unref (part);
@@ -1460,14 +1411,13 @@ composer_build_message (EMsgComposer *composer,
}
/* Run any blocking operations in a separate thread. */
- if (context->need_thread) {
+ if (context->need_thread)
g_simple_async_result_run_in_thread (
simple, (GSimpleAsyncThreadFunc)
composer_build_message_thread,
io_priority, cancellable);
- } else {
+ else
g_simple_async_result_complete (simple);
- }
g_object_unref (simple);
}
@@ -1487,23 +1437,20 @@ composer_build_message_finish (EMsgComposer *composer,
simple = G_SIMPLE_ASYNC_RESULT (result);
context = g_simple_async_result_get_op_res_gpointer (simple);
- if (g_simple_async_result_propagate_error (simple, error)) {
+ if (g_simple_async_result_propagate_error (simple, error))
return NULL;
- }
/* Finalize some details before returning. */
- if (!context->skip_content) {
+ if (!context->skip_content)
camel_medium_set_content (
CAMEL_MEDIUM (context->message),
context->top_level_part);
- }
- if (context->top_level_part == context->text_plain_part) {
+ if (context->top_level_part == context->text_plain_part)
camel_mime_part_set_encoding (
CAMEL_MIME_PART (context->message),
context->plain_encoding);
- }
return g_object_ref (context->message);
}
@@ -1523,9 +1470,8 @@ use_top_signature (EMsgComposer *composer)
* signature placement is either there already, or pt it at the
* bottom regardless of a preferences (which is for reply anyway,
* not for Edit as new) */
- if (priv->is_from_message) {
+ if (priv->is_from_message)
return FALSE;
- }
/* FIXME This should be an EMsgComposer property. */
settings = g_settings_new ("org.gnome.evolution.mail");
@@ -1585,9 +1531,8 @@ set_editor_text (EMsgComposer *composer,
editor_widget = e_editor_get_editor_widget (editor);
e_editor_widget_set_text_html (editor_widget, body);
- if (set_signature) {
+ if (set_signature)
e_composer_update_signature (composer);
- }
g_free (body);
}
@@ -1616,9 +1561,8 @@ msg_composer_subject_changed_cb (EMsgComposer *composer)
table = e_msg_composer_get_header_table (composer);
subject = e_composer_header_table_get_subject (table);
- if (subject == NULL || *subject == '\0') {
+ if (subject == NULL || *subject == '\0')
subject = _("Compose Message");
- }
gtk_window_set_title (GTK_WINDOW (composer), subject);
}
@@ -1645,9 +1589,8 @@ msg_composer_mail_identity_changed_cb (EMsgComposer *composer)
uid = e_composer_header_table_get_identity_uid (table);
/* Silently return if no identity is selected. */
- if (uid == NULL) {
+ if (uid == NULL)
return;
- }
source = e_composer_header_table_ref_source (table, uid);
g_return_if_fail (source != NULL);
@@ -1811,16 +1754,14 @@ msg_composer_drag_data_received_cb (GtkWidget *widget,
/* If we're receiving an image, we want the image to be
* inserted in the message body. Let GtkHtml handle it. */
- if (gtk_selection_data_targets_include_image (selection, TRUE)) {
+ if (gtk_selection_data_targets_include_image (selection, TRUE))
return;
- }
/* If we're receiving URIs and -all- the URIs point to
* image files, we want the image(s) to be inserted in
* the message body. Let GtkHtml handle it. */
- if (e_composer_selection_is_image_uris (composer, selection)) {
+ if (e_composer_selection_is_image_uris (composer, selection))
return;
- }
}
view = e_msg_composer_get_attachment_view (composer);
@@ -1845,7 +1786,7 @@ msg_composer_notify_header_cb (EMsgComposer *composer)
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
- e_editor_widget_set_changed(editor_widget, TRUE);
+ e_editor_widget_set_changed (editor_widget, TRUE);
}
static gboolean
@@ -1859,9 +1800,8 @@ msg_composer_delete_event_cb (EMsgComposer *composer)
/* If the "async" action group is insensitive, it means an
* asynchronous operation is in progress. Block the event. */
- if (!gtk_action_group_get_sensitive (composer->priv->async_actions)) {
+ if (!gtk_action_group_get_sensitive (composer->priv->async_actions))
return TRUE;
- }
application = GTK_APPLICATION (shell);
windows = gtk_application_get_windows (application);
@@ -1988,9 +1928,8 @@ msg_composer_gallery_drag_data_get (GtkIconView *icon_view,
GdkAtom target;
gchar *str_data;
- if (!gtk_icon_view_get_cursor (icon_view, &path, &cell)) {
+ if (!gtk_icon_view_get_cursor (icon_view, &path, &cell))
return;
- }
target = gtk_selection_data_get_target (selection_data);
@@ -2342,27 +2281,24 @@ msg_composer_image_uri (EMsgComposer *composer,
hash_table = composer->priv->inline_images_by_url;
part = g_hash_table_lookup (hash_table, uri);
- if (part == NULL && g_str_has_prefix (uri, "file:")) {
+ if (part == NULL && g_str_has_prefix (uri, "file:"))
part = e_msg_composer_add_inline_image_from_file (
composer, uri + 5);
- }
if (part == NULL && g_str_has_prefix (uri, "cid:")) {
hash_table = composer->priv->inline_images;
part = g_hash_table_lookup (hash_table, uri);
}
- if (part == NULL) {
+ if (part == NULL)
return NULL;
- }
composer->priv->current_images =
g_list_prepend (composer->priv->current_images, part);
cid = camel_mime_part_get_content_id (part);
- if (cid == NULL) {
+ if (cid == NULL)
return NULL;
- }
return g_strconcat ("cid:", cid, NULL);
}
@@ -2419,25 +2355,25 @@ msg_composer_accumulator_false_abort (GSignalInvocationHint *ihint,
}
static void
-e_msg_composer_class_init (EMsgComposerClass *klass)
+e_msg_composer_class_init (EMsgComposerClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- g_type_class_add_private (klass, sizeof (EMsgComposerPrivate));
+ g_type_class_add_private (class, sizeof (EMsgComposerPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->set_property = msg_composer_set_property;
object_class->get_property = msg_composer_get_property;
object_class->dispose = msg_composer_dispose;
object_class->finalize = msg_composer_finalize;
object_class->constructed = msg_composer_constructed;
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->map = msg_composer_map;
widget_class->key_press_event = msg_composer_key_press_event;
- klass->presend = msg_composer_presend;
+ class->presend = msg_composer_presend;
g_object_class_install_property (
object_class,
@@ -2462,7 +2398,7 @@ e_msg_composer_class_init (EMsgComposerClass *klass)
signals[PRESEND] = g_signal_new (
"presend",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMsgComposerClass, presend),
msg_composer_accumulator_false_abort,
@@ -2472,7 +2408,7 @@ e_msg_composer_class_init (EMsgComposerClass *klass)
signals[SEND] = g_signal_new (
"send",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMsgComposerClass, send),
NULL, NULL,
@@ -2483,7 +2419,7 @@ e_msg_composer_class_init (EMsgComposerClass *klass)
signals[SAVE_TO_DRAFTS] = g_signal_new (
"save-to-drafts",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMsgComposerClass, save_to_drafts),
NULL, NULL,
@@ -2494,7 +2430,7 @@ e_msg_composer_class_init (EMsgComposerClass *klass)
signals[SAVE_TO_OUTBOX] = g_signal_new (
"save-to-outbox",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EMsgComposerClass, save_to_outbox),
NULL, NULL,
@@ -2505,7 +2441,7 @@ e_msg_composer_class_init (EMsgComposerClass *klass)
signals[PRINT] = g_signal_new (
"print",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
e_marshal_VOID__ENUM_OBJECT_OBJECT,
@@ -2570,9 +2506,8 @@ e_msg_composer_flush_pending_body (EMsgComposer *composer)
body = g_object_get_data (G_OBJECT (composer), "body:text");
- if (body != NULL) {
+ if (body != NULL)
set_editor_text (composer, body, FALSE);
- }
g_object_set_data (G_OBJECT (composer), "body:text", NULL);
}
@@ -2587,9 +2522,8 @@ add_attachments_handle_mime_part (EMsgComposer *composer,
CamelContentType *content_type;
CamelDataWrapper *wrapper;
- if (!mime_part) {
+ if (!mime_part)
return;
- }
content_type = camel_mime_part_get_content_type (mime_part);
wrapper = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
@@ -2667,9 +2601,8 @@ e_msg_composer_add_message_attachments (EMsgComposer *composer,
CamelDataWrapper *wrapper;
wrapper = camel_medium_get_content (CAMEL_MEDIUM (message));
- if (!CAMEL_IS_MULTIPART (wrapper)) {
+ if (!CAMEL_IS_MULTIPART (wrapper))
return;
- }
add_attachments_from_multipart (
composer, (CamelMultipart *) wrapper, just_inlines, 0);
@@ -2692,24 +2625,21 @@ handle_multipart_signed (EMsgComposer *composer,
content_type = camel_data_wrapper_get_mime_type_field (content);
protocol = camel_content_type_param (content_type, "protocol");
- if (protocol == NULL) {
+ if (protocol == NULL)
action = NULL;
- } else if (g_ascii_strcasecmp (protocol, "application/pgp-signature") == 0) {
+ else if (g_ascii_strcasecmp (protocol, "application/pgp-signature") == 0)
action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
- } else if (g_ascii_strcasecmp (protocol, "application/x-pkcs7-signature") == 0) {
+ else if (g_ascii_strcasecmp (protocol, "application/x-pkcs7-signature") == 0)
action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
- }
- if (action) {
+ if (action)
gtk_toggle_action_set_active (action, TRUE);
- }
mime_part = camel_multipart_get_part (
multipart, CAMEL_MULTIPART_SIGNED_CONTENT);
- if (mime_part == NULL) {
+ if (mime_part == NULL)
return;
- }
content_type = camel_mime_part_get_content_type (mime_part);
content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
@@ -2778,17 +2708,15 @@ handle_multipart_encrypted (EMsgComposer *composer,
content_type = camel_mime_part_get_content_type (multipart);
protocol = camel_content_type_param (content_type, "protocol");
- if (protocol && g_ascii_strcasecmp (protocol, "application/pgp-encrypted") == 0) {
+ if (protocol && g_ascii_strcasecmp (protocol, "application/pgp-encrypted") == 0)
action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
- } else if (content_type && (
+ else if (content_type && (
camel_content_type_is (content_type, "application", "x-pkcs7-mime")
- || camel_content_type_is (content_type, "application", "pkcs7-mime"))) {
+ || camel_content_type_is (content_type, "application", "pkcs7-mime")))
action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
- }
- if (action) {
+ if (action)
gtk_toggle_action_set_active (action, TRUE);
- }
session = e_msg_composer_ref_session (composer);
cipher = camel_gpg_context_new (session);
@@ -2798,9 +2726,8 @@ handle_multipart_encrypted (EMsgComposer *composer,
g_object_unref (cipher);
g_object_unref (session);
- if (valid == NULL) {
+ if (valid == NULL)
return;
- }
camel_cipher_validity_free (valid);
@@ -2875,9 +2802,8 @@ handle_multipart_alternative (EMsgComposer *composer,
mime_part = camel_multipart_get_part (multipart, i);
- if (!mime_part) {
+ if (!mime_part)
continue;
- }
content_type = camel_mime_part_get_content_type (mime_part);
content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
@@ -2949,9 +2875,8 @@ handle_multipart (EMsgComposer *composer,
mime_part = camel_multipart_get_part (multipart, i);
- if (!mime_part) {
+ if (!mime_part)
continue;
- }
content_type = camel_mime_part_get_content_type (mime_part);
content = camel_medium_get_content (CAMEL_MEDIUM (mime_part));
@@ -3024,14 +2949,13 @@ set_signature_gui (EMsgComposer *composer)
table = e_msg_composer_get_header_table (composer);
combo_box = e_composer_header_table_get_signature_combo_box (table);
-
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
widget = e_editor_get_editor_widget (editor);
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
uid = NULL;
nodes = webkit_dom_document_get_elements_by_class_name (
- document, "-x-evolution-signature");
+ document, "-x-evolution-signature");
length = webkit_dom_node_list_get_length (nodes);
for (ii = 0; ii < length; ii++) {
WebKitDOMNode *node;
@@ -3040,20 +2964,19 @@ set_signature_gui (EMsgComposer *composer)
node = webkit_dom_node_list_item (nodes, ii);
id = webkit_dom_html_element_get_id (WEBKIT_DOM_HTML_ELEMENT (node));
if (id && (strlen (id) == 1) && (*id == '1')) {
- uid = webkit_dom_element_get_attribute (
- WEBKIT_DOM_ELEMENT (node), "name");
- g_free (id);
- break;
+ uid = webkit_dom_element_get_attribute (
+ WEBKIT_DOM_ELEMENT (node), "name");
+ g_free (id);
+ break;
}
g_free (id);
}
- if (!uid) {
- return;
- }
- // The combo box active ID is the signature's ESource UID.
- gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), uid);
- g_free (uid);
+ /* The combo box active ID is the signature's ESource UID. */
+ if (uid != NULL) {
+ gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo_box), uid);
+ g_free (uid);
+ }
}
static void
@@ -3263,9 +3186,8 @@ e_msg_composer_new_with_message (EShell *shell,
Bccv = NULL;
}
- if (source != NULL) {
+ if (source != NULL)
g_object_unref (source);
- }
subject = camel_mime_message_get_subject (message);
@@ -3508,22 +3430,6 @@ e_msg_composer_get_shell (EMsgComposer *composer)
return E_SHELL (composer->priv->shell);
}
-/**
- * e_msg_composer_get_editor:
- * @composer: an #EMsgComposer
- *
- * Returns the #EEditor widget in @composer.
- *
- * Returns: the #EEditor
- **/
-EEditor *
-e_msg_composer_get_editor (EMsgComposer *composer)
-{
- g_return_val_if_fail (E_IS_MSG_COMPOSER (composer), NULL);
-
- return e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
-}
-
static void
msg_composer_send_cb (EMsgComposer *composer,
GAsyncResult *result,
@@ -3680,9 +3586,10 @@ msg_composer_save_to_drafts_cb (EMsgComposer *composer,
g_object_unref (message);
- if (e_msg_composer_is_exiting (composer)) {
- g_object_weak_ref (G_OBJECT (context->activity), (GWeakNotify) gtk_widget_destroy, composer);
- }
+ if (e_msg_composer_is_exiting (composer))
+ g_object_weak_ref (
+ G_OBJECT (context->activity),
+ (GWeakNotify) gtk_widget_destroy, composer);
async_context_free (context);
}
@@ -3790,9 +3697,8 @@ e_msg_composer_save_to_outbox (EMsgComposer *composer)
/* This gives the user a chance to abort the save. */
g_signal_emit (composer, signals[PRESEND], 0, &proceed_with_save);
- if (!proceed_with_save) {
+ if (!proceed_with_save)
return;
- }
context = g_slice_new0 (AsyncContext);
context->activity = e_composer_activity_new (composer);
@@ -3925,9 +3831,8 @@ list_contains_addr (const GList *list,
g_return_val_if_fail (dest != NULL, FALSE);
while (list != NULL) {
- if (e_destination_equal (dest, list->data)) {
+ if (e_destination_equal (dest, list->data))
return TRUE;
- }
list = list->next;
}
@@ -3992,9 +3897,8 @@ file_is_blacklisted (const gchar *argument)
filename = g_file_get_path (file);
g_object_unref (file);
- if (filename == NULL) {
+ if (filename == NULL)
return FALSE;
- }
parts = g_strsplit (filename, G_DIR_SEPARATOR_S, -1);
n_parts = g_strv_length (parts);
@@ -4012,30 +3916,25 @@ file_is_blacklisted (const gchar *argument)
gchar *base_dir;
/* Don't blacklist files in trusted base directories. */
- if (g_str_has_prefix (filename, g_get_user_data_dir ())) {
+ if (g_str_has_prefix (filename, g_get_user_data_dir ()))
blacklisted = FALSE;
- }
- if (g_str_has_prefix (filename, g_get_user_cache_dir ())) {
+ if (g_str_has_prefix (filename, g_get_user_cache_dir ()))
blacklisted = FALSE;
- }
- if (g_str_has_prefix (filename, g_get_user_config_dir ())) {
+ if (g_str_has_prefix (filename, g_get_user_config_dir ()))
blacklisted = FALSE;
- }
/* Apparently KDE still uses ~/.kde heavily, and some
* distributions use ~/.kde4 to distinguish KDE4 data
* from KDE3 data. Trust these directories as well. */
base_dir = g_build_filename (g_get_home_dir (), ".kde", NULL);
- if (g_str_has_prefix (filename, base_dir)) {
+ if (g_str_has_prefix (filename, base_dir))
blacklisted = FALSE;
- }
g_free (base_dir);
base_dir = g_build_filename (g_get_home_dir (), ".kde4", NULL);
- if (g_str_has_prefix (filename, base_dir)) {
+ if (g_str_has_prefix (filename, base_dir))
blacklisted = FALSE;
- }
g_free (base_dir);
}
@@ -4144,11 +4043,10 @@ handle_mailto (EMsgComposer *composer,
E_ALERT_SINK (composer),
"mail:blacklisted-file",
content, NULL);
- if (g_ascii_strncasecmp (content, "file:", 5) == 0) {
+ if (g_ascii_strncasecmp (content, "file:", 5) == 0)
attachment = e_attachment_new_for_uri (content);
- } else {
+ else
attachment = e_attachment_new_for_path (content);
- }
e_attachment_store_add_attachment (store, attachment);
e_attachment_load_async (
attachment, (GAsyncReadyCallback)
@@ -4169,9 +4067,8 @@ handle_mailto (EMsgComposer *composer,
p += clen;
if (*p == '&') {
p++;
- if (!g_ascii_strncasecmp (p, "amp;", 4)) {
+ if (!g_ascii_strncasecmp (p, "amp;", 4))
p += 4;
- }
}
}
}
@@ -4531,15 +4428,13 @@ e_msg_composer_add_inline_image_from_file (EMsgComposer *composer,
dec_file_name = g_strdup (filename);
camel_url_decode (dec_file_name);
- if (!g_file_test (dec_file_name, G_FILE_TEST_IS_REGULAR)) {
+ if (!g_file_test (dec_file_name, G_FILE_TEST_IS_REGULAR))
return NULL;
- }
stream = camel_stream_fs_new_with_name (
dec_file_name, O_RDONLY, 0, NULL);
- if (!stream) {
+ if (!stream)
return NULL;
- }
wrapper = camel_data_wrapper_new ();
camel_data_wrapper_construct_from_stream_sync (
@@ -4547,9 +4442,8 @@ e_msg_composer_add_inline_image_from_file (EMsgComposer *composer,
g_object_unref (CAMEL_OBJECT (stream));
mime_type = e_util_guess_mime_type (dec_file_name, TRUE);
- if (mime_type == NULL) {
+ if (mime_type == NULL)
mime_type = g_strdup ("application/octet-stream");
- }
camel_data_wrapper_set_mime_type (wrapper, mime_type);
g_free (mime_type);
@@ -4603,11 +4497,10 @@ e_msg_composer_add_inline_image_from_mime_part (EMsgComposer *composer,
g_object_ref (part);
location = camel_mime_part_get_content_location (part);
- if (location != NULL) {
+ if (location != NULL)
g_hash_table_insert (
p->inline_images_by_url,
g_strdup (location), part);
- }
}
static void
@@ -4620,10 +4513,9 @@ composer_get_message_ready (EMsgComposer *composer,
message = composer_build_message_finish (composer, result, &error);
- if (message != NULL) {
+ if (message != NULL)
g_simple_async_result_set_op_res_gpointer (
simple, message, (GDestroyNotify) g_object_unref);
- }
if (error != NULL) {
g_warn_if_fail (message == NULL);
@@ -4667,40 +4559,33 @@ e_msg_composer_get_message (EMsgComposer *composer,
g_simple_async_result_set_check_cancellable (simple, cancellable);
- if (e_editor_widget_get_html_mode (editor_widget)) {
+ if (e_editor_widget_get_html_mode (editor_widget))
flags |= COMPOSER_FLAG_HTML_CONTENT;
- }
action = ACTION (PRIORITIZE_MESSAGE);
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
flags |= COMPOSER_FLAG_PRIORITIZE_MESSAGE;
- }
action = ACTION (REQUEST_READ_RECEIPT);
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
flags |= COMPOSER_FLAG_REQUEST_READ_RECEIPT;
- }
action = ACTION (PGP_SIGN);
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
flags |= COMPOSER_FLAG_PGP_SIGN;
- }
action = ACTION (PGP_ENCRYPT);
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
flags |= COMPOSER_FLAG_PGP_ENCRYPT;
- }
#ifdef HAVE_NSS
action = ACTION (SMIME_SIGN);
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
flags |= COMPOSER_FLAG_SMIME_SIGN;
- }
action = ACTION (SMIME_ENCRYPT);
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))) {
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
flags |= COMPOSER_FLAG_SMIME_ENCRYPT;
- }
#endif
composer_build_message (
@@ -4725,9 +4610,8 @@ e_msg_composer_get_message_finish (EMsgComposer *composer,
simple = G_SIMPLE_ASYNC_RESULT (result);
message = g_simple_async_result_get_op_res_gpointer (simple);
- if (g_simple_async_result_propagate_error (simple, error)) {
+ if (g_simple_async_result_propagate_error (simple, error))
return NULL;
- }
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
@@ -4777,9 +4661,8 @@ e_msg_composer_get_message_print_finish (EMsgComposer *composer,
simple = G_SIMPLE_ASYNC_RESULT (result);
message = g_simple_async_result_get_op_res_gpointer (simple);
- if (g_simple_async_result_propagate_error (simple, error)) {
+ if (g_simple_async_result_propagate_error (simple, error))
return NULL;
- }
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
@@ -4808,9 +4691,8 @@ e_msg_composer_get_message_draft (EMsgComposer *composer,
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
- if (e_editor_widget_get_html_mode (editor_widget)) {
+ if (e_editor_widget_get_html_mode (editor_widget))
flags |= COMPOSER_FLAG_HTML_CONTENT;
- }
composer_build_message (
composer, flags, io_priority,
@@ -4834,9 +4716,8 @@ e_msg_composer_get_message_draft_finish (EMsgComposer *composer,
simple = G_SIMPLE_ASYNC_RESULT (result);
message = g_simple_async_result_get_op_res_gpointer (simple);
- if (g_simple_async_result_propagate_error (simple, error)) {
+ if (g_simple_async_result_propagate_error (simple, error))
return NULL;
- }
g_return_val_if_fail (CAMEL_IS_MIME_MESSAGE (message), NULL);
@@ -4894,9 +4775,8 @@ e_msg_composer_get_reply_to (EMsgComposer *composer)
table = e_msg_composer_get_header_table (composer);
reply_to = e_composer_header_table_get_reply_to (table);
- if (reply_to == NULL || *reply_to == '\0') {
+ if (reply_to == NULL || *reply_to == '\0')
return NULL;
- }
address = camel_internet_address_new ();
if (camel_address_unformat (CAMEL_ADDRESS (address), reply_to) == -1) {
@@ -4974,13 +4854,11 @@ e_msg_composer_can_close (EMsgComposer *composer,
/* this means that there is an async operation running,
* in which case the composer cannot be closed */
- if (!gtk_action_group_get_sensitive (composer->priv->async_actions)) {
+ if (!gtk_action_group_get_sensitive (composer->priv->async_actions))
return FALSE;
- }
- if (!e_editor_widget_get_changed (editor_widget)) {
+ if (!e_editor_widget_get_changed (editor_widget))
return TRUE;
- }
window = gtk_widget_get_window (widget);
gdk_window_raise (window);
@@ -4988,9 +4866,8 @@ e_msg_composer_can_close (EMsgComposer *composer,
table = e_msg_composer_get_header_table (composer);
subject = e_composer_header_table_get_subject (table);
- if (subject == NULL || *subject == '\0') {
+ if (subject == NULL || *subject == '\0')
subject = _("Untitled Message");
- }
response = e_alert_run_dialog_for_args (
GTK_WINDOW (composer),
@@ -5019,8 +4896,8 @@ e_msg_composer_can_close (EMsgComposer *composer,
void
e_msg_composer_reply_indent (EMsgComposer *composer)
{
- /* FIXME WEBKIT We already have indentation implementation. Why
- * is this done?
+#if 0 /* FIXME WEBKIT We already have indentation implementation.
+ * Why is this done? */
GtkhtmlEditor *editor;
g_return_if_fail (E_IS_MSG_COMPOSER (composer));
@@ -5042,7 +4919,7 @@ e_msg_composer_reply_indent (EMsgComposer *composer)
gtkhtml_editor_run_command (editor, "indent-zero");
gtkhtml_editor_run_command (editor, "text-default-color");
gtkhtml_editor_run_command (editor, "italic-off");
- */
+#endif
}
EComposerHeaderTable *
@@ -5079,11 +4956,10 @@ e_load_spell_languages (ESpellChecker *spell_checker)
gchar *language_code = strv[ii];
ESpellDictionary *dict;
- dict = e_spell_checker_lookup_dictionary (spell_checker, language_code);
- if (dict != NULL) {
- spell_dicts = g_list_prepend (
- spell_dicts, (gpointer) dict);
- }
+ dict = e_spell_checker_lookup_dictionary (
+ spell_checker, language_code);
+ if (dict != NULL)
+ spell_dicts = g_list_prepend (spell_dicts, dict);
}
g_strfreev (strv);
@@ -5096,10 +4972,8 @@ e_load_spell_languages (ESpellChecker *spell_checker)
dict = e_spell_checker_lookup_dictionary (spell_checker, NULL);
- if (dict) {
- spell_dicts = g_list_prepend (
- spell_dicts, (gpointer) dict);
- }
+ if (dict != NULL)
+ spell_dicts = g_list_prepend (spell_dicts, dict);
}
return spell_dicts;
diff --git a/composer/e-msg-composer.h b/composer/e-msg-composer.h
index 114230f..7584816 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -97,8 +97,6 @@ EFocusTracker * e_msg_composer_get_focus_tracker
(EMsgComposer *composer);
CamelSession * e_msg_composer_ref_session (EMsgComposer *composer);
EShell * e_msg_composer_get_shell (EMsgComposer *composer);
-EEditor *
- e_msg_composer_get_editor (EMsgComposer *composer);
void e_msg_composer_send (EMsgComposer *composer);
void e_msg_composer_save_to_drafts (EMsgComposer *composer);
diff --git a/e-util/e-color-chooser-widget.c b/e-util/e-color-chooser-widget.c
index 7cc0b06..a662a3c 100644
--- a/e-util/e-color-chooser-widget.c
+++ b/e-util/e-color-chooser-widget.c
@@ -26,10 +26,9 @@
#include <glib/gi18n-lib.h>
-G_DEFINE_TYPE (
- EColorChooserWidget,
- e_color_chooser_widget,
- GTK_TYPE_COLOR_CHOOSER_WIDGET);
+#define E_COLOR_CHOOSER_WIDGET_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_COLOR_CHOOSER_WIDGET, EColorChooserWidgetPrivate))
/**
* EColorChooserWidget:
@@ -49,6 +48,11 @@ enum {
static guint signals[LAST_SIGNAL];
+G_DEFINE_TYPE (
+ EColorChooserWidget,
+ e_color_chooser_widget,
+ GTK_TYPE_COLOR_CHOOSER_WIDGET);
+
/* UGLY UGLY UGLY!
* GtkColorChooserWidget sends "color-activated" signal
* only when user double-clicks the color. This is totally stupid
@@ -65,7 +69,7 @@ static guint signals[LAST_SIGNAL];
*/
static gboolean
color_chooser_widget_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
+ GdkEventButton *event)
{
if ((event->type == GDK_BUTTON_PRESS) &&
(event->button == GDK_BUTTON_PRIMARY)) {
@@ -80,8 +84,8 @@ color_chooser_widget_button_press_event (GtkWidget *widget,
static void
color_chooser_widget_color_activated (GtkColorChooser *chooser,
- GdkRGBA *color,
- gpointer user_data)
+ GdkRGBA *color,
+ gpointer user_data)
{
/* Because we are simulating the double-click by accepting only
* single click, the color in the swatch is actually not selected,
@@ -92,6 +96,7 @@ color_chooser_widget_color_activated (GtkColorChooser *chooser,
static gboolean
run_color_chooser_dialog (gpointer user_data)
{
+ EColorChooserWidgetPrivate *priv;
GtkWidget *parent_window;
GtkWidget *parent_chooser;
GtkWidget *dialog;
@@ -99,7 +104,6 @@ run_color_chooser_dialog (gpointer user_data)
parent_chooser = user_data;
-
g_object_set (
G_OBJECT (parent_chooser), "show-editor", FALSE, NULL);
@@ -107,11 +111,11 @@ run_color_chooser_dialog (gpointer user_data)
if (!parent_window)
parent_window = gtk_widget_get_toplevel (parent_chooser);
dialog = gtk_dialog_new_with_buttons (
- N_("Choose custom color"),
- GTK_WINDOW (parent_window),
- GTK_DIALOG_MODAL,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
+ N_("Choose custom color"),
+ GTK_WINDOW (parent_window),
+ GTK_DIALOG_MODAL,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL);
chooser = gtk_color_chooser_widget_new ();
g_object_set (G_OBJECT (chooser), "show-editor", TRUE, NULL);
@@ -132,14 +136,16 @@ run_color_chooser_dialog (gpointer user_data)
gtk_widget_destroy (dialog);
- E_COLOR_CHOOSER_WIDGET (parent_chooser)->priv->showing_editor = FALSE;
+ priv = E_COLOR_CHOOSER_WIDGET_GET_PRIVATE (parent_chooser);
+ priv->showing_editor = FALSE;
+
return FALSE;
}
static void
color_chooser_show_editor_notify_cb (EColorChooserWidget *chooser,
- GParamSpec *pspec,
- gpointer user_data)
+ GParamSpec *pspec,
+ gpointer user_data)
{
gboolean show_editor;
@@ -160,9 +166,9 @@ color_chooser_show_editor_notify_cb (EColorChooserWidget *chooser,
}
void
-e_color_chooser_widget_class_init (EColorChooserWidgetClass *klass)
+e_color_chooser_widget_class_init (EColorChooserWidgetClass *class)
{
- g_type_class_add_private (klass, sizeof (EColorChooserWidgetPrivate));
+ g_type_class_add_private (class, sizeof (EColorChooserWidgetPrivate));
signals[SIGNAL_EDITOR_ACTIVATED] = g_signal_new (
"editor-activated",
@@ -212,9 +218,7 @@ e_color_chooser_widget_init (EColorChooserWidget *widget)
{
GtkWidget *swatch;
- widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- widget, E_TYPE_COLOR_CHOOSER_WIDGET,
- EColorChooserWidgetPrivate);
+ widget->priv = E_COLOR_CHOOSER_WIDGET_GET_PRIVATE (widget);
widget->priv->showing_editor = FALSE;
swatch = find_swatch (GTK_CONTAINER (widget));
diff --git a/e-util/e-color-chooser-widget.h b/e-util/e-color-chooser-widget.h
index 5960542..3b7c60d 100644
--- a/e-util/e-color-chooser-widget.h
+++ b/e-util/e-color-chooser-widget.h
@@ -53,18 +53,16 @@ typedef struct _EColorChooserWidgetPrivate EColorChooserWidgetPrivate;
struct _EColorChooserWidget {
GtkColorChooserWidget parent;
-
EColorChooserWidgetPrivate *priv;
};
struct _EColorChooserWidgetClass {
GtkColorChooserWidgetClass parent_class;
- void (*editor_activated) (GtkColorChooserWidget *chooser);
+ void (*editor_activated) (GtkColorChooserWidget *chooser);
};
-GType e_color_chooser_widget_get_type (void);
-
+GType e_color_chooser_widget_get_type (void) G_GNUC_CONST;
GtkWidget * e_color_chooser_widget_new (void);
G_END_DECLS
diff --git a/e-util/e-color-combo.c b/e-util/e-color-combo.c
index ebc3565..5c79439 100644
--- a/e-util/e-color-combo.c
+++ b/e-util/e-color-combo.c
@@ -29,27 +29,9 @@
#include <cairo/cairo.h>
#include <alloca.h>
-G_DEFINE_TYPE (
- EColorCombo,
- e_color_combo,
- GTK_TYPE_BUTTON);
-
-enum {
- PROP_0,
- PROP_CURRENT_COLOR,
- PROP_DEFAULT_COLOR,
- PROP_DEFAULT_LABEL,
- PROP_DEFAULT_TRANSPARENT,
- PROP_PALETTE,
- PROP_POPUP_SHOWN
-};
-
-enum {
- ACTIVATED,
- POPUP,
- POPDOWN,
- LAST_SIGNAL
-};
+#define E_COLOR_COMBO_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_COLOR_COMBO, EColorComboPrivate))
struct _EColorComboPrivate {
GtkWidget *color_frame;
@@ -72,6 +54,23 @@ struct _EColorComboPrivate {
GdkDevice *grab_mouse;
};
+enum {
+ PROP_0,
+ PROP_CURRENT_COLOR,
+ PROP_DEFAULT_COLOR,
+ PROP_DEFAULT_LABEL,
+ PROP_DEFAULT_TRANSPARENT,
+ PROP_PALETTE,
+ PROP_POPUP_SHOWN
+};
+
+enum {
+ ACTIVATED,
+ POPUP,
+ POPDOWN,
+ LAST_SIGNAL
+};
+
static guint signals[LAST_SIGNAL];
static GdkRGBA black = { 0, 0, 0, 1 };
@@ -126,6 +125,11 @@ static struct {
{ "#FFFFFF", N_("white") }
};
+G_DEFINE_TYPE (
+ EColorCombo,
+ e_color_combo,
+ GTK_TYPE_BUTTON);
+
static void
color_combo_reposition_window (EColorCombo *combo)
{
@@ -194,17 +198,23 @@ color_combo_popup (EColorCombo *combo)
/* Try to grab the pointer and keyboard. */
window = gtk_widget_get_window (combo->priv->window);
- grab_status = !keyboard ||
- gdk_device_grab (keyboard, window,
+ grab_status =
+ (keyboard == NULL) ||
+ (gdk_device_grab (
+ keyboard, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
- NULL, activate_time) == GDK_GRAB_SUCCESS;
+ NULL, activate_time) == GDK_GRAB_SUCCESS);
if (grab_status) {
- grab_status = !mouse ||
- gdk_device_grab (mouse, window,
+ grab_status =
+ (mouse == NULL) ||
+ (gdk_device_grab (
+ mouse, window,
GDK_OWNERSHIP_WINDOW, TRUE,
- GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK,
- NULL, activate_time) == GDK_GRAB_SUCCESS;
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK,
+ NULL, activate_time) == GDK_GRAB_SUCCESS);
if (!grab_status && keyboard)
gdk_device_ungrab (keyboard, activate_time);
}
@@ -219,7 +229,8 @@ color_combo_popup (EColorCombo *combo)
/* Always make sure the editor-mode is OFF */
g_object_set (
- G_OBJECT (combo->priv->chooser_widget), "show-editor", FALSE, NULL);
+ G_OBJECT (combo->priv->chooser_widget),
+ "show-editor", FALSE, NULL);
}
static void
@@ -246,8 +257,8 @@ color_combo_popdown (EColorCombo *combo)
static gboolean
color_combo_window_button_press_event_cb (EColorCombo *combo,
- GdkEvent *event,
- gpointer user_data)
+ GdkEvent *event,
+ gpointer user_data)
{
GtkWidget *event_widget;
@@ -268,8 +279,8 @@ color_combo_window_button_press_event_cb (EColorCombo *combo,
static gboolean
color_combo_window_button_release_event_cb (EColorCombo *combo,
- GdkEvent *event,
- gpointer user_data)
+ GdkEvent *event,
+ gpointer user_data)
{
gboolean popup_in_progress;
@@ -306,8 +317,8 @@ color_combo_child_hide_cb (EColorCombo *combo)
static void
color_combo_get_preferred_width (GtkWidget *widget,
- gint *min_width,
- gint *natural_width)
+ gint *min_width,
+ gint *natural_width)
{
GtkWidgetClass *widget_class;
@@ -324,7 +335,7 @@ color_combo_get_preferred_width (GtkWidget *widget,
static gboolean
color_combo_button_press_event_cb (GtkWidget *widget,
- GdkEventButton *event)
+ GdkEventButton *event)
{
EColorCombo *combo = E_COLOR_COMBO (widget);
GdkWindow *window;
@@ -354,7 +365,7 @@ color_combo_button_press_event_cb (GtkWidget *widget,
if (combo->priv->popup_shown) {
color_combo_popdown (combo);
} else {
- color_combo_popup (combo);
+ color_combo_popup (combo);
}
return FALSE;
@@ -362,8 +373,8 @@ color_combo_button_press_event_cb (GtkWidget *widget,
static void
color_combo_swatch_color_changed (EColorCombo *combo,
- GdkRGBA *color,
- gpointer user_data)
+ GdkRGBA *color,
+ gpointer user_data)
{
g_signal_emit (combo, signals[ACTIVATED], 0, color);
@@ -374,8 +385,8 @@ color_combo_swatch_color_changed (EColorCombo *combo,
static void
color_combo_draw_frame_cb (GtkWidget *widget,
- cairo_t *cr,
- gpointer user_data)
+ cairo_t *cr,
+ gpointer user_data)
{
EColorCombo *combo = user_data;
GdkRGBA rgba;
@@ -395,7 +406,7 @@ color_combo_draw_frame_cb (GtkWidget *widget,
static void
color_combo_set_default_color_cb (EColorCombo *combo,
- gpointer user_data)
+ gpointer user_data)
{
GdkRGBA color;
@@ -461,8 +472,10 @@ color_combo_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
+ EColorComboPrivate *priv;
GdkRGBA color;
- EColorComboPrivate *priv = E_COLOR_COMBO (object)->priv;
+
+ priv = E_COLOR_COMBO_GET_PRIVATE (object);
switch (property_id) {
case PROP_CURRENT_COLOR:
@@ -509,49 +522,44 @@ color_combo_dispose (GObject *object)
{
EColorComboPrivate *priv;
- priv = E_COLOR_COMBO (object)->priv;
-
- if (priv->palette) {
- g_list_free_full (
- priv->palette,
- (GDestroyNotify) gdk_color_free);
- priv->palette = NULL;
- }
+ priv = E_COLOR_COMBO_GET_PRIVATE (object);
- if (priv->current_color) {
+ if (priv->current_color != NULL) {
gdk_rgba_free (priv->current_color);
priv->current_color = NULL;
}
- if (priv->default_color) {
+ if (priv->default_color != NULL) {
gdk_rgba_free (priv->default_color);
priv->default_color = NULL;
}
+ g_list_free_full (priv->palette, (GDestroyNotify) gdk_color_free);
+ priv->palette = NULL;
+
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_color_combo_parent_class)->dispose (object);
}
static void
-e_color_combo_class_init (EColorComboClass *klass)
+e_color_combo_class_init (EColorComboClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- e_color_combo_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EColorComboPrivate));
+ g_type_class_add_private (class, sizeof (EColorComboPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->set_property = color_combo_set_property;
object_class->get_property = color_combo_get_property;
object_class->dispose = color_combo_dispose;
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->get_preferred_width = color_combo_get_preferred_width;
widget_class->button_press_event = color_combo_button_press_event_cb;
- klass->popup = color_combo_popup;
- klass->popdown = color_combo_popdown;
+ class->popup = color_combo_popup;
+ class->popdown = color_combo_popdown;
g_object_class_install_property (
object_class,
@@ -617,7 +625,7 @@ e_color_combo_class_init (EColorComboClass *klass)
signals[ACTIVATED] = g_signal_new (
"activated",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EColorComboClass, activated),
NULL, NULL,
@@ -626,7 +634,7 @@ e_color_combo_class_init (EColorComboClass *klass)
signals[POPUP] = g_signal_new (
"popup",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EColorComboClass, popup),
NULL, NULL,
@@ -635,7 +643,7 @@ e_color_combo_class_init (EColorComboClass *klass)
signals[POPDOWN] = g_signal_new (
"popdown",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (EColorComboClass, popdown),
NULL, NULL,
@@ -643,107 +651,113 @@ e_color_combo_class_init (EColorComboClass *klass)
G_TYPE_NONE, 0);
gtk_binding_entry_add_signal (
- gtk_binding_set_by_class (klass),
+ gtk_binding_set_by_class (class),
GDK_KEY_Down, GDK_MOD1_MASK, "popup", 0);
gtk_binding_entry_add_signal (
- gtk_binding_set_by_class (klass),
+ gtk_binding_set_by_class (class),
GDK_KEY_KP_Down, GDK_MOD1_MASK, "popup", 0);
gtk_binding_entry_add_signal (
- gtk_binding_set_by_class (klass),
+ gtk_binding_set_by_class (class),
GDK_KEY_Up, GDK_MOD1_MASK, "popdown", 0);
gtk_binding_entry_add_signal (
- gtk_binding_set_by_class (klass),
+ gtk_binding_set_by_class (class),
GDK_KEY_KP_Up, GDK_MOD1_MASK, "popdown", 0);
gtk_binding_entry_add_signal (
- gtk_binding_set_by_class (klass),
+ gtk_binding_set_by_class (class),
GDK_KEY_Escape, 0, "popdown", 0);
}
static void
e_color_combo_init (EColorCombo *combo)
{
+ GtkWidget *container;
GtkWidget *toplevel;
- GtkWidget *layout;
GtkWidget *widget;
GList *palette;
guint ii;
- combo->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- combo, E_TYPE_COLOR_COMBO, EColorComboPrivate);
+ combo->priv = E_COLOR_COMBO_GET_PRIVATE (combo);
- layout = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_container_add (GTK_CONTAINER (combo), layout);
+ widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_container_add (GTK_CONTAINER (combo), widget);
+
+ container = widget;
/* Build the combo button. */
widget = gtk_frame_new (NULL);
- gtk_box_pack_start (GTK_BOX (layout), widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
g_signal_connect (
widget, "draw",
G_CALLBACK (color_combo_draw_frame_cb), combo);
combo->priv->color_frame = widget;
widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
- gtk_box_pack_start (GTK_BOX (layout), widget, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
widget = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
- gtk_box_pack_start (GTK_BOX (layout), widget, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (container), widget, FALSE, TRUE, 0);
combo->priv->arrow = widget;
-
/* Build the drop-down menu */
- combo->priv->window = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_container_set_border_width (GTK_CONTAINER (combo->priv->window), 5);
- gtk_window_set_resizable (GTK_WINDOW (combo->priv->window), FALSE);
+ widget = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_container_set_border_width (GTK_CONTAINER (widget), 5);
+ gtk_window_set_resizable (GTK_WINDOW (widget), FALSE);
gtk_window_set_type_hint (
- GTK_WINDOW (combo->priv->window), GDK_WINDOW_TYPE_HINT_COMBO);
+ GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_COMBO);
+ combo->priv->window = widget;
+
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo));
- if (gtk_widget_is_toplevel (toplevel)) {
+ if (GTK_IS_WINDOW (toplevel)) {
gtk_window_group_add_window (
gtk_window_get_group (GTK_WINDOW (toplevel)),
- GTK_WINDOW (combo->priv->window ));
+ GTK_WINDOW (widget));
gtk_window_set_transient_for (
- GTK_WINDOW (combo->priv->window), GTK_WINDOW (toplevel));
+ GTK_WINDOW (widget), GTK_WINDOW (toplevel));
}
g_signal_connect_swapped (
- combo->priv->window, "show",
+ widget, "show",
G_CALLBACK (color_combo_child_show_cb), combo);
g_signal_connect_swapped (
- combo->priv->window, "hide",
+ widget, "hide",
G_CALLBACK (color_combo_child_hide_cb), combo);
g_signal_connect_swapped (
- combo->priv->window, "button-press-event",
+ widget, "button-press-event",
G_CALLBACK (color_combo_window_button_press_event_cb), combo);
g_signal_connect_swapped (
- combo->priv->window, "button-release-event",
+ widget, "button-release-event",
G_CALLBACK (color_combo_window_button_release_event_cb), combo);
- layout = gtk_grid_new ();
- gtk_grid_set_row_spacing (GTK_GRID (layout), 5);
- gtk_container_add (GTK_CONTAINER (combo->priv->window), layout);
+ container = widget;
+
+ widget = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (widget), 5);
+ gtk_container_add (GTK_CONTAINER (container), widget);
+
+ container = widget;
widget = gtk_button_new ();
- gtk_grid_attach (GTK_GRID (layout), widget, 0, 0, 1, 1);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 0, 1, 1);
combo->priv->default_button = widget;
+
g_signal_connect_swapped (
- combo->priv->default_button, "clicked",
+ widget, "clicked",
G_CALLBACK (color_combo_set_default_color_cb), combo);
g_signal_connect_swapped (
- combo->priv->default_button, "clicked",
+ widget, "clicked",
G_CALLBACK (color_combo_popdown), combo);
- combo->priv->chooser_widget = e_color_chooser_widget_new ();
- g_object_set_data (
- G_OBJECT (combo->priv->chooser_widget),
- "window", combo->priv->window);
- gtk_grid_attach (
- GTK_GRID (layout), combo->priv->chooser_widget, 0, 1, 1, 1);
+ widget = e_color_chooser_widget_new ();
+ g_object_set_data (G_OBJECT (widget), "window", combo->priv->window);
+ gtk_grid_attach (GTK_GRID (container), widget, 0, 1, 1, 1);
+ combo->priv->chooser_widget = widget;
+
g_signal_connect_swapped (
- combo->priv->chooser_widget, "color-activated",
+ widget, "color-activated",
G_CALLBACK (color_combo_swatch_color_changed), combo);
g_signal_connect_swapped (
- combo->priv->chooser_widget, "editor-activated",
+ widget, "editor-activated",
G_CALLBACK (color_combo_popdown), combo);
palette = NULL;
@@ -759,17 +773,6 @@ e_color_combo_init (EColorCombo *combo)
combo->priv->current_color = gdk_rgba_copy (&black);
combo->priv->default_color = gdk_rgba_copy (&black);
- /*
- for (ii = 0; ii < NUM_CUSTOM_COLORS; ii++) {
- widget = color_combo_new_swatch_button (
- combo, _("custom"), &black);
- gtk_table_attach (
- GTK_TABLE (container), widget,
- ii, ii + 1, 6, 7, 0, 0, 0, 0);
- combo->priv->custom[ii] = g_object_ref (
- gtk_bin_get_child (GTK_BIN (widget)));
- }
- */
}
GtkWidget *
@@ -780,7 +783,7 @@ e_color_combo_new (void)
GtkWidget *
e_color_combo_new_defaults (GdkRGBA *default_color,
- const gchar *default_label)
+ const gchar *default_label)
{
g_return_val_if_fail (default_color != NULL, NULL);
g_return_val_if_fail (default_label != NULL, NULL);
@@ -810,7 +813,7 @@ e_color_combo_popdown (EColorCombo *combo)
void
e_color_combo_get_current_color (EColorCombo *combo,
- GdkRGBA *color)
+ GdkRGBA *color)
{
g_return_if_fail (E_IS_COLOR_COMBO (combo));
g_return_if_fail (color != NULL);
@@ -823,7 +826,7 @@ e_color_combo_get_current_color (EColorCombo *combo,
void
e_color_combo_set_current_color (EColorCombo *combo,
- const GdkRGBA *color)
+ const GdkRGBA *color)
{
g_return_if_fail (E_IS_COLOR_COMBO (combo));
@@ -850,7 +853,7 @@ e_color_combo_set_current_color (EColorCombo *combo,
void
e_color_combo_get_default_color (EColorCombo *combo,
- GdkRGBA *color)
+ GdkRGBA *color)
{
g_return_if_fail (E_IS_COLOR_COMBO (combo));
g_return_if_fail (color != NULL);
@@ -863,7 +866,7 @@ e_color_combo_get_default_color (EColorCombo *combo,
void
e_color_combo_set_default_color (EColorCombo *combo,
- const GdkRGBA *color)
+ const GdkRGBA *color)
{
g_return_if_fail (E_IS_COLOR_COMBO (combo));
@@ -896,7 +899,7 @@ e_color_combo_get_default_label (EColorCombo *combo)
void
e_color_combo_set_default_label (EColorCombo *combo,
- const gchar *text)
+ const gchar *text)
{
g_return_if_fail (E_IS_COLOR_COMBO (combo));
@@ -915,7 +918,7 @@ e_color_combo_get_default_transparent (EColorCombo *combo)
void
e_color_combo_set_default_transparent (EColorCombo *combo,
- gboolean transparent)
+ gboolean transparent)
{
g_return_if_fail (E_IS_COLOR_COMBO (combo));
@@ -934,7 +937,7 @@ e_color_combo_get_palette (EColorCombo *combo)
void
e_color_combo_set_palette (EColorCombo *combo,
- GList *palette)
+ GList *palette)
{
gint ii, count, colors_per_line;
GList *iter;
@@ -958,7 +961,6 @@ e_color_combo_set_palette (EColorCombo *combo,
}
combo->priv->palette = g_list_reverse (combo->priv->palette);
-
gtk_color_chooser_add_palette (
GTK_COLOR_CHOOSER (combo->priv->chooser_widget),
GTK_ORIENTATION_HORIZONTAL, 0, 0, NULL);
diff --git a/e-util/e-color-combo.h b/e-util/e-color-combo.h
index 265d1ee..41f7fd1 100644
--- a/e-util/e-color-combo.h
+++ b/e-util/e-color-combo.h
@@ -65,39 +65,32 @@ struct _EColorComboClass {
GdkRGBA *color);
};
-GType e_color_combo_get_type (void);
+GType e_color_combo_get_type (void) G_GNUC_CONST;
GtkWidget * e_color_combo_new (void);
GtkWidget * e_color_combo_new_defaults (GdkRGBA *default_color,
const gchar *default_label);
void e_color_combo_popup (EColorCombo *combo);
void e_color_combo_popdown (EColorCombo *combo);
-
void e_color_combo_get_current_color (EColorCombo *combo,
GdkRGBA *rgba);
-
void e_color_combo_set_current_color (EColorCombo *combo,
const GdkRGBA *color);
-
void e_color_combo_get_default_color (EColorCombo *combo,
GdkRGBA *color);
void e_color_combo_set_default_color (EColorCombo *combo,
const GdkRGBA *default_color);
-
const gchar * e_color_combo_get_default_label (EColorCombo *combo);
void e_color_combo_set_default_label (EColorCombo *combo,
const gchar *text);
-
gboolean e_color_combo_get_default_transparent
(EColorCombo *combo);
void e_color_combo_set_default_transparent
(EColorCombo *combo,
gboolean transparent);
-
-GList * e_color_combo_get_palette (EColorCombo *combo);
+GList * e_color_combo_get_palette (EColorCombo *combo);
void e_color_combo_set_palette (EColorCombo *combo,
GList *palette);
-
G_END_DECLS
#endif /* E_COLOR_COMBO_H */
diff --git a/e-util/e-editor-actions.c b/e-util/e-editor-actions.c
index 7dc3e31..3d4ffd5 100644
--- a/e-util/e-editor-actions.c
+++ b/e-util/e-editor-actions.c
@@ -202,7 +202,7 @@ action_context_delete_row_cb (GtkAction *action,
static void
action_context_delete_table_cb (GtkAction *action,
- EEditor *editor)
+ EEditor *editor)
{
WebKitDOMElement *table;
@@ -425,7 +425,7 @@ action_indent_cb (GtkAction *action,
static void
action_insert_emoticon_cb (GtkAction *action,
- EEditor *editor)
+ EEditor *editor)
{
EEditorWidget *widget;
EEditorSelection *selection;
@@ -452,10 +452,10 @@ action_insert_html_file_cb (GtkToggleAction *action,
GtkFileFilter *filter;
dialog = gtk_file_chooser_dialog_new (
- _("Insert HTML File"), NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+ _("Insert HTML File"), NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("HTML file"));
@@ -463,8 +463,9 @@ action_insert_html_file_cb (GtkToggleAction *action,
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- GFile *file = gtk_file_chooser_get_file (
- GTK_FILE_CHOOSER (dialog));
+ GFile *file;
+
+ file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
/* XXX Need a way to cancel this. */
g_file_load_contents_async (
@@ -484,20 +485,20 @@ action_insert_image_cb (GtkAction *action,
{
GtkWidget *dialog;
- dialog = e_image_chooser_dialog_new (
- _("Insert Image"), NULL);
+ dialog = e_image_chooser_dialog_new (_("Insert Image"), NULL);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- gchar *uri;
+ EEditorWidget *editor_widget;
EEditorSelection *selection;
+ gchar *uri;
+
+ uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
- uri = gtk_file_chooser_get_uri (
- GTK_FILE_CHOOSER (dialog));
+ editor_widget = e_editor_get_editor_widget (editor);
+ selection = e_editor_widget_get_selection (editor_widget);
+ e_editor_selection_insert_image (selection, uri);
- selection = e_editor_widget_get_selection (
- e_editor_get_editor_widget (editor));
- e_editor_selection_insert_image (selection, uri);
- g_free (uri);
+ g_free (uri);
}
gtk_widget_destroy (dialog);
@@ -507,10 +508,9 @@ static void
action_insert_link_cb (GtkAction *action,
EEditor *editor)
{
- if (editor->priv->link_dialog == NULL) {
+ if (editor->priv->link_dialog == NULL)
editor->priv->link_dialog =
e_editor_link_dialog_new (editor);
- }
gtk_window_present (GTK_WINDOW (editor->priv->link_dialog));
}
@@ -519,10 +519,9 @@ static void
action_insert_rule_cb (GtkAction *action,
EEditor *editor)
{
- if (editor->priv->hrule_dialog == NULL) {
+ if (editor->priv->hrule_dialog == NULL)
editor->priv->hrule_dialog =
e_editor_hrule_dialog_new (editor);
- }
gtk_window_present (GTK_WINDOW (editor->priv->hrule_dialog));
}
@@ -531,10 +530,9 @@ static void
action_insert_table_cb (GtkAction *action,
EEditor *editor)
{
- if (editor->priv->table_dialog == NULL) {
+ if (editor->priv->table_dialog == NULL)
editor->priv->table_dialog =
e_editor_table_dialog_new (editor);
- }
gtk_window_present (GTK_WINDOW (editor->priv->table_dialog));
}
@@ -547,10 +545,10 @@ action_insert_text_file_cb (GtkAction *action,
GtkFileFilter *filter;
dialog = gtk_file_chooser_dialog_new (
- _("Insert text file"), NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+ _("Insert text file"), NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
filter = gtk_file_filter_new ();
gtk_file_filter_set_name (filter, _("Text file"));
@@ -558,8 +556,9 @@ action_insert_text_file_cb (GtkAction *action,
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
- GFile *file = gtk_file_chooser_get_file (
- GTK_FILE_CHOOSER (dialog));
+ GFile *file;
+
+ file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
/* XXX Need a way to cancel this. */
g_file_load_contents_async (
@@ -636,8 +635,10 @@ update_mode_combobox (gpointer data)
editor_widget = e_editor_get_editor_widget (editor);
is_html = e_editor_widget_get_html_mode (editor_widget);
- action = gtk_action_group_get_action (editor->priv->core_actions, "mode-html");
- gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), (is_html ? TRUE : FALSE));
+ action = gtk_action_group_get_action (
+ editor->priv->core_actions, "mode-html");
+ gtk_radio_action_set_current_value (
+ GTK_RADIO_ACTION (action), (is_html ? 1 : 0));
return FALSE;
}
@@ -682,8 +683,6 @@ action_mode_cb (GtkRadioAction *action,
gtk_action_set_sensitive (ACTION (STYLE_ADDRESS), is_html);
}
-
-
static void
action_paste_cb (GtkAction *action,
EEditor *editor)
@@ -894,13 +893,13 @@ static void
action_show_webkit_inspector_cb (GtkAction *action,
EEditor *editor)
{
- WebKitWebInspector *inspector;
- EEditorWidget *widget;
+ WebKitWebInspector *inspector;
+ EEditorWidget *widget;
- widget = e_editor_get_editor_widget (editor);
- inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (widget));
+ widget = e_editor_get_editor_widget (editor);
+ inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (widget));
- webkit_web_inspector_show (inspector);
+ webkit_web_inspector_show (inspector);
}
/*****************************************************************************
@@ -1664,19 +1663,22 @@ static void
editor_actions_setup_languages_menu (EEditor *editor)
{
ESpellChecker *checker;
+ EEditorWidget *editor_widget;
GtkUIManager *manager;
GtkActionGroup *action_group;
- GList *available_dicts, *iter;
+ GList *list, *link;
guint merge_id;
manager = editor->priv->manager;
action_group = editor->priv->language_actions;
- checker = e_editor_widget_get_spell_checker (editor->priv->editor_widget);
- available_dicts = e_spell_checker_list_available_dicts (checker);
+ editor_widget = e_editor_get_editor_widget (editor);
+ checker = e_editor_widget_get_spell_checker (editor_widget);
merge_id = gtk_ui_manager_new_merge_id (manager);
- for (iter = available_dicts; iter; iter = iter->next) {
- ESpellDictionary *dictionary = iter->data;
+ list = e_spell_checker_list_available_dicts (checker);
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESpellDictionary *dictionary = link->data;
GtkToggleAction *action;
action = gtk_toggle_action_new (
@@ -1701,7 +1703,7 @@ editor_actions_setup_languages_menu (EEditor *editor)
GTK_UI_MANAGER_AUTO, FALSE);
}
- g_list_free (available_dicts);
+ g_list_free (list);
}
static void
@@ -1761,7 +1763,7 @@ editor_actions_setup_spell_check_menu (EEditor *editor)
G_CALLBACK (action_context_spell_add_cb), editor);
/* Visibility is dependent on whether the
- corresponding language action is active. */
+ * corresponding language action is active. */
gtk_action_set_visible (action, FALSE);
gtk_action_group_add_action (action_group, action);
diff --git a/e-util/e-editor-actions.h b/e-util/e-editor-actions.h
index 4d50ac7..8f987d5 100644
--- a/e-util/e-editor-actions.h
+++ b/e-util/e-editor-actions.h
@@ -151,4 +151,5 @@
E_EDITOR_ACTION ((editor), "unindent")
#define E_EDITOR_ACTION_WEBKIT_INSPECTOR(editor) \
E_EDITOR_ACTION ((editor), "webkit-inspector")
+
#endif /* E_EDITOR_ACTIONS_H */
diff --git a/e-util/e-editor-cell-dialog.c b/e-util/e-editor-cell-dialog.c
index 13640e3..7314a9a 100644
--- a/e-util/e-editor-cell-dialog.c
+++ b/e-util/e-editor-cell-dialog.c
@@ -32,17 +32,9 @@
#include "e-image-chooser-dialog.h"
#include "e-misc-utils.h"
-G_DEFINE_TYPE (
- EEditorCellDialog,
- e_editor_cell_dialog,
- E_TYPE_EDITOR_DIALOG);
-
-enum {
- SCOPE_CELL,
- SCOPE_ROW,
- SCOPE_COLUMN,
- SCOPE_TABLE
-} DialogScope;
+#define E_EDITOR_CELL_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_CELL_DIALOG, EEditorCellDialogPrivate))
struct _EEditorCellDialogPrivate {
GtkWidget *scope_cell_button;
@@ -70,17 +62,29 @@ struct _EEditorCellDialogPrivate {
guint scope;
};
+enum {
+ SCOPE_CELL,
+ SCOPE_ROW,
+ SCOPE_COLUMN,
+ SCOPE_TABLE
+} DialogScope;
+
static GdkRGBA white = { 1, 1, 1, 1 };
typedef void (*DOMStrFunc) (WebKitDOMHTMLTableCellElement *cell, const gchar *val, gpointer user_data);
typedef void (*DOMUlongFunc) (WebKitDOMHTMLTableCellElement *cell, gulong val, gpointer user_data);
typedef void (*DOMBoolFunc) (WebKitDOMHTMLTableCellElement *cell, gboolean val, gpointer user_data);
+G_DEFINE_TYPE (
+ EEditorCellDialog,
+ e_editor_cell_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
static void
call_cell_dom_func (WebKitDOMHTMLTableCellElement *cell,
- gpointer func,
- GValue *value,
- gpointer user_data)
+ gpointer func,
+ GValue *value,
+ gpointer user_data)
{
if (G_VALUE_HOLDS_STRING (value)) {
DOMStrFunc f = func;
@@ -96,9 +100,9 @@ call_cell_dom_func (WebKitDOMHTMLTableCellElement *cell,
static void
for_each_cell_do (WebKitDOMElement *row,
- gpointer func,
- GValue *value,
- gpointer user_data)
+ gpointer func,
+ GValue *value,
+ gpointer user_data)
{
WebKitDOMHTMLCollection *cells;
gulong ii, length;
@@ -119,9 +123,9 @@ for_each_cell_do (WebKitDOMElement *row,
static void
editor_cell_dialog_set_attribute (EEditorCellDialog *dialog,
- gpointer func,
- GValue *value,
- gpointer user_data)
+ gpointer func,
+ GValue *value,
+ gpointer user_data)
{
if (dialog->priv->scope == SCOPE_CELL) {
@@ -201,7 +205,6 @@ editor_cell_dialog_set_attribute (EEditorCellDialog *dialog,
}
}
-
static void
editor_cell_dialog_set_scope (EEditorCellDialog *dialog)
{
@@ -268,19 +271,19 @@ editor_cell_dialog_set_wrap_text (EEditorCellDialog *dialog)
GValue val = { 0 };
g_value_init (&val, G_TYPE_BOOLEAN);
- g_value_set_boolean (&val,
+ g_value_set_boolean (
+ &val,
!gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (dialog->priv->wrap_text_check)));
-
editor_cell_dialog_set_attribute (
dialog, webkit_dom_html_table_cell_element_set_no_wrap, &val, NULL);
}
static void
cell_set_header_style (WebKitDOMHTMLTableCellElement *cell,
- gboolean header_style,
- gpointer user_data)
+ gboolean header_style,
+ gpointer user_data)
{
EEditorCellDialog *dialog = user_data;
WebKitDOMDocument *document;
@@ -338,11 +341,11 @@ editor_cell_dialog_set_header_style (EEditorCellDialog *dialog)
GValue val = { 0 };
g_value_init (&val, G_TYPE_BOOLEAN);
- g_value_set_boolean (&val,
+ g_value_set_boolean (
+ &val,
gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (dialog->priv->header_style_check)));
-
editor_cell_dialog_set_attribute (
dialog, cell_set_header_style, &val, dialog);
}
@@ -359,7 +362,8 @@ editor_cell_dialog_set_width (EEditorCellDialog *dialog)
width = g_strdup ("auto");
} else {
- width = g_strdup_printf ("%d%s",
+ width = g_strdup_printf (
+ "%d%s",
gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->width_edit)),
((gtk_combo_box_get_active (
@@ -381,7 +385,8 @@ editor_cell_dialog_set_column_span (EEditorCellDialog *dialog)
GValue val = { 0 };
g_value_init (&val, G_TYPE_ULONG);
- g_value_set_ulong (&val,
+ g_value_set_ulong (
+ &val,
gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->col_span_edit)));
@@ -395,7 +400,8 @@ editor_cell_dialog_set_row_span (EEditorCellDialog *dialog)
GValue val = { 0 };
g_value_init (&val, G_TYPE_ULONG);
- g_value_set_ulong (&val,
+ g_value_set_ulong (
+ &val,
gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->row_span_edit)));
@@ -425,8 +431,8 @@ editor_cell_dialog_set_background_color (EEditorCellDialog *dialog)
static void
cell_set_background_image (WebKitDOMHTMLTableCellElement *cell,
- const gchar *uri,
- gpointer user_data)
+ const gchar *uri,
+ gpointer user_data)
{
if (!uri || !*uri) {
webkit_dom_element_remove_attribute (
@@ -454,13 +460,13 @@ editor_cell_dialog_set_background_image (EEditorCellDialog *dialog)
}
static void
-editor_cell_dialog_show (GtkWidget *gtk_widget)
+editor_cell_dialog_show (GtkWidget *widget)
{
EEditorCellDialog *dialog;
gchar *tmp;
GdkRGBA color;
- dialog = E_EDITOR_CELL_DIALOG (gtk_widget);
+ dialog = E_EDITOR_CELL_DIALOG (widget);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dialog->priv->scope_cell_button), TRUE);
@@ -549,23 +555,20 @@ editor_cell_dialog_show (GtkWidget *gtk_widget)
}
g_free (tmp);
-
- GTK_WIDGET_CLASS (e_editor_cell_dialog_parent_class)->show (gtk_widget);
+ GTK_WIDGET_CLASS (e_editor_cell_dialog_parent_class)->show (widget);
}
static void
-e_editor_cell_dialog_class_init (EEditorCellDialogClass *klass)
+e_editor_cell_dialog_class_init (EEditorCellDialogClass *class)
{
GtkWidgetClass *widget_class;
- e_editor_cell_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorCellDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorCellDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_cell_dialog_show;
}
-
static void
e_editor_cell_dialog_init (EEditorCellDialog *dialog)
{
@@ -573,8 +576,7 @@ e_editor_cell_dialog_init (EEditorCellDialog *dialog)
GtkWidget *widget;
GtkFileFilter *file_filter;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_CELL_DIALOG, EEditorCellDialogPrivate);
+ dialog->priv = E_EDITOR_CELL_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -594,8 +596,8 @@ e_editor_cell_dialog_init (EEditorCellDialog *dialog)
widget = gtk_image_new_from_icon_name ("stock_select-cell", GTK_ICON_SIZE_BUTTON);
gtk_grid_attach (grid, widget, 0, 0, 1, 1);
- widget = gtk_radio_button_new_with_mnemonic(NULL, _("C_ell"));
- gtk_grid_attach (grid, widget, 1, 0, 1, 1);
+ widget = gtk_radio_button_new_with_mnemonic (NULL, _("C_ell"));
+ gtk_grid_attach (grid, widget, 1, 0, 1, 1);
dialog->priv->scope_cell_button = widget;
g_signal_connect_swapped (
@@ -829,7 +831,6 @@ e_editor_cell_dialog_init (EEditorCellDialog *dialog)
G_CALLBACK (editor_cell_dialog_set_background_image), dialog);
dialog->priv->background_image_chooser = widget;
-
widget =gtk_label_new_with_mnemonic (_("_Image:"));
gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_RIGHT);
gtk_label_set_mnemonic_widget (
@@ -839,7 +840,6 @@ e_editor_cell_dialog_init (EEditorCellDialog *dialog)
gtk_widget_show_all (GTK_WIDGET (main_layout));
}
-
GtkWidget *
e_editor_cell_dialog_new (EEditor *editor)
{
@@ -853,9 +853,9 @@ e_editor_cell_dialog_new (EEditor *editor)
void
e_editor_cell_dialog_show (EEditorCellDialog *dialog,
- WebKitDOMNode *cell)
+ WebKitDOMNode *cell)
{
- EEditorCellDialogClass *klass;
+ EEditorCellDialogClass *class;
g_return_if_fail (E_IS_EDITOR_CELL_DIALOG (dialog));
g_return_if_fail (cell != NULL);
@@ -866,8 +866,7 @@ e_editor_cell_dialog_show (EEditorCellDialog *dialog,
e_editor_dom_node_find_parent_element (cell, "TH");
}
- klass = E_EDITOR_CELL_DIALOG_GET_CLASS (dialog);
- GTK_WIDGET_CLASS (klass)->show (GTK_WIDGET (dialog));
+ class = E_EDITOR_CELL_DIALOG_GET_CLASS (dialog);
+ GTK_WIDGET_CLASS (class)->show (GTK_WIDGET (dialog));
}
-
diff --git a/e-util/e-editor-cell-dialog.h b/e-util/e-editor-cell-dialog.h
index 62a4009..1393948 100644
--- a/e-util/e-editor-cell-dialog.h
+++ b/e-util/e-editor-cell-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorCellDialogPrivate EEditorCellDialogPrivate;
struct _EEditorCellDialog {
EEditorDialog parent;
-
EEditorCellDialogPrivate *priv;
};
@@ -62,10 +61,8 @@ struct _EEditorCellDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_cell_dialog_get_type (void);
-
-GtkWidget* e_editor_cell_dialog_new (EEditor *editor);
-
+GType e_editor_cell_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_cell_dialog_new (EEditor *editor);
void e_editor_cell_dialog_show (EEditorCellDialog *dialog,
WebKitDOMNode *cell);
diff --git a/e-util/e-editor-dialog.c b/e-util/e-editor-dialog.c
index 368385f..3afd2ad 100644
--- a/e-util/e-editor-dialog.c
+++ b/e-util/e-editor-dialog.c
@@ -24,10 +24,9 @@
#include "e-editor-dialog.h"
-G_DEFINE_ABSTRACT_TYPE (
- EEditorDialog,
- e_editor_dialog,
- GTK_TYPE_WINDOW);
+#define E_EDITOR_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_DIALOG, EEditorDialogPrivate))
struct _EEditorDialogPrivate {
EEditor *editor;
@@ -41,10 +40,14 @@ enum {
PROP_EDITOR,
};
+G_DEFINE_ABSTRACT_TYPE (
+ EEditorDialog,
+ e_editor_dialog,
+ GTK_TYPE_WINDOW);
static void
editor_dialog_set_editor (EEditorDialog *dialog,
- EEditor *editor)
+ EEditor *editor)
{
dialog->priv->editor = g_object_ref (editor);
@@ -53,13 +56,14 @@ editor_dialog_set_editor (EEditorDialog *dialog,
static void
editor_dialog_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_EDITOR:
- g_value_set_object (value,
+ g_value_set_object (
+ value,
e_editor_dialog_get_editor (E_EDITOR_DIALOG (object)));
return;
}
@@ -69,9 +73,9 @@ editor_dialog_get_property (GObject *object,
static void
editor_dialog_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_EDITOR:
@@ -101,8 +105,12 @@ editor_dialog_constructed (GObject *object)
static void
editor_dialog_show (GtkWidget *widget)
{
- gtk_widget_show_all (GTK_WIDGET (E_EDITOR_DIALOG (widget)->priv->container));
- gtk_widget_show_all (GTK_WIDGET (E_EDITOR_DIALOG (widget)->priv->button_box));
+ EEditorDialogPrivate *priv;
+
+ priv = E_EDITOR_DIALOG_GET_PRIVATE (widget);
+
+ gtk_widget_show_all (GTK_WIDGET (priv->container));
+ gtk_widget_show_all (GTK_WIDGET (priv->button_box));
GTK_WIDGET_CLASS (e_editor_dialog_parent_class)->show (widget);
}
@@ -110,7 +118,9 @@ editor_dialog_show (GtkWidget *widget)
static void
editor_dialog_dispose (GObject *object)
{
- EEditorDialogPrivate *priv = E_EDITOR_DIALOG (object)->priv;
+ EEditorDialogPrivate *priv;
+
+ priv = E_EDITOR_DIALOG_GET_PRIVATE (object);
g_clear_object (&priv->editor);
@@ -119,21 +129,20 @@ editor_dialog_dispose (GObject *object)
}
static void
-e_editor_dialog_class_init (EEditorDialogClass *klass)
+e_editor_dialog_class_init (EEditorDialogClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorDialogPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->get_property = editor_dialog_get_property;
object_class->set_property = editor_dialog_set_property;
object_class->dispose = editor_dialog_dispose;
object_class->constructed = editor_dialog_constructed;
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_dialog_show;
g_object_class_install_property (
@@ -141,10 +150,10 @@ e_editor_dialog_class_init (EEditorDialogClass *klass)
PROP_EDITOR,
g_param_spec_object (
"editor",
- NULL,
- NULL,
- E_TYPE_EDITOR,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+ NULL,
+ NULL,
+ E_TYPE_EDITOR,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
}
static void
@@ -154,8 +163,7 @@ e_editor_dialog_init (EEditorDialog *dialog)
GtkGrid *grid;
GtkWidget *widget, *button_box;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_DIALOG, EEditorDialogPrivate);
+ dialog->priv = E_EDITOR_DIALOG_GET_PRIVATE (dialog);
main_layout = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 5));
gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (main_layout));
@@ -185,7 +193,7 @@ e_editor_dialog_init (EEditorDialog *dialog)
g_object_set (
G_OBJECT (dialog),
"destroy-with-parent", TRUE,
- "modal", TRUE,
+ "modal", TRUE,
"resizable", FALSE,
"type-hint", GDK_WINDOW_TYPE_HINT_POPUP_MENU,
"window-position", GTK_WIN_POS_CENTER_ON_PARENT,
@@ -197,8 +205,6 @@ e_editor_dialog_init (EEditorDialog *dialog)
G_CALLBACK (gtk_widget_hide_on_delete), NULL);
}
-
-
EEditor *
e_editor_dialog_get_editor (EEditorDialog *dialog)
{
diff --git a/e-util/e-editor-dialog.h b/e-util/e-editor-dialog.h
index cfa44c0..9b6ff5b 100644
--- a/e-util/e-editor-dialog.h
+++ b/e-util/e-editor-dialog.h
@@ -55,7 +55,6 @@ typedef struct _EEditorDialogPrivate EEditorDialogPrivate;
struct _EEditorDialog {
GtkWindow parent;
-
EEditorDialogPrivate *priv;
};
@@ -63,12 +62,9 @@ struct _EEditorDialogClass {
GtkWindowClass parent_class;
};
-GType e_editor_dialog_get_type (void);
-
+GType e_editor_dialog_get_type (void) G_GNUC_CONST;
EEditor * e_editor_dialog_get_editor (EEditorDialog *dialog);
-
GtkBox * e_editor_dialog_get_button_box (EEditorDialog *dialog);
-
GtkGrid * e_editor_dialog_get_container (EEditorDialog *dialog);
G_END_DECLS
diff --git a/e-util/e-editor-find-dialog.c b/e-util/e-editor-find-dialog.c
index be22721..9aa68b9 100644
--- a/e-util/e-editor-find-dialog.c
+++ b/e-util/e-editor-find-dialog.c
@@ -27,10 +27,9 @@
#include <glib/gi18n-lib.h>
#include <gdk/gdkkeysyms.h>
-G_DEFINE_TYPE (
- EEditorFindDialog,
- e_editor_find_dialog,
- E_TYPE_EDITOR_DIALOG);
+#define E_EDITOR_FIND_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_FIND_DIALOG, EEditorFindDialogPrivate))
struct _EEditorFindDialogPrivate {
GtkWidget *entry;
@@ -43,6 +42,11 @@ struct _EEditorFindDialogPrivate {
GtkWidget *result_label;
};
+G_DEFINE_TYPE (
+ EEditorFindDialog,
+ e_editor_find_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
static void
reset_dialog (EEditorFindDialog *dialog)
{
@@ -104,8 +108,8 @@ editor_find_dialog_find_cb (EEditorFindDialog *dialog)
static gboolean
entry_key_release_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer user_data)
+ GdkEvent *event,
+ gpointer user_data)
{
GdkEventKey *key = &event->key;
EEditorFindDialog *dialog = user_data;
@@ -120,14 +124,13 @@ entry_key_release_event (GtkWidget *widget,
}
static void
-e_editor_find_dialog_class_init (EEditorFindDialogClass *klass)
+e_editor_find_dialog_class_init (EEditorFindDialogClass *class)
{
GtkWidgetClass *widget_class;
- e_editor_find_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorFindDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorFindDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_find_dialog_show;
}
@@ -138,8 +141,7 @@ e_editor_find_dialog_init (EEditorFindDialog *dialog)
GtkBox *box;
GtkWidget *widget;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_FIND_DIALOG, EEditorFindDialogPrivate);
+ dialog->priv = E_EDITOR_FIND_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -200,7 +202,7 @@ e_editor_find_dialog_init (EEditorFindDialog *dialog)
}
GtkWidget *
-e_editor_find_dialog_new(EEditor *editor)
+e_editor_find_dialog_new (EEditor *editor)
{
return GTK_WIDGET (
g_object_new (
diff --git a/e-util/e-editor-find-dialog.h b/e-util/e-editor-find-dialog.h
index 66a1556..922f301 100644
--- a/e-util/e-editor-find-dialog.h
+++ b/e-util/e-editor-find-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorFindDialogPrivate EEditorFindDialogPrivate;
struct _EEditorFindDialog {
EEditorDialog parent;
-
EEditorFindDialogPrivate *priv;
};
@@ -62,10 +61,8 @@ struct _EEditorFindDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_find_dialog_get_type (void);
-
-GtkWidget* e_editor_find_dialog_new (EEditor *editor);
-
+GType e_editor_find_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_find_dialog_new (EEditor *editor);
void e_editor_find_dialog_find_next (EEditorFindDialog *dialog);
G_END_DECLS
diff --git a/e-util/e-editor-hrule-dialog.c b/e-util/e-editor-hrule-dialog.c
index bca6b20..c954277 100644
--- a/e-util/e-editor-hrule-dialog.c
+++ b/e-util/e-editor-hrule-dialog.c
@@ -30,10 +30,9 @@
#include <webkit/webkitdom.h>
#include <stdlib.h>
-G_DEFINE_TYPE (
- EEditorHRuleDialog,
- e_editor_hrule_dialog,
- E_TYPE_EDITOR_DIALOG);
+#define E_EDITOR_HRULE_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_HRULE_DIALOG, EEditorHRuleDialogPrivate))
struct _EEditorHRuleDialogPrivate {
GtkWidget *width_edit;
@@ -46,6 +45,11 @@ struct _EEditorHRuleDialogPrivate {
WebKitDOMHTMLHRElement *hr_element;
};
+G_DEFINE_TYPE (
+ EEditorHRuleDialog,
+ e_editor_hrule_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
static void
editor_hrule_dialog_set_alignment (EEditorHRuleDialog *dialog)
{
@@ -191,11 +195,15 @@ editor_hrule_dialog_get_shading (EEditorHRuleDialog *dialog)
}
static void
-editor_hrule_dialog_hide (GtkWidget *gtk_widget)
+editor_hrule_dialog_hide (GtkWidget *widget)
{
- E_EDITOR_HRULE_DIALOG (gtk_widget)->priv->hr_element = NULL;
+ EEditorHRuleDialogPrivate *priv;
- GTK_WIDGET_CLASS (e_editor_hrule_dialog_parent_class)->hide (gtk_widget);
+ priv = E_EDITOR_HRULE_DIALOG_GET_PRIVATE (widget);
+
+ priv->hr_element = NULL;
+
+ GTK_WIDGET_CLASS (e_editor_hrule_dialog_parent_class)->hide (widget);
}
static void
@@ -272,14 +280,13 @@ editor_hrule_dialog_show (GtkWidget *widget)
}
static void
-e_editor_hrule_dialog_class_init (EEditorHRuleDialogClass *klass)
+e_editor_hrule_dialog_class_init (EEditorHRuleDialogClass *class)
{
GtkWidgetClass *widget_class;
- g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorHRuleDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorHRuleDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_hrule_dialog_show;
widget_class->hide = editor_hrule_dialog_hide;
}
@@ -290,8 +297,7 @@ e_editor_hrule_dialog_init (EEditorHRuleDialog *dialog)
GtkGrid *main_layout, *grid;
GtkWidget *widget;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_HRULE_DIALOG, EEditorHRuleDialogPrivate);
+ dialog->priv = E_EDITOR_HRULE_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -347,7 +353,6 @@ e_editor_hrule_dialog_init (EEditorHRuleDialog *dialog)
gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->size_edit);
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
-
/* == Style == */
widget = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL (widget), _("<b>Style</b>"));
diff --git a/e-util/e-editor-hrule-dialog.h b/e-util/e-editor-hrule-dialog.h
index 46877f7..fad94fc 100644
--- a/e-util/e-editor-hrule-dialog.h
+++ b/e-util/e-editor-hrule-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorHRuleDialogPrivate EEditorHRuleDialogPrivate;
struct _EEditorHRuleDialog {
EEditorDialog parent;
-
EEditorHRuleDialogPrivate *priv;
};
@@ -62,9 +61,8 @@ struct _EEditorHRuleDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_hrule_dialog_get_type (void);
-
-GtkWidget* e_editor_hrule_dialog_new (EEditor *editor);
+GType e_editor_hrule_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_hrule_dialog_new (EEditor *editor);
G_END_DECLS
diff --git a/e-util/e-editor-image-dialog.c b/e-util/e-editor-image-dialog.c
index d2d0f11..fc277df 100644
--- a/e-util/e-editor-image-dialog.c
+++ b/e-util/e-editor-image-dialog.c
@@ -30,10 +30,9 @@
#include "e-editor-utils.h"
#include "e-image-chooser-dialog.h"
-G_DEFINE_TYPE (
- EEditorImageDialog,
- e_editor_image_dialog,
- E_TYPE_EDITOR_DIALOG);
+#define E_EDITOR_IMAGE_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_IMAGE_DIALOG, EEditorImageDialogPrivate))
struct _EEditorImageDialogPrivate {
GtkWidget *file_chooser;
@@ -55,6 +54,11 @@ struct _EEditorImageDialogPrivate {
WebKitDOMHTMLImageElement *image;
};
+G_DEFINE_TYPE (
+ EEditorImageDialog,
+ e_editor_image_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
static void
editor_image_dialog_set_src (EEditorImageDialog *dialog)
{
@@ -116,7 +120,6 @@ editor_image_dialog_set_width_units (EEditorImageDialog *dialog)
requested = gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->width_edit));
-
switch (gtk_combo_box_get_active (
GTK_COMBO_BOX (dialog->priv->width_units))) {
@@ -193,7 +196,6 @@ editor_image_dialog_set_height_units (EEditorImageDialog *dialog)
requested = gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->height_edit));
-
switch (gtk_combo_box_get_active (
GTK_COMBO_BOX (dialog->priv->height_units))) {
@@ -328,14 +330,14 @@ editor_image_dialog_test_url (EEditorImageDialog *dialog)
}
static void
-editor_image_dialog_show (GtkWidget *gtk_widget)
+editor_image_dialog_show (GtkWidget *widget)
{
EEditorImageDialog *dialog;
WebKitDOMElement *link;
gchar *tmp;
glong val;
- dialog = E_EDITOR_IMAGE_DIALOG (gtk_widget);
+ dialog = E_EDITOR_IMAGE_DIALOG (widget);
if (!dialog->priv->image) {
return;
@@ -376,7 +378,6 @@ editor_image_dialog_show (GtkWidget *gtk_widget)
gtk_spin_button_set_value (
GTK_SPIN_BUTTON (dialog->priv->y_padding_edit), val);
-
link = e_editor_dom_node_find_parent_element (
WEBKIT_DOM_NODE (dialog->priv->image), "A");
if (link) {
@@ -387,26 +388,29 @@ editor_image_dialog_show (GtkWidget *gtk_widget)
}
/* Chain up to parent implementation */
- GTK_WIDGET_CLASS (e_editor_image_dialog_parent_class)->show (gtk_widget);
+ GTK_WIDGET_CLASS (e_editor_image_dialog_parent_class)->show (widget);
}
static void
-editor_image_dialog_hide (GtkWidget *gtk_widget)
+editor_image_dialog_hide (GtkWidget *widget)
{
- E_EDITOR_IMAGE_DIALOG (gtk_widget)->priv->image = NULL;
+ EEditorImageDialogPrivate *priv;
- GTK_WIDGET_CLASS (e_editor_image_dialog_parent_class)->hide (gtk_widget);
+ priv = E_EDITOR_IMAGE_DIALOG_GET_PRIVATE (widget);
+
+ priv->image = NULL;
+
+ GTK_WIDGET_CLASS (e_editor_image_dialog_parent_class)->hide (widget);
}
static void
-e_editor_image_dialog_class_init (EEditorImageDialogClass *klass)
+e_editor_image_dialog_class_init (EEditorImageDialogClass *class)
{
GtkWidgetClass *widget_class;
- e_editor_image_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorImageDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorImageDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_image_dialog_show;
widget_class->hide = editor_image_dialog_hide;
}
@@ -418,8 +422,7 @@ e_editor_image_dialog_init (EEditorImageDialog *dialog)
GtkWidget *widget;
GtkFileFilter *file_filter;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_IMAGE_DIALOG, EEditorImageDialogPrivate);
+ dialog->priv = E_EDITOR_IMAGE_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -473,7 +476,6 @@ e_editor_image_dialog_init (EEditorImageDialog *dialog)
gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->description_edit);
gtk_grid_attach (grid, widget, 0, 1, 1, 1);
-
/* == Layout == */
widget = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL (widget), _("<b>Layout</b>"));
@@ -647,9 +649,9 @@ e_editor_image_dialog_new (EEditor *editor)
void
e_editor_image_dialog_show (EEditorImageDialog *dialog,
- WebKitDOMNode *image)
+ WebKitDOMNode *image)
{
- EEditorImageDialogClass *klass;
+ EEditorImageDialogClass *class;
g_return_if_fail (E_IS_EDITOR_IMAGE_DIALOG (dialog));
@@ -659,6 +661,6 @@ e_editor_image_dialog_show (EEditorImageDialog *dialog,
dialog->priv->image = NULL;
}
- klass = E_EDITOR_IMAGE_DIALOG_GET_CLASS (dialog);
- GTK_WIDGET_CLASS (klass)->show (GTK_WIDGET (dialog));
+ class = E_EDITOR_IMAGE_DIALOG_GET_CLASS (dialog);
+ GTK_WIDGET_CLASS (class)->show (GTK_WIDGET (dialog));
}
diff --git a/e-util/e-editor-image-dialog.h b/e-util/e-editor-image-dialog.h
index 21f7a93..aeb5aa1 100644
--- a/e-util/e-editor-image-dialog.h
+++ b/e-util/e-editor-image-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorImageDialogPrivate EEditorImageDialogPrivate;
struct _EEditorImageDialog {
EEditorDialog parent;
-
EEditorImageDialogPrivate *priv;
};
@@ -62,10 +61,8 @@ struct _EEditorImageDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_image_dialog_get_type (void);
-
-GtkWidget* e_editor_image_dialog_new (EEditor *editor);
-
+GType e_editor_image_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_image_dialog_new (EEditor *editor);
void e_editor_image_dialog_show (EEditorImageDialog *dialog,
WebKitDOMNode *image);
diff --git a/e-util/e-editor-link-dialog.c b/e-util/e-editor-link-dialog.c
index ea75db8..1674e19 100644
--- a/e-util/e-editor-link-dialog.c
+++ b/e-util/e-editor-link-dialog.c
@@ -29,6 +29,10 @@
#include <glib/gi18n-lib.h>
+#define E_EDITOR_LINK_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_LINK_DIALOG, EEditorLinkDialogPrivate))
+
G_DEFINE_TYPE (
EEditorLinkDialog,
e_editor_link_dialog,
@@ -128,7 +132,7 @@ editor_link_dialog_ok (EEditorLinkDialog *dialog)
if ((webkit_dom_range_get_start_container (range, NULL) !=
webkit_dom_range_get_end_container (range, NULL)) ||
(webkit_dom_range_get_start_offset (range, NULL) !=
- webkit_dom_range_get_end_offset (range, NULL))) {
+ webkit_dom_range_get_end_offset (range, NULL))) {
WebKitDOMDocumentFragment *fragment;
fragment = webkit_dom_range_extract_contents (range, NULL);
@@ -184,7 +188,7 @@ editor_link_dialog_ok (EEditorLinkDialog *dialog)
static gboolean
editor_link_dialog_entry_key_pressed (EEditorLinkDialog *dialog,
- GdkEventKey *event)
+ GdkEventKey *event)
{
/* We can't do thins in key_released, because then you could not open
* this dialog from main menu by pressing enter on Insert->Link action */
@@ -196,7 +200,6 @@ editor_link_dialog_entry_key_pressed (EEditorLinkDialog *dialog,
return FALSE;
}
-
static void
editor_link_dialog_show (GtkWidget *widget)
{
@@ -238,7 +241,7 @@ editor_link_dialog_show (GtkWidget *widget)
if ((webkit_dom_range_get_start_container (range, NULL) !=
webkit_dom_range_get_end_container (range, NULL)) ||
(webkit_dom_range_get_start_offset (range, NULL) !=
- webkit_dom_range_get_end_offset (range, NULL))) {
+ webkit_dom_range_get_end_offset (range, NULL))) {
WebKitDOMDocumentFragment *fragment;
fragment = webkit_dom_range_clone_contents (range, NULL);
@@ -284,14 +287,13 @@ editor_link_dialog_show (GtkWidget *widget)
}
static void
-e_editor_link_dialog_class_init (EEditorLinkDialogClass *klass)
+e_editor_link_dialog_class_init (EEditorLinkDialogClass *class)
{
GtkWidgetClass *widget_class;
- e_editor_link_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorLinkDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorLinkDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_link_dialog_show;
}
@@ -302,9 +304,7 @@ e_editor_link_dialog_init (EEditorLinkDialog *dialog)
GtkBox *button_box;
GtkWidget *widget;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_LINK_DIALOG,
- EEditorLinkDialogPrivate);
+ dialog->priv = E_EDITOR_LINK_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
diff --git a/e-util/e-editor-link-dialog.h b/e-util/e-editor-link-dialog.h
index 921d718..99141b0 100644
--- a/e-util/e-editor-link-dialog.h
+++ b/e-util/e-editor-link-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorLinkDialogPrivate EEditorLinkDialogPrivate;
struct _EEditorLinkDialog {
EEditorDialog parent;
-
EEditorLinkDialogPrivate *priv;
};
@@ -62,9 +61,8 @@ struct _EEditorLinkDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_link_dialog_get_type (void);
-
-GtkWidget* e_editor_link_dialog_new (EEditor *editor);
+GType e_editor_link_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_link_dialog_new (EEditor *editor);
G_END_DECLS
diff --git a/e-util/e-editor-page-dialog.c b/e-util/e-editor-page-dialog.c
index a5681e3..1932872 100644
--- a/e-util/e-editor-page-dialog.c
+++ b/e-util/e-editor-page-dialog.c
@@ -29,10 +29,9 @@
#include "e-color-combo.h"
#include "e-misc-utils.h"
-G_DEFINE_TYPE (
- EEditorPageDialog,
- e_editor_page_dialog,
- E_TYPE_EDITOR_DIALOG);
+#define E_EDITOR_PAGE_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_PAGE_DIALOG, EEditorPageDialogPrivate))
struct _EEditorPageDialogPrivate {
GtkWidget *text_color_picker;
@@ -134,9 +133,13 @@ static const Template templates[] = {
{ 1.0 , 1.0 , 1.0 , 1 },
0
}
-
};
+G_DEFINE_TYPE (
+ EEditorPageDialog,
+ e_editor_page_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
static void
editor_page_dialog_set_text_color (EEditorPageDialog *dialog)
{
@@ -147,7 +150,7 @@ editor_page_dialog_set_text_color (EEditorPageDialog *dialog)
GdkRGBA rgba;
gchar *color;
- editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ 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);
@@ -155,7 +158,7 @@ editor_page_dialog_set_text_color (EEditorPageDialog *dialog)
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));
+ color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
webkit_dom_html_body_element_set_text (
(WebKitDOMHTMLBodyElement *) body, color);
@@ -172,7 +175,7 @@ editor_page_dialog_set_link_color (EEditorPageDialog *dialog)
GdkRGBA rgba;
gchar *color;
- editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ 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);
@@ -180,7 +183,7 @@ editor_page_dialog_set_link_color (EEditorPageDialog *dialog)
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));
+ color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
webkit_dom_html_body_element_set_link (
(WebKitDOMHTMLBodyElement *) body, color);
@@ -197,7 +200,7 @@ editor_page_dialog_set_background_color (EEditorPageDialog *dialog)
GdkRGBA rgba;
gchar *color;
- editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ 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);
@@ -205,7 +208,7 @@ editor_page_dialog_set_background_color (EEditorPageDialog *dialog)
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));
+ color = g_strdup_printf ("#%06x", e_rgba_to_value (&rgba));
webkit_dom_html_body_element_set_bg_color (
(WebKitDOMHTMLBodyElement *) body, color);
@@ -222,7 +225,6 @@ editor_page_dialog_set_background_from_template (EEditorPageDialog *dialog)
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 (
@@ -259,7 +261,7 @@ editor_page_dialog_set_background_image (EEditorPageDialog *dialog)
WebKitDOMHTMLElement *body;
gchar *uri;
- editor = e_editor_dialog_get_editor(E_EDITOR_DIALOG (dialog));
+ 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);
@@ -369,19 +371,17 @@ editor_page_dialog_show (GtkWidget *widget)
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)
+e_editor_page_dialog_class_init (EEditorPageDialogClass *class)
{
GtkWidgetClass *widget_class;
- e_editor_page_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorPageDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorPageDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_page_dialog_show;
}
@@ -392,8 +392,7 @@ e_editor_page_dialog_init (EEditorPageDialog *dialog)
GtkWidget *widget;
gint ii;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_PAGE_DIALOG, EEditorPageDialogPrivate);
+ dialog->priv = E_EDITOR_PAGE_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -502,7 +501,6 @@ e_editor_page_dialog_init (EEditorPageDialog *dialog)
gtk_widget_show_all (GTK_WIDGET (main_layout));
}
-
GtkWidget *
e_editor_page_dialog_new (EEditor *editor)
{
diff --git a/e-util/e-editor-page-dialog.h b/e-util/e-editor-page-dialog.h
index 145a092..b794cb5 100644
--- a/e-util/e-editor-page-dialog.h
+++ b/e-util/e-editor-page-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorPageDialogPrivate EEditorPageDialogPrivate;
struct _EEditorPageDialog {
EEditorDialog parent;
-
EEditorPageDialogPrivate *priv;
};
@@ -62,9 +61,8 @@ struct _EEditorPageDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_page_dialog_get_type (void);
-
-GtkWidget* e_editor_page_dialog_new (EEditor *editor);
+GType e_editor_page_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_page_dialog_new (EEditor *editor);
G_END_DECLS
diff --git a/e-util/e-editor-paragraph-dialog.c b/e-util/e-editor-paragraph-dialog.c
index 477ce10..1a12976 100644
--- a/e-util/e-editor-paragraph-dialog.c
+++ b/e-util/e-editor-paragraph-dialog.c
@@ -28,6 +28,10 @@
#include "e-action-combo-box.h"
+#define E_EDITOR_PARAGRAPH_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_PARAGRAPH_DIALOG, EEditorParagraphDialogPrivate))
+
G_DEFINE_TYPE (
EEditorParagraphDialog,
e_editor_paragraph_dialog,
@@ -121,22 +125,21 @@ editor_paragraph_dialog_constructed (GObject *object)
}
static void
-e_editor_paragraph_dialog_class_init (EEditorParagraphDialogClass *klass)
+e_editor_paragraph_dialog_class_init (EEditorParagraphDialogClass *class)
{
GObjectClass *object_class;
- e_editor_paragraph_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorParagraphDialogPrivate));
+ g_type_class_add_private (
+ class, sizeof (EEditorParagraphDialogPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->constructed = editor_paragraph_dialog_constructed;
}
static void
e_editor_paragraph_dialog_init (EEditorParagraphDialog *dialog)
{
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_PARAGRAPH_DIALOG, EEditorParagraphDialogPrivate);
+ dialog->priv = E_EDITOR_PARAGRAPH_DIALOG_GET_PRIVATE (dialog);
}
GtkWidget *
diff --git a/e-util/e-editor-paragraph-dialog.h b/e-util/e-editor-paragraph-dialog.h
index 1c8f0e7..ed5e4f5 100644
--- a/e-util/e-editor-paragraph-dialog.h
+++ b/e-util/e-editor-paragraph-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorParagraphDialogPrivate EEditorParagraphDialogPrivate;
struct _EEditorParagraphDialog {
EEditorDialog parent;
-
EEditorParagraphDialogPrivate *priv;
};
@@ -62,9 +61,9 @@ struct _EEditorParagraphDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_paragraph_dialog_get_type (void);
-
-GtkWidget* e_editor_paragraph_dialog_new (EEditor *editor);
+GType e_editor_paragraph_dialog_get_type
+ (void) G_GNUC_CONST;
+GtkWidget * e_editor_paragraph_dialog_new (EEditor *editor);
G_END_DECLS
diff --git a/e-util/e-editor-private.h b/e-util/e-editor-private.h
index e62f825..cf313f6 100644
--- a/e-util/e-editor-private.h
+++ b/e-util/e-editor-private.h
@@ -42,7 +42,6 @@
#include <X11/XF86keysym.h>
#endif
-
#define ACTION(name) (E_EDITOR_ACTION_##name (editor))
#define WIDGET(name) (E_EDITOR_WIDGETS_##name (editor))
@@ -93,7 +92,7 @@ struct _EEditorPrivate {
WebKitDOMNode *image;
WebKitDOMNode *table_cell;
- int editor_layout_row;
+ gint editor_layout_row;
};
void editor_actions_init (EEditor *editor);
diff --git a/e-util/e-editor-replace-dialog.c b/e-util/e-editor-replace-dialog.c
index c396b17..4f7b64b 100644
--- a/e-util/e-editor-replace-dialog.c
+++ b/e-util/e-editor-replace-dialog.c
@@ -26,6 +26,10 @@
#include <glib/gi18n-lib.h>
+#define E_EDITOR_REPLACE_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_REPLACE_DIALOG, EEditorReplaceDialogPrivate))
+
G_DEFINE_TYPE (
EEditorReplaceDialog,
e_editor_replace_dialog,
@@ -128,7 +132,7 @@ editor_replace_dialog_replace_all_cb (EEditorReplaceDialog *dialog)
while (jump (dialog)) {
e_editor_selection_replace (selection, replacement);
i++;
-
+
/* Jump behind the word */
e_editor_selection_move (selection, TRUE, E_EDITOR_SELECTION_GRANULARITY_WORD);
}
@@ -166,14 +170,13 @@ editor_replace_dialog_show (GtkWidget *widget)
}
static void
-e_editor_replace_dialog_class_init (EEditorReplaceDialogClass *klass)
+e_editor_replace_dialog_class_init (EEditorReplaceDialogClass *class)
{
GtkWidgetClass *widget_class;
- e_editor_replace_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorReplaceDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorReplaceDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_replace_dialog_show;
}
@@ -184,9 +187,7 @@ e_editor_replace_dialog_init (EEditorReplaceDialog *dialog)
GtkWidget *widget, *layout;
GtkBox *button_box;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_REPLACE_DIALOG,
- EEditorReplaceDialogPrivate);
+ dialog->priv = E_EDITOR_REPLACE_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
diff --git a/e-util/e-editor-replace-dialog.h b/e-util/e-editor-replace-dialog.h
index f6c80ee..4ee9f7e 100644
--- a/e-util/e-editor-replace-dialog.h
+++ b/e-util/e-editor-replace-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorReplaceDialogPrivate EEditorReplaceDialogPrivate;
struct _EEditorReplaceDialog {
EEditorDialog parent;
-
EEditorReplaceDialogPrivate *priv;
};
@@ -62,9 +61,9 @@ struct _EEditorReplaceDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_replace_dialog_get_type (void);
-
-GtkWidget* e_editor_replace_dialog_new (EEditor *editor);
+GType e_editor_replace_dialog_get_type
+ (void) G_GNUC_CONST;
+GtkWidget * e_editor_replace_dialog_new (EEditor *editor);
G_END_DECLS
diff --git a/e-util/e-editor-selection.c b/e-util/e-editor-selection.c
index 2b1fde5..56a770e 100644
--- a/e-util/e-editor-selection.c
+++ b/e-util/e-editor-selection.c
@@ -41,19 +41,12 @@
#define WORD_WRAP_LENGTH 71
-
-G_DEFINE_TYPE (
- EEditorSelection,
- e_editor_selection,
- G_TYPE_OBJECT
-);
-
/**
* EEditorSelection:
*
* The #EEditorSelection object represents current position of the cursor
* with the editor or current text selection within the editor. To obtain
- * valid #EEditorSelection, call #e_editor_widget_get_selection().
+ * valid #EEditorSelection, call e_editor_widget_get_selection().
*/
struct _EEditorSelectionPrivate {
@@ -70,14 +63,14 @@ struct _EEditorSelectionPrivate {
enum {
PROP_0,
- PROP_EDITOR_WIDGET,
PROP_ALIGNMENT,
PROP_BACKGROUND_COLOR,
+ PROP_BLOCK_FORMAT,
PROP_BOLD,
+ PROP_EDITOR_WIDGET,
+ PROP_FONT_COLOR,
PROP_FONT_NAME,
PROP_FONT_SIZE,
- PROP_FONT_COLOR,
- PROP_BLOCK_FORMAT,
PROP_INDENTED,
PROP_ITALIC,
PROP_MONOSPACED,
@@ -85,11 +78,17 @@ enum {
PROP_SUBSCRIPT,
PROP_SUPERSCRIPT,
PROP_TEXT,
- PROP_UNDERLINE,
+ PROP_UNDERLINE
};
static const GdkRGBA black = { 0 };
+G_DEFINE_TYPE (
+ EEditorSelection,
+ e_editor_selection,
+ G_TYPE_OBJECT
+);
+
static WebKitDOMRange *
editor_selection_get_current_range (EEditorSelection *selection)
{
@@ -99,21 +98,19 @@ editor_selection_get_current_range (EEditorSelection *selection)
document = webkit_web_view_get_dom_document (selection->priv->webview);
window = webkit_dom_document_get_default_view (document);
- if (!window) {
+ if (window == NULL)
return NULL;
- }
dom_selection = webkit_dom_dom_window_get_selection (window);
- if (webkit_dom_dom_selection_get_range_count (dom_selection) < 1) {
+ if (webkit_dom_dom_selection_get_range_count (dom_selection) < 1)
return NULL;
- }
return webkit_dom_dom_selection_get_range_at (dom_selection, 0, NULL);
}
static gboolean
get_has_style (EEditorSelection *selection,
- const gchar *style_tag)
+ const gchar *style_tag)
{
WebKitDOMNode *node;
WebKitDOMElement *element;
@@ -121,18 +118,15 @@ get_has_style (EEditorSelection *selection,
gboolean result;
gint tag_len;
-
range = editor_selection_get_current_range (selection);
- if (!range) {
+ if (range == NULL)
return FALSE;
- }
node = webkit_dom_range_get_start_container (range, NULL);
- if (!WEBKIT_DOM_IS_ELEMENT (node)) {
- element = webkit_dom_node_get_parent_element (node);
- } else {
+ if (WEBKIT_DOM_IS_ELEMENT (node))
element = WEBKIT_DOM_ELEMENT (node);
- }
+ else
+ element = webkit_dom_node_get_parent_element (node);
tag_len = strlen (style_tag);
result = FALSE;
@@ -167,12 +161,11 @@ get_has_style (EEditorSelection *selection,
g_free (element_tag);
- if (result) {
+ if (result)
break;
- }
element = webkit_dom_node_get_parent_element (
- WEBKIT_DOM_NODE (element));
+ WEBKIT_DOM_NODE (element));
}
return result;
@@ -180,7 +173,7 @@ get_has_style (EEditorSelection *selection,
static gchar *
get_font_property (EEditorSelection *selection,
- const gchar *font_property)
+ const gchar *font_property)
{
WebKitDOMRange *range;
WebKitDOMNode *node;
@@ -188,15 +181,13 @@ get_font_property (EEditorSelection *selection,
gchar *value;
range = editor_selection_get_current_range (selection);
- if (!range) {
+ if (range == NULL)
return NULL;
- }
node = webkit_dom_range_get_common_ancestor_container (range, NULL);
element = e_editor_dom_node_find_parent_element (node, "FONT");
- if (!element) {
+ if (element == NULL)
return NULL;
- }
g_object_get (G_OBJECT (element), font_property, &value, NULL);
@@ -204,9 +195,11 @@ get_font_property (EEditorSelection *selection,
}
static void
-webview_selection_changed (WebKitWebView *webview,
- EEditorSelection *selection)
+editor_selection_selection_changed_cb (WebKitWebView *webview,
+ EEditorSelection *selection)
{
+ g_object_freeze_notify (G_OBJECT (selection));
+
g_object_notify (G_OBJECT (selection), "alignment");
g_object_notify (G_OBJECT (selection), "background-color");
g_object_notify (G_OBJECT (selection), "bold");
@@ -222,102 +215,135 @@ webview_selection_changed (WebKitWebView *webview,
g_object_notify (G_OBJECT (selection), "superscript");
g_object_notify (G_OBJECT (selection), "text");
g_object_notify (G_OBJECT (selection), "underline");
+
+ g_object_thaw_notify (G_OBJECT (selection));
}
static void
editor_selection_set_editor_widget (EEditorSelection *selection,
- EEditorWidget *editor_widget)
+ EEditorWidget *editor_widget)
{
- selection->priv->webview = g_object_ref (E_EDITOR_WIDGET (editor_widget));
+ g_return_if_fail (E_IS_EDITOR_WIDGET (editor_widget));
+ g_return_if_fail (selection->priv->webview == NULL);
+
+ selection->priv->webview = g_object_ref (editor_widget);
+
g_signal_connect (
editor_widget, "selection-changed",
- G_CALLBACK (webview_selection_changed), selection);
+ G_CALLBACK (editor_selection_selection_changed_cb), selection);
}
-
static void
-e_editor_selection_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+editor_selection_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
GdkRGBA rgba = { 0 };
- EEditorSelection *selection = E_EDITOR_SELECTION (object);
switch (property_id) {
case PROP_ALIGNMENT:
- g_value_set_int (value,
- e_editor_selection_get_alignment (selection));
+ g_value_set_int (
+ value,
+ e_editor_selection_get_alignment (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_BACKGROUND_COLOR:
- g_value_set_string (value,
- e_editor_selection_get_background_color (selection));
- return;
-
- case PROP_BOLD:
- g_value_set_boolean (value,
- e_editor_selection_is_bold (selection));
+ g_value_set_string (
+ value,
+ e_editor_selection_get_background_color (
+ E_EDITOR_SELECTION (object)));
return;
- case PROP_FONT_NAME:
- g_value_set_string (value,
- e_editor_selection_get_font_name (selection));
+ case PROP_BLOCK_FORMAT:
+ g_value_set_int (
+ value,
+ e_editor_selection_get_block_format (
+ E_EDITOR_SELECTION (object)));
return;
- case PROP_FONT_SIZE:
- g_value_set_int (value,
- e_editor_selection_get_font_size (selection));
+ case PROP_BOLD:
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_bold (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_FONT_COLOR:
- e_editor_selection_get_font_color (selection, &rgba);
+ e_editor_selection_get_font_color (
+ E_EDITOR_SELECTION (object), &rgba);
g_value_set_boxed (value, &rgba);
return;
- case PROP_BLOCK_FORMAT:
- g_value_set_int (value,
- e_editor_selection_get_block_format (selection));
+ case PROP_FONT_NAME:
+ g_value_set_string (
+ value,
+ e_editor_selection_get_font_name (
+ E_EDITOR_SELECTION (object)));
+ return;
+
+ case PROP_FONT_SIZE:
+ g_value_set_int (
+ value,
+ e_editor_selection_get_font_size (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_INDENTED:
- g_value_set_boolean (value,
- e_editor_selection_is_indented (selection));
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_indented (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_ITALIC:
- g_value_set_boolean (value,
- e_editor_selection_is_italic (selection));
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_italic (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_MONOSPACED:
- g_value_set_boolean (value,
- e_editor_selection_is_monospaced (selection));
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_monospaced (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_STRIKE_THROUGH:
- g_value_set_boolean (value,
- e_editor_selection_is_strike_through (selection));
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_strike_through (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_SUBSCRIPT:
- g_value_set_boolean (value,
- e_editor_selection_is_subscript (selection));
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_subscript (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_SUPERSCRIPT:
- g_value_set_boolean (value,
- e_editor_selection_is_superscript (selection));
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_superscript (
+ E_EDITOR_SELECTION (object)));
return;
case PROP_TEXT:
- g_value_set_string (value,
- e_editor_selection_get_string (selection));
+ g_value_set_string (
+ value,
+ e_editor_selection_get_string (
+ E_EDITOR_SELECTION (object)));
break;
case PROP_UNDERLINE:
- g_value_set_boolean (value,
- e_editor_selection_is_underline (selection));
+ g_value_set_boolean (
+ value,
+ e_editor_selection_is_underline (
+ E_EDITOR_SELECTION (object)));
return;
}
@@ -325,82 +351,94 @@ e_editor_selection_get_property (GObject *object,
}
static void
-e_editor_selection_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+editor_selection_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
- EEditorSelection *selection = E_EDITOR_SELECTION (object);
-
switch (property_id) {
- case PROP_EDITOR_WIDGET:
- editor_selection_set_editor_widget (
- selection, g_value_get_object (value));
- return;
-
case PROP_ALIGNMENT:
e_editor_selection_set_alignment (
- selection, g_value_get_int (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_int (value));
return;
case PROP_BACKGROUND_COLOR:
e_editor_selection_set_background_color (
- selection, g_value_get_string (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_string (value));
return;
case PROP_BOLD:
e_editor_selection_set_bold (
- selection, g_value_get_boolean (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boolean (value));
+ return;
+
+ case PROP_EDITOR_WIDGET:
+ editor_selection_set_editor_widget (
+ E_EDITOR_SELECTION (object),
+ g_value_get_object (value));
return;
case PROP_FONT_COLOR:
e_editor_selection_set_font_color (
- selection, g_value_get_boxed (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boxed (value));
return;
case PROP_BLOCK_FORMAT:
e_editor_selection_set_block_format (
- selection, g_value_get_int (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_int (value));
return;
case PROP_FONT_NAME:
e_editor_selection_set_font_name (
- selection, g_value_get_string (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_string (value));
return;
case PROP_FONT_SIZE:
e_editor_selection_set_font_size (
- selection, g_value_get_int (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_int (value));
return;
case PROP_ITALIC:
e_editor_selection_set_italic (
- selection, g_value_get_boolean (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boolean (value));
return;
case PROP_MONOSPACED:
e_editor_selection_set_monospaced (
- selection, g_value_get_boolean (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boolean (value));
return;
case PROP_STRIKE_THROUGH:
e_editor_selection_set_strike_through (
- selection, g_value_get_boolean (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boolean (value));
return;
case PROP_SUBSCRIPT:
e_editor_selection_set_subscript (
- selection, g_value_get_boolean (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boolean (value));
return;
case PROP_SUPERSCRIPT:
e_editor_selection_set_superscript (
- selection, g_value_get_boolean (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boolean (value));
return;
case PROP_UNDERLINE:
e_editor_selection_set_underline (
- selection, g_value_get_boolean (value));
+ E_EDITOR_SELECTION (object),
+ g_value_get_boolean (value));
return;
}
@@ -408,38 +446,41 @@ e_editor_selection_set_property (GObject *object,
}
static void
-e_editor_selection_finalize (GObject *object)
+editor_selection_dispose (GObject *object)
{
- EEditorSelection *selection = E_EDITOR_SELECTION (object);
+ EEditorSelectionPrivate *priv;
- g_clear_object (&selection->priv->webview);
+ priv = E_EDITOR_SELECTION_GET_PRIVATE (object);
+
+ g_clear_object (&priv->webview);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_editor_selection_parent_class)->dispose (object);
+}
+
+static void
+editor_selection_finalize (GObject *object)
+{
+ EEditorSelection *selection = E_EDITOR_SELECTION (object);
g_free (selection->priv->text);
- selection->priv->text = NULL;
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_editor_selection_parent_class)->finalize (object);
}
static void
-e_editor_selection_class_init (EEditorSelectionClass *klass)
+e_editor_selection_class_init (EEditorSelectionClass *class)
{
GObjectClass *object_class;
- g_type_class_add_private (klass, sizeof (EEditorSelectionPrivate));
+ g_type_class_add_private (class, sizeof (EEditorSelectionPrivate));
- object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = e_editor_selection_get_property;
- object_class->set_property = e_editor_selection_set_property;
- object_class->finalize = e_editor_selection_finalize;
-
- g_object_class_install_property (
- object_class,
- PROP_EDITOR_WIDGET,
- g_param_spec_object (
- "editor-widget",
- NULL,
- NULL,
- E_TYPE_EDITOR_WIDGET,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY));
+ object_class = G_OBJECT_CLASS (class);
+ object_class->get_property = editor_selection_get_property;
+ object_class->set_property = editor_selection_set_property;
+ object_class->dispose = editor_selection_dispose;
+ object_class->finalize = editor_selection_finalize;
/**
* EEditorSelection:alignment
@@ -470,10 +511,31 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
PROP_BACKGROUND_COLOR,
g_param_spec_string (
"background-color",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE));
+
+ /**
+ * EEditorSelection:block-format
+ *
+ * Holds block format of current paragraph. See
+ * #EEditorSelectionBlockFormat for valid values.
+ */
+ /* FIXME Convert the EEditorSelectionBlockFormat
+ * enum to a proper type. */
+ g_object_class_install_property (
+ object_class,
+ PROP_BLOCK_FORMAT,
+ g_param_spec_int (
+ "block-format",
+ NULL,
+ NULL,
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:bold
@@ -489,73 +551,71 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
- /**
- * EEditorSelection:font-name
- *
- * Holds name of font in current selection or at current cursor position.
- */
g_object_class_install_property (
object_class,
- PROP_FONT_NAME,
- g_param_spec_string (
- "font-name",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
+ PROP_EDITOR_WIDGET,
+ g_param_spec_object (
+ "editor-widget",
+ NULL,
+ NULL,
+ E_TYPE_EDITOR_WIDGET,
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
- * EEditorSelection:font-size
+ * EEditorSelection:font-color
*
- * Holds point size of current selection or at current cursor position.
+ * Holds font color of current selection or at current cursor position.
*/
g_object_class_install_property (
object_class,
- PROP_FONT_SIZE,
- g_param_spec_int (
- "font-size",
+ PROP_FONT_COLOR,
+ g_param_spec_boxed (
+ "font-color",
NULL,
NULL,
- 1,
- 7,
- 3,
- G_PARAM_READWRITE));
+ GDK_TYPE_RGBA,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
- * EEditorSelection:font-color
+ * EEditorSelection:font-name
*
- * Holds font color of current selection or at current cursor position
+ * Holds name of font in current selection or at current cursor
+ * position.
*/
g_object_class_install_property (
object_class,
- PROP_FONT_COLOR,
- g_param_spec_boxed (
- "font-color",
+ PROP_FONT_NAME,
+ g_param_spec_string (
+ "font-name",
NULL,
NULL,
- GDK_TYPE_RGBA,
- G_PARAM_READWRITE));
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
- * EEditorSelection:block-format
+ * EEditorSelection:font-size
*
- * Holds block format of current paragraph. See #EEditorSelectionBlockFormat
- * for valid values.
+ * Holds point size of current selection or at current cursor position.
*/
- /* FIXME: Convert the EEditorSelectionBlockFormat enum to a propert type */
g_object_class_install_property (
object_class,
- PROP_BLOCK_FORMAT,
+ PROP_FONT_SIZE,
g_param_spec_int (
- "block-format",
+ "font-size",
NULL,
NULL,
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ 1,
+ 7,
+ 3,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:indented
@@ -571,7 +631,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:italic
@@ -587,7 +648,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:monospaced
@@ -603,7 +665,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:strike-through
@@ -619,7 +682,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:superscript
@@ -635,7 +699,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:subscript
@@ -651,7 +716,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:text
@@ -663,10 +729,11 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
PROP_TEXT,
g_param_spec_string (
"text",
- NULL,
- NULL,
- NULL,
- G_PARAM_READABLE));
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:underline
@@ -682,10 +749,10 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
-
static void
e_editor_selection_init (EEditorSelection *selection)
{
@@ -711,20 +778,17 @@ e_editor_selection_has_text (EEditorSelection *selection)
range = editor_selection_get_current_range (selection);
node = webkit_dom_range_get_start_container (range, NULL);
- if (webkit_dom_node_get_node_type (node) == 3) {
+ if (webkit_dom_node_get_node_type (node) == 3)
return TRUE;
- }
node = webkit_dom_range_get_end_container (range, NULL);
- if (webkit_dom_node_get_node_type (node) == 3) {
+ if (webkit_dom_node_get_node_type (node) == 3)
return TRUE;
- }
node = WEBKIT_DOM_NODE (webkit_dom_range_clone_contents (range, NULL));
while (node) {
- if (webkit_dom_node_get_node_type (node) == 3) {
+ if (webkit_dom_node_get_node_type (node) == 3)
return TRUE;
- }
if (webkit_dom_node_has_child_nodes (node)) {
node = webkit_dom_node_get_first_child (node);
@@ -775,7 +839,7 @@ e_editor_selection_get_caret_word (EEditorSelection *selection)
*/
void
e_editor_selection_replace_caret_word (EEditorSelection *selection,
- const gchar *replacement)
+ const gchar *replacement)
{
WebKitDOMDocument *document;
WebKitDOMDOMWindow *window;
@@ -829,7 +893,7 @@ e_editor_selection_get_string (EEditorSelection *selection)
*/
void
e_editor_selection_replace (EEditorSelection *selection,
- const gchar *new_string)
+ const gchar *new_string)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
@@ -862,24 +926,21 @@ e_editor_selection_get_alignment (EEditorSelection *selection)
E_EDITOR_SELECTION_ALIGNMENT_LEFT);
range = editor_selection_get_current_range (selection);
- if (!range) {
+ if (range == NULL)
return E_EDITOR_SELECTION_ALIGNMENT_LEFT;
- }
node = webkit_dom_range_get_start_container (range, NULL);
- if (!node) {
+ if (node == NULL)
return E_EDITOR_SELECTION_ALIGNMENT_LEFT;
- }
- if (!WEBKIT_DOM_IS_ELEMENT (node)) {
- element = webkit_dom_node_get_parent_element (node);
- } else {
+ if (WEBKIT_DOM_IS_ELEMENT (node))
element = WEBKIT_DOM_ELEMENT (node);
- }
+ else
+ element = webkit_dom_node_get_parent_element (node);
style = webkit_dom_element_get_style (element);
value = webkit_dom_css_style_declaration_get_property_value (
- style, "text-align");
+ style, "text-align");
if (!value || !*value ||
(g_ascii_strncasecmp (value, "left", 4) == 0)) {
@@ -906,15 +967,14 @@ e_editor_selection_get_alignment (EEditorSelection *selection)
*/
void
e_editor_selection_set_alignment (EEditorSelection *selection,
- EEditorSelectionAlignment alignment)
+ EEditorSelectionAlignment alignment)
{
EEditorWidgetCommand command;
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if (e_editor_selection_get_alignment (selection) == alignment) {
+ if (e_editor_selection_get_alignment (selection) == alignment)
return;
- }
switch (alignment) {
case E_EDITOR_SELECTION_ALIGNMENT_CENTER:
@@ -976,10 +1036,10 @@ e_editor_selection_get_background_color (EEditorSelection *selection)
*/
void
e_editor_selection_set_background_color (EEditorSelection *selection,
- const gchar *color)
+ const gchar *color)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- g_return_if_fail (color && *color);
+ g_return_if_fail (color != NULL && *color != '\0');
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1004,13 +1064,13 @@ e_editor_selection_get_block_format (EEditorSelection *selection)
WebKitDOMElement *element;
EEditorSelectionBlockFormat result;
- g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection),
- E_EDITOR_SELECTION_BLOCK_FORMAT_PARAGRAPH);
+ g_return_val_if_fail (
+ E_IS_EDITOR_SELECTION (selection),
+ E_EDITOR_SELECTION_BLOCK_FORMAT_PARAGRAPH);
range = editor_selection_get_current_range (selection);
- if (!range) {
+ if (range == NULL)
return E_EDITOR_SELECTION_BLOCK_FORMAT_PARAGRAPH;
- }
node = webkit_dom_range_get_start_container (range, NULL);
@@ -1020,7 +1080,7 @@ e_editor_selection_get_block_format (EEditorSelection *selection)
if (webkit_dom_element_has_attribute (element, "type")) {
gchar *type;
- type = webkit_dom_element_get_attribute(element, "type");
+ type = webkit_dom_element_get_attribute (element, "type");
if (type && ((*type == 'a') || (*type == 'A'))) {
result = E_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA;
} else if (type && ((*type == 'i') || (*type == 'I'))) {
@@ -1069,7 +1129,7 @@ e_editor_selection_get_block_format (EEditorSelection *selection)
*/
void
e_editor_selection_set_block_format (EEditorSelection *selection,
- EEditorSelectionBlockFormat format)
+ EEditorSelectionBlockFormat format)
{
EEditorSelectionBlockFormat current_format;
EEditorWidgetCommand command;
@@ -1140,14 +1200,13 @@ e_editor_selection_set_block_format (EEditorSelection *selection,
break;
}
-
/* First remove (un)ordered list before changing formatting */
if (current_format == E_EDITOR_SELECTION_BLOCK_FORMAT_UNORDERED_LIST) {
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
E_EDITOR_WIDGET_COMMAND_INSERT_UNORDERED_LIST, NULL);
- /* ^-- not a typo, "insert" toggles the formatting
- * if already present */
+ /* ^-- not a typo, "insert" toggles the
+ * formatting if already present */
} else if (current_format >= E_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST) {
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1161,18 +1220,18 @@ e_editor_selection_set_block_format (EEditorSelection *selection,
if ((format == E_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA) ||
(format == E_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ROMAN)) {
- WebKitDOMRange *range = editor_selection_get_current_range (selection);
+ WebKitDOMRange *range;
WebKitDOMNode *node;
WebKitDOMElement *list;
+ range = editor_selection_get_current_range (selection);
node = webkit_dom_range_get_start_container (range, NULL);
list = e_editor_dom_node_find_child_element (node, "OL");
- if (!list) {
+ if (list == NULL)
list = e_editor_dom_node_find_parent_element (node, "OL");
- }
- if (list) {
+ if (list != NULL) {
webkit_dom_element_set_attribute (
list, "type",
(format == E_EDITOR_SELECTION_BLOCK_FORMAT_ORDERED_LIST_ALPHA) ?
@@ -1193,7 +1252,7 @@ e_editor_selection_set_block_format (EEditorSelection *selection,
*/
void
e_editor_selection_get_font_color (EEditorSelection *selection,
- GdkRGBA *rgba)
+ GdkRGBA *rgba)
{
gchar *color;
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
@@ -1218,17 +1277,19 @@ e_editor_selection_get_font_color (EEditorSelection *selection,
*/
void
e_editor_selection_set_font_color (EEditorSelection *selection,
- const GdkRGBA *rgba)
+ const GdkRGBA *rgba)
{
+ guint32 rgba_value;
gchar *color;
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if (!rgba) {
+ if (rgba == NULL)
rgba = &black;
- }
- color = g_strdup_printf ("#%06x", e_rgba_to_value ((GdkRGBA *) rgba));
+ rgba_value = e_rgba_to_value ((GdkRGBA *) rgba);
+
+ color = g_strdup_printf ("#%06x", rgba_value);
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1278,7 +1339,7 @@ e_editor_selection_get_font_name (EEditorSelection *selection)
*/
void
e_editor_selection_set_font_name (EEditorSelection *selection,
- const gchar *font_name)
+ const gchar *font_name)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
@@ -1286,7 +1347,6 @@ e_editor_selection_set_font_name (EEditorSelection *selection,
E_EDITOR_WIDGET (selection->priv->webview),
E_EDITOR_WIDGET_COMMAND_FONT_NAME, font_name);
-
g_object_notify (G_OBJECT (selection), "font-name");
}
@@ -1331,13 +1391,13 @@ e_editor_selection_get_font_size (EEditorSelection *selection)
*/
void
e_editor_selection_set_font_size (EEditorSelection *selection,
- guint font_size)
+ guint font_size)
{
gchar *size_str;
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- size_str = g_strdup_printf("%d", font_size);
+ size_str = g_strdup_printf ("%d", font_size);
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1356,11 +1416,12 @@ e_editor_selection_set_font_size (EEditorSelection *selection,
* Returns: @TRUE when current paragraph is a citation, @FALSE otherwise.
*/
gboolean
-e_editor_selection_is_citation (EEditorSelection* selection)
+e_editor_selection_is_citation (EEditorSelection *selection)
{
g_return_val_if_fail (E_IS_EDITOR_SELECTION (selection), FALSE);
- /* citation == <blockquote type='cite'> - special case handled in get_has_style() */
+ /* citation == <blockquote type='cite'>
+ * special case handled in get_has_style() */
return get_has_style (selection, "citation");
}
@@ -1368,8 +1429,9 @@ e_editor_selection_is_citation (EEditorSelection* selection)
* e_editor_selection_is_indented:
* @selection: an #EEditorSelection
*
- * Returns whether current paragraph is indented. This does not include citations.
- * To check, whether paragraph is a citation, use #e_editor_selection_is_citation().
+ * Returns whether current paragraph is indented. This does not include
+ * citations. To check, whether paragraph is a citation, use
+ * e_editor_selection_is_citation().
*
* Returns: @TRUE when current paragraph is indented, @FALSE otherwise.
*/
@@ -1396,7 +1458,6 @@ e_editor_selection_indent (EEditorSelection *selection)
E_EDITOR_WIDGET (selection->priv->webview),
E_EDITOR_WIDGET_COMMAND_INDENT, NULL);
-
g_object_notify (G_OBJECT (selection), "indented");
}
@@ -1415,7 +1476,6 @@ e_editor_selection_unindent (EEditorSelection *selection)
E_EDITOR_WIDGET (selection->priv->webview),
E_EDITOR_WIDGET_COMMAND_OUTDENT, NULL);
-
g_object_notify (G_OBJECT (selection), "indented");
}
@@ -1446,20 +1506,17 @@ e_editor_selection_is_bold (EEditorSelection *selection)
*/
void
e_editor_selection_set_bold (EEditorSelection *selection,
- gboolean bold)
+ gboolean bold)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if ((e_editor_selection_is_bold (selection) ? TRUE : FALSE)
- == (bold ? TRUE : FALSE)) {
+ if (e_editor_selection_is_bold (selection) == bold)
return;
- }
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
E_EDITOR_WIDGET_COMMAND_BOLD, NULL);
-
g_object_notify (G_OBJECT (selection), "bold");
}
@@ -1490,14 +1547,12 @@ e_editor_selection_is_italic (EEditorSelection *selection)
*/
void
e_editor_selection_set_italic (EEditorSelection *selection,
- gboolean italic)
+ gboolean italic)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if ((e_editor_selection_is_italic (selection) ? TRUE : FALSE)
- == (italic ? TRUE : FALSE)) {
+ if (e_editor_selection_is_italic (selection) == italic)
return;
- }
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1533,43 +1588,41 @@ e_editor_selection_is_monospaced (EEditorSelection *selection)
*/
void
e_editor_selection_set_monospaced (EEditorSelection *selection,
- gboolean monospaced)
+ gboolean monospaced)
{
WebKitDOMDocument *document;
WebKitDOMRange *range;
- gboolean is_monospaced;
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- is_monospaced = e_editor_selection_is_monospaced (selection) ? TRUE : FALSE;
- if ((is_monospaced ? TRUE : FALSE) == (monospaced ? TRUE : FALSE)) {
+ if (e_editor_selection_is_monospaced (selection) == monospaced)
return;
- }
range = editor_selection_get_current_range (selection);
- if (!range) {
+ if (range == NULL)
return;
- }
document = webkit_web_view_get_dom_document (selection->priv->webview);
if (monospaced) {
WebKitDOMElement *wrapper;
gchar *html;
- wrapper = webkit_dom_document_create_element (document, "TT", NULL);
+ wrapper = webkit_dom_document_create_element (
+ document, "TT", NULL);
webkit_dom_node_append_child (
WEBKIT_DOM_NODE (wrapper),
WEBKIT_DOM_NODE (webkit_dom_range_clone_contents (range, NULL)),
NULL);
html = webkit_dom_html_element_get_outer_html (
- WEBKIT_DOM_HTML_ELEMENT (wrapper));
+ WEBKIT_DOM_HTML_ELEMENT (wrapper));
e_editor_selection_insert_html (selection, html);
} else {
/* XXX This removes _all_ formatting that the selection has.
- * In theory it's possible to write a code that would remove
- * the <TT> from selection using advanced DOM manipulation,
- * but right now I don't really feel like writing it all... */
+ * In theory it's possible to write a code that would
+ * remove the <TT> from selection using advanced DOM
+ * manipulation, but right now I don't really feel like
+ * writing it all. */
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
E_EDITOR_WIDGET_COMMAND_REMOVE_FORMAT, NULL);
@@ -1605,14 +1658,12 @@ e_editor_selection_is_strike_through (EEditorSelection *selection)
*/
void
e_editor_selection_set_strike_through (EEditorSelection *selection,
- gboolean strike_through)
+ gboolean strike_through)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if ((e_editor_selection_is_strike_through (selection) ? TRUE : FALSE)
- == (strike_through? TRUE : FALSE)) {
+ if (e_editor_selection_is_strike_through (selection) == strike_through)
return;
- }
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1668,14 +1719,12 @@ e_editor_selection_is_subscript (EEditorSelection *selection)
*/
void
e_editor_selection_set_subscript (EEditorSelection *selection,
- gboolean subscript)
+ gboolean subscript)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if ((e_editor_selection_is_subscript (selection) ? TRUE : FALSE)
- == (subscript? TRUE : FALSE)) {
+ if (e_editor_selection_is_subscript (selection) == subscript)
return;
- }
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1731,14 +1780,12 @@ e_editor_selection_is_superscript (EEditorSelection *selection)
*/
void
e_editor_selection_set_superscript (EEditorSelection *selection,
- gboolean superscript)
+ gboolean superscript)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if ((e_editor_selection_is_superscript (selection) ? TRUE : FALSE)
- == (superscript? TRUE : FALSE)) {
+ if (e_editor_selection_is_superscript (selection) == superscript)
return;
- }
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1774,14 +1821,12 @@ e_editor_selection_is_underline (EEditorSelection *selection)
*/
void
e_editor_selection_set_underline (EEditorSelection *selection,
- gboolean underline)
+ gboolean underline)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
- if ((e_editor_selection_is_underline (selection) ? TRUE : FALSE)
- == (underline? TRUE : FALSE)) {
+ if (e_editor_selection_is_underline (selection) == underline)
return;
- }
e_editor_widget_exec_command (
E_EDITOR_WIDGET (selection->priv->webview),
@@ -1816,7 +1861,7 @@ e_editor_selection_unlink (EEditorSelection *selection)
*/
void
e_editor_selection_create_link (EEditorSelection *selection,
- const gchar *uri)
+ const gchar *uri)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
g_return_if_fail (uri && *uri);
@@ -1836,7 +1881,7 @@ e_editor_selection_create_link (EEditorSelection *selection,
*/
void
e_editor_selection_insert_text (EEditorSelection *selection,
- const gchar *plain_text)
+ const gchar *plain_text)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
g_return_if_fail (plain_text != NULL);
@@ -1856,7 +1901,7 @@ e_editor_selection_insert_text (EEditorSelection *selection,
*/
void
e_editor_selection_insert_html (EEditorSelection *selection,
- const gchar *html_text)
+ const gchar *html_text)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
g_return_if_fail (html_text != NULL);
@@ -1876,7 +1921,7 @@ e_editor_selection_insert_html (EEditorSelection *selection,
*/
void
e_editor_selection_insert_image (EEditorSelection *selection,
- const gchar *image_uri)
+ const gchar *image_uri)
{
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
g_return_if_fail (image_uri != NULL);
@@ -1888,7 +1933,7 @@ e_editor_selection_insert_image (EEditorSelection *selection,
static gint
find_where_to_break_line (WebKitDOMNode *node,
- gint max_len)
+ gint max_len)
{
gchar *str, *text_start;
gunichar uc;
@@ -2008,7 +2053,7 @@ e_editor_selection_wrap_lines (EEditorSelection *selection)
(WebKitDOMText *) node, len + offset, NULL);
element = webkit_dom_document_create_element (
- document, "BR", NULL);
+ document, "BR", NULL);
/* WebKit throws warning when ref_child is NULL */
if (webkit_dom_node_get_next_sibling (node)) {
@@ -2050,7 +2095,7 @@ e_editor_selection_wrap_lines (EEditorSelection *selection)
/* Get HTML code of the processed content */
html = webkit_dom_html_element_get_inner_html (
- WEBKIT_DOM_HTML_ELEMENT (element));
+ WEBKIT_DOM_HTML_ELEMENT (element));
/* Overwrite the current selection be the processed content, so that
* "UNDO" and "REDO" buttons work as expected */
@@ -2064,30 +2109,34 @@ e_editor_selection_wrap_lines (EEditorSelection *selection)
* @selection: an #EEditorSelection
*
* Saves current cursor position or current selection range. The selection can
- * be later restored by calling #e_editor_selection_restore().
+ * be later restored by calling e_editor_selection_restore().
*
- * Note that calling #e_editor_selection_save() overwrites previously saved
+ * Note that calling e_editor_selection_save() overwrites previously saved
* position.
*
* Note that this method inserts special markings into the HTML code that are
- * used to later restore the selection. It can happen that by deleting some segments
- * of the document some of the markings are deleted too. In that case restoring
- * the selection by #e_editor_selection_restore() can fail. Also by moving text
- * segments (Cut & Paste) can result in moving the markings elsewhere, thus
- * #e_editor_selection_restore() will restore the selection incorrectly.
+ * used to later restore the selection. It can happen that by deleting some
+ * segments of the document some of the markings are deleted too. In that case
+ * restoring the selection by e_editor_selection_restore() can fail. Also by
+ * moving text segments (Cut & Paste) can result in moving the markings
+ * elsewhere, thus e_editor_selection_restore() will restore the selection
+ * incorrectly.
*
* It is recommended to use this method only when you are not planning to make
* bigger changes to content or structure of the document (formatting changes
* are usually OK).
*/
void
-e_editor_selection_save (EEditorSelection* selection)
+e_editor_selection_save (EEditorSelection *selection)
{
WebKitDOMDocument *document;
WebKitDOMRange *range;
- WebKitDOMNode *container, *split;
+ WebKitDOMNode *container;
WebKitDOMElement *marker;
-
+ WebKitDOMNode *marker_node;
+ WebKitDOMNode *parent_node;
+ WebKitDOMNode *split_node;
+ glong start_offset;
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
@@ -2095,54 +2144,74 @@ e_editor_selection_save (EEditorSelection* selection)
/* First remove all markers (if present) */
marker = webkit_dom_document_get_element_by_id (
- document, "-x-evolution-selection-start-marker");
- if (marker) {
- webkit_dom_node_remove_child (
- webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker)),
- WEBKIT_DOM_NODE (marker), NULL);
+ document, "-x-evolution-selection-start-marker");
+ if (marker != NULL) {
+ WebKitDOMNode *marker_node;
+ WebKitDOMNode *parent_node;
+
+ marker_node = WEBKIT_DOM_NODE (marker);
+ parent_node = webkit_dom_node_get_parent_node (marker_node);
+ webkit_dom_node_remove_child (parent_node, marker_node, NULL);
}
marker = webkit_dom_document_get_element_by_id (
- document, "-x-evolution-selection-end-marker");
- if (marker) {
- webkit_dom_node_remove_child (
- webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker)),
- WEBKIT_DOM_NODE (marker), NULL);
+ document, "-x-evolution-selection-end-marker");
+ if (marker != NULL) {
+ WebKitDOMNode *marker_node;
+ WebKitDOMNode *parent_node;
+
+ marker_node = WEBKIT_DOM_NODE (marker);
+ parent_node = webkit_dom_node_get_parent_node (marker_node);
+ webkit_dom_node_remove_child (parent_node, marker_node, NULL);
}
range = editor_selection_get_current_range (selection);
+ start_offset = webkit_dom_range_get_start_offset (range, NULL);
+
marker = webkit_dom_document_create_element (document, "SPAN", NULL);
webkit_dom_html_element_set_id (
- WEBKIT_DOM_HTML_ELEMENT (marker), "-x-evolution-selection-start-marker");
+ WEBKIT_DOM_HTML_ELEMENT (marker),
+ "-x-evolution-selection-start-marker");
+
container = webkit_dom_range_get_start_container (range, NULL);
- if (!WEBKIT_DOM_IS_TEXT (container)) {
- split = container;
+ if (WEBKIT_DOM_IS_TEXT (container)) {
+ WebKitDOMText *split_text;
+
+ split_text = webkit_dom_text_split_text (
+ WEBKIT_DOM_TEXT (container), start_offset, NULL);
+ split_node = WEBKIT_DOM_NODE (split_text);
} else {
- split = WEBKIT_DOM_NODE (webkit_dom_text_split_text (
- (WebKitDOMText *) container,
- webkit_dom_range_get_start_offset (range, NULL),
- NULL));
+ split_node = container;
}
+
+ marker_node = WEBKIT_DOM_NODE (marker);
+ parent_node = webkit_dom_node_get_parent_node (container);
+
webkit_dom_node_insert_before (
- webkit_dom_node_get_parent_node (container),
- WEBKIT_DOM_NODE (marker), split, NULL);
+ parent_node, marker_node, split_node, NULL);
marker = webkit_dom_document_create_element (document, "SPAN", NULL);
webkit_dom_html_element_set_id (
- WEBKIT_DOM_HTML_ELEMENT (marker), "-x-evolution-selection-end-marker");
+ WEBKIT_DOM_HTML_ELEMENT (marker),
+ "-x-evolution-selection-end-marker");
+
container = webkit_dom_range_get_end_container (range, NULL);
- if (!WEBKIT_DOM_IS_TEXT (container)) {
- split = container;
+ if (WEBKIT_DOM_IS_TEXT (container)) {
+ WebKitDOMText *split_text;
+
+ split_text = webkit_dom_text_split_text (
+ WEBKIT_DOM_TEXT (container), start_offset, NULL);
+ split_node = WEBKIT_DOM_NODE (split_text);
} else {
- split = WEBKIT_DOM_NODE (webkit_dom_text_split_text (
- (WebKitDOMText *) container,
- webkit_dom_range_get_start_offset (range, NULL),
- NULL));
+ split_node = container;
}
+
+ marker_node = WEBKIT_DOM_NODE (marker);
+ parent_node = webkit_dom_node_get_parent_node (container);
+
webkit_dom_node_insert_before (
- webkit_dom_node_get_parent_node (container),
- WEBKIT_DOM_NODE (marker), split, NULL);
+ parent_node, marker_node, split_node, NULL);
}
/**
@@ -2150,17 +2219,19 @@ e_editor_selection_save (EEditorSelection* selection)
* @selection: an #EEditorSelection
*
* Restores cursor position or selection range that was saved by
- * #e_editor_selection_save().
+ * e_editor_selection_save().
*
- * Note that calling this function without calling #e_editor_selection_save()
+ * Note that calling this function without calling e_editor_selection_save()
* before is a programming error and the behavior is undefined.
*/
void
-e_editor_selection_restore (EEditorSelection* selection)
+e_editor_selection_restore (EEditorSelection *selection)
{
WebKitDOMDocument *document;
WebKitDOMRange *range;
WebKitDOMElement *marker;
+ WebKitDOMNode *marker_node;
+ WebKitDOMNode *parent_node;
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
@@ -2168,28 +2239,31 @@ e_editor_selection_restore (EEditorSelection* selection)
range = editor_selection_get_current_range (selection);
marker = webkit_dom_document_get_element_by_id (
- document, "-x-evolution-selection-start-marker");
+ document, "-x-evolution-selection-start-marker");
g_return_if_fail (marker != NULL);
- webkit_dom_range_set_start_after (range, WEBKIT_DOM_NODE (marker), NULL);
- webkit_dom_node_remove_child (
- webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker)),
- WEBKIT_DOM_NODE (marker), NULL);
+
+ marker_node = WEBKIT_DOM_NODE (marker);
+ parent_node = webkit_dom_node_get_parent_node (marker_node);
+
+ webkit_dom_range_set_start_after (range, marker_node, NULL);
+ webkit_dom_node_remove_child (parent_node, marker_node, NULL);
marker = webkit_dom_document_get_element_by_id (
- document, "-x-evolution-selection-end-marker");
+ document, "-x-evolution-selection-end-marker");
g_return_if_fail (marker != NULL);
- webkit_dom_range_set_end_before (range, WEBKIT_DOM_NODE (marker), NULL);
- webkit_dom_node_remove_child (
- webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker)),
- WEBKIT_DOM_NODE (marker), NULL);
-}
+ marker_node = WEBKIT_DOM_NODE (marker);
+ parent_node = webkit_dom_node_get_parent_node (marker_node);
+
+ webkit_dom_range_set_end_before (range, marker_node, NULL);
+ webkit_dom_node_remove_child (parent_node, marker_node, NULL);
+}
static void
editor_selection_modify (EEditorSelection *selection,
- const gchar *alter,
- gboolean forward,
- EEditorSelectionGranularity granularity)
+ const gchar *alter,
+ gboolean forward,
+ EEditorSelectionGranularity granularity)
{
WebKitDOMDocument *document;
WebKitDOMDOMWindow *window;
@@ -2213,7 +2287,7 @@ editor_selection_modify (EEditorSelection *selection,
webkit_dom_dom_selection_modify (
dom_selection, alter,
- (forward ? "forward" : "backward"),
+ forward ? "forward" : "backward",
granularity_str);
}
@@ -2226,9 +2300,9 @@ editor_selection_modify (EEditorSelection *selection,
* Extends current selection in given direction by given granularity.
*/
void
-e_editor_selection_extend (EEditorSelection* selection,
- gboolean forward,
- EEditorSelectionGranularity granularity)
+e_editor_selection_extend (EEditorSelection *selection,
+ gboolean forward,
+ EEditorSelectionGranularity granularity)
{
editor_selection_modify (selection, "extend", forward, granularity);
}
@@ -2242,9 +2316,9 @@ e_editor_selection_extend (EEditorSelection* selection,
* Moves current selection in given direction by given granularity
*/
void
-e_editor_selection_move (EEditorSelection* selection,
- gboolean forward,
- EEditorSelectionGranularity granularity)
+e_editor_selection_move (EEditorSelection *selection,
+ gboolean forward,
+ EEditorSelectionGranularity granularity)
{
editor_selection_modify (selection, "move", forward, granularity);
}
diff --git a/e-util/e-editor-selection.h b/e-util/e-editor-selection.h
index 8b07373..553b352 100644
--- a/e-util/e-editor-selection.h
+++ b/e-util/e-editor-selection.h
@@ -94,7 +94,6 @@ typedef enum {
struct _EEditorSelection {
GObject parent;
-
EEditorSelectionPrivate *priv;
};
@@ -102,124 +101,102 @@ struct _EEditorSelectionClass {
GObjectClass parent_class;
};
-GType e_editor_selection_get_type (void);
-
-gboolean e_editor_selection_has_text (EEditorSelection *selection);
-
-gchar * e_editor_selection_get_caret_word
- (EEditorSelection *selection);
-void e_editor_selection_replace_caret_word
- (EEditorSelection *selection,
- const gchar *replacement);
-void e_editor_selection_set_alignment
- (EEditorSelection *selection,
- EEditorSelectionAlignment alignment);
+GType e_editor_selection_get_type (void) G_GNUC_CONST;
+gboolean e_editor_selection_has_text (EEditorSelection *selection);
+gchar * e_editor_selection_get_caret_word
+ (EEditorSelection *selection);
+void e_editor_selection_replace_caret_word
+ (EEditorSelection *selection,
+ const gchar *replacement);
EEditorSelectionAlignment
- e_editor_selection_get_alignment
- (EEditorSelection *selection);
-
-void e_editor_selection_set_background_color
- (EEditorSelection *selection,
- const gchar *color);
-const gchar* e_editor_selection_get_background_color
- (EEditorSelection *selection);
-
-void e_editor_selection_set_font_name
- (EEditorSelection *selection,
- const gchar *font_name);
-const gchar * e_editor_selection_get_font_name
- (EEditorSelection *selection);
-
-void e_editor_selection_set_font_size
- (EEditorSelection *selection,
- guint font_size);
-guint e_editor_selection_get_font_size
- (EEditorSelection *selection);
-
-void e_editor_selection_set_font_color
- (EEditorSelection *selection,
- const GdkRGBA *color);
-void e_editor_selection_get_font_color
- (EEditorSelection *selection,
- GdkRGBA *color);
-
-void e_editor_selection_set_block_format
- (EEditorSelection *selection,
- EEditorSelectionBlockFormat format);
+ e_editor_selection_get_alignment
+ (EEditorSelection *selection);
+void e_editor_selection_set_alignment
+ (EEditorSelection *selection,
+ EEditorSelectionAlignment alignment);
+const gchar * e_editor_selection_get_background_color
+ (EEditorSelection *selection);
+void e_editor_selection_set_background_color
+ (EEditorSelection *selection,
+ const gchar *color);
+void e_editor_selection_get_font_color
+ (EEditorSelection *selection,
+ GdkRGBA *color);
+void e_editor_selection_set_font_color
+ (EEditorSelection *selection,
+ const GdkRGBA *color);
+const gchar * e_editor_selection_get_font_name
+ (EEditorSelection *selection);
+void e_editor_selection_set_font_name
+ (EEditorSelection *selection,
+ const gchar *font_name);
+guint e_editor_selection_get_font_size
+ (EEditorSelection *selection);
+void e_editor_selection_set_font_size
+ (EEditorSelection *selection,
+ guint font_size);
EEditorSelectionBlockFormat
- e_editor_selection_get_block_format
- (EEditorSelection *selection);
-
-gboolean e_editor_selection_is_citation (EEditorSelection *selection);
-gboolean e_editor_selection_is_indented (EEditorSelection *selection);
-void e_editor_selection_indent (EEditorSelection *selection);
-void e_editor_selection_unindent (EEditorSelection *selection);
-
-void e_editor_selection_set_bold (EEditorSelection *selection,
- gboolean bold);
-gboolean e_editor_selection_is_bold (EEditorSelection *selection);
-
-void e_editor_selection_set_italic (EEditorSelection *selection,
- gboolean italic);
-gboolean e_editor_selection_is_italic (EEditorSelection *selection);
-
-void e_editor_selection_set_monospaced
- (EEditorSelection *selection,
- gboolean monospaced);
-gboolean e_editor_selection_is_monospaced
- (EEditorSelection *selection);
-
-void e_editor_selection_set_strike_through
- (EEditorSelection *selection,
- gboolean strike_through);
-gboolean e_editor_selection_is_strike_through
- (EEditorSelection *selection);
-
-void e_editor_selection_set_superscript
- (EEditorSelection *selection,
- gboolean superscript);
-gboolean e_editor_selection_is_superscript
- (EEditorSelection *selection);
-
-void e_editor_selection_set_subscript
- (EEditorSelection *selection,
- gboolean subscript);
-gboolean e_editor_selection_is_subscript
- (EEditorSelection *selection);
-
-void e_editor_selection_set_underline
- (EEditorSelection *selection,
- gboolean underline);
-gboolean e_editor_selection_is_underline
- (EEditorSelection *selection);
-
-void e_editor_selection_unlink (EEditorSelection *selection);
-
-void e_editor_selection_create_link (EEditorSelection *selection,
- const gchar *uri);
-
-const gchar * e_editor_selection_get_string (EEditorSelection *selection);
-
-void e_editor_selection_replace (EEditorSelection *selection,
- const gchar *new_string);
-
-void e_editor_selection_insert_html (EEditorSelection *selection,
- const gchar *html_text);
-void e_editor_selection_insert_image (EEditorSelection *selection,
- const gchar *image_uri);
-void e_editor_selection_insert_text (EEditorSelection *selection,
- const gchar *plain_text);
-void e_editor_selection_wrap_lines (EEditorSelection *selection);
-
-void e_editor_selection_save (EEditorSelection *selection);
-void e_editor_selection_restore (EEditorSelection *selection);
-
-void e_editor_selection_move (EEditorSelection *selection,
- gboolean forward,
- EEditorSelectionGranularity granularity);
-void e_editor_selection_extend (EEditorSelection *selection,
- gboolean forward,
- EEditorSelectionGranularity granularity);
+ e_editor_selection_get_block_format
+ (EEditorSelection *selection);
+void e_editor_selection_set_block_format
+ (EEditorSelection *selection,
+ EEditorSelectionBlockFormat format);
+gboolean e_editor_selection_is_citation (EEditorSelection *selection);
+gboolean e_editor_selection_is_indented (EEditorSelection *selection);
+void e_editor_selection_indent (EEditorSelection *selection);
+void e_editor_selection_unindent (EEditorSelection *selection);
+gboolean e_editor_selection_is_bold (EEditorSelection *selection);
+void e_editor_selection_set_bold (EEditorSelection *selection,
+ gboolean bold);
+gboolean e_editor_selection_is_italic (EEditorSelection *selection);
+void e_editor_selection_set_italic (EEditorSelection *selection,
+ gboolean italic);
+gboolean e_editor_selection_is_monospaced
+ (EEditorSelection *selection);
+void e_editor_selection_set_monospaced
+ (EEditorSelection *selection,
+ gboolean monospaced);
+gboolean e_editor_selection_is_strike_through
+ (EEditorSelection *selection);
+void e_editor_selection_set_strike_through
+ (EEditorSelection *selection,
+ gboolean strike_through);
+gboolean e_editor_selection_is_superscript
+ (EEditorSelection *selection);
+void e_editor_selection_set_superscript
+ (EEditorSelection *selection,
+ gboolean superscript);
+gboolean e_editor_selection_is_subscript
+ (EEditorSelection *selection);
+void e_editor_selection_set_subscript
+ (EEditorSelection *selection,
+ gboolean subscript);
+gboolean e_editor_selection_is_underline
+ (EEditorSelection *selection);
+void e_editor_selection_set_underline
+ (EEditorSelection *selection,
+ gboolean underline);
+void e_editor_selection_unlink (EEditorSelection *selection);
+void e_editor_selection_create_link (EEditorSelection *selection,
+ const gchar *uri);
+const gchar * e_editor_selection_get_string (EEditorSelection *selection);
+void e_editor_selection_replace (EEditorSelection *selection,
+ const gchar *new_string);
+void e_editor_selection_insert_html (EEditorSelection *selection,
+ const gchar *html_text);
+void e_editor_selection_insert_image (EEditorSelection *selection,
+ const gchar *image_uri);
+void e_editor_selection_insert_text (EEditorSelection *selection,
+ const gchar *plain_text);
+void e_editor_selection_wrap_lines (EEditorSelection *selection);
+void e_editor_selection_save (EEditorSelection *selection);
+void e_editor_selection_restore (EEditorSelection *selection);
+void e_editor_selection_move (EEditorSelection *selection,
+ gboolean forward,
+ EEditorSelectionGranularity granularity);
+void e_editor_selection_extend (EEditorSelection *selection,
+ gboolean forward,
+ EEditorSelectionGranularity granularity);
G_END_DECLS
diff --git a/e-util/e-editor-spell-check-dialog.c b/e-util/e-editor-spell-check-dialog.c
index a303482..1b102f7 100644
--- a/e-util/e-editor-spell-check-dialog.c
+++ b/e-util/e-editor-spell-check-dialog.c
@@ -31,16 +31,9 @@
#include "e-spell-checker.h"
#include "e-spell-dictionary.h"
-G_DEFINE_TYPE (
- EEditorSpellCheckDialog,
- e_editor_spell_check_dialog,
- E_TYPE_EDITOR_DIALOG
-);
-
-enum {
- COMBO_COLUMN_DICTIONARY, /* E_TYPE_SPELL_DICTIONARY */
- COMBO_COLUMN_TEXT /* G_TYPE_STRING */
-};
+#define E_EDITOR_SPELL_CHECK_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_SPELL_CHECK_DIALOG, EEditorSpellCheckDialogPrivate))
struct _EEditorSpellCheckDialogPrivate {
GtkWidget *add_word_button;
@@ -60,19 +53,30 @@ struct _EEditorSpellCheckDialogPrivate {
ESpellDictionary *current_dict;
};
+enum {
+ COLUMN_NAME,
+ COLUMN_DICTIONARY,
+ NUM_COLUMNS
+};
+
+G_DEFINE_TYPE (
+ EEditorSpellCheckDialog,
+ e_editor_spell_check_dialog,
+ E_TYPE_EDITOR_DIALOG)
+
static void
editor_spell_check_dialog_set_word (EEditorSpellCheckDialog *dialog,
- const gchar *word)
+ const gchar *word)
{
EEditor *editor;
EEditorWidget *editor_widget;
+ GtkTreeView *tree_view;
GtkListStore *store;
gchar *markup;
- GList *suggestions, *iter;
+ GList *list, *link;
- if (word == NULL) {
+ if (word == NULL)
return;
- }
if (dialog->priv->word != word) {
g_free (dialog->priv->word);
@@ -84,22 +88,22 @@ editor_spell_check_dialog_set_word (EEditorSpellCheckDialog *dialog,
GTK_LABEL (dialog->priv->suggestion_label), markup);
g_free (markup);
- store = GTK_LIST_STORE (
- gtk_tree_view_get_model (
- GTK_TREE_VIEW (dialog->priv->tree_view)));
+ tree_view = GTK_TREE_VIEW (dialog->priv->tree_view);
+ store = GTK_LIST_STORE (gtk_tree_view_get_model (tree_view));
gtk_list_store_clear (store);
- suggestions = e_spell_dictionary_get_suggestions (
- dialog->priv->current_dict, word, -1);
- for (iter = suggestions; iter; iter = g_list_next (iter)) {
- GtkTreeIter tree_iter;
- gchar *suggestion = iter->data;
+ list = e_spell_dictionary_get_suggestions (
+ dialog->priv->current_dict, word, -1);
- gtk_list_store_append (store, &tree_iter);
- gtk_list_store_set (store, &tree_iter, 0, suggestion, -1);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ GtkTreeIter iter;
+ gchar *suggestion = link->data;
+
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, suggestion, -1);
}
- e_spell_dictionary_free_suggestions (suggestions);
+ e_spell_dictionary_free_suggestions (list);
/* We give focus to WebKit so that the currently selected word
* is highlited. Without focus selection is not visible (at
@@ -145,7 +149,6 @@ select_next_word (EEditorSpellCheckDialog *dialog)
dialog->priv->selection)));
}
-
static gboolean
editor_spell_check_dialog_next (EEditorSpellCheckDialog *dialog)
{
@@ -158,13 +161,13 @@ editor_spell_check_dialog_next (EEditorSpellCheckDialog *dialog)
} else {
/* Remember last selected word */
start = webkit_dom_dom_selection_get_anchor_node (
- dialog->priv->selection);
+ dialog->priv->selection);
end = webkit_dom_dom_selection_get_focus_node (
- dialog->priv->selection);
+ dialog->priv->selection);
start_offset = webkit_dom_dom_selection_get_anchor_offset (
- dialog->priv->selection);
+ dialog->priv->selection);
end_offset = webkit_dom_dom_selection_get_focus_offset (
- dialog->priv->selection);
+ dialog->priv->selection);
}
while (select_next_word (dialog)) {
@@ -173,7 +176,8 @@ editor_spell_check_dialog_next (EEditorSpellCheckDialog *dialog)
gint loc, len;
gchar *word;
- range = webkit_dom_dom_selection_get_range_at (dialog->priv->selection, 0, NULL);
+ range = webkit_dom_dom_selection_get_range_at (
+ dialog->priv->selection, 0, NULL);
word = webkit_dom_range_get_text (range);
checker = WEBKIT_SPELL_CHECKER (webkit_get_text_checker ());
@@ -199,18 +203,22 @@ editor_spell_check_dialog_next (EEditorSpellCheckDialog *dialog)
}
/* Close the dialog */
- gtk_widget_hide (GTK_WIDGET (dialog));
+ gtk_widget_hide (GTK_WIDGET (dialog));
return FALSE;
}
static gboolean
select_previous_word (EEditorSpellCheckDialog *dialog)
{
- WebKitDOMNode *anchor;
- gulong anchor_offset;
+ WebKitDOMNode *old_anchor_node;
+ WebKitDOMNode *new_anchor_node;
+ gulong old_anchor_offset;
+ gulong new_anchor_offset;
- anchor = webkit_dom_dom_selection_get_anchor_node (dialog->priv->selection);
- anchor_offset = webkit_dom_dom_selection_get_anchor_offset (dialog->priv->selection);
+ old_anchor_node = webkit_dom_dom_selection_get_anchor_node (
+ dialog->priv->selection);
+ old_anchor_offset = webkit_dom_dom_selection_get_anchor_offset (
+ dialog->priv->selection);
/* Jump on the beginning of current word */
webkit_dom_dom_selection_modify (
@@ -224,10 +232,14 @@ select_previous_word (EEditorSpellCheckDialog *dialog)
/* If the selection start didn't change, then we have most probably
* reached the beginnig of document. Return FALSE */
- return ((anchor != webkit_dom_dom_selection_get_anchor_node (
- dialog->priv->selection)) ||
- (anchor_offset != webkit_dom_dom_selection_get_anchor_offset (
- dialog->priv->selection)));
+
+ new_anchor_node = webkit_dom_dom_selection_get_anchor_node (
+ dialog->priv->selection);
+ new_anchor_offset = webkit_dom_dom_selection_get_anchor_offset (
+ dialog->priv->selection);
+
+ return (new_anchor_node != old_anchor_node) ||
+ (new_anchor_offset != old_anchor_offset);
}
static gboolean
@@ -238,19 +250,21 @@ editor_spell_check_dialog_prev (EEditorSpellCheckDialog *dialog)
if (dialog->priv->word == NULL) {
webkit_dom_dom_selection_modify (
- dialog->priv->selection, "move", "right", "documentboundary");
+ dialog->priv->selection,
+ "move", "right", "documentboundary");
webkit_dom_dom_selection_modify (
- dialog->priv->selection, "extend", "backward", "word");
+ dialog->priv->selection,
+ "extend", "backward", "word");
} else {
/* Remember last selected word */
start = webkit_dom_dom_selection_get_anchor_node (
- dialog->priv->selection);
+ dialog->priv->selection);
end = webkit_dom_dom_selection_get_focus_node (
- dialog->priv->selection);
+ dialog->priv->selection);
start_offset = webkit_dom_dom_selection_get_anchor_offset (
- dialog->priv->selection);
+ dialog->priv->selection);
end_offset = webkit_dom_dom_selection_get_focus_offset (
- dialog->priv->selection);
+ dialog->priv->selection);
}
while (select_previous_word (dialog)) {
@@ -259,12 +273,13 @@ editor_spell_check_dialog_prev (EEditorSpellCheckDialog *dialog)
gint loc, len;
gchar *word;
- range = webkit_dom_dom_selection_get_range_at (dialog->priv->selection, 0, NULL);
+ range = webkit_dom_dom_selection_get_range_at (
+ dialog->priv->selection, 0, NULL);
word = webkit_dom_range_get_text (range);
checker = WEBKIT_SPELL_CHECKER (webkit_get_text_checker ());
webkit_spell_checker_check_spelling_of_string (
- checker, word, &loc, &len);
+ checker, word, &loc, &len);
/* Found misspelled word! */
if (loc != -1) {
@@ -305,7 +320,7 @@ editor_spell_check_dialog_replace (EEditorSpellCheckDialog *dialog)
editor_selection = e_editor_widget_get_selection (widget);
selection = gtk_tree_view_get_selection (
- GTK_TREE_VIEW (dialog->priv->tree_view));
+ GTK_TREE_VIEW (dialog->priv->tree_view));
gtk_tree_selection_get_selected (selection, &model, &iter);
gtk_tree_model_get (model, &iter, 0, &replacement, -1);
@@ -332,7 +347,7 @@ editor_spell_check_dialog_replace_all (EEditorSpellCheckDialog *dialog)
editor_selection = e_editor_widget_get_selection (widget);
selection = gtk_tree_view_get_selection (
- GTK_TREE_VIEW (dialog->priv->tree_view));
+ GTK_TREE_VIEW (dialog->priv->tree_view));
gtk_tree_selection_get_selected (selection, &model, &iter);
gtk_tree_model_get (model, &iter, 0, &replacement, -1);
@@ -345,7 +360,6 @@ editor_spell_check_dialog_replace_all (EEditorSpellCheckDialog *dialog)
e_editor_selection_insert_html (
editor_selection, replacement);
-
}
g_free (replacement);
@@ -355,9 +369,8 @@ editor_spell_check_dialog_replace_all (EEditorSpellCheckDialog *dialog)
static void
editor_spell_check_dialog_ignore (EEditorSpellCheckDialog *dialog)
{
- if (dialog->priv->word == NULL) {
+ if (dialog->priv->word == NULL)
return;
- }
e_spell_dictionary_ignore_word (
dialog->priv->current_dict, dialog->priv->word, -1);
@@ -368,9 +381,8 @@ editor_spell_check_dialog_ignore (EEditorSpellCheckDialog *dialog)
static void
editor_spell_check_dialog_learn (EEditorSpellCheckDialog *dialog)
{
- if (dialog->priv->word == NULL) {
+ if (dialog->priv->word == NULL)
return;
- }
e_spell_dictionary_learn_word (
dialog->priv->current_dict, dialog->priv->word, -1);
@@ -381,14 +393,14 @@ editor_spell_check_dialog_learn (EEditorSpellCheckDialog *dialog)
static void
editor_spell_check_dialog_set_dictionary (EEditorSpellCheckDialog *dialog)
{
+ GtkComboBox *combo_box;
GtkTreeModel *model;
GtkTreeIter iter;
ESpellDictionary *dictionary;
- gtk_combo_box_get_active_iter (
- GTK_COMBO_BOX (dialog->priv->dictionary_combo), &iter);
- model = gtk_combo_box_get_model (
- GTK_COMBO_BOX (dialog->priv->dictionary_combo));
+ combo_box = GTK_COMBO_BOX (dialog->priv->dictionary_combo);
+ gtk_combo_box_get_active_iter (combo_box, &iter);
+ model = gtk_combo_box_get_model (combo_box);
gtk_tree_model_get (model, &iter, 1, &dictionary, -1);
@@ -399,17 +411,13 @@ editor_spell_check_dialog_set_dictionary (EEditorSpellCheckDialog *dialog)
}
static void
-editor_spell_check_dialog_show (GtkWidget *gtk_widget)
+editor_spell_check_dialog_show (GtkWidget *widget)
{
EEditorSpellCheckDialog *dialog;
- EEditor *editor;
- EEditorWidget *widget;
WebKitDOMDocument *document;
WebKitDOMDOMWindow *window;
- dialog = E_EDITOR_SPELL_CHECK_DIALOG (gtk_widget);
- editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
- widget = e_editor_get_editor_widget (editor);
+ dialog = E_EDITOR_SPELL_CHECK_DIALOG (widget);
g_free (dialog->priv->word);
dialog->priv->word = NULL;
@@ -420,34 +428,38 @@ editor_spell_check_dialog_show (GtkWidget *gtk_widget)
/* Select the first word or quit */
if (editor_spell_check_dialog_next (dialog)) {
- GTK_WIDGET_CLASS (e_editor_spell_check_dialog_parent_class)->show (gtk_widget);
+ GTK_WIDGET_CLASS (e_editor_spell_check_dialog_parent_class)->
+ show (widget);
}
}
static void
editor_spell_check_dialog_finalize (GObject *object)
{
- EEditorSpellCheckDialog *dialog;
+ EEditorSpellCheckDialogPrivate *priv;
- dialog = E_EDITOR_SPELL_CHECK_DIALOG (object);
+ priv = E_EDITOR_SPELL_CHECK_DIALOG_GET_PRIVATE (object);
- g_free (dialog->priv->word);
- dialog->priv->word = NULL;
+ g_free (priv->word);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_editor_spell_check_dialog_parent_class)->
+ finalize (object);
}
static void
-e_editor_spell_check_dialog_class_init (EEditorSpellCheckDialogClass *klass)
+e_editor_spell_check_dialog_class_init (EEditorSpellCheckDialogClass *class)
{
GtkWidgetClass *widget_class;
GObjectClass *object_class;
- e_editor_spell_check_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorSpellCheckDialogPrivate));
+ g_type_class_add_private (
+ class, sizeof (EEditorSpellCheckDialogPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->finalize = editor_spell_check_dialog_finalize;
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_spell_check_dialog_show;
}
@@ -455,13 +467,12 @@ static void
e_editor_spell_check_dialog_init (EEditorSpellCheckDialog *dialog)
{
GtkWidget *widget;
- GtkGrid *main_layout;
+ GtkGrid *main_layout;
GtkListStore *store;
GtkTreeViewColumn *column;
GtkCellRenderer *renderer;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_SPELL_CHECK_DIALOG, EEditorSpellCheckDialogPrivate);
+ dialog->priv = E_EDITOR_SPELL_CHECK_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -481,7 +492,7 @@ e_editor_spell_check_dialog_init (EEditorSpellCheckDialog *dialog)
/* Column */
column = gtk_tree_view_column_new_with_attributes (
- "", gtk_cell_renderer_text_new (), "text", 0, NULL);
+ "", gtk_cell_renderer_text_new (), "text", 0, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column);
/* Store */
@@ -605,12 +616,11 @@ e_editor_spell_check_dialog_init (EEditorSpellCheckDialog *dialog)
GtkWidget *
e_editor_spell_check_dialog_new (EEditor *editor)
{
- return GTK_WIDGET (
- g_object_new (
- E_TYPE_EDITOR_SPELL_CHECK_DIALOG,
- "editor", editor,
- "title", N_("Spell Checking"),
- NULL));
+ return g_object_new (
+ E_TYPE_EDITOR_SPELL_CHECK_DIALOG,
+ "editor", editor,
+ "title", N_("Spell Checking"),
+ NULL);
}
GList *
@@ -623,7 +633,7 @@ e_editor_spell_check_dialog_get_dictionaries (EEditorSpellCheckDialog *dialog)
void
e_editor_spell_check_dialog_set_dictionaries (EEditorSpellCheckDialog *dialog,
- GList *dictionaries)
+ GList *dictionaries)
{
GtkComboBox *combo_box;
GtkListStore *store;
@@ -631,8 +641,6 @@ e_editor_spell_check_dialog_set_dictionaries (EEditorSpellCheckDialog *dialog,
g_return_if_fail (E_IS_EDITOR_SPELL_CHECK_DIALOG (dialog));
- combo_box = GTK_COMBO_BOX (dialog->priv->dictionary_combo);
-
/* Free the old list of spell checkers. */
g_list_free (dialog->priv->dictionaries);
@@ -643,22 +651,31 @@ e_editor_spell_check_dialog_set_dictionaries (EEditorSpellCheckDialog *dialog,
dialog->priv->dictionaries = list;
/* Populate a list store for the combo box. */
- store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER);
+ store = gtk_list_store_new (
+ NUM_COLUMNS,
+ G_TYPE_STRING, /* COLUMN_NAME */
+ E_TYPE_SPELL_DICTIONARY); /* COLUMN_DICTIONARY */
while (list != NULL) {
ESpellDictionary *dictionary = list->data;
GtkTreeIter iter;
+ const gchar *name;
+
+ dictionary = E_SPELL_DICTIONARY (list->data);
+ name = e_spell_dictionary_get_name (dictionary);
gtk_list_store_append (store, &iter);
gtk_list_store_set (
store, &iter,
- 0, e_spell_dictionary_get_name (dictionary),
- 1, dictionary, -1);
+ COLUMN_NAME, name,
+ COLUMN_DICTIONARY, dictionary,
+ -1);
list = g_list_next (list);
}
- /* FIXME: Try to restore selection */
+ /* FIXME Try to restore selection. */
+ combo_box = GTK_COMBO_BOX (dialog->priv->dictionary_combo);
gtk_combo_box_set_model (combo_box, GTK_TREE_MODEL (store));
gtk_combo_box_set_active (combo_box, 0);
diff --git a/e-util/e-editor-spell-check-dialog.h b/e-util/e-editor-spell-check-dialog.h
index a8202e2..1df962e 100644
--- a/e-util/e-editor-spell-check-dialog.h
+++ b/e-util/e-editor-spell-check-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorSpellCheckDialogPrivate EEditorSpellCheckDialogPrivate;
struct _EEditorSpellCheckDialog {
EEditorDialog parent;
-
EEditorSpellCheckDialogPrivate *priv;
};
@@ -62,14 +61,14 @@ struct _EEditorSpellCheckDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_spell_check_dialog_get_type (void);
-GtkWidget * e_editor_spell_check_dialog_new (EEditor *editor);
-
+GType e_editor_spell_check_dialog_get_type
+ (void) G_GNUC_CONST;
+GtkWidget * e_editor_spell_check_dialog_new (EEditor *editor);
GList * e_editor_spell_check_dialog_get_dictionaries
- (EEditorSpellCheckDialog *dialog);
+ (EEditorSpellCheckDialog *dialog);
void e_editor_spell_check_dialog_set_dictionaries
- (EEditorSpellCheckDialog *dialog,
- GList *dictionaries);
+ (EEditorSpellCheckDialog *dialog,
+ GList *dictionaries);
G_END_DECLS
diff --git a/e-util/e-editor-table-dialog.c b/e-util/e-editor-table-dialog.c
index cce1edd..64ad2f5 100644
--- a/e-util/e-editor-table-dialog.c
+++ b/e-util/e-editor-table-dialog.c
@@ -31,10 +31,9 @@
#include "e-image-chooser-dialog.h"
#include "e-misc-utils.h"
-G_DEFINE_TYPE (
- EEditorTableDialog,
- e_editor_table_dialog,
- E_TYPE_EDITOR_DIALOG);
+#define E_EDITOR_TABLE_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_TABLE_DIALOG, EEditorTableDialogPrivate))
struct _EEditorTableDialogPrivate {
GtkWidget *rows_edit;
@@ -59,6 +58,11 @@ struct _EEditorTableDialogPrivate {
static GdkRGBA white = { 1, 1, 1, 1 };
+G_DEFINE_TYPE (
+ EEditorTableDialog,
+ e_editor_table_dialog,
+ E_TYPE_EDITOR_DIALOG);
+
static WebKitDOMElement *
editor_table_dialog_create_table (EEditorTableDialog *dialog)
{
@@ -290,7 +294,8 @@ editor_table_dialog_set_padding (EEditorTableDialog *dialog)
g_return_if_fail (dialog->priv->table_element);
- padding = g_strdup_printf ("%d",
+ padding = g_strdup_printf (
+ "%d",
gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->padding_edit)));
@@ -329,7 +334,8 @@ editor_table_dialog_set_spacing (EEditorTableDialog *dialog)
g_return_if_fail (dialog->priv->table_element);
- spacing = g_strdup_printf ("%d",
+ spacing = g_strdup_printf (
+ "%d",
gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->spacing_edit)));
@@ -368,7 +374,8 @@ editor_table_dialog_set_border (EEditorTableDialog *dialog)
g_return_if_fail (dialog->priv->table_element);
- border = g_strdup_printf ("%d",
+ border = g_strdup_printf (
+ "%d",
gtk_spin_button_get_value_as_int (
GTK_SPIN_BUTTON (dialog->priv->border_edit)));
@@ -467,7 +474,7 @@ editor_table_dialog_get_background_image (EEditorTableDialog *dialog)
if (!webkit_dom_element_has_attribute (
WEBKIT_DOM_ELEMENT (dialog->priv->table_element), "background")) {
- gtk_file_chooser_unselect_all(
+ gtk_file_chooser_unselect_all (
GTK_FILE_CHOOSER (dialog->priv->background_image_button));
return;
} else {
@@ -538,7 +545,6 @@ editor_table_dialog_reset_values (EEditorTableDialog *dialog)
editor_table_dialog_set_background_image (dialog);
}
-
static void
editor_table_dialog_show (GtkWidget *widget)
{
@@ -582,20 +588,23 @@ editor_table_dialog_show (GtkWidget *widget)
static void
editor_table_dialog_hide (GtkWidget *widget)
{
- E_EDITOR_TABLE_DIALOG (widget)->priv->table_element = NULL;
+ EEditorTableDialogPrivate *priv;
+
+ priv = E_EDITOR_TABLE_DIALOG_GET_PRIVATE (widget);
+
+ priv->table_element = NULL;
GTK_WIDGET_CLASS (e_editor_table_dialog_parent_class)->hide (widget);
}
static void
-e_editor_table_dialog_class_init (EEditorTableDialogClass *klass)
+e_editor_table_dialog_class_init (EEditorTableDialogClass *class)
{
GtkWidgetClass *widget_class;
- g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorTableDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorTableDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_table_dialog_show;
widget_class->hide = editor_table_dialog_hide;
}
@@ -607,8 +616,7 @@ e_editor_table_dialog_init (EEditorTableDialog *dialog)
GtkWidget *widget;
GtkFileFilter *file_filter;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_TABLE_DIALOG, EEditorTableDialogPrivate);
+ dialog->priv = E_EDITOR_TABLE_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -658,7 +666,6 @@ e_editor_table_dialog_init (EEditorTableDialog *dialog)
gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dialog->priv->columns_edit);
gtk_grid_attach (grid, widget, 4, 0, 1, 1);
-
/* == Layout == */
widget = gtk_label_new ("");
gtk_label_set_markup (GTK_LABEL (widget), _("<b>Layout</b>"));
@@ -811,7 +818,6 @@ e_editor_table_dialog_init (EEditorTableDialog *dialog)
G_CALLBACK (editor_table_dialog_set_background_image), dialog);
dialog->priv->background_image_button = widget;
-
widget =gtk_label_new_with_mnemonic (_("Image:"));
gtk_label_set_justify (GTK_LABEL (widget), GTK_JUSTIFY_RIGHT);
gtk_label_set_mnemonic_widget (
diff --git a/e-util/e-editor-table-dialog.h b/e-util/e-editor-table-dialog.h
index e3262f6..834b3c4 100644
--- a/e-util/e-editor-table-dialog.h
+++ b/e-util/e-editor-table-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorTableDialogPrivate EEditorTableDialogPrivate;
struct _EEditorTableDialog {
EEditorDialog parent;
-
EEditorTableDialogPrivate *priv;
};
@@ -62,9 +61,8 @@ struct _EEditorTableDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_table_dialog_get_type (void);
-
-GtkWidget* e_editor_table_dialog_new (EEditor *editor);
+GType e_editor_table_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_table_dialog_new (EEditor *editor);
G_END_DECLS
diff --git a/e-util/e-editor-text-dialog.c b/e-util/e-editor-text-dialog.c
index 9668200..78cc052 100644
--- a/e-util/e-editor-text-dialog.c
+++ b/e-util/e-editor-text-dialog.c
@@ -28,10 +28,9 @@
#include "e-color-combo.h"
-G_DEFINE_TYPE (
- EEditorTextDialog,
- e_editor_text_dialog,
- E_TYPE_EDITOR_DIALOG);
+#define E_EDITOR_TEXT_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_TEXT_DIALOG, EEditorTextDialogPrivate))
struct _EEditorTextDialogPrivate {
GtkWidget *bold_check;
@@ -43,6 +42,10 @@ struct _EEditorTextDialogPrivate {
GtkWidget *size_check;
};
+G_DEFINE_TYPE (
+ EEditorTextDialog,
+ e_editor_text_dialog,
+ E_TYPE_EDITOR_DIALOG);
static void
editor_text_dialog_set_bold (EEditorTextDialog *dialog)
@@ -146,18 +149,18 @@ editor_text_dialog_set_size (EEditorTextDialog *dialog)
}
static void
-editor_text_dialog_show (GtkWidget *gtk_widget)
+editor_text_dialog_show (GtkWidget *widget)
{
EEditorTextDialog *dialog;
EEditor *editor;
- EEditorWidget *widget;
+ EEditorWidget *editor_widget;
EEditorSelection *selection;
GdkRGBA rgba;
- dialog = E_EDITOR_TEXT_DIALOG (gtk_widget);
+ dialog = E_EDITOR_TEXT_DIALOG (widget);
editor = e_editor_dialog_get_editor (E_EDITOR_DIALOG (dialog));
- widget = e_editor_get_editor_widget (editor);
- selection = e_editor_widget_get_selection (widget);
+ editor_widget = e_editor_get_editor_widget (editor);
+ selection = e_editor_widget_get_selection (editor_widget);
gtk_toggle_button_set_active (
GTK_TOGGLE_BUTTON (dialog->priv->bold_check),
@@ -180,18 +183,17 @@ editor_text_dialog_show (GtkWidget *gtk_widget)
e_color_combo_set_current_color (
E_COLOR_COMBO (dialog->priv->color_check), &rgba);
- GTK_WIDGET_CLASS (e_editor_text_dialog_parent_class)->show (gtk_widget);
+ GTK_WIDGET_CLASS (e_editor_text_dialog_parent_class)->show (widget);
}
static void
-e_editor_text_dialog_class_init (EEditorTextDialogClass *klass)
+e_editor_text_dialog_class_init (EEditorTextDialogClass *class)
{
GtkWidgetClass *widget_class;
- e_editor_text_dialog_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorTextDialogPrivate));
+ g_type_class_add_private (class, sizeof (EEditorTextDialogPrivate));
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->show = editor_text_dialog_show;
}
@@ -201,8 +203,7 @@ e_editor_text_dialog_init (EEditorTextDialog *dialog)
GtkGrid *main_layout;
GtkWidget *widget;
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_EDITOR_TEXT_DIALOG, EEditorTextDialogPrivate);
+ dialog->priv = E_EDITOR_TEXT_DIALOG_GET_PRIVATE (dialog);
main_layout = e_editor_dialog_get_container (E_EDITOR_DIALOG (dialog));
@@ -285,7 +286,6 @@ e_editor_text_dialog_init (EEditorTextDialog *dialog)
gtk_widget_show_all (GTK_WIDGET (main_layout));
}
-
GtkWidget *
e_editor_text_dialog_new (EEditor *editor)
{
diff --git a/e-util/e-editor-text-dialog.h b/e-util/e-editor-text-dialog.h
index 2eea996..2acaf30 100644
--- a/e-util/e-editor-text-dialog.h
+++ b/e-util/e-editor-text-dialog.h
@@ -54,7 +54,6 @@ typedef struct _EEditorTextDialogPrivate EEditorTextDialogPrivate;
struct _EEditorTextDialog {
EEditorDialog parent;
-
EEditorTextDialogPrivate *priv;
};
@@ -62,9 +61,8 @@ struct _EEditorTextDialogClass {
EEditorDialogClass parent_class;
};
-GType e_editor_text_dialog_get_type (void);
-
-GtkWidget* e_editor_text_dialog_new (EEditor *editor);
+GType e_editor_text_dialog_get_type (void) G_GNUC_CONST;
+GtkWidget * e_editor_text_dialog_new (EEditor *editor);
G_END_DECLS
diff --git a/e-util/e-editor-utils.c b/e-util/e-editor-utils.c
index ee872b5..d4f6308 100644
--- a/e-util/e-editor-utils.c
+++ b/e-util/e-editor-utils.c
@@ -39,7 +39,7 @@
*/
WebKitDOMElement *
e_editor_dom_node_find_parent_element (WebKitDOMNode *node,
- const gchar *tagname)
+ const gchar *tagname)
{
gint taglen = strlen (tagname);
@@ -81,7 +81,7 @@ e_editor_dom_node_find_parent_element (WebKitDOMNode *node,
*/
WebKitDOMElement *
e_editor_dom_node_find_child_element (WebKitDOMNode *node,
- const gchar *tagname)
+ const gchar *tagname)
{
WebKitDOMNode *start_node = node;
gint taglen = strlen (tagname);
diff --git a/e-util/e-editor-utils.h b/e-util/e-editor-utils.h
index fb4d313..b41a9ab 100644
--- a/e-util/e-editor-utils.h
+++ b/e-util/e-editor-utils.h
@@ -27,12 +27,18 @@
#include <webkit/webkitdom.h>
-WebKitDOMElement * e_editor_dom_node_find_parent_element
- (WebKitDOMNode *node,
- const gchar *tagname);
+G_BEGIN_DECLS
-WebKitDOMElement * e_editor_dom_node_find_child_element
- (WebKitDOMNode *node,
- const gchar *tagname);
+WebKitDOMElement *
+ e_editor_dom_node_find_parent_element
+ (WebKitDOMNode *node,
+ const gchar *tagname);
+
+WebKitDOMElement *
+ e_editor_dom_node_find_child_element
+ (WebKitDOMNode *node,
+ const gchar *tagname);
+
+G_END_DECLS
#endif /* E_EDITOR_UTILS_H */
diff --git a/e-util/e-editor-widget.c b/e-util/e-editor-widget.c
index 1e12629..3e4085d 100644
--- a/e-util/e-editor-widget.c
+++ b/e-util/e-editor-widget.c
@@ -31,10 +31,9 @@
#include <glib/gi18n-lib.h>
#include <gdk/gdkkeysyms.h>
-G_DEFINE_TYPE (
- EEditorWidget,
- e_editor_widget,
- WEBKIT_TYPE_WEB_VIEW);
+#define E_EDITOR_WIDGET_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_WIDGET, EEditorWidgetPrivate))
/**
* EEditorWidget:
@@ -69,20 +68,19 @@ struct _EEditorWidgetPrivate {
GQueue *postreload_operations;
};
-
enum {
PROP_0,
+ PROP_CAN_COPY,
+ PROP_CAN_CUT,
+ PROP_CAN_PASTE,
+ PROP_CAN_REDO,
+ PROP_CAN_UNDO,
PROP_CHANGED,
PROP_HTML_MODE,
PROP_INLINE_SPELLING,
PROP_MAGIC_LINKS,
PROP_MAGIC_SMILEYS,
- PROP_SPELL_LANGUAGES,
- PROP_CAN_COPY,
- PROP_CAN_CUT,
- PROP_CAN_PASTE,
- PROP_CAN_REDO,
- PROP_CAN_UNDO
+ PROP_SPELL_LANGUAGES
};
enum {
@@ -91,7 +89,7 @@ enum {
};
typedef void (*PostReloadOperationFunc) (EEditorWidget *widget,
- gpointer data);
+ gpointer data);
typedef struct {
PostReloadOperationFunc func;
@@ -101,11 +99,16 @@ typedef struct {
static guint signals[LAST_SIGNAL] = { 0 };
+G_DEFINE_TYPE (
+ EEditorWidget,
+ e_editor_widget,
+ WEBKIT_TYPE_WEB_VIEW);
+
static void
editor_widget_queue_postreload_operation (EEditorWidget *widget,
- PostReloadOperationFunc func,
- gpointer data,
- GDestroyNotify data_free_func)
+ PostReloadOperationFunc func,
+ gpointer data,
+ GDestroyNotify data_free_func)
{
PostReloadOperation *op;
@@ -142,20 +145,23 @@ editor_widget_get_dom_range (EEditorWidget *widget)
static void
editor_widget_user_changed_contents_cb (EEditorWidget *widget,
- gpointer user_data)
+ gpointer user_data)
{
+ WebKitWebView *web_view;
gboolean can_redo, can_undo;
+ web_view = WEBKIT_WEB_VIEW (widget);
+
e_editor_widget_set_changed (widget, TRUE);
- can_redo = webkit_web_view_can_redo (WEBKIT_WEB_VIEW (widget));
- if ((widget->priv->can_redo ? TRUE : FALSE) != (can_redo ? TRUE : FALSE)) {
+ can_redo = webkit_web_view_can_redo (web_view);
+ if (widget->priv->can_redo != can_redo) {
widget->priv->can_redo = can_redo;
g_object_notify (G_OBJECT (widget), "can-redo");
}
- can_undo = webkit_web_view_can_undo (WEBKIT_WEB_VIEW (widget));
- if ((widget->priv->can_undo ? TRUE : FALSE) != (can_undo ? TRUE : FALSE)) {
+ can_undo = webkit_web_view_can_undo (web_view);
+ if (widget->priv->can_undo != can_undo) {
widget->priv->can_undo = can_undo;
g_object_notify (G_OBJECT (widget), "can-undo");
}
@@ -163,32 +169,36 @@ editor_widget_user_changed_contents_cb (EEditorWidget *widget,
static void
editor_widget_selection_changed_cb (EEditorWidget *widget,
- gpointer user_data)
+ gpointer user_data)
{
+ WebKitWebView *web_view;
gboolean can_copy, can_cut, can_paste;
- /* When the webview is being (re)loaded, the document is in inconsitant
- * state and there is no selection, so don't propagate the signal further
- * to EEditorSelection and others and wait until the load is finished */
+ web_view = WEBKIT_WEB_VIEW (widget);
+
+ /* When the webview is being (re)loaded, the document is in an
+ * inconsistant state and there is no selection, so don't propagate
+ * the signal further to EEditorSelection and others and wait until
+ * the load is finished. */
if (widget->priv->reload_in_progress) {
g_signal_stop_emission_by_name (widget, "selection-changed");
return;
}
- can_copy = webkit_web_view_can_copy_clipboard (WEBKIT_WEB_VIEW (widget));
- if ((widget->priv->can_copy ? TRUE : FALSE) != (can_copy ? TRUE : FALSE)) {
+ can_copy = webkit_web_view_can_copy_clipboard (web_view);
+ if (widget->priv->can_copy != can_copy) {
widget->priv->can_copy = can_copy;
g_object_notify (G_OBJECT (widget), "can-copy");
}
- can_cut = webkit_web_view_can_cut_clipboard (WEBKIT_WEB_VIEW (widget));
- if ((widget->priv->can_cut ? TRUE : FALSE) != (can_cut ? TRUE : FALSE)) {
+ can_cut = webkit_web_view_can_cut_clipboard (web_view);
+ if (widget->priv->can_cut != can_cut) {
widget->priv->can_cut = can_cut;
g_object_notify (G_OBJECT (widget), "can-cut");
}
- can_paste = webkit_web_view_can_paste_clipboard (WEBKIT_WEB_VIEW (widget));
- if ((widget->priv->can_paste ? TRUE : FALSE) != (can_paste ? TRUE : FALSE)) {
+ can_paste = webkit_web_view_can_paste_clipboard (web_view);
+ if (widget->priv->can_paste != can_paste) {
widget->priv->can_paste = can_paste;
g_object_notify (G_OBJECT (widget), "can-paste");
}
@@ -196,7 +206,7 @@ editor_widget_selection_changed_cb (EEditorWidget *widget,
static gboolean
editor_widget_should_show_delete_interface_for_element (EEditorWidget *widget,
- WebKitDOMHTMLElement *element)
+ WebKitDOMHTMLElement *element)
{
return FALSE;
}
@@ -250,8 +260,8 @@ editor_widget_load_status_changed (EEditorWidget *widget)
static WebKitWebView *
editor_widget_open_inspector (WebKitWebInspector *inspector,
- WebKitWebView *webview,
- gpointer user_data)
+ WebKitWebView *webview,
+ gpointer user_data)
{
GtkWidget *window;
GtkWidget *inspector_view;
@@ -267,28 +277,6 @@ editor_widget_open_inspector (WebKitWebInspector *inspector,
return WEBKIT_WEB_VIEW (inspector_view);
}
-static gboolean
-editor_widget_button_press_event (GtkWidget *gtk_widget,
- GdkEventButton *event)
-{
- gboolean event_handled;
-
- if (event->button != 3) {
- event_handled = FALSE;
- } else {
- g_signal_emit (
- gtk_widget, signals[POPUP_EVENT],
- 0, event, &event_handled);
- }
-
- if (event_handled) {
- return TRUE;
- }
-
- /* Chain up to parent implementation */
- return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->button_press_event (gtk_widget, event);
-}
-
/* Based on original use_pictograms() from GtkHTML */
static const gchar *emoticons_chars =
/* 0 */ "DO)(|/PQ*!"
@@ -334,7 +322,7 @@ static const gchar *emoticons_icon_names[] = {
static void
editor_widget_check_magic_smileys (EEditorWidget *widget,
- WebKitDOMRange *range)
+ WebKitDOMRange *range)
{
gint pos;
gint state;
@@ -436,7 +424,7 @@ editor_widget_check_magic_smileys (EEditorWidget *widget,
static void
editor_widget_set_links_active (EEditorWidget *widget,
- gboolean active)
+ gboolean active)
{
WebKitDOMDocument *document;
WebKitDOMElement *style;
@@ -467,110 +455,16 @@ editor_widget_set_links_active (EEditorWidget *widget,
}
}
-static gboolean
-editor_widget_key_press_event (GtkWidget *gtk_widget,
- GdkEventKey *event)
-{
- EEditorWidget *editor = E_EDITOR_WIDGET (gtk_widget);
-
- if ((event->keyval == GDK_KEY_Control_L) ||
- (event->keyval == GDK_KEY_Control_R)) {
-
- editor_widget_set_links_active (editor, TRUE);
- }
-
- if ((event->keyval == GDK_KEY_Return) ||
- (event->keyval == GDK_KEY_KP_Enter)) {
-
- /* When user presses ENTER in a citation block, WebKit does not
- * break the citation automatically, so we need to use the special
- * command to do it. */
- EEditorSelection *selection = e_editor_widget_get_selection (E_EDITOR_WIDGET (gtk_widget));
- if (e_editor_selection_is_citation (selection)) {
- return e_editor_widget_exec_command (
- editor, E_EDITOR_WIDGET_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT, NULL);
- }
- }
-
- /* Propagate the event to WebKit */
- return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->key_press_event (gtk_widget, event);
-}
-
-static gboolean
-editor_widget_key_release_event (GtkWidget *gtk_widget,
- GdkEventKey *event)
-{
- WebKitDOMRange *range;
- EEditorWidget *widget = E_EDITOR_WIDGET (gtk_widget);
-
- range = editor_widget_get_dom_range (widget);
-
- if (widget->priv->magic_smileys &&
- widget->priv->html_mode) {
- editor_widget_check_magic_smileys (widget, range);
- }
-
- if ((event->keyval == GDK_KEY_Control_L) ||
- (event->keyval == GDK_KEY_Control_R)) {
-
- editor_widget_set_links_active (widget, FALSE);
- }
-
- /* Propagate the event to WebKit */
- return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->key_release_event (gtk_widget, event);
-}
-
-static gboolean
-editor_widget_button_release_event (GtkWidget *gtk_widget,
- GdkEventButton *event)
-{
- WebKitWebView *webview;
- WebKitHitTestResult *hit_test;
- WebKitHitTestResultContext context;
- gchar *uri;
-
- webview = WEBKIT_WEB_VIEW (gtk_widget);
- hit_test = webkit_web_view_get_hit_test_result (webview, event);
-
- g_object_get (
- hit_test,
- "context", &context,
- "link-uri", &uri,
- NULL);
-
- g_object_unref (hit_test);
-
- /* Left click on a link */
- if ((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) &&
- (event->button == 1)) {
-
- /* Ctrl + Left Click on link opens it, otherwise ignore the
- * click completely */
- if (event->state & GDK_CONTROL_MASK) {
-
- gtk_show_uri (
- gtk_window_get_screen (
- GTK_WINDOW (gtk_widget_get_toplevel (gtk_widget))),
- uri, event->time, NULL);
- }
-
- return TRUE;
- }
-
- /* Propagate the event to WebKit */
- return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->button_release_event (gtk_widget, event);
-}
-
static void
clipboard_text_received (GtkClipboard *clipboard,
- const gchar *text,
- EEditorWidget *widget)
+ const gchar *text,
+ EEditorWidget *widget)
{
gchar *html, *escaped_text;
WebKitDOMDocument *document;
WebKitDOMElement *element;
- /* This is a little trick to escape any HTML characters (like <, > or &).
+ /* This is a trick to escape any HTML characters (like <, > or &).
* <textarea> automatically replaces all these unsafe characters
* by <, > etc. */
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
@@ -591,121 +485,111 @@ clipboard_text_received (GtkClipboard *clipboard,
}
static void
-editor_widget_paste_clipboard_quoted (EEditorWidget *widget)
-{
- GtkClipboard *clipboard;
-
- clipboard = gtk_clipboard_get_for_display (
- gdk_display_get_default (),
- GDK_SELECTION_CLIPBOARD);
-
- gtk_clipboard_request_text (
- clipboard,
- (GtkClipboardTextReceivedFunc) clipboard_text_received,
- widget);
-}
-
-static void
-e_editor_widget_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+editor_widget_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
+ case PROP_CHANGED:
+ e_editor_widget_set_changed (
+ E_EDITOR_WIDGET (object),
+ g_value_get_boolean (value));
+ return;
case PROP_HTML_MODE:
- g_value_set_boolean (
- value, e_editor_widget_get_html_mode (
- E_EDITOR_WIDGET (object)));
+ e_editor_widget_set_html_mode (
+ E_EDITOR_WIDGET (object),
+ g_value_get_boolean (value));
return;
case PROP_INLINE_SPELLING:
- g_value_set_boolean (
- value, e_editor_widget_get_inline_spelling (
- E_EDITOR_WIDGET (object)));
+ e_editor_widget_set_inline_spelling (
+ E_EDITOR_WIDGET (object),
+ g_value_get_boolean (value));
return;
case PROP_MAGIC_LINKS:
- g_value_set_boolean (
- value, e_editor_widget_get_magic_links (
- E_EDITOR_WIDGET (object)));
+ e_editor_widget_set_magic_links (
+ E_EDITOR_WIDGET (object),
+ g_value_get_boolean (value));
return;
case PROP_MAGIC_SMILEYS:
- g_value_set_boolean (
- value, e_editor_widget_get_magic_smileys (
- E_EDITOR_WIDGET (object)));
- return;
- case PROP_CHANGED:
- g_value_set_boolean (
- value, e_editor_widget_get_changed (
- E_EDITOR_WIDGET (object)));
+ e_editor_widget_set_magic_smileys (
+ E_EDITOR_WIDGET (object),
+ g_value_get_boolean (value));
return;
+ }
+
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+}
+
+static void
+editor_widget_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ switch (property_id) {
case PROP_CAN_COPY:
g_value_set_boolean (
value, webkit_web_view_can_copy_clipboard (
WEBKIT_WEB_VIEW (object)));
return;
+
case PROP_CAN_CUT:
g_value_set_boolean (
value, webkit_web_view_can_cut_clipboard (
WEBKIT_WEB_VIEW (object)));
return;
+
case PROP_CAN_PASTE:
g_value_set_boolean (
value, webkit_web_view_can_paste_clipboard (
WEBKIT_WEB_VIEW (object)));
return;
+
case PROP_CAN_REDO:
g_value_set_boolean (
value, webkit_web_view_can_redo (
WEBKIT_WEB_VIEW (object)));
return;
+
case PROP_CAN_UNDO:
g_value_set_boolean (
value, webkit_web_view_can_undo (
WEBKIT_WEB_VIEW (object)));
return;
- }
-
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-}
-static void
-e_editor_widget_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- switch (property_id) {
+ case PROP_CHANGED:
+ g_value_set_boolean (
+ value, e_editor_widget_get_changed (
+ E_EDITOR_WIDGET (object)));
+ return;
case PROP_HTML_MODE:
- e_editor_widget_set_html_mode (
- E_EDITOR_WIDGET (object),
- g_value_get_boolean (value));
+ g_value_set_boolean (
+ value, e_editor_widget_get_html_mode (
+ E_EDITOR_WIDGET (object)));
return;
case PROP_INLINE_SPELLING:
- e_editor_widget_set_inline_spelling (
- E_EDITOR_WIDGET (object),
- g_value_get_boolean (value));
+ g_value_set_boolean (
+ value, e_editor_widget_get_inline_spelling (
+ E_EDITOR_WIDGET (object)));
return;
case PROP_MAGIC_LINKS:
- e_editor_widget_set_magic_links (
- E_EDITOR_WIDGET (object),
- g_value_get_boolean (value));
+ g_value_set_boolean (
+ value, e_editor_widget_get_magic_links (
+ E_EDITOR_WIDGET (object)));
return;
case PROP_MAGIC_SMILEYS:
- e_editor_widget_set_magic_smileys (
- E_EDITOR_WIDGET (object),
- g_value_get_boolean (value));
- return;
- case PROP_CHANGED:
- e_editor_widget_set_changed (
- E_EDITOR_WIDGET (object),
- g_value_get_boolean (value));
+ g_value_set_boolean (
+ value, e_editor_widget_get_magic_smileys (
+ E_EDITOR_WIDGET (object)));
return;
}
@@ -713,117 +597,178 @@ e_editor_widget_set_property (GObject *object,
}
static void
-e_editor_widget_finalize (GObject *object)
+editor_widget_dispose (GObject *object)
{
- EEditorWidgetPrivate *priv = E_EDITOR_WIDGET (object)->priv;
+ EEditorWidgetPrivate *priv;
+
+ priv = E_EDITOR_WIDGET_GET_PRIVATE (object);
g_clear_object (&priv->selection);
- /* Chain up to parent's implementation */
- G_OBJECT_CLASS (e_editor_widget_parent_class)->finalize (object);
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_editor_widget_parent_class)->dispose (object);
+}
+
+static gboolean
+editor_widget_button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ gboolean event_handled;
+
+ if (event->button != 3) {
+ event_handled = FALSE;
+ } else {
+ g_signal_emit (
+ widget, signals[POPUP_EVENT],
+ 0, event, &event_handled);
+ }
+
+ if (event_handled)
+ return TRUE;
+
+ /* Chain up to parent's button_press_event() method. */
+ return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->
+ button_press_event (widget, event);
+}
+
+static gboolean
+editor_widget_button_release_event (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ WebKitWebView *webview;
+ WebKitHitTestResult *hit_test;
+ WebKitHitTestResultContext context;
+ gchar *uri;
+
+ webview = WEBKIT_WEB_VIEW (widget);
+ hit_test = webkit_web_view_get_hit_test_result (webview, event);
+
+ g_object_get (
+ hit_test,
+ "context", &context,
+ "link-uri", &uri,
+ NULL);
+
+ g_object_unref (hit_test);
+
+ /* Left click on a link */
+ if ((context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) &&
+ (event->button == 1)) {
+
+ /* Ctrl + Left Click on link opens it, otherwise ignore the
+ * click completely */
+ if (event->state & GDK_CONTROL_MASK) {
+ GtkWidget *toplevel;
+ GdkScreen *screen;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
+ gtk_show_uri (screen, uri, event->time, NULL);
+ }
+
+ return TRUE;
+ }
+
+ /* Chain up to parent's button_release_event() method. */
+ return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->
+ button_release_event (widget, event);
+}
+
+static gboolean
+editor_widget_key_press_event (GtkWidget *widget,
+ GdkEventKey *event)
+{
+ EEditorWidget *editor = E_EDITOR_WIDGET (widget);
+
+ if ((event->keyval == GDK_KEY_Control_L) ||
+ (event->keyval == GDK_KEY_Control_R)) {
+
+ editor_widget_set_links_active (editor, TRUE);
+ }
+
+ if ((event->keyval == GDK_KEY_Return) ||
+ (event->keyval == GDK_KEY_KP_Enter)) {
+
+ /* When user presses ENTER in a citation block, WebKit does
+ * not break the citation automatically, so we need to use
+ * the special command to do it. */
+ EEditorSelection *selection;
+
+ selection = e_editor_widget_get_selection (editor);
+ if (e_editor_selection_is_citation (selection)) {
+ return e_editor_widget_exec_command (
+ editor,
+ E_EDITOR_WIDGET_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT,
+ NULL);
+ }
+ }
+
+ /* Chain up to parent's key_press_event() method. */
+ return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->
+ key_press_event (widget, event);
+}
+
+static gboolean
+editor_widget_key_release_event (GtkWidget *widget,
+ GdkEventKey *event)
+{
+ WebKitDOMRange *range;
+ EEditorWidget *editor_widget;
+
+ editor_widget = E_EDITOR_WIDGET (widget);
+ range = editor_widget_get_dom_range (editor_widget);
+
+ if (editor_widget->priv->magic_smileys &&
+ editor_widget->priv->html_mode) {
+ editor_widget_check_magic_smileys (editor_widget, range);
+ }
+
+ if ((event->keyval == GDK_KEY_Control_L) ||
+ (event->keyval == GDK_KEY_Control_R)) {
+
+ editor_widget_set_links_active (editor_widget, FALSE);
+ }
+
+ /* Chain up to parent's key_release_event() method. */
+ return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->
+ key_release_event (widget, event);
+}
+
+static void
+editor_widget_paste_clipboard_quoted (EEditorWidget *widget)
+{
+ GtkClipboard *clipboard;
+
+ clipboard = gtk_clipboard_get_for_display (
+ gdk_display_get_default (),
+ GDK_SELECTION_CLIPBOARD);
+
+ gtk_clipboard_request_text (
+ clipboard,
+ (GtkClipboardTextReceivedFunc) clipboard_text_received,
+ widget);
}
static void
-e_editor_widget_class_init (EEditorWidgetClass *klass)
+e_editor_widget_class_init (EEditorWidgetClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- g_type_class_add_private (klass, sizeof (EEditorWidgetPrivate));
+ g_type_class_add_private (class, sizeof (EEditorWidgetPrivate));
- object_class = G_OBJECT_CLASS (klass);
- object_class->get_property = e_editor_widget_get_property;
- object_class->set_property = e_editor_widget_set_property;
- object_class->finalize = e_editor_widget_finalize;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->get_property = editor_widget_get_property;
+ object_class->set_property = editor_widget_set_property;
+ object_class->dispose = editor_widget_dispose;
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->button_press_event = editor_widget_button_press_event;
widget_class->button_release_event = editor_widget_button_release_event;
widget_class->key_press_event = editor_widget_key_press_event;
widget_class->key_release_event = editor_widget_key_release_event;
- klass->paste_clipboard_quoted = editor_widget_paste_clipboard_quoted;
-
- /**
- * EEditorWidget:html-mode
- *
- * Determines whether HTML or plain text mode is enabled.
- **/
- g_object_class_install_property (
- object_class,
- PROP_HTML_MODE,
- g_param_spec_boolean (
- "html-mode",
- "HTML Mode",
- "Edit HTML or plain text",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- /**
- * EEditorWidget::inline-spelling
- *
- * Determines whether automatic spellchecking is enabled.
- */
- g_object_class_install_property (
- object_class,
- PROP_INLINE_SPELLING,
- g_param_spec_boolean (
- "inline-spelling",
- "Inline Spelling",
- "Check your spelling as you type",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- /**
- * EEditorWidget:magic-links
- *
- * Determines whether automatic conversion of text links into
- * HTML links is enabled.
- */
- g_object_class_install_property (
- object_class,
- PROP_MAGIC_LINKS,
- g_param_spec_boolean (
- "magic-links",
- "Magic Links",
- "Make URIs clickable as you type",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- /**
- * EEditorWidget:magic-smileys
- *
- * Determines whether automatic conversion of text smileys into
- * images is enabled.
- */
- g_object_class_install_property (
- object_class,
- PROP_MAGIC_SMILEYS,
- g_param_spec_boolean (
- "magic-smileys",
- "Magic Smileys",
- "Convert emoticons to images as you type",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- /**
- * EEditorWidget:changed
- *
- * Determines whether document has been modified
- */
- g_object_class_install_property (
- object_class,
- PROP_CHANGED,
- g_param_spec_boolean (
- "changed",
- _("Changed property"),
- _("Whether editor changed"),
- FALSE,
- G_PARAM_READWRITE));
+ class->paste_clipboard_quoted = editor_widget_paste_clipboard_quoted;
/**
* EEditorWidget:can-copy
@@ -839,7 +784,8 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
"Can Copy",
NULL,
FALSE,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorWidget:can-cut
@@ -855,13 +801,15 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
"Can Cut",
NULL,
FALSE,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorWidget:can-paste
*
* Determines whether it's possible to paste from clipboard. The action
- * is usually disabled when there is no valid content in clipboard to paste.
+ * is usually disabled when there is no valid content in clipboard to
+ * paste.
*/
g_object_class_install_property (
object_class,
@@ -871,10 +819,11 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
"Can Paste",
NULL,
FALSE,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
- * EEditorWidget:can-redu
+ * EEditorWidget:can-redo
*
* Determines whether it's possible to redo previous action. The action
* is usually disabled when there is no action to redo.
@@ -887,7 +836,8 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
"Can Redo",
NULL,
FALSE,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorWidget:can-undo
@@ -903,7 +853,94 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
"Can Undo",
NULL,
FALSE,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * EEditorWidget:changed
+ *
+ * Determines whether document has been modified
+ */
+ g_object_class_install_property (
+ object_class,
+ PROP_CHANGED,
+ g_param_spec_boolean (
+ "changed",
+ _("Changed property"),
+ _("Whether editor changed"),
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * EEditorWidget:html-mode
+ *
+ * Determines whether HTML or plain text mode is enabled.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_HTML_MODE,
+ g_param_spec_boolean (
+ "html-mode",
+ "HTML Mode",
+ "Edit HTML or plain text",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * EEditorWidget::inline-spelling
+ *
+ * Determines whether automatic spellchecking is enabled.
+ */
+ g_object_class_install_property (
+ object_class,
+ PROP_INLINE_SPELLING,
+ g_param_spec_boolean (
+ "inline-spelling",
+ "Inline Spelling",
+ "Check your spelling as you type",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * EEditorWidget:magic-links
+ *
+ * Determines whether automatic conversion of text links into
+ * HTML links is enabled.
+ */
+ g_object_class_install_property (
+ object_class,
+ PROP_MAGIC_LINKS,
+ g_param_spec_boolean (
+ "magic-links",
+ "Magic Links",
+ "Make URIs clickable as you type",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ /**
+ * EEditorWidget:magic-smileys
+ *
+ * Determines whether automatic conversion of text smileys into
+ * images is enabled.
+ */
+ g_object_class_install_property (
+ object_class,
+ PROP_MAGIC_SMILEYS,
+ g_param_spec_boolean (
+ "magic-smileys",
+ "Magic Smileys",
+ "Convert emoticons to images as you type",
+ TRUE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorWidget:spell-languages
@@ -917,7 +954,8 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
"spell-languages",
"Active spell checking languages",
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorWidget:popup-event
@@ -926,7 +964,7 @@ e_editor_widget_class_init (EEditorWidgetClass *klass)
*/
signals[POPUP_EVENT] = g_signal_new (
"popup-event",
- G_TYPE_FROM_CLASS (klass),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EEditorWidgetClass, popup_event),
g_signal_accumulator_true_handled, NULL,
@@ -944,8 +982,7 @@ e_editor_widget_init (EEditorWidget *editor)
GSettingsSchema *settings_schema;
ESpellChecker *checker;
- editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- editor, E_TYPE_EDITOR_WIDGET, EEditorWidgetPrivate);
+ editor->priv = E_EDITOR_WIDGET_GET_PRIVATE (editor);
webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor), TRUE);
settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (editor));
@@ -955,9 +992,9 @@ e_editor_widget_init (EEditorWidget *editor)
"enable-developer-extras", TRUE,
"enable-dom-paste", TRUE,
"enable-file-access-from-file-uris", TRUE,
- "enable-plugins", FALSE,
- "enable-scripts", FALSE,
- "enable-spell-checking", TRUE,
+ "enable-plugins", FALSE,
+ "enable-scripts", FALSE,
+ "enable-spell-checking", TRUE,
NULL);
webkit_web_view_set_settings (WEBKIT_WEB_VIEW (editor), settings);
@@ -972,23 +1009,28 @@ e_editor_widget_init (EEditorWidget *editor)
e_editor_widget_exec_command (
editor, E_EDITOR_WIDGET_COMMAND_STYLE_WITH_CSS, "false");
- g_signal_connect (editor, "user-changed-contents",
+ g_signal_connect (
+ editor, "user-changed-contents",
G_CALLBACK (editor_widget_user_changed_contents_cb), NULL);
- g_signal_connect (editor, "selection-changed",
+ g_signal_connect (
+ editor, "selection-changed",
G_CALLBACK (editor_widget_selection_changed_cb), NULL);
- g_signal_connect (editor, "should-show-delete-interface-for-element",
+ g_signal_connect (
+ editor, "should-show-delete-interface-for-element",
G_CALLBACK (editor_widget_should_show_delete_interface_for_element), NULL);
- g_signal_connect (editor, "notify::load-status",
+ g_signal_connect (
+ editor, "notify::load-status",
G_CALLBACK (editor_widget_load_status_changed), NULL);
inspector = webkit_web_view_get_inspector (WEBKIT_WEB_VIEW (editor));
- g_signal_connect (inspector, "inspect-web-view",
+ g_signal_connect (
+ inspector, "inspect-web-view",
G_CALLBACK (editor_widget_open_inspector), NULL);
editor->priv->selection = g_object_new (
- E_TYPE_EDITOR_SELECTION,
- "editor-widget", editor,
- NULL);
+ E_TYPE_EDITOR_SELECTION,
+ "editor-widget", editor,
+ NULL);
g_settings = g_settings_new ("org.gnome.desktop.interface");
g_signal_connect_swapped (
@@ -1013,7 +1055,6 @@ e_editor_widget_init (EEditorWidget *editor)
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 */
webkit_web_view_load_string (
@@ -1067,9 +1108,9 @@ e_editor_widget_get_selection (EEditorWidget *widget)
* Returns: @TRUE when the command was succesfully executed, @FALSE otherwise.
*/
gboolean
-e_editor_widget_exec_command (EEditorWidget* widget,
- EEditorWidgetCommand command,
- const gchar* value)
+e_editor_widget_exec_command (EEditorWidget *widget,
+ EEditorWidgetCommand command,
+ const gchar *value)
{
WebKitDOMDocument *document;
const gchar *cmd_str = 0;
@@ -1086,55 +1127,55 @@ e_editor_widget_exec_command (EEditorWidget* widget,
break;
switch (command) {
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_BACKGROUND_COLOR, "BackColor", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_BOLD, "Bold", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_COPY, "Copy", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_CREATE_LINK, "CreateLink", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_CUT, "Cut", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_DEFAULT_PARAGRAPH_SEPARATOR,
"DefaultParagraphSeparator", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_DELETE, "Delete", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_FIND_STRING, "FindString", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_FONT_NAME, "FontName", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_FONT_SIZE, "FontSize", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_FONT_SIZE_DELTA, "FontSizeDelta", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_FORE_COLOR, "ForeColor", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_FORMAT_BLOCK, "FormatBlock", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_FORWARD_DELETE, "ForwardDelete", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_HILITE_COLOR, "HiliteColor", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INDENT, "Indent", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_HORIZONTAL_RULE, "InsertHorizontalRule", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_HTML, "InsertHTML", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_IMAGE, "InsertImage", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_LINE_BREAK, "InsertLineBreak", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT,
"InsertNewlineInQuotedContent", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_ORDERED_LIST, "InsertOrderedList", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_PARAGRAPH, "InsertParagraph", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_TEXT, "InsertText", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_INSERT_UNORDERED_LIST, "InsertUnorderedList", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_ITALIC, "Italic", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_JUSTIFY_CENTER, "JustifyCenter", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_JUSTIFY_FULL, "JustifyFull", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_JUSTIFY_LEFT, "JustifyLeft", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_JUSTIFY_NONE, "JustifyNone", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_JUSTIFY_RIGHT, "JustifyRight", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_OUTDENT, "Outdent", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_PASTE, "Paste", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_PASTE_AND_MATCH_STYLE, "PasteAndMatchStyle", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_PASTE_AS_PLAIN_TEXT, "PasteAsPlainText", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_PRINT, "Print", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_REDO, "Redo", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_REMOVE_FORMAT, "RemoveFormat", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_SELECT_ALL, "SelectAll", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_STRIKETHROUGH, "Strikethrough", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_STYLE_WITH_CSS, "StyleWithCSS", TRUE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_SUBSCRIPT, "Subscript", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_SUPERSCRIPT, "Superscript", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_TRANSPOSE, "Transpose", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_UNDERLINE, "Underline", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_UNDO, "Undo", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_UNLINK, "Unlink", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_UNSELECT, "Unselect", FALSE)
- CHECK_COMMAND(E_EDITOR_WIDGET_COMMAND_USE_CSS, "UseCSS", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_BACKGROUND_COLOR, "BackColor", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_BOLD, "Bold", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_COPY, "Copy", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_CREATE_LINK, "CreateLink", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_CUT, "Cut", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_DEFAULT_PARAGRAPH_SEPARATOR,
"DefaultParagraphSeparator", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_DELETE, "Delete", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_FIND_STRING, "FindString", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_FONT_NAME, "FontName", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_FONT_SIZE, "FontSize", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_FONT_SIZE_DELTA, "FontSizeDelta", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_FORE_COLOR, "ForeColor", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_FORMAT_BLOCK, "FormatBlock", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_FORWARD_DELETE, "ForwardDelete", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_HILITE_COLOR, "HiliteColor", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INDENT, "Indent", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_HORIZONTAL_RULE, "InsertHorizontalRule", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_HTML, "InsertHTML", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_IMAGE, "InsertImage", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_LINE_BREAK, "InsertLineBreak", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_NEW_LINE_IN_QUOTED_CONTENT,
"InsertNewlineInQuotedContent", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_ORDERED_LIST, "InsertOrderedList", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_PARAGRAPH, "InsertParagraph", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_TEXT, "InsertText", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_INSERT_UNORDERED_LIST, "InsertUnorderedList", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_ITALIC, "Italic", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_JUSTIFY_CENTER, "JustifyCenter", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_JUSTIFY_FULL, "JustifyFull", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_JUSTIFY_LEFT, "JustifyLeft", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_JUSTIFY_NONE, "JustifyNone", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_JUSTIFY_RIGHT, "JustifyRight", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_OUTDENT, "Outdent", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_PASTE, "Paste", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_PASTE_AND_MATCH_STYLE, "PasteAndMatchStyle", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_PASTE_AS_PLAIN_TEXT, "PasteAsPlainText", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_PRINT, "Print", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_REDO, "Redo", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_REMOVE_FORMAT, "RemoveFormat", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_SELECT_ALL, "SelectAll", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_STRIKETHROUGH, "Strikethrough", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_STYLE_WITH_CSS, "StyleWithCSS", TRUE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_SUBSCRIPT, "Subscript", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_SUPERSCRIPT, "Superscript", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_TRANSPOSE, "Transpose", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_UNDERLINE, "Underline", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_UNDO, "Undo", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_UNLINK, "Unlink", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_UNSELECT, "Unselect", FALSE)
+ CHECK_COMMAND (E_EDITOR_WIDGET_COMMAND_USE_CSS, "UseCSS", TRUE)
}
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
@@ -1169,11 +1210,11 @@ e_editor_widget_get_changed (EEditorWidget *widget)
*/
void
e_editor_widget_set_changed (EEditorWidget *widget,
- gboolean changed)
+ gboolean changed)
{
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
- if ((widget->priv->changed ? TRUE : FALSE) == (changed ? TRUE : FALSE))
+ if (widget->priv->changed == changed)
return;
widget->priv->changed = changed;
@@ -1211,27 +1252,27 @@ e_editor_widget_get_html_mode (EEditorWidget *widget)
*/
void
e_editor_widget_set_html_mode (EEditorWidget *widget,
- gboolean html_mode)
+ gboolean html_mode)
{
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
/* If toggling from HTML to plain text mode, ask user first */
if (widget->priv->html_mode && !html_mode && widget->priv->changed) {
- GtkWidget *parent, *dialog;
+ GtkWidget *toplevel, *dialog;
+ GtkWindow *parent = NULL;
- parent = gtk_widget_get_toplevel (GTK_WIDGET (widget));
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (widget));
- if (!GTK_IS_WINDOW (parent)) {
- parent = NULL;
- }
+ if (GTK_IS_WINDOW (toplevel))
+ parent = GTK_WINDOW (toplevel);
dialog = gtk_message_dialog_new (
- parent ? GTK_WINDOW (parent) : NULL,
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_NONE,
- _("Turning HTML mode off will cause the text "
- "to lose all formatting. Do you want to continue?"));
+ parent,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_NONE,
+ _("Turning HTML mode off will cause the text "
+ "to lose all formatting. Do you want to continue?"));
gtk_dialog_add_buttons (
GTK_DIALOG (dialog),
_("_Don't lose formatting"), GTK_RESPONSE_CANCEL,
@@ -1248,9 +1289,8 @@ e_editor_widget_set_html_mode (EEditorWidget *widget,
gtk_widget_destroy (dialog);
}
- if ((widget->priv->html_mode ? 1 : 0) == (html_mode ? 1 : 0)) {
+ if (html_mode == widget->priv->html_mode)
return;
- }
widget->priv->html_mode = html_mode;
@@ -1285,7 +1325,7 @@ e_editor_widget_set_html_mode (EEditorWidget *widget,
g_free (plain);
}
-
+
g_object_notify (G_OBJECT (widget), "html-mode");
}
@@ -1316,11 +1356,11 @@ e_editor_widget_get_inline_spelling (EEditorWidget *widget)
*/
void
e_editor_widget_set_inline_spelling (EEditorWidget *widget,
- gboolean inline_spelling)
+ gboolean inline_spelling)
{
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
- if ((widget->priv->inline_spelling ? TRUE : FALSE) == (inline_spelling ? TRUE : FALSE))
+ if (widget->priv->inline_spelling == inline_spelling)
return;
widget->priv->inline_spelling = inline_spelling;
@@ -1354,11 +1394,11 @@ e_editor_widget_get_magic_links (EEditorWidget *widget)
*/
void
e_editor_widget_set_magic_links (EEditorWidget *widget,
- gboolean magic_links)
+ gboolean magic_links)
{
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
- if ((widget->priv->magic_links ? TRUE : FALSE) == (magic_links ? TRUE : FALSE))
+ if (widget->priv->magic_links == magic_links)
return;
widget->priv->magic_links = magic_links;
@@ -1393,11 +1433,11 @@ e_editor_widget_get_magic_smileys (EEditorWidget *widget)
*/
void
e_editor_widget_set_magic_smileys (EEditorWidget *widget,
- gboolean magic_smileys)
+ gboolean magic_smileys)
{
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
- if ((widget->priv->magic_smileys ? TRUE : FALSE) == (magic_smileys ? TRUE : FALSE))
+ if (widget->priv->magic_smileys == magic_smileys)
return;
widget->priv->magic_smileys = magic_smileys;
@@ -1481,7 +1521,7 @@ e_editor_widget_get_text_html (EEditorWidget *widget)
static void
process_elements (WebKitDOMNode *node,
- GString *buffer)
+ GString *buffer)
{
WebKitDOMDocument *document;
WebKitDOMDOMWindow *window;
@@ -1496,9 +1536,9 @@ process_elements (WebKitDOMNode *node,
/* Is this a block element? */
style = webkit_dom_dom_window_get_computed_style (
- window, WEBKIT_DOM_ELEMENT (node), "");
+ window, WEBKIT_DOM_ELEMENT (node), "");
display = webkit_dom_css_style_declaration_get_property_value (
- style, "display");
+ style, "display");
tagname = webkit_dom_element_get_tag_name (WEBKIT_DOM_ELEMENT (node));
@@ -1511,12 +1551,12 @@ process_elements (WebKitDOMNode *node,
const EEmoticon *emoticon;
smiley_name = webkit_dom_element_get_attribute (
- WEBKIT_DOM_ELEMENT (node), "x-evo-smiley");
+ WEBKIT_DOM_ELEMENT (node), "x-evo-smiley");
emoticon = e_emoticon_chooser_lookup_emoticon (smiley_name);
- if (emoticon) {
+ if (emoticon != NULL)
g_string_append_printf (
buffer, " %s ", emoticon->text_face);
- }
+
g_free (smiley_name);
g_free (display);
@@ -1525,7 +1565,6 @@ process_elements (WebKitDOMNode *node,
}
}
-
nodes = webkit_dom_node_get_child_nodes (node);
length = webkit_dom_node_list_get_length (nodes);
regex = g_regex_new ("\x9", 0, 0, NULL);
@@ -1540,7 +1579,7 @@ process_elements (WebKitDOMNode *node,
tmp = webkit_dom_node_get_text_content (child);
/* Replace tabs with 4 whitespaces, otherwise they got
- replaced by single whitespace */
+ * replaced by single whitespace */
content = g_regex_replace (
regex, tmp, -1, 0, " ",
0, NULL);
@@ -1567,10 +1606,11 @@ process_elements (WebKitDOMNode *node,
* e_editor_widget_get_text_plain:
* @widget: an #EEditorWidget
*
- * Returns plain text content of the @widget. The algorithm removes any formatting
- * or styles from the document and keeps only the text and line breaks.
+ * Returns plain text content of the @widget. The algorithm removes any
+ * formatting or styles from the document and keeps only the text and line
+ * breaks.
*
- * Returns: A newly allocated string with plain text content of the document. [transfer-full]
+ * Returns: A newly allocated string with plain text content of the document.
*/
gchar *
e_editor_widget_get_text_plain (EEditorWidget *widget)
@@ -1598,7 +1638,7 @@ e_editor_widget_get_text_plain (EEditorWidget *widget)
*/
void
e_editor_widget_set_text_html (EEditorWidget *widget,
- const gchar *text)
+ const gchar *text)
{
widget->priv->reload_in_progress = TRUE;
@@ -1608,7 +1648,7 @@ e_editor_widget_set_text_html (EEditorWidget *widget,
static void
do_set_text_plain (EEditorWidget *widget,
- gpointer data)
+ gpointer data)
{
e_editor_widget_exec_command (
widget, E_EDITOR_WIDGET_COMMAND_INSERT_TEXT, data);
@@ -1623,7 +1663,7 @@ do_set_text_plain (EEditorWidget *widget,
*/
void
e_editor_widget_set_text_plain (EEditorWidget *widget,
- const gchar *text)
+ const gchar *text)
{
widget->priv->reload_in_progress = TRUE;
@@ -1647,14 +1687,14 @@ e_editor_widget_set_text_plain (EEditorWidget *widget,
void
e_editor_widget_paste_clipboard_quoted (EEditorWidget *widget)
{
- EEditorWidgetClass *klass;
+ EEditorWidgetClass *class;
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
- klass = E_EDITOR_WIDGET_GET_CLASS (widget);
- g_return_if_fail (klass->paste_clipboard_quoted != NULL);
+ class = E_EDITOR_WIDGET_GET_CLASS (widget);
+ g_return_if_fail (class->paste_clipboard_quoted != NULL);
- klass->paste_clipboard_quoted (widget);
+ class->paste_clipboard_quoted (widget);
}
/**
@@ -1699,7 +1739,8 @@ e_editor_widget_update_fonts (EEditorWidget *widget)
}
stylesheet = g_string_new ("");
- g_string_append_printf (stylesheet,
+ g_string_append_printf (
+ stylesheet,
"body {\n"
" font-family: '%s';\n"
" font-size: %dpt;\n"
@@ -1731,7 +1772,8 @@ e_editor_widget_update_fonts (EEditorWidget *widget)
g_string_append (stylesheet, "}\n");
- g_string_append_printf (stylesheet,
+ g_string_append_printf (
+ stylesheet,
"pre,code,.pre {\n"
" font-family: '%s';\n"
" font-size: %dpt;\n"
@@ -1744,7 +1786,8 @@ e_editor_widget_update_fonts (EEditorWidget *widget)
styles[pango_font_description_get_style (ms)]);
context = gtk_widget_get_style_context (GTK_WIDGET (widget));
- gtk_style_context_get_style (context,
+ gtk_style_context_get_style (
+ context,
"link-color", &link,
"visited-link-color", &visited,
NULL);
@@ -1759,7 +1802,8 @@ e_editor_widget_update_fonts (EEditorWidget *widget)
visited->red = G_MAXINT16;
}
- g_string_append_printf (stylesheet,
+ g_string_append_printf (
+ stylesheet,
"a {\n"
" color: #%06x;\n"
"}\n"
@@ -1770,7 +1814,8 @@ e_editor_widget_update_fonts (EEditorWidget *widget)
e_color_to_value (visited));
/* See bug #689777 for details */
- g_string_append_printf (stylesheet,
+ g_string_append_printf (
+ stylesheet,
"p,pre,code,address {\n"
" margin: 0;\n"
"}\n"
@@ -1790,7 +1835,8 @@ e_editor_widget_update_fonts (EEditorWidget *widget)
g_free (base64);
settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (widget));
- g_object_set (G_OBJECT (settings),
+ 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),
diff --git a/e-util/e-editor-widget.h b/e-util/e-editor-widget.h
index 1c07d5d..4bc26e3 100644
--- a/e-util/e-editor-widget.h
+++ b/e-util/e-editor-widget.h
@@ -58,7 +58,6 @@ typedef enum {
E_EDITOR_WIDGET_REPLACE_ANSWER_NEXT
} EEditorWidgetReplaceAnswer;
-
/**
* EEditorWidgetCommand:
* @E_EDITOR_WIDGET_COMMAND_BACKGROUND_COLOR: Sets background color to given value.
@@ -112,7 +111,7 @@ typedef enum {
* @E_EDITOR_WIDGET_COMMAND_UNSELECT: Cancels current selection.
* @E_EDITOR_WIDGET_COMMAND_USE_CSS: Whether to allow use of CSS or not depending on whether given value is
"true" or "false".
*
- * Used to identify DOM command to execute using #e_editor_widget_exec_command().
+ * Used to identify DOM command to execute using e_editor_widget_exec_command().
* Some commands require value to be passed in, which is always stated in the documentation.
*/
@@ -174,38 +173,31 @@ typedef struct _EEditorWidgetPrivate EEditorWidgetPrivate;
struct _EEditorWidget {
WebKitWebView parent;
-
EEditorWidgetPrivate *priv;
};
struct _EEditorWidgetClass {
WebKitWebViewClass parent_class;
- void (*paste_clipboard_quoted) (EEditorWidget *widget);
-
- gboolean (*popup_event) (EEditorWidget *widget,
- GdkEventButton *event);
+ void (*paste_clipboard_quoted)
+ (EEditorWidget *widget);
+ gboolean (*popup_event) (EEditorWidget *widget,
+ GdkEventButton *event);
};
-GType e_editor_widget_get_type (void);
-
+GType e_editor_widget_get_type (void) G_GNUC_CONST;
EEditorWidget * e_editor_widget_new (void);
-
EEditorSelection *
e_editor_widget_get_selection (EEditorWidget *widget);
-
gboolean e_editor_widget_exec_command (EEditorWidget *widget,
EEditorWidgetCommand command,
const gchar *value);
-
gboolean e_editor_widget_get_changed (EEditorWidget *widget);
void e_editor_widget_set_changed (EEditorWidget *widget,
gboolean changed);
-
gboolean e_editor_widget_get_html_mode (EEditorWidget *widget);
void e_editor_widget_set_html_mode (EEditorWidget *widget,
gboolean html_mode);
-
gboolean e_editor_widget_get_inline_spelling
(EEditorWidget *widget);
void e_editor_widget_set_inline_spelling
@@ -219,26 +211,21 @@ gboolean e_editor_widget_get_magic_smileys
void e_editor_widget_set_magic_smileys
(EEditorWidget *widget,
gboolean magic_smileys);
-
GList * e_editor_widget_get_spell_languages
(EEditorWidget *widget);
void e_editor_widget_set_spell_languages
(EEditorWidget *widget,
GList *spell_languages);
-
ESpellChecker * e_editor_widget_get_spell_checker
(EEditorWidget *widget);
-
gchar * e_editor_widget_get_text_html (EEditorWidget *widget);
gchar * e_editor_widget_get_text_plain (EEditorWidget *widget);
void e_editor_widget_set_text_html (EEditorWidget *widget,
const gchar *text);
void e_editor_widget_set_text_plain (EEditorWidget *widget,
const gchar *text);
-
void e_editor_widget_paste_clipboard_quoted
(EEditorWidget *widget);
-
void e_editor_widget_update_fonts (EEditorWidget *widget);
G_END_DECLS
diff --git a/e-util/e-editor-window.c b/e-util/e-editor-window.c
index cbf1005..c8c007b 100644
--- a/e-util/e-editor-window.c
+++ b/e-util/e-editor-window.c
@@ -24,18 +24,17 @@
#include "e-editor-window.h"
-G_DEFINE_TYPE (
- EEditorWindow,
- e_editor_window,
- GTK_TYPE_WINDOW)
+#define E_EDITOR_WINDOW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR_WINDOW, EEditorWindowPrivate))
/**
* EEditorWindow:
*
* A #GtkWindow that contains main toolbars and an #EEditor. To create a
- * custom editor window, one can subclass this class and pack additional widgets
- * above and below the editor using #e_editor_window_pack_above() and
- * #e_editor_window_pack_below().
+ * custom editor window, one can subclass this class and pack additional
+ * widgets above and below the editor using e_editor_window_pack_above()
+ * and e_editor_window_pack_below().
*/
struct _EEditorWindowPrivate {
@@ -53,16 +52,23 @@ enum {
PROP_EDITOR
};
+G_DEFINE_TYPE (
+ EEditorWindow,
+ e_editor_window,
+ GTK_TYPE_WINDOW)
+
static void
editor_window_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_EDITOR:
g_value_set_object (
- value, E_EDITOR_WINDOW (object)->priv->editor);
+ value,
+ e_editor_window_get_editor (
+ E_EDITOR_WINDOW (object)));
return;
}
@@ -70,14 +76,13 @@ editor_window_get_property (GObject *object,
}
static void
-e_editor_window_class_init (EEditorWindowClass *klass)
+e_editor_window_class_init (EEditorWindowClass *class)
{
GObjectClass *object_class;
- e_editor_window_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (EEditorWindowPrivate));
+ g_type_class_add_private (class, sizeof (EEditorWindowPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->get_property = editor_window_get_property;
g_object_class_install_property (
@@ -85,10 +90,10 @@ e_editor_window_class_init (EEditorWindowClass *klass)
PROP_EDITOR,
g_param_spec_object (
"editor",
- NULL,
- NULL,
- E_TYPE_EDITOR,
- G_PARAM_READABLE));
+ NULL,
+ NULL,
+ E_TYPE_EDITOR,
+ G_PARAM_READABLE));
}
static void
@@ -97,8 +102,7 @@ e_editor_window_init (EEditorWindow *window)
EEditorWindowPrivate *priv;
GtkWidget *widget;
- window->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- window, E_TYPE_EDITOR_WINDOW, EEditorWindowPrivate);
+ window->priv = E_EDITOR_WINDOW_GET_PRIVATE (window);
priv = window->priv;
priv->editor = E_EDITOR (e_editor_new ());
@@ -176,7 +180,7 @@ e_editor_window_get_editor (EEditorWindow *window)
*/
void
e_editor_window_pack_above (EEditorWindow *window,
- GtkWidget *child)
+ GtkWidget *child)
{
g_return_if_fail (E_IS_EDITOR_WINDOW (window));
g_return_if_fail (GTK_IS_WIDGET (child));
@@ -201,7 +205,7 @@ e_editor_window_pack_above (EEditorWindow *window,
*/
void
e_editor_window_pack_below (EEditorWindow *window,
- GtkWidget *child)
+ GtkWidget *child)
{
g_return_if_fail (E_IS_EDITOR_WINDOW (window));
g_return_if_fail (GTK_IS_WIDGET (child));
@@ -221,8 +225,8 @@ e_editor_window_pack_below (EEditorWindow *window,
* (immediatelly adjacent to the editor itself).
*/
void
-e_editor_window_pack_inside (EEditorWindow* window,
- GtkWidget* child)
+e_editor_window_pack_inside (EEditorWindow *window,
+ GtkWidget *child)
{
g_return_if_fail (E_IS_EDITOR_WINDOW (window));
g_return_if_fail (GTK_IS_WIDGET (child));
diff --git a/e-util/e-editor-window.h b/e-util/e-editor-window.h
index f73acc0..97c4f44 100644
--- a/e-util/e-editor-window.h
+++ b/e-util/e-editor-window.h
@@ -55,7 +55,6 @@ typedef struct _EEditorWindowPrivate EEditorWindowPrivate;
struct _EEditorWindow {
GtkWindow parent;
-
EEditorWindowPrivate *priv;
};
@@ -63,18 +62,13 @@ struct _EEditorWindowClass {
GtkWindowClass parent_class;
};
-GType e_editor_window_get_type (void);
-
+GType e_editor_window_get_type (void) G_GNUC_CONST;
GtkWidget * e_editor_window_new (GtkWindowType type);
-
EEditor * e_editor_window_get_editor (EEditorWindow *window);
-
void e_editor_window_pack_above (EEditorWindow *window,
GtkWidget *child);
-
void e_editor_window_pack_inside (EEditorWindow *window,
GtkWidget *child);
-
void e_editor_window_pack_below (EEditorWindow *window,
GtkWidget *child);
diff --git a/e-util/e-editor.c b/e-util/e-editor.c
index ecbaf28..a4cfae6 100644
--- a/e-util/e-editor.c
+++ b/e-util/e-editor.c
@@ -18,22 +18,18 @@
* Boston, MA 02111-1307, USA.
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
+#include <glib/gi18n-lib.h>
+#include <enchant/enchant.h>
#include "e-editor.h"
#include "e-editor-private.h"
#include "e-editor-utils.h"
#include "e-editor-selection.h"
-#include <glib/gi18n-lib.h>
-#include <enchant/enchant.h>
-
-G_DEFINE_TYPE (
- EEditor,
- e_editor,
- GTK_TYPE_GRID);
+#define E_EDITOR_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EDITOR, EEditorPrivate))
/**
* EEditor:
@@ -42,20 +38,6 @@ G_DEFINE_TYPE (
* it's #EEditorSelection - i.e. toolbars and actions.
*/
-enum {
- PROP_0,
- PROP_FILENAME
-};
-
-enum {
- UPDATE_ACTIONS,
- SPELL_LANGUAGES_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
-
-
/* This controls how spelling suggestions are divided between the primary
* context menu and a secondary menu. The idea is to prevent the primary
* menu from growing too long.
@@ -76,6 +58,24 @@ static guint signals[LAST_SIGNAL] = { 0 };
#define MAX_LEVEL1_SUGGESTIONS 4
#define MIN_LEVEL2_SUGGESTIONS 3
+enum {
+ PROP_0,
+ PROP_FILENAME
+};
+
+enum {
+ UPDATE_ACTIONS,
+ SPELL_LANGUAGES_CHANGED,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (
+ EEditor,
+ e_editor,
+ GTK_TYPE_GRID)
+
/* Action callback for context menu spelling suggestions.
* XXX This should really be in e-editor-actions.c */
static void
@@ -118,9 +118,8 @@ editor_inline_spelling_suggestions (EEditor *editor,
checker = WEBKIT_SPELL_CHECKER (webkit_get_text_checker ());
word = e_editor_selection_get_caret_word (selection);
- if (!word || !*word) {
+ if (word == NULL || *word == '\0')
return;
- }
suggestions = webkit_spell_checker_get_guesses_for_word (checker, word, NULL);
@@ -129,10 +128,7 @@ editor_inline_spelling_suggestions (EEditor *editor,
action_group = editor->priv->suggestion_actions;
merge_id = editor->priv->spell_suggestions_merge_id;
- length = 0;
- while (suggestions && suggestions[length]) {
- length++;
- }
+ length = (suggestions != NULL) ? g_strv_length (suggestions) : 0;
/* Calculate how many suggestions to put directly in the
* context menu. The rest will go in a secondary menu. */
@@ -203,12 +199,12 @@ static void
editor_spell_checkers_foreach (ESpellDictionary *dictionary,
EEditor *editor)
{
- EEditorWidget *widget;
+ EEditorWidget *editor_widget;
EEditorSelection *selection;
const gchar *language_code;
GtkActionGroup *action_group;
GtkUIManager *manager;
- GList *suggestions, *iter;
+ GList *list, *link;
gchar *path;
gchar *word;
gint ii = 0;
@@ -216,14 +212,13 @@ editor_spell_checkers_foreach (ESpellDictionary *dictionary,
language_code = e_spell_dictionary_get_code (dictionary);
- widget = e_editor_get_editor_widget (editor);
- selection = e_editor_widget_get_selection (widget);
+ editor_widget = e_editor_get_editor_widget (editor);
+ selection = e_editor_widget_get_selection (editor_widget);
word = e_editor_selection_get_caret_word (selection);
- if (!word || !*word) {
+ if (word == NULL || *word == '\0')
return;
- }
- suggestions = e_spell_dictionary_get_suggestions (dictionary, word, -1);
+ list = e_spell_dictionary_get_suggestions (dictionary, word, -1);
manager = e_editor_get_ui_manager (editor);
action_group = editor->priv->suggestion_actions;
@@ -233,8 +228,8 @@ editor_spell_checkers_foreach (ESpellDictionary *dictionary,
"/context-menu/context-spell-suggest/"
"context-spell-suggest-%s-menu", language_code);
- for (iter = suggestions; iter; iter = iter->next) {
- gchar *suggestion = iter->data;
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ gchar *suggestion = link->data;
gchar *action_name;
gchar *action_label;
GtkAction *action;
@@ -278,7 +273,7 @@ editor_spell_checkers_foreach (ESpellDictionary *dictionary,
g_free (action_label);
}
- e_spell_dictionary_free_suggestions (suggestions);
+ e_spell_dictionary_free_suggestions (list);
g_free (path);
g_free (word);
@@ -286,7 +281,7 @@ editor_spell_checkers_foreach (ESpellDictionary *dictionary,
static void
editor_update_actions (EEditor *editor,
- GdkEventButton *event)
+ GdkEventButton *event)
{
WebKitWebView *webview;
WebKitSpellChecker *checker;
@@ -314,14 +309,13 @@ editor_update_actions (EEditor *editor,
g_object_get (
G_OBJECT (hit_test),
"context", &context,
- "inner-node", &node, NULL);
+ "inner-node", &node, NULL);
g_object_unref (hit_test);
visible = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE);
gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_IMAGE), visible);
- if (visible) {
+ if (visible)
editor->priv->image = node;
- }
visible = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK);
gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_LINK), visible);
@@ -344,13 +338,12 @@ editor_update_actions (EEditor *editor,
* - Cursor is on an image that has a URL or target.
*/
visible = (WEBKIT_DOM_IS_HTML_ANCHOR_ELEMENT (node) ||
- (e_editor_dom_node_find_parent_element (node, "A") != NULL));
+ (e_editor_dom_node_find_parent_element (node, "A") != NULL));
gtk_action_set_visible (ACTION (CONTEXT_REMOVE_LINK), visible);
-
visible = (WEBKIT_DOM_IS_HTML_TABLE_CELL_ELEMENT (node) ||
- (e_editor_dom_node_find_parent_element (node, "TD") != NULL) ||
- (e_editor_dom_node_find_parent_element (node, "TH") != NULL));
+ (e_editor_dom_node_find_parent_element (node, "TD") != NULL) ||
+ (e_editor_dom_node_find_parent_element (node, "TH") != NULL));
gtk_action_set_visible (ACTION (CONTEXT_DELETE_CELL), visible);
gtk_action_set_visible (ACTION (CONTEXT_DELETE_COLUMN), visible);
gtk_action_set_visible (ACTION (CONTEXT_DELETE_ROW), visible);
@@ -361,13 +354,12 @@ editor_update_actions (EEditor *editor,
gtk_action_set_visible (ACTION (CONTEXT_INSERT_ROW_BELOW), visible);
gtk_action_set_visible (ACTION (CONTEXT_INSERT_TABLE), visible);
gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_CELL), visible);
- if (visible) {
+ if (visible)
editor->priv->table_cell = node;
- }
/* Note the |= (cursor must be in a table cell). */
visible |= (WEBKIT_DOM_IS_HTML_TABLE_ELEMENT (node) ||
- (e_editor_dom_node_find_parent_element (node, "TABLE") != NULL));
+ (e_editor_dom_node_find_parent_element (node, "TABLE") != NULL));
gtk_action_set_visible (ACTION (CONTEXT_PROPERTIES_TABLE), visible);
/********************** Spell Check Suggestions **********************/
@@ -431,7 +423,7 @@ editor_update_actions (EEditor *editor,
static void
editor_spell_languages_changed (EEditor *editor,
- GList *dictionaries)
+ GList *dictionaries)
{
ESpellChecker *checker;
WebKitWebSettings *settings;
@@ -448,9 +440,8 @@ editor_spell_languages_changed (EEditor *editor,
for (iter = dictionaries; iter; iter = iter->next) {
ESpellDictionary *dictionary = iter->data;
- if (iter != dictionaries) {
+ if (languages->len > 0)
g_string_append (languages, ",");
- }
g_string_append (
languages,
@@ -459,7 +450,8 @@ editor_spell_languages_changed (EEditor *editor,
/* Set the languages for webview to highlight misspelled words */
settings = webkit_web_view_get_settings (
- WEBKIT_WEB_VIEW (editor->priv->editor_widget));
+ WEBKIT_WEB_VIEW (editor->priv->editor_widget));
+
g_object_set (
G_OBJECT (settings),
"spell-checking-languages", languages->str,
@@ -476,14 +468,14 @@ editor_spell_languages_changed (EEditor *editor,
static gboolean
editor_show_popup (EEditor *editor,
- GdkEventButton *event,
- gpointer user_data)
+ GdkEventButton *event,
+ gpointer user_data)
{
GtkWidget *menu;
menu = e_editor_get_managed_widget (editor, "/context-menu");
- g_signal_emit(editor, signals[UPDATE_ACTIONS], 0, event);
+ g_signal_emit (editor, signals[UPDATE_ACTIONS], 0, event);
if (event != NULL)
gtk_menu_popup (
@@ -523,7 +515,7 @@ editor_find_ui_file (const gchar *basename)
static void
editor_parent_changed (GtkWidget *widget,
- GtkWidget *previous_parent)
+ GtkWidget *previous_parent)
{
GtkWidget *top_level;
EEditor *editor = E_EDITOR (widget);
@@ -539,14 +531,14 @@ editor_parent_changed (GtkWidget *widget,
static void
editor_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
-
case PROP_FILENAME:
- e_editor_set_filename (E_EDITOR (object),
+ e_editor_set_filename (
+ E_EDITOR (object),
g_value_get_string (value));
return;
@@ -557,17 +549,16 @@ editor_set_property (GObject *object,
static void
editor_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
-
case PROP_FILENAME:
g_value_set_string (
- value, e_editor_get_filename(
+ value, e_editor_get_filename (
E_EDITOR (object)));
- return;
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -584,7 +575,8 @@ editor_constructed (GObject *object)
GtkToolbar *toolbar;
GtkToolItem *tool_item;
- /* Construct main window widgets. */
+ /* Construct the editing toolbars. */
+
widget = e_editor_get_managed_widget (editor, "/edit-toolbar");
gtk_widget_set_hexpand (widget, TRUE);
gtk_toolbar_set_style (GTK_TOOLBAR (widget), GTK_TOOLBAR_BOTH_HORIZ);
@@ -599,6 +591,8 @@ editor_constructed (GObject *object)
priv->html_toolbar = g_object_ref (widget);
gtk_widget_show (widget);
+ /* Construct the main editing area. */
+
widget = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (
GTK_SCROLLED_WINDOW (widget),
@@ -614,7 +608,8 @@ editor_constructed (GObject *object)
widget = GTK_WIDGET (e_editor_get_editor_widget (editor));
gtk_container_add (GTK_CONTAINER (priv->scrolled_window), widget);
gtk_widget_show (widget);
- g_signal_connect_swapped (widget, "popup-event",
+ g_signal_connect_swapped (
+ widget, "popup-event",
G_CALLBACK (editor_show_popup), editor);
/* Add some combo boxes to the "edit" toolbar. */
@@ -689,8 +684,9 @@ editor_constructed (GObject *object)
static void
editor_dispose (GObject *object)
{
- EEditor *editor = E_EDITOR (object);
- EEditorPrivate *priv = editor->priv;
+ EEditorPrivate *priv;
+
+ priv = E_EDITOR_GET_PRIVATE (object);
g_clear_object (&priv->manager);
g_clear_object (&priv->core_actions);
@@ -717,41 +713,45 @@ editor_dispose (GObject *object)
g_clear_object (&priv->scrolled_window);
g_clear_object (&priv->editor_widget);
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_editor_parent_class)->dispose (object);
}
static void
-e_editor_class_init (EEditorClass *klass)
+e_editor_class_init (EEditorClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
- g_type_class_add_private (klass, sizeof (EEditorPrivate));
+ g_type_class_add_private (class, sizeof (EEditorPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->set_property = editor_set_property;
object_class->get_property = editor_get_property;
object_class->constructed = editor_constructed;
object_class->dispose = editor_dispose;
- widget_class = GTK_WIDGET_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (class);
widget_class->parent_set = editor_parent_changed;
- klass->update_actions = editor_update_actions;
- klass->spell_languages_changed = editor_spell_languages_changed;
+ class->update_actions = editor_update_actions;
+ class->spell_languages_changed = editor_spell_languages_changed;
g_object_class_install_property (
object_class,
PROP_FILENAME,
g_param_spec_string (
"filename",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE));
+ NULL,
+ NULL,
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
signals[UPDATE_ACTIONS] = g_signal_new (
"update-actions",
- G_TYPE_FROM_CLASS (klass),
+ G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EEditorClass, update_actions),
NULL, NULL,
@@ -761,7 +761,7 @@ e_editor_class_init (EEditorClass *klass)
signals[SPELL_LANGUAGES_CHANGED] = g_signal_new (
"spell-languages-changed",
- G_OBJECT_CLASS_TYPE (klass),
+ G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EEditorClass, spell_languages_changed),
NULL, NULL,
@@ -774,11 +774,10 @@ static void
e_editor_init (EEditor *editor)
{
EEditorPrivate *priv;
- GError *error;
gchar *filename;
+ GError *error = NULL;
- editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- editor, E_TYPE_EDITOR, EEditorPrivate);
+ editor->priv = E_EDITOR_GET_PRIVATE (editor);
priv = editor->priv;
@@ -794,13 +793,10 @@ e_editor_init (EEditor *editor)
priv->selection = e_editor_widget_get_selection (priv->editor_widget);
filename = editor_find_ui_file ("e-editor-manager.ui");
-
- error = NULL;
if (!gtk_ui_manager_add_ui_from_file (priv->manager, filename, &error)) {
g_critical ("Couldn't load builder file: %s\n", error->message);
g_clear_error (&error);
}
-
g_free (filename);
editor_actions_init (editor);
@@ -857,24 +853,25 @@ e_editor_get_ui_manager (EEditor *editor)
*/
GtkAction *
e_editor_get_action (EEditor *editor,
- const gchar *action_name)
+ const gchar *action_name)
{
GtkUIManager *manager;
GtkAction *action = NULL;
- GList *iter;
+ GList *list;
g_return_val_if_fail (E_IS_EDITOR (editor), NULL);
g_return_val_if_fail (action_name != NULL, NULL);
manager = e_editor_get_ui_manager (editor);
- iter = gtk_ui_manager_get_action_groups (manager);
+ list = gtk_ui_manager_get_action_groups (manager);
- while (iter != NULL && action == NULL) {
- GtkActionGroup *action_group = iter->data;
+ while (list != NULL && action == NULL) {
+ GtkActionGroup *action_group = list->data;
action = gtk_action_group_get_action (
action_group, action_name);
- iter = g_list_next (iter);
+
+ list = g_list_next (list);
}
g_return_val_if_fail (action != NULL, NULL);
@@ -892,26 +889,26 @@ e_editor_get_action (EEditor *editor,
*/
GtkActionGroup *
e_editor_get_action_group (EEditor *editor,
- const gchar *group_name)
+ const gchar *group_name)
{
GtkUIManager *manager;
- GList *iter;
+ GList *list;
g_return_val_if_fail (E_IS_EDITOR (editor), NULL);
g_return_val_if_fail (group_name != NULL, NULL);
manager = e_editor_get_ui_manager (editor);
- iter = gtk_ui_manager_get_action_groups (manager);
+ list = gtk_ui_manager_get_action_groups (manager);
- while (iter != NULL) {
- GtkActionGroup *action_group = iter->data;
+ while (list != NULL) {
+ GtkActionGroup *action_group = list->data;
const gchar *name;
name = gtk_action_group_get_name (action_group);
if (strcmp (name, group_name) == 0)
return action_group;
- iter = g_list_next (iter);
+ list = g_list_next (list);
}
return NULL;
@@ -919,7 +916,7 @@ e_editor_get_action_group (EEditor *editor,
GtkWidget *
e_editor_get_managed_widget (EEditor *editor,
- const gchar *widget_path)
+ const gchar *widget_path)
{
GtkUIManager *manager;
GtkWidget *widget;
@@ -954,11 +951,12 @@ e_editor_get_filename (EEditor *editor)
* @editor: an #EEditor
* @filename: Target file
*
- * Sets file to which content of the editor should be saved (see #e_editor_save())
+ * Sets file to which content of the editor should be saved (see
+ * e_editor_save()).
*/
void
e_editor_set_filename (EEditor *editor,
- const gchar *filename)
+ const gchar *filename)
{
g_return_if_fail (E_IS_EDITOR (editor));
@@ -979,8 +977,8 @@ e_editor_set_filename (EEditor *editor,
* Inserts @child right between the toolbars and the editor widget itself.
*/
void
-e_editor_pack_above (EEditor* editor,
- GtkWidget* child)
+e_editor_pack_above (EEditor *editor,
+ GtkWidget *child)
{
g_return_if_fail (E_IS_EDITOR (editor));
g_return_if_fail (GTK_IS_WIDGET (child));
@@ -1004,9 +1002,9 @@ e_editor_pack_above (EEditor* editor,
*/
gboolean
e_editor_save (EEditor *editor,
- const gchar *filename,
- gboolean as_html,
- GError **error)
+ const gchar *filename,
+ gboolean as_html,
+ GError **error)
{
GFile *file;
GFileOutputStream *stream;
@@ -1019,17 +1017,17 @@ e_editor_save (EEditor *editor,
if ((error && *error) || !stream)
return FALSE;
- if (as_html) {
+ if (as_html)
content = e_editor_widget_get_text_html (
- E_EDITOR_WIDGET (editor));
- } else {
+ E_EDITOR_WIDGET (editor));
+ else
content = e_editor_widget_get_text_plain (
- E_EDITOR_WIDGET (editor));
- }
+ E_EDITOR_WIDGET (editor));
if (!content || !*content) {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
- "Failed to obtain content of editor");
+ g_set_error (
+ error, G_IO_ERROR, G_IO_ERROR_FAILED,
+ "Failed to obtain content of editor");
return FALSE;
}
@@ -1056,20 +1054,14 @@ e_editor_save (EEditor *editor,
void
e_editor_emit_spell_languages_changed (EEditor *editor)
{
- GList *dictionaries, *iter;
+ GList *dictionaries;
g_return_if_fail (editor != NULL);
- dictionaries = NULL;
- for (iter = editor->priv->active_dictionaries; iter; iter = g_list_next (iter)) {
- EnchantDict *dictionary = iter->data;
-
- dictionaries = g_list_prepend (dictionaries, dictionary);
- }
-
- dictionaries = g_list_reverse (dictionaries);
+ dictionaries = g_list_copy (editor->priv->active_dictionaries);
- g_signal_emit (editor, signals[SPELL_LANGUAGES_CHANGED], 0, dictionaries);
+ g_signal_emit (
+ editor, signals[SPELL_LANGUAGES_CHANGED], 0, dictionaries);
g_list_free (dictionaries);
}
diff --git a/e-util/e-editor.h b/e-util/e-editor.h
index 76e3c62..50ee5f2 100644
--- a/e-util/e-editor.h
+++ b/e-util/e-editor.h
@@ -55,7 +55,6 @@ typedef struct _EEditorPrivate EEditorPrivate;
struct _EEditor {
GtkGrid parent;
-
EEditorPrivate *priv;
};
@@ -64,17 +63,14 @@ struct _EEditorClass {
void (*update_actions) (EEditor *editor,
GdkEventButton *event);
-
void (*spell_languages_changed)
(EEditor *editor,
GList *dictionaries);
};
-GType e_editor_get_type (void);
+GType e_editor_get_type (void) G_GNUC_CONST;
GtkWidget * e_editor_new (void);
-
-EEditorWidget* e_editor_get_editor_widget (EEditor *editor);
-
+EEditorWidget * e_editor_get_editor_widget (EEditor *editor);
GtkBuilder * e_editor_get_builder (EEditor *editor);
GtkUIManager * e_editor_get_ui_manager (EEditor *editor);
GtkAction * e_editor_get_action (EEditor *editor,
@@ -83,20 +79,16 @@ GtkActionGroup *e_editor_get_action_group (EEditor *editor,
const gchar *group_name);
GtkWidget * e_editor_get_widget (EEditor *editor,
const gchar *widget_name);
-GtkWidget * e_editor_get_managed_widget
- (EEditor *editor,
+GtkWidget * e_editor_get_managed_widget (EEditor *editor,
const gchar *widget_path);
const gchar * e_editor_get_filename (EEditor *editor);
void e_editor_set_filename (EEditor *editor,
const gchar *filename);
-
void e_editor_pack_above (EEditor *editor,
GtkWidget *child);
-
void e_editor_emit_spell_languages_changed
(EEditor *editor);
-
/*****************************************************************************
* High-Level Editing Interface
*****************************************************************************/
diff --git a/e-util/e-emoticon-action.c b/e-util/e-emoticon-action.c
index cc9a640..0850d33 100644
--- a/e-util/e-emoticon-action.c
+++ b/e-util/e-emoticon-action.c
@@ -25,6 +25,10 @@
#include "e-emoticon-chooser-menu.h"
#include "e-emoticon-tool-button.h"
+#define E_EMOTICON_ACTION_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EMOTICON_ACTION, EEmoticonActionPrivate))
+
struct _EEmoticonActionPrivate {
GList *choosers;
EEmoticonChooser *current_chooser;
@@ -35,11 +39,21 @@ enum {
PROP_CURRENT_FACE
};
-static gpointer parent_class;
+/* Forward Declarations */
+static void e_emoticon_action_interface_init
+ (EEmoticonChooserInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+ EEmoticonAction,
+ e_emoticon_action,
+ GTK_TYPE_ACTION,
+ G_IMPLEMENT_INTERFACE (
+ E_TYPE_EMOTICON_CHOOSER,
+ e_emoticon_action_interface_init))
static void
emoticon_action_proxy_item_activated_cb (EEmoticonAction *action,
- EEmoticonChooser *chooser)
+ EEmoticonChooser *chooser)
{
action->priv->current_chooser = chooser;
@@ -48,9 +62,9 @@ emoticon_action_proxy_item_activated_cb (EEmoticonAction *action,
static void
emoticon_action_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_CURRENT_FACE:
@@ -65,9 +79,9 @@ emoticon_action_set_property (GObject *object,
static void
emoticon_action_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_CURRENT_FACE:
@@ -85,12 +99,12 @@ emoticon_action_finalize (GObject *object)
{
EEmoticonActionPrivate *priv;
- priv = E_EMOTICON_ACTION (object)->priv;
+ priv = E_EMOTICON_ACTION_GET_PRIVATE (object);
g_list_free (priv->choosers);
/* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (e_emoticon_action_parent_class)->finalize (object);
}
static void
@@ -98,7 +112,7 @@ emoticon_action_activate (GtkAction *action)
{
EEmoticonActionPrivate *priv;
- priv = E_EMOTICON_ACTION (action)->priv;
+ priv = E_EMOTICON_ACTION_GET_PRIVATE (action);
priv->current_chooser = NULL;
}
@@ -125,11 +139,11 @@ emoticon_action_create_tool_item (GtkAction *action)
static void
emoticon_action_connect_proxy (GtkAction *action,
- GtkWidget *proxy)
+ GtkWidget *proxy)
{
EEmoticonActionPrivate *priv;
- priv = E_EMOTICON_ACTION (action)->priv;
+ priv = E_EMOTICON_ACTION_GET_PRIVATE (action);
if (!E_IS_EMOTICON_CHOOSER (proxy))
goto chainup;
@@ -143,21 +157,23 @@ emoticon_action_connect_proxy (GtkAction *action,
chainup:
/* Chain up to parent's connect_proxy() method. */
- GTK_ACTION_CLASS (parent_class)->connect_proxy (action, proxy);
+ GTK_ACTION_CLASS (e_emoticon_action_parent_class)->
+ connect_proxy (action, proxy);
}
static void
emoticon_action_disconnect_proxy (GtkAction *action,
- GtkWidget *proxy)
+ GtkWidget *proxy)
{
EEmoticonActionPrivate *priv;
- priv = E_EMOTICON_ACTION (action)->priv;
+ priv = E_EMOTICON_ACTION_GET_PRIVATE (action);
priv->choosers = g_list_remove (priv->choosers, proxy);
/* Chain up to parent's disconnect_proxy() method. */
- GTK_ACTION_CLASS (parent_class)->disconnect_proxy (action, proxy);
+ GTK_ACTION_CLASS (e_emoticon_action_parent_class)->
+ disconnect_proxy (action, proxy);
}
static GtkWidget *
@@ -166,7 +182,7 @@ emoticon_action_create_menu (GtkAction *action)
EEmoticonActionPrivate *priv;
GtkWidget *widget;
- priv = E_EMOTICON_ACTION (action)->priv;
+ priv = E_EMOTICON_ACTION_GET_PRIVATE (action);
widget = e_emoticon_chooser_menu_new ();
@@ -185,7 +201,7 @@ emoticon_action_get_current_emoticon (EEmoticonChooser *chooser)
EEmoticonActionPrivate *priv;
EEmoticon *emoticon = NULL;
- priv = E_EMOTICON_ACTION (chooser)->priv;
+ priv = E_EMOTICON_ACTION_GET_PRIVATE (chooser);
if (priv->current_chooser != NULL)
emoticon = e_emoticon_chooser_get_current_emoticon (
@@ -196,12 +212,12 @@ emoticon_action_get_current_emoticon (EEmoticonChooser *chooser)
static void
emoticon_action_set_current_emoticon (EEmoticonChooser *chooser,
- EEmoticon *emoticon)
+ EEmoticon *emoticon)
{
EEmoticonActionPrivate *priv;
GList *iter;
- priv = E_EMOTICON_ACTION (chooser)->priv;
+ priv = E_EMOTICON_ACTION_GET_PRIVATE (chooser);
for (iter = priv->choosers; iter != NULL; iter = iter->next) {
EEmoticonChooser *proxy_chooser = iter->data;
@@ -211,12 +227,11 @@ emoticon_action_set_current_emoticon (EEmoticonChooser *chooser,
}
static void
-emoticon_action_class_init (EEmoticonActionClass *class)
+e_emoticon_action_class_init (EEmoticonActionClass *class)
{
GObjectClass *object_class;
GtkActionClass *action_class;
- parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EEmoticonAction));
object_class = G_OBJECT_CLASS (class);
@@ -237,59 +252,23 @@ emoticon_action_class_init (EEmoticonActionClass *class)
}
static void
-emoticon_action_iface_init (EEmoticonChooserIface *iface)
+e_emoticon_action_interface_init (EEmoticonChooserInterface *interface)
{
- iface->get_current_emoticon = emoticon_action_get_current_emoticon;
- iface->set_current_emoticon = emoticon_action_set_current_emoticon;
+ interface->get_current_emoticon = emoticon_action_get_current_emoticon;
+ interface->set_current_emoticon = emoticon_action_set_current_emoticon;
}
static void
-emoticon_action_init (EEmoticonAction *action)
+e_emoticon_action_init (EEmoticonAction *action)
{
- action->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- action, E_TYPE_EMOTICON_ACTION, EEmoticonActionPrivate);
-}
-
-GType
-e_emoticon_action_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EEmoticonActionClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) emoticon_action_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EEmoticonAction),
- 0, /* n_preallocs */
- (GInstanceInitFunc) emoticon_action_init,
- NULL /* value_table */
- };
-
- static const GInterfaceInfo iface_info = {
- (GInterfaceInitFunc) emoticon_action_iface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL /* interemoticon_data */
- };
-
- type = g_type_register_static (
- GTK_TYPE_ACTION, "EEmoticonAction", &type_info, 0);
-
- g_type_add_interface_static (
- type, E_TYPE_EMOTICON_CHOOSER, &iface_info);
- }
-
- return type;
+ action->priv = E_EMOTICON_ACTION_GET_PRIVATE (action);
}
GtkAction *
e_emoticon_action_new (const gchar *name,
- const gchar *label,
- const gchar *tooltip,
- const gchar *stock_id)
+ const gchar *label,
+ const gchar *tooltip,
+ const gchar *stock_id)
{
g_return_val_if_fail (name != NULL, NULL);
diff --git a/e-util/e-emoticon-action.h b/e-util/e-emoticon-action.h
index 3e62881..0e450e8 100644
--- a/e-util/e-emoticon-action.h
+++ b/e-util/e-emoticon-action.h
@@ -62,7 +62,7 @@ struct _EEmoticonActionClass {
GtkActionClass parent_class;
};
-GType e_emoticon_action_get_type (void);
+GType e_emoticon_action_get_type (void) G_GNUC_CONST;
GtkAction * e_emoticon_action_new (const gchar *name,
const gchar *label,
const gchar *tooltip,
diff --git a/e-util/e-emoticon-chooser-menu.c b/e-util/e-emoticon-chooser-menu.c
index c70c034..f2ed337 100644
--- a/e-util/e-emoticon-chooser-menu.c
+++ b/e-util/e-emoticon-chooser-menu.c
@@ -33,13 +33,23 @@ enum {
PROP_CURRENT_FACE
};
-static gpointer parent_class;
+/* Forward Declarations */
+static void e_emoticon_chooser_menu_interface_init
+ (EEmoticonChooserInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+ EEmoticonChooserMenu,
+ e_emoticon_chooser_menu,
+ GTK_TYPE_MENU,
+ G_IMPLEMENT_INTERFACE (
+ E_TYPE_EMOTICON_CHOOSER,
+ e_emoticon_chooser_menu_interface_init))
static void
emoticon_chooser_menu_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_CURRENT_FACE:
@@ -54,9 +64,9 @@ emoticon_chooser_menu_set_property (GObject *object,
static void
emoticon_chooser_menu_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_CURRENT_FACE:
@@ -84,7 +94,7 @@ emoticon_chooser_menu_get_current_emoticon (EEmoticonChooser *chooser)
static void
emoticon_chooser_menu_set_current_emoticon (EEmoticonChooser *chooser,
- EEmoticon *emoticon)
+ EEmoticon *emoticon)
{
GList *list, *iter;
@@ -109,12 +119,10 @@ emoticon_chooser_menu_set_current_emoticon (EEmoticonChooser *chooser,
}
static void
-emoticon_chooser_menu_class_init (EEmoticonChooserMenuClass *class)
+e_emoticon_chooser_menu_class_init (EEmoticonChooserMenuClass *class)
{
GObjectClass *object_class;
- parent_class = g_type_class_peek_parent (class);
-
object_class = G_OBJECT_CLASS (class);
object_class->set_property = emoticon_chooser_menu_set_property;
object_class->get_property = emoticon_chooser_menu_get_property;
@@ -124,14 +132,16 @@ emoticon_chooser_menu_class_init (EEmoticonChooserMenuClass *class)
}
static void
-emoticon_chooser_menu_iface_init (EEmoticonChooserIface *iface)
+e_emoticon_chooser_menu_interface_init (EEmoticonChooserInterface *interface)
{
- iface->get_current_emoticon = emoticon_chooser_menu_get_current_emoticon;
- iface->set_current_emoticon = emoticon_chooser_menu_set_current_emoticon;
+ interface->get_current_emoticon =
+ emoticon_chooser_menu_get_current_emoticon;
+ interface->set_current_emoticon =
+ emoticon_chooser_menu_set_current_emoticon;
}
static void
-emoticon_chooser_menu_init (EEmoticonChooserMenu *chooser_menu)
+e_emoticon_chooser_menu_init (EEmoticonChooserMenu *chooser_menu)
{
EEmoticonChooser *chooser;
GList *list, *iter;
@@ -167,42 +177,6 @@ emoticon_chooser_menu_init (EEmoticonChooserMenu *chooser_menu)
g_list_free (list);
}
-GType
-e_emoticon_chooser_menu_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EEmoticonChooserMenuClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) emoticon_chooser_menu_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EEmoticonChooserMenu),
- 0, /* n_preallocs */
- (GInstanceInitFunc) emoticon_chooser_menu_init,
- NULL /* value_table */
- };
-
- static const GInterfaceInfo iface_info = {
- (GInterfaceInitFunc) emoticon_chooser_menu_iface_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL /* interface_data */
- };
-
- type = g_type_register_static (
- GTK_TYPE_MENU, "EEmoticonChooserMenu",
- &type_info, 0);
-
- g_type_add_interface_static (
- type, E_TYPE_EMOTICON_CHOOSER, &iface_info);
- }
-
- return type;
-}
-
GtkWidget *
e_emoticon_chooser_menu_new (void)
{
diff --git a/e-util/e-emoticon-chooser-menu.h b/e-util/e-emoticon-chooser-menu.h
index 4c17e9d..d4f9954 100644
--- a/e-util/e-emoticon-chooser-menu.h
+++ b/e-util/e-emoticon-chooser-menu.h
@@ -61,8 +61,9 @@ struct _EEmoticonChooserMenuClass {
GtkMenuClass parent_class;
};
-GType e_emoticon_chooser_menu_get_type (void);
-GtkWidget * e_emoticon_chooser_menu_new (void);
+GType e_emoticon_chooser_menu_get_type
+ (void) G_GNUC_CONST;
+GtkWidget * e_emoticon_chooser_menu_new (void);
G_END_DECLS
diff --git a/e-util/e-emoticon-chooser.c b/e-util/e-emoticon-chooser.c
index 550ffc8..44ce06b 100644
--- a/e-util/e-emoticon-chooser.c
+++ b/e-util/e-emoticon-chooser.c
@@ -86,11 +86,16 @@ enum {
static guint signals[LAST_SIGNAL];
+G_DEFINE_INTERFACE (
+ EEmoticonChooser,
+ e_emoticon_chooser,
+ G_TYPE_OBJECT)
+
static void
-emoticon_chooser_class_init (EEmoticonChooserIface *iface)
+e_emoticon_chooser_default_init (EEmoticonChooserInterface *interface)
{
g_object_interface_install_property (
- iface,
+ interface,
g_param_spec_boxed (
"current-emoticon",
"Current Emoticon",
@@ -100,67 +105,39 @@ emoticon_chooser_class_init (EEmoticonChooserIface *iface)
signals[ITEM_ACTIVATED] = g_signal_new (
"item-activated",
- G_TYPE_FROM_INTERFACE (iface),
+ G_TYPE_FROM_INTERFACE (interface),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EEmoticonChooserIface, item_activated),
+ G_STRUCT_OFFSET (EEmoticonChooserInterface, item_activated),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
-GType
-e_emoticon_chooser_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EEmoticonChooserIface),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) emoticon_chooser_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- 0, /* instance_size */
- 0, /* n_preallocs */
- NULL, /* instance_init */
- NULL /* value_table */
- };
-
- type = g_type_register_static (
- G_TYPE_INTERFACE, "EEmoticonChooser", &type_info, 0);
-
- g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
- }
-
- return type;
-}
-
EEmoticon *
e_emoticon_chooser_get_current_emoticon (EEmoticonChooser *chooser)
{
- EEmoticonChooserIface *iface;
+ EEmoticonChooserInterface *interface;
g_return_val_if_fail (E_IS_EMOTICON_CHOOSER (chooser), NULL);
- iface = E_EMOTICON_CHOOSER_GET_IFACE (chooser);
- g_return_val_if_fail (iface->get_current_emoticon != NULL, NULL);
+ interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
+ g_return_val_if_fail (interface->get_current_emoticon != NULL, NULL);
- return iface->get_current_emoticon (chooser);
+ return interface->get_current_emoticon (chooser);
}
void
e_emoticon_chooser_set_current_emoticon (EEmoticonChooser *chooser,
- EEmoticon *emoticon)
+ EEmoticon *emoticon)
{
- EEmoticonChooserIface *iface;
+ EEmoticonChooserInterface *interface;
g_return_if_fail (E_IS_EMOTICON_CHOOSER (chooser));
- iface = E_EMOTICON_CHOOSER_GET_IFACE (chooser);
- g_return_if_fail (iface->set_current_emoticon != NULL);
+ interface = E_EMOTICON_CHOOSER_GET_INTERFACE (chooser);
+ g_return_if_fail (interface->set_current_emoticon != NULL);
- iface->set_current_emoticon (chooser, emoticon);
+ interface->set_current_emoticon (chooser, emoticon);
}
void
diff --git a/e-util/e-emoticon-chooser.h b/e-util/e-emoticon-chooser.h
index 1a82d9b..14e899f 100644
--- a/e-util/e-emoticon-chooser.h
+++ b/e-util/e-emoticon-chooser.h
@@ -37,17 +37,17 @@
#define E_IS_EMOTICON_CHOOSER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE \
((obj), E_TYPE_EMOTICON_CHOOSER))
-#define E_EMOTICON_CHOOSER_GET_IFACE(obj) \
+#define E_EMOTICON_CHOOSER_GET_INTERFACE(obj) \
(G_TYPE_INSTANCE_GET_INTERFACE \
- ((obj), E_TYPE_EMOTICON_CHOOSER, EEmoticonChooserIface))
+ ((obj), E_TYPE_EMOTICON_CHOOSER, EEmoticonChooserInterface))
G_BEGIN_DECLS
typedef struct _EEmoticonChooser EEmoticonChooser;
-typedef struct _EEmoticonChooserIface EEmoticonChooserIface;
+typedef struct _EEmoticonChooserInterface EEmoticonChooserInterface;
-struct _EEmoticonChooserIface {
- GTypeInterface parent_iface;
+struct _EEmoticonChooserInterface {
+ GTypeInterface parent_interface;
/* Methods */
EEmoticon * (*get_current_emoticon) (EEmoticonChooser *chooser);
@@ -58,8 +58,7 @@ struct _EEmoticonChooserIface {
void (*item_activated) (EEmoticonChooser *chooser);
};
-GType e_emoticon_chooser_get_type (void);
-
+GType e_emoticon_chooser_get_type (void) G_GNUC_CONST;
EEmoticon * e_emoticon_chooser_get_current_emoticon
(EEmoticonChooser *chooser);
void e_emoticon_chooser_set_current_emoticon
@@ -69,7 +68,6 @@ void e_emoticon_chooser_item_activated
(EEmoticonChooser *chooser);
GList * e_emoticon_chooser_get_items (void);
-
const EEmoticon *
e_emoticon_chooser_lookup_emoticon
(const gchar *icon_name);
diff --git a/e-util/e-emoticon-tool-button.c b/e-util/e-emoticon-tool-button.c
index 7f28a1e..e544dc4 100644
--- a/e-util/e-emoticon-tool-button.c
+++ b/e-util/e-emoticon-tool-button.c
@@ -35,6 +35,10 @@
#include "e-emoticon-chooser.h"
+#define E_EMOTICON_TOOL_BUTTON_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_EMOTICON_TOOL_BUTTON, EEmoticonToolButtonPrivate))
+
/* XXX Should calculate this dynamically. */
#define NUM_ROWS 7
#define NUM_COLS 3
@@ -62,9 +66,20 @@ struct _EEmoticonToolButtonPrivate {
GdkDevice *grab_mouse;
};
-static gpointer parent_class;
static guint signals[LAST_SIGNAL];
+/* Forward Declarations */
+static void e_emoticon_tool_button_interface_init
+ (EEmoticonChooserInterface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+ EEmoticonToolButton,
+ e_emoticon_tool_button,
+ GTK_TYPE_TOGGLE_TOOL_BUTTON,
+ G_IMPLEMENT_INTERFACE (
+ E_TYPE_EMOTICON_CHOOSER,
+ e_emoticon_tool_button_interface_init))
+
/* XXX Copied from _gtk_toolbar_elide_underscores() */
static gchar *
emoticon_tool_button_elide_underscores (const gchar *original)
@@ -141,7 +156,7 @@ emoticon_tool_button_reposition_window (EEmoticonToolButton *button)
static void
emoticon_tool_button_emoticon_clicked_cb (EEmoticonToolButton *button,
- GtkWidget *emoticon_button)
+ GtkWidget *emoticon_button)
{
button->priv->active_button = emoticon_button;
e_emoticon_tool_button_popdown (button);
@@ -149,8 +164,8 @@ emoticon_tool_button_emoticon_clicked_cb (EEmoticonToolButton *button,
static gboolean
emoticon_tool_button_emoticon_release_event_cb (EEmoticonToolButton *button,
- GdkEventButton *event,
- GtkButton *emoticon_button)
+ GdkEventButton *event,
+ GtkButton *emoticon_button)
{
GtkStateType state;
@@ -164,7 +179,7 @@ emoticon_tool_button_emoticon_release_event_cb (EEmoticonToolButton *button,
static gboolean
emoticon_tool_button_button_release_event_cb (EEmoticonToolButton *button,
- GdkEventButton *event)
+ GdkEventButton *event)
{
GtkToggleToolButton *tool_button;
GtkWidget *event_widget;
@@ -209,7 +224,7 @@ emoticon_tool_button_child_hide_cb (EEmoticonToolButton *button)
static gboolean
emoticon_tool_button_child_key_press_event_cb (EEmoticonToolButton *button,
- GdkEventKey *event)
+ GdkEventKey *event)
{
GtkWidget *window = button->priv->window;
@@ -221,9 +236,9 @@ emoticon_tool_button_child_key_press_event_cb (EEmoticonToolButton *button,
static void
emoticon_tool_button_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_CURRENT_EMOTICON:
@@ -247,13 +262,13 @@ emoticon_tool_button_set_property (GObject *object,
static void
emoticon_tool_button_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
EEmoticonToolButtonPrivate *priv;
- priv = E_EMOTICON_TOOL_BUTTON (object)->priv;
+ priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (object);
switch (property_id) {
case PROP_CURRENT_EMOTICON:
@@ -276,7 +291,7 @@ emoticon_tool_button_dispose (GObject *object)
{
EEmoticonToolButtonPrivate *priv;
- priv = E_EMOTICON_TOOL_BUTTON (object)->priv;
+ priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (object);
if (priv->window != NULL) {
g_object_unref (priv->window);
@@ -284,12 +299,12 @@ emoticon_tool_button_dispose (GObject *object)
}
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (parent_class)->dispose (object);
+ G_OBJECT_CLASS (e_emoticon_tool_button_parent_class)->dispose (object);
}
static gboolean
emoticon_tool_button_press_event (GtkWidget *widget,
- GdkEventButton *event)
+ GdkEventButton *event)
{
EEmoticonToolButton *button;
GtkToggleToolButton *toggle_button;
@@ -368,7 +383,8 @@ emoticon_tool_button_popup (EEmoticonToolButton *button)
/* Try to grab the pointer and keyboard. */
window = gtk_widget_get_window (button->priv->window);
grab_status = !keyboard ||
- gdk_device_grab (keyboard, window,
+ gdk_device_grab (
+ keyboard, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, activate_time) == GDK_GRAB_SUCCESS;
@@ -424,7 +440,7 @@ emoticon_tool_button_get_current_emoticon (EEmoticonChooser *chooser)
{
EEmoticonToolButtonPrivate *priv;
- priv = E_EMOTICON_TOOL_BUTTON (chooser)->priv;
+ priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (chooser);
if (priv->active_button == NULL)
return NULL;
@@ -434,12 +450,12 @@ emoticon_tool_button_get_current_emoticon (EEmoticonChooser *chooser)
static void
emoticon_tool_button_set_current_emoticon (EEmoticonChooser *chooser,
- EEmoticon *emoticon)
+ EEmoticon *emoticon)
{
EEmoticonToolButtonPrivate *priv;
GList *list, *iter;
- priv = E_EMOTICON_TOOL_BUTTON (chooser)->priv;
+ priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (chooser);
list = gtk_container_get_children (GTK_CONTAINER (priv->table));
@@ -461,13 +477,12 @@ emoticon_tool_button_set_current_emoticon (EEmoticonChooser *chooser,
}
static void
-emoticon_tool_button_class_init (EEmoticonToolButtonClass *class)
+e_emoticon_tool_button_class_init (EEmoticonToolButtonClass *class)
{
GObjectClass *object_class;
GtkWidgetClass *widget_class;
GtkToggleToolButtonClass *toggle_tool_button_class;
- parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EEmoticonToolButtonPrivate));
object_class = G_OBJECT_CLASS (class);
@@ -534,14 +549,16 @@ emoticon_tool_button_class_init (EEmoticonToolButtonClass *class)
}
static void
-emoticon_tool_button_iemoticon_init (EEmoticonChooserIface *iemoticon)
+e_emoticon_tool_button_interface_init (EEmoticonChooserInterface *interface)
{
- iemoticon->get_current_emoticon = emoticon_tool_button_get_current_emoticon;
- iemoticon->set_current_emoticon = emoticon_tool_button_set_current_emoticon;
+ interface->get_current_emoticon =
+ emoticon_tool_button_get_current_emoticon;
+ interface->set_current_emoticon =
+ emoticon_tool_button_set_current_emoticon;
}
static void
-emoticon_tool_button_init (EEmoticonToolButton *button)
+e_emoticon_tool_button_init (EEmoticonToolButton *button)
{
EEmoticonChooser *chooser;
GtkWidget *toplevel;
@@ -551,9 +568,7 @@ emoticon_tool_button_init (EEmoticonToolButton *button)
GList *list, *iter;
gint ii;
- button->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- button, E_TYPE_EMOTICON_TOOL_BUTTON,
- EEmoticonToolButtonPrivate);
+ button->priv = E_EMOTICON_TOOL_BUTTON_GET_PRIVATE (button);
/* Build the pop-up window. */
@@ -562,7 +577,7 @@ emoticon_tool_button_init (EEmoticonToolButton *button)
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_window_set_type_hint (
GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_COMBO);
- if (gtk_widget_is_toplevel (toplevel)) {
+ if (GTK_IS_WINDOW (toplevel)) {
gtk_window_group_add_window (
gtk_window_get_group (GTK_WINDOW (toplevel)),
GTK_WINDOW (window));
@@ -656,42 +671,6 @@ emoticon_tool_button_init (EEmoticonToolButton *button)
g_list_free (list);
}
-GType
-e_emoticon_tool_button_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static const GTypeInfo type_info = {
- sizeof (EEmoticonToolButtonClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) emoticon_tool_button_class_init,
- (GClassFinalizeFunc) NULL,
- NULL, /* class_data */
- sizeof (EEmoticonToolButton),
- 0, /* n_preallocs */
- (GInstanceInitFunc) emoticon_tool_button_init,
- NULL /* value_table */
- };
-
- static const GInterfaceInfo iemoticon_info = {
- (GInterfaceInitFunc) emoticon_tool_button_iemoticon_init,
- (GInterfaceFinalizeFunc) NULL,
- NULL /* interemoticon_data */
- };
-
- type = g_type_register_static (
- GTK_TYPE_TOGGLE_TOOL_BUTTON,
- "EEmoticonToolButton", &type_info, 0);
-
- g_type_add_interface_static (
- type, E_TYPE_EMOTICON_CHOOSER, &iemoticon_info);
- }
-
- return type;
-}
-
GtkToolItem *
e_emoticon_tool_button_new (void)
{
diff --git a/e-util/e-emoticon-tool-button.h b/e-util/e-emoticon-tool-button.h
index 77e0ccf..fc7dc8e 100644
--- a/e-util/e-emoticon-tool-button.h
+++ b/e-util/e-emoticon-tool-button.h
@@ -61,11 +61,11 @@ struct _EEmoticonToolButton {
struct _EEmoticonToolButtonClass {
GtkToggleToolButtonClass parent_class;
- void (*popup) (EEmoticonToolButton *button);
- void (*popdown) (EEmoticonToolButton *button);
+ void (*popup) (EEmoticonToolButton *button);
+ void (*popdown) (EEmoticonToolButton *button);
};
-GType e_emoticon_tool_button_get_type (void);
+GType e_emoticon_tool_button_get_type (void) G_GNUC_CONST;
GtkToolItem * e_emoticon_tool_button_new (void);
void e_emoticon_tool_button_popup (EEmoticonToolButton *button);
void e_emoticon_tool_button_popdown (EEmoticonToolButton *button);
diff --git a/e-util/e-emoticon.c b/e-util/e-emoticon.c
index 76dd512..c543e52 100644
--- a/e-util/e-emoticon.c
+++ b/e-util/e-emoticon.c
@@ -61,7 +61,7 @@ e_emoticon_get_type (void)
gboolean
e_emoticon_equal (EEmoticon *emoticon_a,
- EEmoticon *emoticon_b)
+ EEmoticon *emoticon_b)
{
if (((emoticon_a == NULL) && (emoticon_b != NULL)) ||
((emoticon_a != NULL) && (emoticon_b == NULL)))
@@ -95,7 +95,7 @@ e_emoticon_free (EEmoticon *emoticon)
}
gchar *
-e_emoticon_get_uri(EEmoticon *emoticon)
+e_emoticon_get_uri (EEmoticon *emoticon)
{
GtkIconInfo *icon_info;
GtkIconTheme *icon_theme;
diff --git a/e-util/e-emoticon.h b/e-util/e-emoticon.h
index d7416de..66327ab 100644
--- a/e-util/e-emoticon.h
+++ b/e-util/e-emoticon.h
@@ -41,12 +41,11 @@ struct _EEmoticon {
gchar *text_face;
};
-GType e_emoticon_get_type (void);
+GType e_emoticon_get_type (void) G_GNUC_CONST;
gboolean e_emoticon_equal (EEmoticon *emoticon_a,
EEmoticon *emoticon_b);
EEmoticon * e_emoticon_copy (EEmoticon *emoticon);
void e_emoticon_free (EEmoticon *emoticon);
-
gchar * e_emoticon_get_uri (EEmoticon *emoticon);
G_END_DECLS
diff --git a/e-util/e-image-chooser-dialog.c b/e-util/e-image-chooser-dialog.c
index 49fcd66..73a6c20 100644
--- a/e-util/e-image-chooser-dialog.c
+++ b/e-util/e-image-chooser-dialog.c
@@ -20,6 +20,10 @@
#include "e-image-chooser-dialog.h"
+#define E_IMAGE_CHOOSER_DIALOG_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_IMAGE_CHOOSER_DIALOG, EImageChooserDialogPrivate))
+
#define PREVIEW_WIDTH 256
#define PREVIEW_HEIGHT 256
@@ -97,7 +101,7 @@ image_chooser_dialog_update_preview (GtkFileChooser *file_chooser)
GFile *preview_file;
Context *context;
- priv = E_IMAGE_CHOOSER_DIALOG (file_chooser)->priv;
+ priv = E_IMAGE_CHOOSER_DIALOG_GET_PRIVATE (file_chooser);
preview_file = gtk_file_chooser_get_preview_file (file_chooser);
preview_widget = gtk_file_chooser_get_preview_widget (file_chooser);
@@ -132,7 +136,7 @@ image_chooser_dialog_dispose (GObject *object)
{
EImageChooserDialogPrivate *priv;
- priv = E_IMAGE_CHOOSER_DIALOG (object)->priv;
+ priv = E_IMAGE_CHOOSER_DIALOG_GET_PRIVATE (object);
if (priv->cancellable != NULL) {
g_cancellable_cancel (priv->cancellable);
@@ -170,14 +174,14 @@ image_chooser_dialog_constructed (GObject *object)
}
static void
-e_image_chooser_dialog_class_init (EImageChooserDialogClass *klass)
+e_image_chooser_dialog_class_init (EImageChooserDialogClass *class)
{
GObjectClass *object_class;
g_type_class_add_private (
- klass, sizeof (EImageChooserDialogPrivate));
+ class, sizeof (EImageChooserDialogPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->dispose = image_chooser_dialog_dispose;
object_class->constructed = image_chooser_dialog_constructed;
}
@@ -185,9 +189,7 @@ e_image_chooser_dialog_class_init (EImageChooserDialogClass *klass)
static void
e_image_chooser_dialog_init (EImageChooserDialog *dialog)
{
- dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dialog, E_TYPE_IMAGE_CHOOSER_DIALOG,
- EImageChooserDialogPrivate);
+ dialog->priv = E_IMAGE_CHOOSER_DIALOG_GET_PRIVATE (dialog);
g_signal_connect (
dialog, "update-preview",
@@ -196,7 +198,7 @@ e_image_chooser_dialog_init (EImageChooserDialog *dialog)
GtkWidget *
e_image_chooser_dialog_new (const gchar *title,
- GtkWindow *parent)
+ GtkWindow *parent)
{
return g_object_new (
E_TYPE_IMAGE_CHOOSER_DIALOG,
diff --git a/e-util/e-mail-signature-editor.c b/e-util/e-mail-signature-editor.c
index 7063f07..4408bb4 100644
--- a/e-util/e-mail-signature-editor.c
+++ b/e-util/e-mail-signature-editor.c
@@ -16,12 +16,9 @@
*
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "e-mail-signature-editor.h"
+#include <config.h>
#include <string.h>
#include <glib/gi18n.h>
@@ -293,8 +290,7 @@ action_save_and_close_cb (GtkAction *action,
/* Only make sure that the 'source-changed' is called,
* thus the preview of the signature is updated on save.
* It is not called when only signature body is changed
- * (and ESource properties are left unchanged).
- */
+ * (and ESource properties are left unchanged). */
g_signal_emit_by_name (registry, "source-changed", source);
gtk_widget_destroy (GTK_WIDGET (editor));
@@ -564,7 +560,6 @@ mail_signature_editor_constructed (GObject *object)
window, "delete-event",
G_CALLBACK (mail_signature_editor_delete_event_cb), NULL);
-
/* Configure an EFocusTracker to manage selection actions. */
focus_tracker = e_focus_tracker_new (GTK_WINDOW (window));
diff --git a/e-util/e-mail-signature-manager.c b/e-util/e-mail-signature-manager.c
index 6475b10..9447063 100644
--- a/e-util/e-mail-signature-manager.c
+++ b/e-util/e-mail-signature-manager.c
@@ -409,7 +409,7 @@ mail_signature_manager_add_signature (EMailSignatureManager *manager)
editor = e_mail_signature_editor_new (registry, NULL);
editor_widget = e_mail_signature_editor_get_editor_widget (
- E_MAIL_SIGNATURE_EDITOR (editor));
+ E_MAIL_SIGNATURE_EDITOR (editor));
e_editor_widget_set_html_mode (editor_widget, manager->priv->prefer_html);
mail_signature_manager_emit_editor_created (manager, editor);
diff --git a/e-util/e-name-selector-entry.c b/e-util/e-name-selector-entry.c
index 12dddb8..553820c 100644
--- a/e-util/e-name-selector-entry.c
+++ b/e-util/e-name-selector-entry.c
@@ -513,10 +513,10 @@ is_quoted_at (const gchar *string,
gunichar c = g_utf8_get_char (p);
if (c == '"')
- quoted = ~quoted;
+ quoted = !quoted;
}
- return quoted ? TRUE : FALSE;
+ return quoted;
}
static gint
@@ -532,7 +532,7 @@ get_index_at_position (const gchar *string,
gunichar c = g_utf8_get_char (p);
if (c == '"')
- quoted = ~quoted;
+ quoted = !quoted;
else if (c == ',' && !quoted)
n++;
}
diff --git a/e-util/e-spell-checker.c b/e-util/e-spell-checker.c
index aad7c45..646d1a8 100644
--- a/e-util/e-spell-checker.c
+++ b/e-util/e-spell-checker.c
@@ -27,24 +27,15 @@
#include <pango/pango.h>
#include <gtk/gtk.h>
-static void e_spell_checker_init_webkit_checker (WebKitSpellCheckerInterface *iface);
-
-G_DEFINE_TYPE_EXTENDED (
- ESpellChecker,
- e_spell_checker,
- G_TYPE_OBJECT,
- 0,
- G_IMPLEMENT_INTERFACE (
- WEBKIT_TYPE_SPELL_CHECKER,
- e_spell_checker_init_webkit_checker))
-
-
-static ESpellChecker *s_instance = NULL;
+#define E_SPELL_CHECKER_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SPELL_CHECKER, ESpellCheckerPrivate))
struct _ESpellCheckerPrivate {
GList *active;
- GHashTable *dictionaries_cache;
EnchantBroker *broker;
+ GHashTable *dictionaries_cache;
+ gboolean dictionaries_loaded;
};
enum {
@@ -52,6 +43,21 @@ enum {
PROP_ACTIVE_DICTIONARIES
};
+static ESpellChecker *s_instance = NULL;
+
+/* Forward Declarations */
+static void e_spell_checker_init_webkit_checker
+ (WebKitSpellCheckerInterface *interface);
+
+G_DEFINE_TYPE_EXTENDED (
+ ESpellChecker,
+ e_spell_checker,
+ G_TYPE_OBJECT,
+ 0,
+ G_IMPLEMENT_INTERFACE (
+ WEBKIT_TYPE_SPELL_CHECKER,
+ e_spell_checker_init_webkit_checker))
+
/**
* ESpellChecker:
*
@@ -62,9 +68,9 @@ enum {
static void
wksc_check_spelling (WebKitSpellChecker *webkit_checker,
- const char *word,
- int *misspelling_location,
- int *misspelling_length)
+ const gchar *word,
+ gint *misspelling_location,
+ gint *misspelling_length)
{
ESpellChecker *checker = E_SPELL_CHECKER (webkit_checker);
PangoLanguage *language;
@@ -88,21 +94,20 @@ wksc_check_spelling (WebKitSpellChecker *webkit_checker,
* then we get into an inner loop to find the is_word_end
* corresponding */
if (attrs[ii].is_word_start) {
- int start = ii;
- int end = ii;
- int word_length;
+ gint start = ii;
+ gint end = ii;
+ gint word_length;
gchar *cstart;
gint bytes;
gchar *new_word;
GList *iter;
- while (attrs[end].is_word_end < 1) {
+ while (attrs[end].is_word_end < 1)
end++;
- }
word_length = end - start;
- /* Set the iterator to be at the current word end, so we don't
- * check characters twice. */
+ /* Set the iterator to be at the current word
+ * end, so we don't check characters twice. */
ii = end;
cstart = g_utf8_offset_to_pointer (word, start);
@@ -139,12 +144,12 @@ wksc_check_spelling (WebKitSpellChecker *webkit_checker,
static gchar **
wksc_get_guesses (WebKitSpellChecker *webkit_checker,
- const gchar *word,
- const gchar *context)
+ const gchar *word,
+ const gchar *context)
{
ESpellChecker *checker = E_SPELL_CHECKER (webkit_checker);
GList *dicts;
- char** guesses;
+ gchar ** guesses;
gint ii;
guesses = g_malloc0_n (sizeof (gchar *), 11);
@@ -178,7 +183,7 @@ wksc_get_guesses (WebKitSpellChecker *webkit_checker,
static gchar *
wksc_get_autocorrect_suggestions (WebKitSpellChecker *webkit_checker,
- const gchar *word)
+ const gchar *word)
{
/* Not supported/needed */
return NULL;
@@ -186,41 +191,47 @@ wksc_get_autocorrect_suggestions (WebKitSpellChecker *webkit_checker,
static void
spell_checker_learn_word (WebKitSpellChecker *webkit_checker,
- const gchar *word)
+ const gchar *word)
{
/* Carefully, this will add the word to all active dictionaries! */
ESpellChecker *checker;
- GList *iter;
+ GList *list, *link;
checker = E_SPELL_CHECKER (webkit_checker);
- for (iter = checker->priv->active; iter; iter = iter->next) {
- ESpellDictionary *dict = iter->data;
+ list = checker->priv->active;
+
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESpellDictionary *dictionary;
- e_spell_dictionary_learn_word (dict, word, -1);
+ dictionary = E_SPELL_DICTIONARY (link->data);
+ e_spell_dictionary_learn_word (dictionary, word, -1);
}
}
static void
spell_checker_ignore_word (WebKitSpellChecker *webkit_checker,
- const gchar *word)
+ const gchar *word)
{
/* Carefully, this will add the word to all active dictionaries */
ESpellChecker *checker;
- GList *iter;
+ GList *list, *link;
checker = E_SPELL_CHECKER (webkit_checker);
- for (iter = checker->priv->active; iter; iter = iter->next) {
- ESpellDictionary *dict = iter->data;
+ list = checker->priv->active;
- e_spell_dictionary_ignore_word (dict, word, -1);
+ for (link = list; link != NULL; link = g_list_next (link)) {
+ ESpellDictionary *dictionary;
+
+ dictionary = E_SPELL_DICTIONARY (link->data);
+ e_spell_dictionary_ignore_word (dictionary, word, -1);
}
}
static void
wksc_update_languages (WebKitSpellChecker *webkit_checker,
- const char *languages)
+ const gchar *languages)
{
ESpellChecker *checker;
GList *dictionaries = NULL;
@@ -254,12 +265,11 @@ wksc_update_languages (WebKitSpellChecker *webkit_checker,
g_list_free (dictionaries);
}
-
static void
spell_checker_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_ACTIVE_DICTIONARIES:
@@ -274,9 +284,9 @@ spell_checker_set_property (GObject *object,
static void
spell_checker_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
case PROP_ACTIVE_DICTIONARIES:
@@ -293,7 +303,9 @@ spell_checker_get_property (GObject *object,
static void
spell_checker_dispose (GObject *object)
{
- ESpellCheckerPrivate *priv = E_SPELL_CHECKER (object)->priv;
+ ESpellCheckerPrivate *priv;
+
+ priv = E_SPELL_CHECKER_GET_PRIVATE (object);
g_list_free_full (priv->active, g_object_unref);
priv->active = NULL;
@@ -301,19 +313,18 @@ spell_checker_dispose (GObject *object)
enchant_broker_free (priv->broker);
priv->broker = NULL;
- /* Chain up to parent implementation */
+ /* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_spell_checker_parent_class)->dispose (object);
}
static void
-e_spell_checker_class_init (ESpellCheckerClass *klass)
+e_spell_checker_class_init (ESpellCheckerClass *class)
{
GObjectClass *object_class;
- e_spell_checker_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (ESpellCheckerPrivate));
+ g_type_class_add_private (class, sizeof (ESpellCheckerPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->set_property = spell_checker_set_property;
object_class->get_property = spell_checker_get_property;
object_class->dispose = spell_checker_dispose;
@@ -329,25 +340,32 @@ e_spell_checker_class_init (ESpellCheckerClass *klass)
}
static void
-e_spell_checker_init_webkit_checker (WebKitSpellCheckerInterface *iface)
+e_spell_checker_init_webkit_checker (WebKitSpellCheckerInterface *interface)
{
- iface->check_spelling_of_string = wksc_check_spelling;
- iface->get_autocorrect_suggestions_for_misspelled_word = wksc_get_autocorrect_suggestions;
- iface->get_guesses_for_word = wksc_get_guesses;
- iface->ignore_word = spell_checker_ignore_word;
- iface->learn_word = spell_checker_learn_word;
- iface->update_spell_checking_languages = wksc_update_languages;
+ interface->check_spelling_of_string = wksc_check_spelling;
+ interface->get_autocorrect_suggestions_for_misspelled_word =
+ wksc_get_autocorrect_suggestions;
+ interface->get_guesses_for_word = wksc_get_guesses;
+ interface->ignore_word = spell_checker_ignore_word;
+ interface->learn_word = spell_checker_learn_word;
+ interface->update_spell_checking_languages = wksc_update_languages;
}
-
static void
e_spell_checker_init (ESpellChecker *checker)
{
- checker->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- checker, E_TYPE_SPELL_CHECKER, ESpellCheckerPrivate);
+ GHashTable *dictionaries_cache;
+
+ dictionaries_cache = g_hash_table_new_full (
+ (GHashFunc) g_str_hash,
+ (GEqualFunc) g_str_equal,
+ (GDestroyNotify) NULL,
+ (GDestroyNotify) g_object_unref);
+
+ checker->priv = E_SPELL_CHECKER_GET_PRIVATE (checker);
checker->priv->broker = enchant_broker_init ();
- checker->priv->dictionaries_cache = NULL;
+ checker->priv->dictionaries_cache = dictionaries_cache;
}
ESpellChecker *
@@ -361,28 +379,30 @@ e_spell_checker_instance (void)
}
static void
-list_enchant_dicts (const char * const lang_tag,
- const char * const provider_name,
- const char * const provider_desc,
- const char * const provider_file,
- void * user_data)
+list_enchant_dicts (const gchar * const lang_tag,
+ const gchar * const provider_name,
+ const gchar * const provider_desc,
+ const gchar * const provider_file,
+ gpointer user_data)
{
ESpellChecker *checker = user_data;
- EnchantDict *dict;
+ EnchantDict *enchant_dict;
- dict = enchant_broker_request_dict (checker->priv->broker, lang_tag);
- if (dict) {
- ESpellDictionary *e_dict;
+ enchant_dict = enchant_broker_request_dict (
+ checker->priv->broker, lang_tag);
+ if (enchant_dict != NULL) {
+ ESpellDictionary *dictionary;
+ const gchar *code;
- e_dict = e_spell_dictionary_new (checker, dict);
+ dictionary = e_spell_dictionary_new (checker, enchant_dict);
+ code = e_spell_dictionary_get_code (dictionary);
g_hash_table_insert (
checker->priv->dictionaries_cache,
- (gpointer) e_spell_dictionary_get_code (e_dict), e_dict);
+ (gpointer) code, dictionary);
}
}
-
/**
* e_spell_checker_list_available_dicts:
* @checker: An #ESpellChecker
@@ -390,8 +410,8 @@ list_enchant_dicts (const char * const lang_tag,
* Returns list of all dictionaries available to the actual
* spell-checking backend.
*
- * Return value: new copy of #GList of #ESpellDictionary. The dictionaries are
- * owned by the @checker and should not be free'd. The list should be free'd
+ * Returns: new copy of #GList of #ESpellDictionary. The dictionaries are
+ * owned by the @checker and should not be free'd. The list should be freed
* using g_list_free() when not neede anymore. [transfer-list]
*/
GList *
@@ -401,12 +421,11 @@ e_spell_checker_list_available_dicts (ESpellChecker *checker)
g_return_val_if_fail (E_IS_SPELL_CHECKER (checker), NULL);
- if (checker->priv->dictionaries_cache == NULL) {
-
- checker->priv->dictionaries_cache = g_hash_table_new_full (
- g_str_hash, g_str_equal, NULL, g_object_unref);
+ if (!checker->priv->dictionaries_loaded) {
enchant_broker_list_dicts (
- checker->priv->broker, list_enchant_dicts, checker);
+ checker->priv->broker,
+ list_enchant_dicts, checker);
+ checker->priv->dictionaries_loaded = TRUE;
}
list = g_hash_table_get_values (checker->priv->dictionaries_cache);
@@ -419,14 +438,15 @@ e_spell_checker_list_available_dicts (ESpellChecker *checker)
* @checker: an #ESpellChecker
* @language_code: (allow-none) language code for which to lookup the dictionary
*
- * Tries to find an #ESpellDictionary for given @language_code. When @language_code
- * is #NULL, this function will return a default #ESpellDictionary.
+ * Tries to find an #ESpellDictionary for given @language_code.
+ * If @language_code is %NULL, the function will return a default
+ * #ESpellDictionary.
*
- * Return value: an #ESpellDictionary for @language_code
+ * Returns: an #ESpellDictionary for @language_code
*/
ESpellDictionary *
e_spell_checker_lookup_dictionary (ESpellChecker *checker,
- const gchar *language_code)
+ const gchar *language_code)
{
ESpellDictionary *e_dict = NULL;
GList *dicts;
@@ -479,7 +499,7 @@ e_spell_checker_get_active_dictionaries (ESpellChecker *checker)
*/
void
e_spell_checker_set_active_dictionaries (ESpellChecker *checker,
- GList *active_dicts)
+ GList *active_dicts)
{
g_return_if_fail (E_IS_SPELL_CHECKER (checker));
@@ -491,12 +511,12 @@ e_spell_checker_set_active_dictionaries (ESpellChecker *checker,
void
e_spell_checker_free_dict (ESpellChecker *checker,
- EnchantDict *dict)
+ EnchantDict *enchant_dict)
{
g_return_if_fail (E_IS_SPELL_CHECKER (checker));
- g_return_if_fail (dict != NULL);
+ g_return_if_fail (enchant_dict != NULL);
- enchant_broker_free_dict (checker->priv->broker, dict);
+ enchant_broker_free_dict (checker->priv->broker, enchant_dict);
}
/**
@@ -504,19 +524,19 @@ e_spell_checker_free_dict (ESpellChecker *checker,
* @checker: an #ESpellChecker
* @word: word to ignore for the rest of session
*
- * Calls #e_spell_dictionary_ignore_word() on all active dictionaries in
+ * Calls e_spell_dictionary_ignore_word() on all active dictionaries in
* the @checker.
*/
void
e_spell_checker_ignore_word (ESpellChecker *checker,
- const gchar *word)
+ const gchar *word)
{
- WebKitSpellCheckerInterface *webkit_checker_iface;
+ WebKitSpellCheckerInterface *interface;
g_return_if_fail (E_IS_SPELL_CHECKER (checker));
- webkit_checker_iface = WEBKIT_SPELL_CHECKER_GET_IFACE (checker);
- webkit_checker_iface->ignore_word (WEBKIT_SPELL_CHECKER (checker), word);
+ interface = WEBKIT_SPELL_CHECKER_GET_IFACE (checker);
+ interface->ignore_word (WEBKIT_SPELL_CHECKER (checker), word);
}
/**
@@ -524,17 +544,17 @@ e_spell_checker_ignore_word (ESpellChecker *checker,
* @checker: an #ESpellChecker
* @word: word to learn
*
- * Calls #e_spell_dictionary_learn_word() on all active dictionaries in
+ * Calls e_spell_dictionary_learn_word() on all active dictionaries in
* the @checker.
*/
void
e_spell_checker_learn_word (ESpellChecker *checker,
- const gchar *word)
+ const gchar *word)
{
- WebKitSpellCheckerInterface *webkit_checker_iface;
+ WebKitSpellCheckerInterface *interface;
g_return_if_fail (E_IS_SPELL_CHECKER (checker));
- webkit_checker_iface = WEBKIT_SPELL_CHECKER_GET_IFACE (checker);
- webkit_checker_iface->learn_word (WEBKIT_SPELL_CHECKER (checker), word);
+ interface = WEBKIT_SPELL_CHECKER_GET_IFACE (checker);
+ interface->learn_word (WEBKIT_SPELL_CHECKER (checker), word);
}
diff --git a/e-util/e-spell-checker.h b/e-util/e-spell-checker.h
index ff3b6eb..3b0737d 100644
--- a/e-util/e-spell-checker.h
+++ b/e-util/e-spell-checker.h
@@ -16,6 +16,10 @@
* Boston, MA 02111-1307, USA.
*/
+#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
+#error "Only <e-util/e-util.h> should be included directly."
+#endif
+
#ifndef E_SPELL_CHECKER_H
#define E_SPELL_CHECKER_H
@@ -41,7 +45,6 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_SPELL_CHECKER, ESpellCheckerClass))
-
G_BEGIN_DECLS
typedef struct _ESpellChecker ESpellChecker;
@@ -50,7 +53,6 @@ typedef struct _ESpellCheckerClass ESpellCheckerClass;
struct _ESpellChecker {
GObject parent;
-
ESpellCheckerPrivate *priv;
};
@@ -58,31 +60,26 @@ struct _ESpellCheckerClass {
GObjectClass parent_class;
};
-GType e_spell_checker_get_type (void);
-
-ESpellChecker * e_spell_checker_instance (void);
-
-GList * e_spell_checker_list_available_dicts
- (ESpellChecker *checker);
-ESpellDictionary * e_spell_checker_lookup_dictionary
- (ESpellChecker *checker,
- const gchar *language_code);
-
-void e_spell_checker_set_active_dictionaries
- (ESpellChecker *checker,
- GList *active_dicts);
-GList * e_spell_checker_get_active_dictionaries
- (ESpellChecker *checker);
-
-void e_spell_checker_free_dict (ESpellChecker *checker,
- EnchantDict *dict);
-
-void e_spell_checker_learn_word (ESpellChecker *checker,
- const gchar *word);
-void e_spell_checker_ignore_word (ESpellChecker *checker,
- const gchar *word);
+GType e_spell_checker_get_type (void) G_GNUC_CONST;
+ESpellChecker * e_spell_checker_instance (void);
+GList * e_spell_checker_list_available_dicts
+ (ESpellChecker *checker);
+ESpellDictionary *
+ e_spell_checker_lookup_dictionary
+ (ESpellChecker *checker,
+ const gchar *language_code);
+void e_spell_checker_set_active_dictionaries
+ (ESpellChecker *checker,
+ GList *active_dicts);
+GList * e_spell_checker_get_active_dictionaries
+ (ESpellChecker *checker);
+void e_spell_checker_free_dict (ESpellChecker *checker,
+ EnchantDict *enchant_dict);
+void e_spell_checker_learn_word (ESpellChecker *checker,
+ const gchar *word);
+void e_spell_checker_ignore_word (ESpellChecker *checker,
+ const gchar *word);
G_END_DECLS
-
-#endif /* E_SPELL_CHECKER_H */
\ No newline at end of file
+#endif /* E_SPELL_CHECKER_H */
diff --git a/e-util/e-spell-dictionary.c b/e-util/e-spell-dictionary.c
index 33d09a9..8a88253 100644
--- a/e-util/e-spell-dictionary.c
+++ b/e-util/e-spell-dictionary.c
@@ -26,10 +26,9 @@
#include <glib/gi18n-lib.h>
#include <string.h>
-G_DEFINE_TYPE (
- ESpellDictionary,
- e_spell_dictionary,
- G_TYPE_OBJECT);
+#define E_SPELL_DICTIONARY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SPELL_DICTIONARY, ESpellDictionaryPrivate))
/**
* ESpellDictionary:
@@ -37,15 +36,14 @@ G_DEFINE_TYPE (
* The #ESpellDictionary is a wrapper around #EnchantDict.
*/
-
enum {
PROP_0,
- PROP_SPELLCHECKER
+ PROP_SPELL_CHECKER
};
struct _ESpellDictionaryPrivate {
ESpellChecker *spell_checker;
- EnchantDict *dict;
+ EnchantDict *enchant_dict;
gchar *name;
gchar *code;
@@ -58,6 +56,11 @@ struct _ESpellDictionaryPrivate {
static GHashTable *iso_639_table = NULL;
static GHashTable *iso_3166_table = NULL;
+G_DEFINE_TYPE (
+ ESpellDictionary,
+ e_spell_dictionary,
+ G_TYPE_OBJECT);
+
#ifdef HAVE_ISO_CODES
#define ISOCODESLOCALEDIR ISO_CODES_PREFIX "/share/locale"
@@ -257,10 +260,10 @@ struct _enchant_dict_description_data {
static void
describe_dictionary (const gchar *language_tag,
- const gchar *provider_name,
- const gchar *provider_desc,
- const gchar *provider_file,
- gpointer user_data)
+ const gchar *provider_name,
+ const gchar *provider_desc,
+ const gchar *provider_file,
+ gpointer user_data)
{
struct _enchant_dict_description_data *data = user_data;
const gchar *iso_639_name;
@@ -312,30 +315,39 @@ exit:
static void
spell_dictionary_set_enchant_dict (ESpellDictionary *dictionary,
- EnchantDict *enchant_dict)
+ EnchantDict *enchant_dict)
{
struct _enchant_dict_description_data data;
enchant_dict_describe (enchant_dict, describe_dictionary, &data);
- dictionary->priv->dict = enchant_dict;
+ dictionary->priv->enchant_dict = enchant_dict;
dictionary->priv->code = data.language_tag;
dictionary->priv->name = data.dict_name;
dictionary->priv->collate_key = g_utf8_collate_key (data.dict_name, -1);
}
static void
-spell_dictionary_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+spell_dictionary_set_spell_checker (ESpellDictionary *dictionary,
+ ESpellChecker *spell_checker)
{
- ESpellDictionary *dict = E_SPELL_DICTIONARY (object);
+ g_return_if_fail (E_IS_SPELL_CHECKER (spell_checker));
+ g_return_if_fail (dictionary->priv->spell_checker == NULL);
+
+ dictionary->priv->spell_checker = g_object_ref (spell_checker);
+}
+static void
+spell_dictionary_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
switch (property_id) {
- case PROP_SPELLCHECKER:
- dict->priv->spell_checker =
- g_object_ref (g_value_get_object (value));
+ case PROP_SPELL_CHECKER:
+ spell_dictionary_set_spell_checker (
+ E_SPELL_DICTIONARY (object),
+ g_value_get_object (value));
return;
}
@@ -344,17 +356,16 @@ spell_dictionary_set_property (GObject *object,
static void
spell_dictionary_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- ESpellDictionary *dict = E_SPELL_DICTIONARY (object);
-
switch (property_id) {
- case PROP_SPELLCHECKER:
+ case PROP_SPELL_CHECKER:
g_value_set_object (
value,
- e_spell_dictionary_get_parent_checker (dict));
+ e_spell_dictionary_get_parent_checker (
+ E_SPELL_DICTIONARY (object)));
return;
}
@@ -364,107 +375,119 @@ spell_dictionary_get_property (GObject *object,
static void
spell_dictionary_dispose (GObject *object)
{
- ESpellDictionaryPrivate *priv = E_SPELL_DICTIONARY (object)->priv;
+ ESpellDictionaryPrivate *priv;
- e_spell_checker_free_dict (priv->spell_checker, priv->dict);
- priv->dict = NULL;
+ priv = E_SPELL_DICTIONARY_GET_PRIVATE (object);
- g_free (priv->name);
- priv->name = NULL;
+ g_clear_object (&priv->spell_checker);
- g_free (priv->code);
- priv->code = NULL;
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_spell_dictionary_parent_class)->dispose (object);
+}
- g_free (priv->collate_key);
- priv->collate_key = NULL;
+static void
+spell_dictionary_finalize (GObject *object)
+{
+ ESpellDictionaryPrivate *priv;
- g_clear_object (&priv->spell_checker);
+ priv = E_SPELL_DICTIONARY_GET_PRIVATE (object);
- /* Chain up to parent implementation */
- G_OBJECT_CLASS (e_spell_dictionary_parent_class)->dispose (object);
+ e_spell_checker_free_dict (priv->spell_checker, priv->enchant_dict);
+
+ g_free (priv->name);
+ g_free (priv->code);
+ g_free (priv->collate_key);
+
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_spell_dictionary_parent_class)->finalize (object);
}
static void
-e_spell_dictionary_class_init (ESpellDictionaryClass *klass)
+e_spell_dictionary_class_init (ESpellDictionaryClass *class)
{
GObjectClass *object_class;
- e_spell_dictionary_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (ESpellDictionaryPrivate));
+ g_type_class_add_private (class, sizeof (ESpellDictionaryPrivate));
- object_class = G_OBJECT_CLASS (klass);
+ object_class = G_OBJECT_CLASS (class);
object_class->set_property = spell_dictionary_set_property;
object_class->get_property = spell_dictionary_get_property;
object_class->dispose = spell_dictionary_dispose;
+ object_class->finalize = spell_dictionary_finalize;
g_object_class_install_property (
object_class,
- PROP_SPELLCHECKER,
+ PROP_SPELL_CHECKER,
g_param_spec_object (
"spell-checker",
- NULL,
- "Parent spell checker",
- E_TYPE_SPELL_CHECKER,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ NULL,
+ "Parent spell checker",
+ E_TYPE_SPELL_CHECKER,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
}
static void
-e_spell_dictionary_init (ESpellDictionary *dict)
+e_spell_dictionary_init (ESpellDictionary *dictionary)
{
- dict->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- dict, E_TYPE_SPELL_DICTIONARY, ESpellDictionaryPrivate);
+ dictionary->priv = E_SPELL_DICTIONARY_GET_PRIVATE (dictionary);
if (!iso_639_table && !iso_3166_table) {
- #if defined (ENABLE_NLS) && defined (HAVE_ISO_CODES)
- bindtextdomain (ISO_639_DOMAIN, ISOCODESLOCALEDIR);
- bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
-
- bindtextdomain (ISO_3166_DOMAIN, ISOCODESLOCALEDIR);
- bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
- #endif
-
- iso_639_table = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- iso_3166_table = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify) g_free);
-
- #ifdef HAVE_ISO_CODES
- iso_codes_parse (
- &iso_639_parser, "iso_639.xml", iso_639_table);
- iso_codes_parse (
- &iso_3166_parser, "iso_3166.xml", iso_3166_table);
- #endif
+#if defined (ENABLE_NLS) && defined (HAVE_ISO_CODES)
+ bindtextdomain (ISO_639_DOMAIN, ISOCODESLOCALEDIR);
+ bind_textdomain_codeset (ISO_639_DOMAIN, "UTF-8");
+
+ bindtextdomain (ISO_3166_DOMAIN, ISOCODESLOCALEDIR);
+ bind_textdomain_codeset (ISO_3166_DOMAIN, "UTF-8");
+#endif /* ENABLE_NLS && HAVE_ISO_CODES */
+
+ iso_639_table = g_hash_table_new_full (
+ (GHashFunc) g_str_hash,
+ (GEqualFunc) g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
+
+ iso_3166_table = g_hash_table_new_full (
+ (GHashFunc) g_str_hash,
+ (GEqualFunc) g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
+
+#ifdef HAVE_ISO_CODES
+ iso_codes_parse (
+ &iso_639_parser, "iso_639.xml", iso_639_table);
+ iso_codes_parse (
+ &iso_3166_parser, "iso_3166.xml", iso_3166_table);
+#endif /* HAVE_ISO_CODES */
}
}
ESpellDictionary *
e_spell_dictionary_new (ESpellChecker *parent_checker,
- EnchantDict *dict)
+ EnchantDict *enchant_dict)
{
- ESpellDictionary *e_dict;
+ ESpellDictionary *dictionary;
- e_dict = g_object_new (E_TYPE_SPELL_DICTIONARY,
- "spell-checker", parent_checker, NULL);
+ g_return_val_if_fail (E_IS_SPELL_CHECKER (parent_checker), NULL);
+ g_return_val_if_fail (enchant_dict != NULL, NULL);
- spell_dictionary_set_enchant_dict (e_dict, dict);
+ dictionary = g_object_new (
+ E_TYPE_SPELL_DICTIONARY,
+ "spell-checker", parent_checker, NULL);
- return e_dict;
-}
+ spell_dictionary_set_enchant_dict (dictionary, enchant_dict);
+ return dictionary;
+}
/**
* e_spell_dictionary_get_name:
* @dictionary: an #ESpellDictionary
*
- * Provides a user-friendly name of the dictionary (for example
+ * Returns the display name of the dictionary (for example
* "English (British)")
*
- * Return value: a name of the @dictionary
+ * Returns: the display name of the @dictionary
*/
const gchar *
e_spell_dictionary_get_name (ESpellDictionary *dictionary)
@@ -478,10 +501,10 @@ e_spell_dictionary_get_name (ESpellDictionary *dictionary)
* e_spell_dictionary_get_code:
* @dictionary: an #ESpellDictionary
*
- * Provides an ISO code of spell-checking language of the
+ * Returns the ISO code of the spell-checking language for
* @dictionary (for example "en_US").
*
- * Return value: language code of the @dictionary
+ * Returns: the language code of the @dictionary
*/
const gchar *
e_spell_dictionary_get_code (ESpellDictionary *dictionary)
@@ -494,95 +517,98 @@ e_spell_dictionary_get_code (ESpellDictionary *dictionary)
/**
* e_spell_dictionary_check:
* @dictionary: an #ESpellDictionary
- * @word: a word whose spelling to checking
- * @len: size of @word in bytes or -1 when NULL-terminated
+ * @word: a word to spell-check
+ * @length: length of @word in bytes or -1 when %NULL-terminated
*
* Tries to lookup the @word in the @dictionary to check whether
* it's spelled correctly or not.
*
- * Return value: #TRUE when the word is spelled correctly, FALSE otherwise
+ * Returns: %TRUE when the word is spelled correctly, %FALSE otherwise
*/
gboolean
e_spell_dictionary_check (ESpellDictionary *dictionary,
- const gchar *word,
- gsize len)
+ const gchar *word,
+ gsize length)
{
g_return_val_if_fail (E_IS_SPELL_DICTIONARY (dictionary), TRUE);
- g_return_val_if_fail (word && *word, TRUE);
+ g_return_val_if_fail (word != NULL && *word != '\0', TRUE);
- return enchant_dict_check (dictionary->priv->dict, word, len);
+ return enchant_dict_check (
+ dictionary->priv->enchant_dict, word, length);
}
/**
* e_spell_dictionary_learn_word:
* @dictionary: an #ESpellDictionary
* @word: a word to add to @dictionary
- * @len: size of @word in bytes or -1 when NULL-terminated
+ * @length: length of @word in bytes or -1 when %NULL-terminated
*
* Permanently adds @word to @dictionary so that next time calling
- * e_spell_dictionary_check() on the @word will return #TRUE.
+ * e_spell_dictionary_check() on the @word will return %TRUE.
*/
void
e_spell_dictionary_learn_word (ESpellDictionary *dictionary,
- const gchar *word,
- gsize len)
+ const gchar *word,
+ gsize length)
{
g_return_if_fail (E_IS_SPELL_DICTIONARY (dictionary));
- g_return_if_fail (word && *word);
+ g_return_if_fail (word != NULL && *word != '\0');
- enchant_dict_add_to_personal (dictionary->priv->dict, word, len);
+ enchant_dict_add_to_personal (
+ dictionary->priv->enchant_dict, word, length);
}
/**
* e_spell_dictionary_ignore_word:
* @dictionary: an #ESpellDictionary
* @word: a word to add to ignore list
- * @len: size of @word in bytes or -1 when NULL-terminated
+ * @length: length of @word in bytes or -1 when %NULL-terminated
*
* Adds @word to temporary ignore list of the @dictionary, so that
- * e_spell_dictionary_check() on the @word will return #TRUE. The
- * list is cleared when the dictionary is free'd.
+ * e_spell_dictionary_check() on the @word will return %TRUE. The
+ * list is cleared when the dictionary is freed.
*/
void
e_spell_dictionary_ignore_word (ESpellDictionary *dictionary,
- const gchar *word,
- gsize len)
+ const gchar *word,
+ gsize length)
{
g_return_if_fail (E_IS_SPELL_DICTIONARY (dictionary));
- g_return_if_fail (word && *word);
+ g_return_if_fail (word != NULL && *word != '\0');
- enchant_dict_add_to_session (dictionary->priv->dict, word, len);
+ enchant_dict_add_to_session (
+ dictionary->priv->enchant_dict, word, length);
}
/**
* e_spell_dictionary_get_suggestions:
* @dictionary: an #ESpellDictionary
* @word: a word to which to find suggestions
- * @len: size of @word in bytes or -1 when NULL-terminated
+ * @length: length of @word in bytes or -1 when %NULL-terminated
*
* Provides list of alternative spellings of @word.
*
- * Return value: a list of strings that has to be free'd by
+ * Returns: a list of strings that has to be free'd by
* e_spell_dictionary_free_suggestions().
*/
GList *
e_spell_dictionary_get_suggestions (ESpellDictionary *dictionary,
- const gchar *word,
- gsize len)
+ const gchar *word,
+ gsize length)
{
- gchar **s;
- GList *list;
- gsize ii, cnt;
+ GList *list = NULL;
+ gchar **suggestions;
+ gsize ii, count;
g_return_val_if_fail (E_IS_SPELL_DICTIONARY (dictionary), NULL);
- g_return_val_if_fail (word && *word, NULL);
+ g_return_val_if_fail (word != NULL && *word != '\0', NULL);
- s = enchant_dict_suggest (dictionary->priv->dict, word, len, &cnt);
- list = NULL;
- for (ii = 0; ii < cnt; ii++) {
- list = g_list_prepend (list, g_strdup (s[ii]));
- }
- enchant_dict_free_suggestions (dictionary->priv->dict, s);
+ suggestions = enchant_dict_suggest (
+ dictionary->priv->enchant_dict, word, length, &count);
+ for (ii = 0; ii < count; ii++)
+ list = g_list_prepend (list, g_strdup (suggestions[ii]));
+ enchant_dict_free_suggestions (
+ dictionary->priv->enchant_dict, suggestions);
return g_list_reverse (list);
}
@@ -603,27 +629,30 @@ e_spell_dictionary_free_suggestions (GList *suggestions)
/**
* e_spell_dictionary_add_correction
* @dictionary: an #ESpellDictionary
- * @misspelled: a word to which add a correction
- * @misspelled_len: size of @misspelled (in bytes) or -1 when string NULL-terminated
- * @correction: a correct word
- * @correction_len: size of @correction (in bytes) or -1 when string NULL-terminated
+ * @misspelled: a misspelled word
+ * @misspelled_length: length of @misspelled in bytes or -1 when
+ * %NULL-terminated
+ * @correction: the corrected word
+ * @correction_length: length of @correction in bytes or -1 when
+ * %NULL-terminated
*
- * Learns a new @correction of @misspelled word
+ * Learns a new @correction of @misspelled word.
*/
void
e_spell_dictionary_store_correction (ESpellDictionary *dictionary,
- const gchar *misspelled,
- gsize misspelled_len,
- const gchar *correction,
- gsize correction_len)
+ const gchar *misspelled,
+ gsize misspelled_length,
+ const gchar *correction,
+ gsize correction_length)
{
g_return_if_fail (E_IS_SPELL_DICTIONARY (dictionary));
- g_return_if_fail (misspelled && *misspelled);
- g_return_if_fail (correction && *correction);
+ g_return_if_fail (misspelled != NULL && *misspelled != '\0');
+ g_return_if_fail (correction != NULL && *correction != '\0');
enchant_dict_store_replacement (
- dictionary->priv->dict, misspelled, misspelled_len,
- correction, correction_len);
+ dictionary->priv->enchant_dict,
+ misspelled, misspelled_length,
+ correction, correction_length);
}
/**
@@ -633,7 +662,7 @@ e_spell_dictionary_store_correction (ESpellDictionary *dictionary,
* Returns an #ESpellChecker which is parent (and the original owner) of
* the @dictionary.
*
- * Return value: an #ESpellChecker
+ * Returns: an #ESpellChecker
*/
ESpellChecker *
e_spell_dictionary_get_parent_checker (ESpellDictionary *dictionary)
@@ -644,11 +673,13 @@ e_spell_dictionary_get_parent_checker (ESpellDictionary *dictionary)
}
gint
-e_spell_dictionary_compare (ESpellDictionary *dict1,
- ESpellDictionary *dict2)
+e_spell_dictionary_compare (ESpellDictionary *dictionary1,
+ ESpellDictionary *dictionary2)
{
- g_return_val_if_fail (E_IS_SPELL_DICTIONARY (dict1), 0);
- g_return_val_if_fail (E_IS_SPELL_DICTIONARY (dict2), 0);
+ g_return_val_if_fail (E_IS_SPELL_DICTIONARY (dictionary1), 0);
+ g_return_val_if_fail (E_IS_SPELL_DICTIONARY (dictionary2), 0);
- return strcmp (dict1->priv->collate_key, dict2->priv->collate_key);
+ return strcmp (
+ dictionary1->priv->collate_key,
+ dictionary2->priv->collate_key);
}
diff --git a/e-util/e-spell-dictionary.h b/e-util/e-spell-dictionary.h
index fd4e307..9f8d2e9 100644
--- a/e-util/e-spell-dictionary.h
+++ b/e-util/e-spell-dictionary.h
@@ -16,6 +16,10 @@
* Boston, MA 02111-1307, USA.
*/
+#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION)
+#error "Only <e-util/e-util.h> should be included directly."
+#endif
+
#ifndef E_SPELL_DICTIONARY_H
#define E_SPELL_DICTIONARY_H
@@ -41,7 +45,6 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), E_TYPE_SPELL_DICTIONARY, ESpellDictionaryClass))
-
G_BEGIN_DECLS
typedef struct _ESpellDictionary ESpellDictionary;
@@ -51,54 +54,45 @@ typedef struct _ESpellChecker ESpellChecker;
struct _ESpellDictionary {
GObject parent;
-
ESpellDictionaryPrivate *priv;
};
struct _ESpellDictionaryClass {
GObjectClass parent_class;
-
};
-GType e_spell_dictionary_get_type (void);
-
-ESpellDictionary * e_spell_dictionary_new (ESpellChecker *parent_checker,
- EnchantDict *dict);
-
-const gchar * e_spell_dictionary_get_name (ESpellDictionary *dict);
-const gchar * e_spell_dictionary_get_code (ESpellDictionary *dict);
-
-
-gboolean e_spell_dictionary_check (ESpellDictionary *dict,
- const gchar *word,
- gsize len);
-
-void e_spell_dictionary_learn_word (ESpellDictionary *dict,
- const gchar *word,
- gsize len);
-void e_spell_dictionary_ignore_word (ESpellDictionary *dict,
- const gchar *word,
- gsize len);
-GList * e_spell_dictionary_get_suggestions
- (ESpellDictionary *dict,
- const gchar *word,
- gsize len);
-void e_spell_dictionary_free_suggestions
- (GList *suggestions);
-void e_spell_dictionary_store_correction
- (ESpellDictionary *dict,
- const gchar *misspelled,
- gsize misspelled_len,
- const gchar *correction,
- gsize correction_len);
-
-ESpellChecker * e_spell_dictionary_get_parent_checker
- (ESpellDictionary *dict);
-
-gint e_spell_dictionary_compare (ESpellDictionary *dict1,
- ESpellDictionary *dict2);
+GType e_spell_dictionary_get_type (void) G_GNUC_CONST;
+ESpellDictionary *
+ e_spell_dictionary_new (ESpellChecker *parent_checker,
+ EnchantDict *enchant_dict);
+const gchar * e_spell_dictionary_get_name (ESpellDictionary *dictionary);
+const gchar * e_spell_dictionary_get_code (ESpellDictionary *dictionary);
+gboolean e_spell_dictionary_check (ESpellDictionary *dictionary,
+ const gchar *word,
+ gsize length);
+void e_spell_dictionary_learn_word (ESpellDictionary *dictionary,
+ const gchar *word,
+ gsize length);
+void e_spell_dictionary_ignore_word (ESpellDictionary *dictionary,
+ const gchar *word,
+ gsize length);
+GList * e_spell_dictionary_get_suggestions
+ (ESpellDictionary *dictionary,
+ const gchar *word,
+ gsize length);
+void e_spell_dictionary_free_suggestions
+ (GList *suggestions);
+void e_spell_dictionary_store_correction
+ (ESpellDictionary *dictionary,
+ const gchar *misspelled,
+ gsize misspelled_length,
+ const gchar *correction,
+ gsize correction_length);
+ESpellChecker * e_spell_dictionary_get_parent_checker
+ (ESpellDictionary *dictionary);
+gint e_spell_dictionary_compare (ESpellDictionary *dictionary1,
+ ESpellDictionary *dictionary2);
G_END_DECLS
-
-#endif /* E_SPELL_DICTIONARY_H */
\ No newline at end of file
+#endif /* E_SPELL_DICTIONARY_H */
diff --git a/e-util/e-spell-entry.c b/e-util/e-spell-entry.c
index 005976b..32afa85 100644
--- a/e-util/e-spell-entry.c
+++ b/e-util/e-spell-entry.c
@@ -376,7 +376,7 @@ build_suggestion_menu (ESpellEntry *entry,
const gchar *word)
{
GtkWidget *mi;
- GList *suggestions;
+ GList *suggestions, *iter;
suggestions = e_spell_dictionary_get_suggestions (dict, word, -1);
@@ -397,13 +397,10 @@ build_suggestion_menu (ESpellEntry *entry,
gtk_widget_show_all (mi);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
} else {
- GList *iter;
- gint ii;
+ gint ii = 0;
/* build a set of menus with suggestions */
- for (iter = suggestions, ii = 0; iter; iter = iter->next, ii++) {
- gchar *suggestion = iter->data;
-
+ for (iter = suggestions; iter; iter = g_list_next (iter), ii++) {
if ((ii != 0) && (ii % 10 == 0)) {
mi = gtk_separator_menu_item_new ();
gtk_widget_show (mi);
@@ -417,9 +414,9 @@ build_suggestion_menu (ESpellEntry *entry,
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
}
- mi = gtk_menu_item_new_with_label (suggestion);
+ mi = gtk_menu_item_new_with_label (iter->data);
g_object_set_data (G_OBJECT (mi), "spell-entry-checker", dict);
- g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (replace_word), entry);
+ g_signal_connect (mi, "activate", G_CALLBACK (replace_word), entry);
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
}
@@ -509,7 +506,7 @@ build_spelling_menu (ESpellEntry *entry,
submi = gtk_menu_item_new_with_label (lang_name ? lang_name : "???");
g_object_set_data (G_OBJECT (submi), "spell-entry-checker", dict);
g_signal_connect (
- G_OBJECT (submi), "activate",
+ submi, "activate",
G_CALLBACK (add_to_dictionary), entry);
gtk_widget_show (submi);
@@ -632,7 +629,7 @@ spell_entry_load_spell_languages (ESpellEntry *entry)
{
ESpellChecker *spell_checker;
GSettings *settings;
- GList *dicts = NULL;
+ GList *list = NULL;
gchar **strv;
gint ii;
@@ -645,32 +642,30 @@ spell_entry_load_spell_languages (ESpellEntry *entry)
/* Convert the codes to spell language structs. */
for (ii = 0; strv[ii] != NULL; ii++) {
+ ESpellDictionary *dictionary;
gchar *language_code = strv[ii];
- ESpellDictionary *dict;
- dict = e_spell_checker_lookup_dictionary (spell_checker, language_code);
- if (dict != NULL)
- dicts = g_list_prepend (
- dicts, (gpointer) dict);
+ dictionary = e_spell_checker_lookup_dictionary (
+ spell_checker, language_code);
+ if (dictionary != NULL)
+ list = g_list_prepend (list, dictionary);
}
g_strfreev (strv);
- dicts = g_list_reverse (dicts);
+ list = g_list_reverse (list);
/* Pick a default spell language if it came back empty. */
- if (dicts == NULL) {
- ESpellDictionary *dict;
-
- dict = e_spell_checker_lookup_dictionary (spell_checker, NULL);
+ if (list == NULL) {
+ ESpellDictionary *dictionary;
- if (dict) {
- dicts = g_list_prepend (
- dicts, (gpointer) dict);
- }
+ dictionary = e_spell_checker_lookup_dictionary (
+ spell_checker, NULL);
+ if (dictionary != NULL)
+ list = g_list_prepend (list, dictionary);
}
- return dicts;
+ return list;
}
static void
@@ -907,17 +902,15 @@ e_spell_entry_set_languages (ESpellEntry *spell_entry,
spell_entry->priv->custom_checkers = TRUE;
- if (spell_entry->priv->dictionaries) {
+ if (spell_entry->priv->dictionaries)
g_list_free_full (spell_entry->priv->dictionaries, g_object_unref);
- }
spell_entry->priv->dictionaries = NULL;
spell_entry->priv->dictionaries = g_list_copy (dictionaries);
g_list_foreach (spell_entry->priv->dictionaries, (GFunc) g_object_ref, NULL);
- if (gtk_widget_get_realized (GTK_WIDGET (spell_entry))) {
+ if (gtk_widget_get_realized (GTK_WIDGET (spell_entry)))
spell_entry_recheck_all (spell_entry);
- }
}
gboolean
@@ -934,7 +927,7 @@ e_spell_entry_set_checking_enabled (ESpellEntry *spell_entry,
{
g_return_if_fail (E_IS_SPELL_ENTRY (spell_entry));
- if ((enable_checking ? 1 : 0) == (spell_entry->priv->checking_enabled ? 1 : 0))
+ if (spell_entry->priv->checking_enabled == enable_checking)
return;
spell_entry->priv->checking_enabled = enable_checking;
diff --git a/e-util/test-editor.c b/e-util/test-editor.c
index ea96790..ef96114 100644
--- a/e-util/test-editor.c
+++ b/e-util/test-editor.c
@@ -133,13 +133,13 @@ static void
view_source_dialog (EEditor *editor,
const gchar *title,
gboolean plain_text,
- gboolean show_source)
+ gboolean show_source)
{
GtkWidget *dialog;
GtkWidget *content;
GtkWidget *content_area;
GtkWidget *scrolled_window;
- gchar* html;
+ gchar * html;
dialog = gtk_dialog_new_with_buttons (
title,
@@ -164,7 +164,6 @@ view_source_dialog (EEditor *editor,
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 6);
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 300);
-
if (plain_text) {
html = e_editor_widget_get_text_plain (
e_editor_get_editor_widget (editor));
@@ -176,7 +175,6 @@ view_source_dialog (EEditor *editor,
if (show_source || plain_text) {
GtkTextBuffer *buffer;
-
content = gtk_text_view_new ();
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (content));
gtk_text_buffer_set_text (buffer, html, -1);
@@ -255,7 +253,7 @@ action_save_as_cb (GtkAction *action,
static void
action_toggle_editor (GtkAction *action,
- EEditor *editor)
+ EEditor *editor)
{
EEditorWidget *widget;
@@ -288,7 +286,7 @@ action_view_plain_source (GtkAction *action,
static void
action_view_inspector (GtkAction *action,
- EEditor *editor)
+ EEditor *editor)
{
WebKitWebInspector *inspector;
EEditorWidget *widget;
@@ -389,11 +387,10 @@ static GtkActionEntry view_entries[] = {
NULL }
};
-
static WebKitWebView *
open_inspector (WebKitWebInspector *inspector,
- WebKitWebView *webview,
- gpointer user_data)
+ WebKitWebView *webview,
+ gpointer user_data)
{
GtkWidget *window;
GtkWidget *inspector_view;
@@ -426,18 +423,19 @@ gint main (gint argc,
gtk_init (&argc, &argv);
- window = g_object_new (E_TYPE_EDITOR_WINDOW, GTK_WINDOW_TOPLEVEL, NULL);
- gtk_widget_set_size_request (window, 600, 400);
- g_signal_connect_swapped (window, "destroy",
- G_CALLBACK (gtk_main_quit), NULL);
+ window = g_object_new (E_TYPE_EDITOR_WINDOW, GTK_WINDOW_TOPLEVEL, NULL);
+ gtk_widget_set_size_request (window, 600, 400);
+ g_signal_connect_swapped (
+ window, "destroy",
+ G_CALLBACK (gtk_main_quit), NULL);
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
inspector = webkit_web_view_get_inspector (
WEBKIT_WEB_VIEW (e_editor_get_editor_widget (
E_EDITOR (editor))));
- g_signal_connect (inspector, "inspect-web-view",
- G_CALLBACK (open_inspector), NULL);
-
+ g_signal_connect (
+ inspector, "inspect-web-view",
+ G_CALLBACK (open_inspector), NULL);
manager = e_editor_get_ui_manager (E_EDITOR (editor));
@@ -473,4 +471,4 @@ gint main (gint argc,
gtk_main ();
return 0;
-}
\ No newline at end of file
+}
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 80602b1..4a2f647 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -455,6 +455,7 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
EComposerHeaderTable *table;
GSettings *settings;
gboolean check_passed = TRUE;
+ gboolean html_mode;
gboolean send_html;
gboolean confirm_html;
gint ii;
@@ -465,6 +466,7 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
recipients = e_composer_header_table_get_destinations (table);
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
+ html_mode = e_editor_widget_get_html_mode (editor_widget);
send_html = g_settings_get_boolean (settings, "composer-send-html");
confirm_html = g_settings_get_boolean (settings, "prompt-on-unwanted-html");
@@ -472,8 +474,7 @@ composer_presend_check_unwanted_html (EMsgComposer *composer,
/* Only show this warning if our default is to send html. If it
* isn't, we've manually switched into html mode in the composer
* and (presumably) had a good reason for doing this. */
- if (e_editor_widget_get_html_mode (editor_widget) && send_html &&
- confirm_html && recipients != NULL) {
+ if (html_mode && send_html && confirm_html && recipients != NULL) {
gboolean html_problem = FALSE;
for (ii = 0; recipients[ii] != NULL; ii++) {
@@ -594,6 +595,7 @@ exit:
E_EDITOR_WINDOW (async_context->composer));
editor_widget = e_editor_get_editor_widget (editor);
e_editor_widget_set_changed (editor_widget, TRUE);
+
gtk_window_present (GTK_WINDOW (async_context->composer));
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index bcb5784..6d1ce64 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1196,7 +1196,7 @@ em_utils_message_to_html (CamelSession *session,
const gchar *credits,
guint32 flags,
EMailPartList *parts_list,
- const gchar *prepend,
+ const gchar *prepend,
const gchar *append,
EMailPartValidityFlags *validity_found)
{
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index c0d14aa..9e882a8 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -372,17 +372,17 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
EEditorWidget *editor_widget;
ESpellChecker *spell_checker;
GSettings *settings;
- GList *spell_languages;
+ GList *list;
gboolean active = TRUE;
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
editor_widget = e_editor_get_editor_widget (editor);
- spell_checker = e_editor_widget_get_spell_checker (editor_widget);
- spell_languages = e_load_spell_languages (spell_checker);
-
- e_editor_widget_set_spell_languages (editor_widget, spell_languages);
- g_list_free_full (spell_languages, g_object_unref);
+ spell_checker =
+ e_editor_widget_get_spell_checker (editor_widget);
+ list = e_load_spell_languages (spell_checker);
+ e_editor_widget_set_spell_languages (editor_widget, list);
+ g_list_free_full (list, (GDestroyNotify) g_object_unref);
settings = g_settings_new ("org.gnome.evolution.mail");
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index cf30a7b..85ca47c 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -53,7 +53,10 @@ composer_prefs_dispose (GObject *object)
{
EMComposerPrefs *prefs = (EMComposerPrefs *) object;
- g_clear_object (&prefs->builder);
+ if (prefs->builder != NULL) {
+ g_object_unref (prefs->builder);
+ prefs->builder = NULL;
+ }
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (em_composer_prefs_parent_class)->dispose (object);
@@ -259,7 +262,6 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
prefs->builder = gtk_builder_new ();
e_load_ui_builder_definition (prefs->builder, "mail-config.ui");
-
prefs->spell_checker = e_spell_checker_instance ();
/** @HookPoint-EMConfig: Mail Composer Preferences
@@ -419,7 +421,6 @@ em_composer_prefs_construct (EMComposerPrefs *prefs,
store, "row-changed",
G_CALLBACK (spell_language_save), prefs);
-
/* Forwards and Replies */
widget = e_builder_get_widget (prefs->builder, "comboboxForwardStyle");
g_settings_bind (
diff --git a/modules/mail/em-composer-prefs.h b/modules/mail/em-composer-prefs.h
index f96ad0a..310b9c5 100644
--- a/modules/mail/em-composer-prefs.h
+++ b/modules/mail/em-composer-prefs.h
@@ -54,7 +54,7 @@ typedef struct _EMComposerPrefsClass EMComposerPrefsClass;
struct _ESignature;
struct _EMComposerPrefs {
- GtkVBox parent;
+ GtkBox parent;
GtkBuilder *builder;
@@ -73,7 +73,7 @@ struct _EMComposerPrefs {
};
struct _EMComposerPrefsClass {
- GtkVBoxClass parent_class;
+ GtkBoxClass parent_class;
};
GType em_composer_prefs_get_type (void);
diff --git a/plugins/email-custom-header/email-custom-header.c
b/plugins/email-custom-header/email-custom-header.c
index 8c63002..0c07592 100644
--- a/plugins/email-custom-header/email-custom-header.c
+++ b/plugins/email-custom-header/email-custom-header.c
@@ -493,7 +493,6 @@ destroy_compo_data (gpointer data)
static void
action_email_custom_header_cb (GtkAction *action,
EMsgComposer *composer)
-
{
GtkUIManager *ui_manager;
GtkWidget *menuitem;
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index 430da41..1f57332 100644
--- a/plugins/external-editor/external-editor.c
+++ b/plugins/external-editor/external-editor.c
@@ -159,11 +159,7 @@ enable_disable_composer (EMsgComposer *composer,
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
editor_widget = e_editor_get_editor_widget (editor);
- if (enable) {
- webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), TRUE);
- } else {
- webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), FALSE);
- }
+ webkit_web_view_set_editable (WEBKIT_WEB_VIEW (editor_widget), enable);
action = E_EDITOR_ACTION_EDIT_MENU (editor);
gtk_action_set_sensitive (action, enable);
@@ -265,16 +261,16 @@ get_caret_position (EEditorWidget *widget)
document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (widget));
window = webkit_dom_document_get_default_view (document);
selection = webkit_dom_dom_window_get_selection (window);
- if (webkit_dom_dom_selection_get_range_count (selection) < 1) {
+
+ if (webkit_dom_dom_selection_get_range_count (selection) < 1)
return 0;
- }
range = webkit_dom_dom_selection_get_range_at (selection, 0, NULL);
range_count = 0;
nodes = webkit_dom_node_get_child_nodes (
- webkit_dom_node_get_parent_node (
- webkit_dom_dom_selection_get_anchor_node (
- selection)));
+ webkit_dom_node_get_parent_node (
+ webkit_dom_dom_selection_get_anchor_node (
+ selection)));
length = webkit_dom_node_list_get_length (nodes);
for (ii = 0; ii < length; ii++) {
WebKitDOMNode *node;
@@ -407,8 +403,9 @@ async_external_editor (EMsgComposer *composer)
htmltext = camel_text_to_html (
buf, CAMEL_MIME_FILTER_TOHTML_PRE, 0);
- array = g_array_sized_new (TRUE, TRUE,
- sizeof (gpointer), 2 * sizeof (gpointer));
+ array = g_array_sized_new (
+ TRUE, TRUE,
+ sizeof (gpointer), 2 * sizeof (gpointer));
array = g_array_append_val (array, composer);
array = g_array_append_val (array, htmltext);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]