[evolution/webkit-composer: 110/147] Coding style and whitespace cleanup.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/webkit-composer: 110/147] Coding style and whitespace cleanup.
- Date: Mon, 21 Jan 2013 02:19:23 +0000 (UTC)
commit 31c000bb452f1241556bdc2aee00f1039c7a507a
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 | 14 +-
composer/e-composer-private.c | 97 ++---
composer/e-msg-composer.c | 406 +++++++-----------
composer/e-msg-composer.h | 3 +-
e-util/e-color-chooser-widget.c | 46 ++-
e-util/e-color-chooser-widget.h | 6 +-
e-util/e-color-combo.c | 133 +++---
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 | 653 ++++++++++++++++-------------
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 | 666 +++++++++++++++--------------
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 | 226 +++++-----
e-util/e-editor.h | 11 +-
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 | 109 ++---
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 | 6 +-
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 | 362 +++++++++-------
e-util/test-editor.c | 32 +-
mail/e-mail-reader-utils.c | 4 +-
mail/em-composer-utils.c | 6 +-
mail/em-utils.c | 2 +-
modules/mail/e-mail-shell-backend.c | 17 +-
modules/mail/em-composer-prefs.c | 13 +-
modules/mail/em-composer-prefs.h | 4 +-
modules/settings/e-settings-web-view.c | 20 +-
plugins/external-editor/external-editor.c | 21 +-
73 files changed, 2478 insertions(+), 2509 deletions(-)
---
diff --git a/composer/e-composer-actions.c b/composer/e-composer-actions.c
index 151affe..e146afa 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
@@ -122,13 +120,12 @@ action_preferences_cb (GtkAction *action,
GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_present (GTK_WINDOW (preferences_window));
- if (e_shell_get_express_mode (shell)) {
+ if (e_shell_get_express_mode (shell))
e_preferences_window_filter_page (
E_PREFERENCES_WINDOW (preferences_window), page_name);
- } else {
+ else
e_preferences_window_show_page (
E_PREFERENCES_WINDOW (preferences_window), page_name);
- }
}
static void
@@ -230,9 +227,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-private.c b/composer/e-composer-private.c
index 2e3ae3f..6a4b7c8 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;
@@ -97,7 +97,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);
}
@@ -261,7 +260,8 @@ e_composer_private_constructed (EMsgComposer *composer)
header->input_widget, "checking-enabled",
G_BINDING_SYNC_CREATE);
- g_signal_connect_swapped (editor_widget, "notify::spell-languages",
+ g_signal_connect_swapped (
+ editor_widget, "notify::spell-languages",
G_CALLBACK (composer_spell_languages_changed), composer);
/* Construct the attachment paned. */
@@ -346,8 +346,8 @@ e_composer_private_constructed (EMsgComposer *composer)
GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
gtk_widget_set_size_request (widget, -1, GALLERY_INITIAL_HEIGHT);
priv->gallery_scrolled_window = g_object_ref (widget);
- container = priv->gallery_scrolled_window;
- e_editor_window_pack_inside (E_EDITOR_WINDOW (composer), container);
+ container = priv->gallery_scrolled_window;
+ e_editor_window_pack_inside (E_EDITOR_WINDOW (composer), container);
/* Construct the picture gallery. */
gallery_path = e_shell_settings_get_string (
@@ -507,16 +507,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);
@@ -548,13 +546,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;
}
@@ -620,15 +616,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. */
@@ -737,9 +731,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;
@@ -859,7 +852,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;
@@ -882,8 +875,8 @@ 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;
@@ -898,9 +891,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);
}
@@ -925,7 +918,7 @@ 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));
@@ -942,40 +935,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) {
+ 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);
@@ -1004,10 +999,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 4919b37..0932c03 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;
@@ -233,9 +231,8 @@ emcu_part_to_html (CamelSession *session,
g_object_unref (mem);
text = (gchar *) buf->data;
- if (len) {
+ if (len)
*len = buf->len - 1;
- }
g_byte_array_free (buf, FALSE);
return text;
@@ -247,15 +244,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;
}
@@ -267,13 +261,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) {
@@ -302,22 +294,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;
@@ -332,14 +320,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;
@@ -348,26 +334,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 *
@@ -479,9 +462,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);
- }
}
}
@@ -495,26 +477,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);
@@ -625,9 +604,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);
}
@@ -734,9 +712,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);
@@ -752,18 +729,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;
@@ -800,11 +775,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 (
@@ -816,11 +790,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);
@@ -858,9 +831,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);
@@ -909,10 +881,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;
@@ -961,11 +932,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 (
@@ -983,11 +953,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 */
@@ -1063,27 +1032,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);
@@ -1142,21 +1106,17 @@ composer_build_message (EMsgComposer *composer,
context->session = g_object_ref (session);
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 ||
@@ -1204,22 +1164,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') {
@@ -1287,14 +1244,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. */
@@ -1306,9 +1261,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);
@@ -1353,9 +1307,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. */
@@ -1368,10 +1321,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 ();
@@ -1442,10 +1394,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);
@@ -1457,14 +1408,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);
}
@@ -1484,23 +1434,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);
}
@@ -1520,9 +1467,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;
- }
shell = e_msg_composer_get_shell (composer);
shell_settings = e_shell_get_shell_settings (shell);
@@ -1580,9 +1526,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);
}
@@ -1611,9 +1556,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);
}
@@ -1644,9 +1588,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_source_registry_ref_source (registry, uid);
g_return_if_fail (source != NULL);
@@ -1810,16 +1753,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);
@@ -1844,7 +1785,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
@@ -1860,9 +1801,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);
@@ -1993,9 +1933,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);
@@ -2353,27 +2292,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);
}
@@ -2430,25 +2366,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,
@@ -2473,7 +2409,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,
@@ -2483,7 +2419,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,
@@ -2494,7 +2430,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,
@@ -2505,7 +2441,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,
@@ -2516,7 +2452,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,
@@ -2581,9 +2517,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);
}
@@ -2598,9 +2533,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));
@@ -2678,9 +2612,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);
@@ -2707,24 +2640,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));
@@ -2793,17 +2723,15 @@ handle_multipart_encrypted (EMsgComposer *composer,
protocol = camel_content_type_param (content_type, "protocol");
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (composer));
- 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_get_session (composer);
cipher = camel_gpg_context_new (session);
@@ -2812,9 +2740,8 @@ handle_multipart_encrypted (EMsgComposer *composer,
cipher, multipart, mime_part, cancellable, NULL);
g_object_unref (cipher);
- if (valid == NULL) {
+ if (valid == NULL)
return;
- }
camel_cipher_validity_free (valid);
@@ -2890,9 +2817,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));
@@ -2966,9 +2892,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));
@@ -3039,14 +2964,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;
@@ -3055,20 +2979,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
@@ -3278,9 +3201,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);
@@ -3692,9 +3614,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);
}
@@ -3802,9 +3725,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);
@@ -3937,9 +3859,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;
}
@@ -4004,9 +3925,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);
@@ -4024,30 +3944,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);
}
@@ -4156,11 +4071,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)
@@ -4181,9 +4095,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;
- }
}
}
}
@@ -4545,15 +4458,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 (
@@ -4561,9 +4472,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);
@@ -4617,11 +4527,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
@@ -4634,10 +4543,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);
@@ -4681,40 +4589,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 (
@@ -4739,9 +4640,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);
@@ -4791,9 +4691,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);
@@ -4822,9 +4721,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,
@@ -4848,9 +4746,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);
@@ -4910,9 +4807,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) {
@@ -4990,13 +4886,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);
@@ -5004,9 +4898,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),
@@ -5035,8 +4928,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));
@@ -5058,7 +4951,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 *
@@ -5095,11 +4988,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);
@@ -5112,10 +5004,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 0e1aa96..429f44a 100644
--- a/composer/e-msg-composer.h
+++ b/composer/e-msg-composer.h
@@ -96,8 +96,7 @@ EFocusTracker * e_msg_composer_get_focus_tracker
(EMsgComposer *composer);
CamelSession * e_msg_composer_get_session (EMsgComposer *composer);
EShell * e_msg_composer_get_shell (EMsgComposer *composer);
-EEditor *
- e_msg_composer_get_editor (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..0cd5689 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)
{
@@ -195,7 +199,8 @@ 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,
+ gdk_device_grab (
+ keyboard, window,
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, activate_time) == GDK_GRAB_SUCCESS;
@@ -246,8 +251,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 +273,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 +311,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 +329,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 +359,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 +367,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 +379,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 +400,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 +466,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,12 +516,12 @@ color_combo_dispose (GObject *object)
{
EColorComboPrivate *priv;
- priv = E_COLOR_COMBO (object)->priv;
+ priv = E_COLOR_COMBO_GET_PRIVATE (object);
if (priv->palette) {
g_list_free_full (
priv->palette,
- (GDestroyNotify) gdk_color_free);
+ (GDestroyNotify) gdk_color_free);
priv->palette = NULL;
}
@@ -533,25 +540,24 @@ color_combo_dispose (GObject *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 +623,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 +632,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 +641,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,20 +649,20 @@ 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);
}
@@ -669,8 +675,7 @@ e_color_combo_init (EColorCombo *combo)
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);
@@ -690,7 +695,6 @@ e_color_combo_init (EColorCombo *combo)
gtk_box_pack_start (GTK_BOX (layout), 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);
@@ -780,7 +784,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 +814,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 +827,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 +854,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 +867,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 +900,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 +919,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 +938,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 +962,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 b17a88d..6e1737d 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,7 +118,6 @@ get_has_style (EEditorSelection *selection,
gboolean result;
gint tag_len;
-
range = editor_selection_get_current_range (selection);
if (!range) {
return FALSE;
@@ -180,7 +176,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;
@@ -204,9 +200,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 +220,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));
+ g_value_set_string (
+ value,
+ e_editor_selection_get_background_color (
+ E_EDITOR_SELECTION (object)));
return;
- case PROP_BOLD:
- g_value_set_boolean (value,
- e_editor_selection_is_bold (selection));
- 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 +356,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,37 +451,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;
+
+ 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);
+}
- g_clear_object (&selection->priv->webview);
+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
@@ -469,10 +516,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
@@ -488,73 +556,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
@@ -570,7 +636,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READABLE));
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:italic
@@ -586,7 +653,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:monospaced
@@ -602,7 +670,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:strike-through
@@ -618,7 +687,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:superscript
@@ -634,7 +704,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:subscript
@@ -650,7 +721,8 @@ e_editor_selection_class_init (EEditorSelectionClass *klass)
NULL,
NULL,
FALSE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
/**
* EEditorSelection:text
@@ -662,10 +734,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
@@ -681,10 +754,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)
{
@@ -774,7 +847,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;
@@ -828,7 +901,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));
@@ -905,15 +978,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:
@@ -975,10 +1047,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),
@@ -1003,8 +1075,9 @@ 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) {
@@ -1019,7 +1092,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'))) {
@@ -1068,7 +1141,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;
@@ -1139,14 +1212,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),
@@ -1192,7 +1264,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));
@@ -1217,17 +1289,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),
@@ -1277,7 +1351,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));
@@ -1285,7 +1359,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");
}
@@ -1330,13 +1403,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),
@@ -1355,11 +1428,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");
}
@@ -1367,8 +1441,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.
*/
@@ -1395,7 +1470,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");
}
@@ -1414,7 +1488,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");
}
@@ -1445,20 +1518,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");
}
@@ -1489,14 +1559,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),
@@ -1532,43 +1600,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);
@@ -1604,14 +1670,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),
@@ -1667,14 +1731,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),
@@ -1730,14 +1792,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),
@@ -1773,14 +1833,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),
@@ -1815,7 +1873,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);
@@ -1835,7 +1893,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);
@@ -1855,7 +1913,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);
@@ -1875,7 +1933,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);
@@ -1887,7 +1945,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;
@@ -2007,7 +2065,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)) {
@@ -2049,7 +2107,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 */
@@ -2063,81 +2121,89 @@ 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;
WebKitDOMElement *marker;
-
g_return_if_fail (E_IS_EDITOR_SELECTION (selection));
document = webkit_web_view_get_dom_document (selection->priv->webview);
/* 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);
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;
+ split = container;
} else {
- split = WEBKIT_DOM_NODE (webkit_dom_text_split_text (
- (WebKitDOMText *) container,
- webkit_dom_range_get_start_offset (range, NULL),
- NULL));
+ split = WEBKIT_DOM_NODE (webkit_dom_text_split_text (
+ WEBKIT_DOM_TEXT (container),
+ webkit_dom_range_get_start_offset (range, NULL),
+ NULL));
}
webkit_dom_node_insert_before (
- webkit_dom_node_get_parent_node (container),
- WEBKIT_DOM_NODE (marker), split, NULL);
+ webkit_dom_node_get_parent_node (container),
+ WEBKIT_DOM_NODE (marker), split, 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;
+ split = container;
} else {
- split = WEBKIT_DOM_NODE (webkit_dom_text_split_text (
- (WebKitDOMText *) container,
- webkit_dom_range_get_start_offset (range, NULL),
- NULL));
+ split = WEBKIT_DOM_NODE (webkit_dom_text_split_text (
+ WEBKIT_DOM_TEXT (container),
+ webkit_dom_range_get_start_offset (range, NULL),
+ NULL));
}
webkit_dom_node_insert_before (
webkit_dom_node_get_parent_node (container),
@@ -2149,13 +2215,13 @@ 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;
@@ -2167,28 +2233,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_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);
+ webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker)),
+ WEBKIT_DOM_NODE (marker), 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_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);
+ webkit_dom_node_get_parent_node (WEBKIT_DOM_NODE (marker)),
+ WEBKIT_DOM_NODE (marker), 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;
@@ -2212,7 +2281,7 @@ editor_selection_modify (EEditorSelection *selection,
webkit_dom_dom_selection_modify (
dom_selection, alter,
- (forward ? "forward" : "backward"),
+ forward ? "forward" : "backward",
granularity_str);
}
@@ -2225,9 +2294,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);
}
@@ -2241,9 +2310,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 8bcea73..7633212 100644
--- a/e-util/e-editor-selection.h
+++ b/e-util/e-editor-selection.h
@@ -95,7 +95,6 @@ typedef enum {
struct _EEditorSelection {
GObject parent;
-
EEditorSelectionPrivate *priv;
};
@@ -103,124 +102,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 bb0182f..e91f6be 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;
@@ -268,8 +278,8 @@ editor_widget_open_inspector (WebKitWebInspector *inspector,
}
static gboolean
-editor_widget_button_press_event (GtkWidget *gtk_widget,
- GdkEventButton *event)
+editor_widget_button_press_event (GtkWidget *widget,
+ GdkEventButton *event)
{
gboolean event_handled;
@@ -277,16 +287,16 @@ editor_widget_button_press_event (GtkWidget *gtk_widget,
event_handled = FALSE;
} else {
g_signal_emit (
- gtk_widget, signals[POPUP_EVENT],
+ widget, signals[POPUP_EVENT],
0, event, &event_handled);
}
- if (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);
+ /* Chain up to parent's button_press_event() method. */
+ return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->
+ button_press_event (widget, event);
}
/* Based on original use_pictograms() from GtkHTML */
@@ -334,7 +344,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 +446,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;
@@ -468,10 +478,10 @@ editor_widget_set_links_active (EEditorWidget *widget,
}
static gboolean
-editor_widget_key_press_event (GtkWidget *gtk_widget,
- GdkEventKey *event)
+editor_widget_key_press_event (GtkWidget *widget,
+ GdkEventKey *event)
{
- EEditorWidget *editor = E_EDITOR_WIDGET (gtk_widget);
+ EEditorWidget *editor = E_EDITOR_WIDGET (widget);
if ((event->keyval == GDK_KEY_Control_L) ||
(event->keyval == GDK_KEY_Control_R)) {
@@ -482,61 +492,68 @@ editor_widget_key_press_event (GtkWidget *gtk_widget,
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));
+ /* 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);
+ 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);
+ /* 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 *gtk_widget,
- GdkEventKey *event)
+editor_widget_key_release_event (GtkWidget *widget,
+ GdkEventKey *event)
{
WebKitDOMRange *range;
- EEditorWidget *widget = E_EDITOR_WIDGET (gtk_widget);
+ EEditorWidget *editor_widget;
- range = editor_widget_get_dom_range (widget);
+ editor_widget = E_EDITOR_WIDGET (widget);
+ range = editor_widget_get_dom_range (editor_widget);
- if (widget->priv->magic_smileys &&
- widget->priv->html_mode) {
- editor_widget_check_magic_smileys (widget, range);
+ 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 (widget, FALSE);
+ editor_widget_set_links_active (editor_widget, FALSE);
}
- /* Propagate the event to WebKit */
- return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->key_release_event (gtk_widget, event);
+ /* Chain up to parent's key_release_event() method. */
+ return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->
+ key_release_event (widget, event);
}
static gboolean
-editor_widget_button_release_event (GtkWidget *gtk_widget,
- GdkEventButton *event)
+editor_widget_button_release_event (GtkWidget *widget,
+ GdkEventButton *event)
{
WebKitWebView *webview;
WebKitHitTestResult *hit_test;
WebKitHitTestResultContext context;
gchar *uri;
- webview = WEBKIT_WEB_VIEW (gtk_widget);
+ 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);
+ "context", &context,
+ "link-uri", &uri,
+ NULL);
g_object_unref (hit_test);
@@ -547,24 +564,26 @@ editor_widget_button_release_event (GtkWidget *gtk_widget,
/* Ctrl + Left Click on link opens it, otherwise ignore the
* click completely */
if (event->state & GDK_CONTROL_MASK) {
+ GtkWidget *toplevel;
+ GdkScreen *screen;
- gtk_show_uri (
- gtk_window_get_screen (
- GTK_WINDOW (gtk_widget_get_toplevel (gtk_widget))),
- uri, event->time, NULL);
+ toplevel = gtk_widget_get_toplevel (widget);
+ screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
+ gtk_show_uri (screen, 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);
+ /* Chain up to parent's button_release_event() method. */
+ return GTK_WIDGET_CLASS (e_editor_widget_parent_class)->
+ button_release_event (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;
@@ -607,65 +626,70 @@ editor_widget_paste_clipboard_quoted (EEditorWidget *widget)
static void
e_editor_widget_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
switch (property_id) {
-
- case PROP_HTML_MODE:
- g_value_set_boolean (
- value, e_editor_widget_get_html_mode (
- E_EDITOR_WIDGET (object)));
- return;
-
- case PROP_INLINE_SPELLING:
- g_value_set_boolean (
- value, e_editor_widget_get_inline_spelling (
- E_EDITOR_WIDGET (object)));
- return;
-
- case PROP_MAGIC_LINKS:
- g_value_set_boolean (
- value, e_editor_widget_get_magic_links (
- E_EDITOR_WIDGET (object)));
- 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)));
- return;
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;
+
+ case PROP_CHANGED:
+ g_value_set_boolean (
+ value, e_editor_widget_get_changed (
+ E_EDITOR_WIDGET (object)));
+ return;
+
+ case PROP_HTML_MODE:
+ g_value_set_boolean (
+ value, e_editor_widget_get_html_mode (
+ E_EDITOR_WIDGET (object)));
+ return;
+
+ case PROP_INLINE_SPELLING:
+ g_value_set_boolean (
+ value, e_editor_widget_get_inline_spelling (
+ E_EDITOR_WIDGET (object)));
+ return;
+
+ case PROP_MAGIC_LINKS:
+ g_value_set_boolean (
+ value, e_editor_widget_get_magic_links (
+ E_EDITOR_WIDGET (object)));
+ return;
+
+ case PROP_MAGIC_SMILEYS:
+ g_value_set_boolean (
+ value, e_editor_widget_get_magic_smileys (
+ E_EDITOR_WIDGET (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -673,11 +697,16 @@ e_editor_widget_get_property (GObject *object,
static void
e_editor_widget_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_CHANGED:
+ e_editor_widget_set_changed (
+ E_EDITOR_WIDGET (object),
+ g_value_get_boolean (value));
+ return;
case PROP_HTML_MODE:
e_editor_widget_set_html_mode (
@@ -702,128 +731,44 @@ e_editor_widget_set_property (GObject *object,
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));
- return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
static void
-e_editor_widget_finalize (GObject *object)
+e_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 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 = G_OBJECT_CLASS (class);
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->dispose = e_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,7 +1252,7 @@ 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));
@@ -1231,7 +1272,7 @@ e_editor_widget_set_html_mode (EEditorWidget *widget,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_NONE,
_("Turning HTML mode off will cause the text "
- "to lose all formatting. Do you want to continue?"));
+ "to lose all formatting. Do you want to continue?"));
gtk_dialog_add_buttons (
GTK_DIALOG (dialog),
_("_Don't lose formatting"), GTK_RESPONSE_CANCEL,
@@ -1285,7 +1326,7 @@ e_editor_widget_set_html_mode (EEditorWidget *widget,
g_free (plain);
}
-
+
g_object_notify (G_OBJECT (widget), "html-mode");
}
@@ -1316,11 +1357,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 +1395,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 +1434,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;
@@ -1433,7 +1474,7 @@ e_editor_widget_get_spell_languages (EEditorWidget *widget)
*/
void
e_editor_widget_set_spell_languages (EEditorWidget *widget,
- const GList *spell_languages)
+ const GList *spell_languages)
{
g_return_if_fail (E_IS_EDITOR_WIDGET (widget));
g_return_if_fail (spell_languages);
@@ -1481,7 +1522,7 @@ e_editor_widget_get_text_html (EEditorWidget *widget)
static void
process_elements (WebKitDOMNode *node,
- GString *buffer)
+ GString *buffer)
{
WebKitDOMDocument *document;
WebKitDOMDOMWindow *window;
@@ -1525,7 +1566,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 +1580,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);
@@ -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 5d77c3e..41662a2 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,
const 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..231944e 100644
--- a/e-util/e-editor.c
+++ b/e-util/e-editor.c
@@ -30,10 +30,9 @@
#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 +41,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 +61,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 +121,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 +131,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 +202,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 +215,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 +231,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 +276,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 +284,7 @@ editor_spell_checkers_foreach (ESpellDictionary *dictionary,
static void
editor_update_actions (EEditor *editor,
- GdkEventButton *event)
+ GdkEventButton *event)
{
WebKitWebView *webview;
WebKitSpellChecker *checker;
@@ -314,14 +312,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 +341,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 +357,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 +426,7 @@ editor_update_actions (EEditor *editor,
static void
editor_spell_languages_changed (EEditor *editor,
- GList *dictionaries)
+ GList *dictionaries)
{
ESpellChecker *checker;
WebKitWebSettings *settings;
@@ -448,9 +443,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 +453,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 +471,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 +518,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 +534,15 @@ 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,15 +553,15 @@ 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;
}
@@ -614,7 +610,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 +686,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 +715,44 @@ 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));
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 +762,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,
@@ -777,8 +778,7 @@ e_editor_init (EEditor *editor)
GError *error;
gchar *filename;
- editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (
- editor, E_TYPE_EDITOR, EEditorPrivate);
+ editor->priv = E_EDITOR_GET_PRIVATE (editor);
priv = editor->priv;
@@ -857,24 +857,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 +893,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 +920,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 +955,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 +981,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 +1006,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 +1021,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 +1058,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..9e49d5f 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,
@@ -89,14 +85,11 @@ GtkWidget * e_editor_get_managed_widget
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..8d2d2da 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. */
@@ -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 4717dea..f69f0c5 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>
@@ -553,7 +550,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 45038c0..86d776b 100644
--- a/e-util/e-name-selector-entry.c
+++ b/e-util/e-name-selector-entry.c
@@ -507,10 +507,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
@@ -526,7 +526,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 dd29a1d..b6c48d1 100644
--- a/e-util/e-spell-entry.c
+++ b/e-util/e-spell-entry.c
@@ -18,24 +18,19 @@
/* This code is based on libsexy's SexySpellEntry */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
-
-#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <glib/gi18n-lib.h>
#include <e-util/e-spell-checker.h>
#include "e-spell-entry.h"
-enum {
- PROP_0,
- PROP_CHECKING_ENABLED
-};
+#define E_SPELL_ENTRY_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE \
+ ((obj), E_TYPE_SPELL_ENTRY, ESpellEntryPrivate))
-struct _ESpellEntryPrivate
-{
+struct _ESpellEntryPrivate {
PangoAttrList *attr_list;
gint mark_character;
gint entry_scroll_offset;
@@ -50,9 +45,10 @@ struct _ESpellEntryPrivate
ESpellChecker *spell_checker;
};
-#define E_SPELL_ENTRY_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE \
- ((obj), E_TYPE_SPELL_ENTRY, ESpellEntryPrivate))
+enum {
+ PROP_0,
+ PROP_CHECKING_ENABLED
+};
G_DEFINE_TYPE (ESpellEntry, e_spell_entry, GTK_TYPE_ENTRY);
@@ -95,8 +91,11 @@ insert_underline (ESpellEntry *entry,
guint start,
guint end)
{
- PangoAttribute *ucolor = pango_attr_underline_color_new (65535, 0, 0);
- PangoAttribute *unline = pango_attr_underline_new (PANGO_UNDERLINE_ERROR);
+ PangoAttribute *ucolor;
+ PangoAttribute *unline;
+
+ ucolor = pango_attr_underline_color_new (65535, 0, 0);
+ unline = pango_attr_underline_new (PANGO_UNDERLINE_ERROR);
ucolor->start_index = start;
unline->start_index = start;
@@ -116,7 +115,7 @@ check_word (ESpellEntry *entry,
PangoAttrIterator *it;
/* Check to see if we've got any attributes at this position.
- * If so, free them, since we'll readd it if the word is misspelled */
+ * If so, free them, since we'll read it if the word is misspelled */
it = pango_attr_list_get_iterator (entry->priv->attr_list);
if (it == NULL)
@@ -125,9 +124,11 @@ check_word (ESpellEntry *entry,
gint s, e;
pango_attr_iterator_range (it, &s, &e);
if (s == start) {
+ /* XXX What does this do? */
GSList *attrs = pango_attr_iterator_get_attrs (it);
- g_slist_foreach (attrs, (GFunc) pango_attribute_destroy, NULL);
- g_slist_free (attrs);
+ g_slist_free_full (
+ attrs, (GDestroyNotify)
+ pango_attribute_destroy);
}
} while (pango_attr_iterator_next (it));
pango_attr_iterator_destroy (it);
@@ -143,10 +144,11 @@ spell_entry_recheck_all (ESpellEntry *entry)
PangoLayout *layout;
gint length, i;
- if (!entry->priv->words)
+ if (entry->priv->words == NULL)
return;
- /* Remove all existing pango attributes. These will get read as we check */
+ /* Remove all existing pango attributes.
+ * These will get read as we check. */
pango_attr_list_unref (entry->priv->attr_list);
entry->priv->attr_list = pango_attr_list_new ();
@@ -156,7 +158,10 @@ spell_entry_recheck_all (ESpellEntry *entry)
length = strlen (entry->priv->words[i]);
if (length == 0)
continue;
- check_word (entry, entry->priv->word_starts[i], entry->priv->word_ends[i]);
+ check_word (
+ entry,
+ entry->priv->word_starts[i],
+ entry->priv->word_ends[i]);
}
layout = gtk_entry_get_layout (GTK_ENTRY (entry));
@@ -189,7 +194,7 @@ get_word_extents_from_position (ESpellEntry *entry,
if (bytes_pos >= entry->priv->word_starts[i] &&
bytes_pos <= entry->priv->word_ends[i]) {
*start = entry->priv->word_starts[i];
- *end = entry->priv->word_ends[i];
+ *end = entry->priv->word_ends[i];
return;
}
}
@@ -201,10 +206,10 @@ entry_strsplit_utf8 (GtkEntry *entry,
gint **starts,
gint **ends)
{
- PangoLayout *layout;
- PangoLogAttr *log_attrs;
- const gchar *text;
- gint n_attrs, n_strings, i, j;
+ PangoLayout *layout;
+ PangoLogAttr *log_attrs;
+ const gchar *text;
+ gint n_attrs, n_strings, i, j;
layout = gtk_entry_get_layout (GTK_ENTRY (entry));
text = gtk_entry_get_text (GTK_ENTRY (entry));
@@ -216,9 +221,9 @@ entry_strsplit_utf8 (GtkEntry *entry,
if (log_attrs[i].is_word_start)
n_strings++;
- *set = g_new0 (gchar *, n_strings + 1);
+ *set = g_new0 (gchar *, n_strings + 1);
*starts = g_new0 (gint, n_strings);
- *ends = g_new0 (gint, n_strings);
+ *ends = g_new0 (gint, n_strings);
/* Copy out strings */
for (i = 0, j = 0; i < n_attrs; i++) {
@@ -234,9 +239,9 @@ entry_strsplit_utf8 (GtkEntry *entry,
/* Copy sub-string */
start = g_utf8_offset_to_pointer (text, i);
bytes = (gint) (g_utf8_offset_to_pointer (text, cend) - start);
- (*set)[j] = g_new0 (gchar, bytes + 1);
+ (*set)[j] = g_new0 (gchar, bytes + 1);
(*starts)[j] = (gint) (start - text);
- (*ends)[j] = (gint) (start - text + bytes);
+ (*ends)[j] = (gint) (start - text + bytes);
g_utf8_strncpy ((*set)[j], start, cend - i);
/* Move on to the next word */
@@ -255,23 +260,29 @@ add_to_dictionary (GtkWidget *menuitem,
gint start, end;
ESpellDictionary *dict;
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
+ get_word_extents_from_position (
+ entry, &start, &end, entry->priv->mark_character);
word = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
dict = g_object_get_data (G_OBJECT (menuitem), "spell-entry-checker");
- if (dict) {
+ if (dict != NULL) {
e_spell_dictionary_learn_word (dict, word, -1);
}
g_free (word);
- if (entry->priv->words) {
+ if (entry->priv->words != NULL) {
g_strfreev (entry->priv->words);
g_free (entry->priv->word_starts);
g_free (entry->priv->word_ends);
}
- entry_strsplit_utf8 (GTK_ENTRY (entry), &entry->priv->words, &entry->priv->word_starts, &entry->priv->word_ends);
+ entry_strsplit_utf8 (
+ GTK_ENTRY (entry),
+ &entry->priv->words,
+ &entry->priv->word_starts,
+ &entry->priv->word_ends);
+
spell_entry_recheck_all (entry);
}
@@ -283,7 +294,8 @@ ignore_all (GtkWidget *menuitem,
gint start, end;
GList *li;
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
+ get_word_extents_from_position (
+ entry, &start, &end, entry->priv->mark_character);
word = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
for (li = entry->priv->dictionaries; li; li = g_list_next (li)) {
@@ -293,12 +305,18 @@ ignore_all (GtkWidget *menuitem,
g_free (word);
- if (entry->priv->words) {
+ if (entry->priv->words != NULL) {
g_strfreev (entry->priv->words);
g_free (entry->priv->word_starts);
g_free (entry->priv->word_ends);
}
- entry_strsplit_utf8 (GTK_ENTRY (entry), &entry->priv->words, &entry->priv->word_starts, &entry->priv->word_ends);
+
+ entry_strsplit_utf8 (
+ GTK_ENTRY (entry),
+ &entry->priv->words,
+ &entry->priv->word_starts,
+ &entry->priv->word_ends);
+
spell_entry_recheck_all (entry);
}
@@ -312,9 +330,11 @@ replace_word (GtkWidget *menuitem,
gint cursor;
ESpellDictionary *dict;
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
+ get_word_extents_from_position (
+ entry, &start, &end, entry->priv->mark_character);
oldword = gtk_editable_get_chars (GTK_EDITABLE (entry), start, end);
- newword = gtk_label_get_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (menuitem))));
+ newword = gtk_label_get_text (
+ GTK_LABEL (gtk_bin_get_child (GTK_BIN (menuitem))));
cursor = gtk_editable_get_position (GTK_EDITABLE (entry));
/* is the cursor at the end? If so, restore it there */
@@ -325,14 +345,15 @@ replace_word (GtkWidget *menuitem,
gtk_editable_delete_text (GTK_EDITABLE (entry), start, end);
gtk_editable_set_position (GTK_EDITABLE (entry), start);
- gtk_editable_insert_text (GTK_EDITABLE (entry), newword, strlen (newword),
- &start);
+ gtk_editable_insert_text (
+ GTK_EDITABLE (entry), newword, strlen (newword), &start);
gtk_editable_set_position (GTK_EDITABLE (entry), cursor);
dict = g_object_get_data (G_OBJECT (menuitem), "spell-entry-checker");
if (dict != NULL)
- e_spell_dictionary_store_correction (dict, oldword, -1, newword, -1);
+ e_spell_dictionary_store_correction (
+ dict, oldword, -1, newword, -1);
g_free (oldword);
}
@@ -344,11 +365,11 @@ build_suggestion_menu (ESpellEntry *entry,
const gchar *word)
{
GtkWidget *mi;
- GList *suggestions;
+ GList *suggestions, *iter;
suggestions = e_spell_dictionary_get_suggestions (dict, word, -1);
- if (!suggestions) {
+ if (suggestions == NULL) {
/* no suggestions. Put something in the menu anyway... */
GtkWidget *label = gtk_label_new (_("(no suggestions)"));
PangoAttribute *attribute;
@@ -365,13 +386,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);
@@ -385,9 +403,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);
}
@@ -406,11 +424,11 @@ build_spelling_menu (ESpellEntry *entry,
topmenu = gtk_menu_new ();
- if (!entry->priv->dictionaries)
+ if (entry->priv->dictionaries == NULL)
return topmenu;
/* Suggestions */
- if (!entry->priv->dictionaries->next) {
+ if (entry->priv->dictionaries->next == NULL) {
dict = entry->priv->dictionaries->data;
build_suggestion_menu (entry, topmenu, dict, word);
} else {
@@ -422,7 +440,7 @@ build_spelling_menu (ESpellEntry *entry,
dict = li->data;
lang_name = e_spell_dictionary_get_name (dict);
- if (!lang_name)
+ if (lang_name == NULL)
lang_name = e_spell_dictionary_get_code (dict);
mi = gtk_menu_item_new_with_label (lang_name ? lang_name : "???");
@@ -445,12 +463,16 @@ build_spelling_menu (ESpellEntry *entry,
mi = gtk_image_menu_item_new_with_label (label);
g_free (label);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
+ gtk_image_menu_item_set_image (
+ GTK_IMAGE_MENU_ITEM (mi),
+ gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU));
- if (!entry->priv->dictionaries->next) {
+ if (entry->priv->dictionaries->next == NULL) {
dict = entry->priv->dictionaries->data;
g_object_set_data (G_OBJECT (mi), "spell-entry-checker", dict);
- g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (add_to_dictionary), entry);
+ g_signal_connect (
+ G_OBJECT (mi), "activate",
+ G_CALLBACK (add_to_dictionary), entry);
} else {
GList *li;
GtkWidget *menu, *submi;
@@ -463,12 +485,14 @@ build_spelling_menu (ESpellEntry *entry,
dict = li->data;
lang_name = e_spell_dictionary_get_name (dict);
- if (!lang_name)
+ if (lang_name == NULL)
lang_name = e_spell_dictionary_get_code (dict);
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", G_CALLBACK (add_to_dictionary), entry);
+ g_signal_connect (
+ submi, "activate",
+ G_CALLBACK (add_to_dictionary), entry);
gtk_widget_show (submi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), submi);
@@ -480,8 +504,10 @@ build_spelling_menu (ESpellEntry *entry,
/* - Ignore All */
mi = gtk_image_menu_item_new_with_label (_("Ignore All"));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
- g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (ignore_all), entry);
+ gtk_image_menu_item_set_image (
+ GTK_IMAGE_MENU_ITEM (mi),
+ gtk_image_new_from_stock (GTK_STOCK_REMOVE, GTK_ICON_SIZE_MENU));
+ g_signal_connect (mi, "activate", G_CALLBACK (ignore_all), entry);
gtk_widget_show_all (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
@@ -517,9 +543,10 @@ spell_entry_add_suggestions_menu (ESpellEntry *entry,
static gboolean
spell_entry_popup_menu (ESpellEntry *entry)
{
- /* Menu popped up from a keybinding (menu key or <shift>+F10). Use
- * the cursor position as the mark position */
- entry->priv->mark_character = gtk_editable_get_position (GTK_EDITABLE (entry));
+ /* Menu popped up from a keybinding (menu key or <shift>+F10).
+ * Use the cursor position as the mark position. */
+ entry->priv->mark_character =
+ gtk_editable_get_position (GTK_EDITABLE (entry));
return FALSE;
}
@@ -532,10 +559,11 @@ spell_entry_populate_popup (ESpellEntry *entry,
gint start, end;
gchar *word;
- if (!entry->priv->dictionaries)
+ if (entry->priv->dictionaries == NULL)
return;
- get_word_extents_from_position (entry, &start, &end, entry->priv->mark_character);
+ get_word_extents_from_position (
+ entry, &start, &end, entry->priv->mark_character);
if (start == end)
return;
@@ -555,15 +583,21 @@ spell_entry_changed (GtkEditable *editable)
{
ESpellEntry *entry = E_SPELL_ENTRY (editable);
- if (!entry->priv->dictionaries)
+ if (entry->priv->dictionaries == NULL)
return;
- if (entry->priv->words) {
+ if (entry->priv->words != NULL) {
g_strfreev (entry->priv->words);
g_free (entry->priv->word_starts);
g_free (entry->priv->word_ends);
}
- entry_strsplit_utf8 (GTK_ENTRY (entry), &entry->priv->words, &entry->priv->word_starts, &entry->priv->word_ends);
+
+ entry_strsplit_utf8 (
+ GTK_ENTRY (entry),
+ &entry->priv->words,
+ &entry->priv->word_starts,
+ &entry->priv->word_ends);
+
spell_entry_recheck_all (entry);
}
@@ -572,7 +606,9 @@ spell_entry_notify_scroll_offset (ESpellEntry *spell_entry)
{
g_return_if_fail (E_IS_SPELL_ENTRY (spell_entry));
- g_object_get (G_OBJECT (spell_entry), "scroll-offset", &spell_entry->priv->entry_scroll_offset, NULL);
+ g_object_get (
+ G_OBJECT (spell_entry), "scroll-offset",
+ &spell_entry->priv->entry_scroll_offset, NULL);
}
static GList *
@@ -580,7 +616,7 @@ spell_entry_load_spell_languages (ESpellEntry *entry)
{
ESpellChecker *spell_checker;
GSettings *settings;
- GList *dicts = NULL;
+ GList *list = NULL;
gchar **strv;
gint ii;
@@ -593,32 +629,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
@@ -666,32 +700,6 @@ spell_entry_find_position (ESpellEntry *spell_entry,
return pos;
}
-static gboolean
-e_spell_entry_draw (GtkWidget *widget,
- cairo_t *cr)
-{
- ESpellEntry *spell_entry = E_SPELL_ENTRY (widget);
- GtkEntry *entry = GTK_ENTRY (widget);
- PangoLayout *layout;
-
- layout = gtk_entry_get_layout (entry);
- pango_layout_set_attributes (layout, spell_entry->priv->attr_list);
-
- return GTK_WIDGET_CLASS (e_spell_entry_parent_class)->draw (widget, cr);
-}
-
-static gboolean
-e_spell_entry_button_press (GtkWidget *widget,
- GdkEventButton *event)
-{
- ESpellEntry *spell_entry = E_SPELL_ENTRY (widget);
-
- spell_entry->priv->mark_character = spell_entry_find_position (
- spell_entry, event->x + spell_entry->priv->entry_scroll_offset);
-
- return GTK_WIDGET_CLASS (e_spell_entry_parent_class)->button_press_event (widget, event);
-}
-
static void
spell_entry_set_property (GObject *object,
guint property_id,
@@ -728,50 +736,70 @@ spell_entry_get_property (GObject *object,
}
static void
-e_spell_entry_init (ESpellEntry *spell_entry)
+spell_entry_dispose (GObject *object)
{
- spell_entry->priv = E_SPELL_ENTRY_GET_PRIVATE (spell_entry);
- spell_entry->priv->attr_list = pango_attr_list_new ();
- spell_entry->priv->dictionaries = NULL;
- spell_entry->priv->checking_enabled = TRUE;
- spell_entry->priv->spell_checker = g_object_new (E_TYPE_SPELL_CHECKER, NULL);
+ ESpellEntryPrivate *priv;
- g_signal_connect (spell_entry, "popup-menu", G_CALLBACK (spell_entry_popup_menu), NULL);
- g_signal_connect (spell_entry, "populate-popup", G_CALLBACK (spell_entry_populate_popup), NULL);
- g_signal_connect (spell_entry, "changed", G_CALLBACK (spell_entry_changed), NULL);
- g_signal_connect (spell_entry, "notify::scroll-offset", G_CALLBACK (spell_entry_notify_scroll_offset), NULL);
+ priv = E_SPELL_ENTRY_GET_PRIVATE (object);
- /* listen for languages changes */
- spell_entry->priv->settings = g_settings_new ("org.gnome.evolution.mail");
- g_signal_connect_swapped (spell_entry->priv->settings, "changed", G_CALLBACK (spell_entry_settings_changed), spell_entry);
+ g_clear_object (&priv->settings);
+ g_clear_object (&priv->spell_checker);
- /* load current settings */
- spell_entry_settings_changed (spell_entry, NULL);
+ g_list_free_full (priv->dictionaries, g_object_unref);
+ priv->dictionaries = NULL;
+
+ if (priv->attr_list != NULL) {
+ pango_attr_list_unref (priv->attr_list);
+ priv->attr_list = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_spell_entry_parent_class)->dispose (object);
}
static void
-e_spell_entry_finalize (GObject *object)
+spell_entry_finalize (GObject *object)
{
- ESpellEntry *entry;
+ ESpellEntryPrivate *priv;
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_SPELL_ENTRY (object));
+ priv = E_SPELL_ENTRY_GET_PRIVATE (object);
- entry = E_SPELL_ENTRY (object);
+ g_strfreev (priv->words);
+ g_free (priv->word_starts);
+ g_free (priv->word_ends);
- g_clear_object (&entry->priv->settings);
- g_clear_object (&entry->priv->spell_checker);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_spell_entry_parent_class)->finalize (object);
+}
- g_list_free_full (entry->priv->dictionaries, g_object_unref);
+static gboolean
+spell_entry_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ ESpellEntry *spell_entry = E_SPELL_ENTRY (widget);
+ GtkEntry *entry = GTK_ENTRY (widget);
+ PangoLayout *layout;
- if (entry->priv->attr_list)
- pango_attr_list_unref (entry->priv->attr_list);
+ layout = gtk_entry_get_layout (entry);
+ pango_layout_set_attributes (layout, spell_entry->priv->attr_list);
- g_strfreev (entry->priv->words);
- g_free (entry->priv->word_starts);
- g_free (entry->priv->word_ends);
+ /* Chain up to parent's draw() method. */
+ return GTK_WIDGET_CLASS (e_spell_entry_parent_class)->
+ draw (widget, cr);
+}
- G_OBJECT_CLASS (e_spell_entry_parent_class)->finalize (object);
+static gboolean
+spell_entry_button_press (GtkWidget *widget,
+ GdkEventButton *event)
+{
+ ESpellEntry *spell_entry = E_SPELL_ENTRY (widget);
+
+ spell_entry->priv->mark_character = spell_entry_find_position (
+ spell_entry, event->x + spell_entry->priv->entry_scroll_offset);
+
+ /* Chain up to parent's button_press_event() method. */
+ return GTK_WIDGET_CLASS (e_spell_entry_parent_class)->
+ button_press_event (widget, event);
}
static void
@@ -785,11 +813,12 @@ e_spell_entry_class_init (ESpellEntryClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->set_property = spell_entry_set_property;
object_class->get_property = spell_entry_get_property;
- object_class->finalize = e_spell_entry_finalize;
+ object_class->dispose = spell_entry_dispose;
+ object_class->finalize = spell_entry_finalize;
- widget_class = GTK_WIDGET_CLASS (class);
- widget_class->draw = e_spell_entry_draw;
- widget_class->button_press_event = e_spell_entry_button_press;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->draw = spell_entry_draw;
+ widget_class->button_press_event = spell_entry_button_press;
g_object_class_install_property (
object_class,
@@ -799,7 +828,40 @@ e_spell_entry_class_init (ESpellEntryClass *class)
"checking enabled",
"Spell Checking is Enabled",
TRUE,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+}
+
+static void
+e_spell_entry_init (ESpellEntry *spell_entry)
+{
+ spell_entry->priv = E_SPELL_ENTRY_GET_PRIVATE (spell_entry);
+ spell_entry->priv->attr_list = pango_attr_list_new ();
+ spell_entry->priv->dictionaries = NULL;
+ spell_entry->priv->checking_enabled = TRUE;
+ spell_entry->priv->spell_checker = g_object_new (E_TYPE_SPELL_CHECKER, NULL);
+
+ g_signal_connect (
+ spell_entry, "popup-menu",
+ G_CALLBACK (spell_entry_popup_menu), NULL);
+ g_signal_connect (
+ spell_entry, "populate-popup",
+ G_CALLBACK (spell_entry_populate_popup), NULL);
+ g_signal_connect (
+ spell_entry, "changed",
+ G_CALLBACK (spell_entry_changed), NULL);
+ g_signal_connect (
+ spell_entry, "notify::scroll-offset",
+ G_CALLBACK (spell_entry_notify_scroll_offset), NULL);
+
+ /* listen for languages changes */
+ spell_entry->priv->settings = g_settings_new ("org.gnome.evolution.mail");
+ g_signal_connect_swapped (
+ spell_entry->priv->settings, "changed",
+ G_CALLBACK (spell_entry_settings_changed), spell_entry);
+
+ /* load current settings */
+ spell_entry_settings_changed (spell_entry, NULL);
}
GtkWidget *
@@ -816,17 +878,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
@@ -843,7 +903,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/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 5ecd8bf..bd0d5e9 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -1487,7 +1487,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
GtkToggleAction *action;
if ((validity_pgp_sum & E_MAIL_PART_VALIDITY_PGP) != 0) {
- EEditor *editor = E_EDITOR (composer);
+ EEditor *editor = E_EDITOR (composer);
if ((validity_pgp_sum & E_MAIL_PART_VALIDITY_SIGNED) != 0) {
action = GTK_TOGGLE_ACTION (E_COMPOSER_ACTION_PGP_SIGN (composer));
gtk_toggle_action_set_active (action, TRUE);
@@ -1500,7 +1500,7 @@ e_mail_reader_reply_to_message (EMailReader *reader,
}
if ((validity_smime_sum & E_MAIL_PART_VALIDITY_SMIME) != 0) {
- EEditor *editor = E_EDITOR (composer);
+ EEditor *editor = E_EDITOR (composer);
if ((validity_smime_sum & E_MAIL_PART_VALIDITY_SIGNED) != 0) {
action = GTK_TOGGLE_ACTION (E_COMPOSER_ACTION_SMIME_SIGN (composer));
gtk_toggle_action_set_active (action, TRUE);
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 4ebfc72..97822bc 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -469,6 +469,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;
@@ -479,6 +480,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");
@@ -486,8 +488,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++) {
@@ -578,6 +579,7 @@ exit:
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (context->composer));
editor_widget = e_editor_get_editor_widget (editor);
e_editor_widget_set_changed (editor_widget, TRUE);
+
gtk_window_present (GTK_WINDOW (context->composer));
}
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 5866702..30543a1 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1277,7 +1277,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,
guint32 *validity_found)
{
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index c9ea976..5e186a4 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -372,26 +372,25 @@ mail_shell_backend_window_added_cb (GtkApplication *application,
EShellSettings *shell_settings;
EEditor *editor;
EEditorWidget *editor_widget;
- GList *spell_languages;
+ ESpellChecker *spell_checker;
+ GList *list;
gboolean active = TRUE;
editor = e_editor_window_get_editor (E_EDITOR_WINDOW (window));
editor_widget = e_editor_get_editor_widget (editor);
- spell_languages = e_load_spell_languages (
- e_editor_widget_get_spell_checker (
- editor_widget));
-
- 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);
shell_settings = e_shell_get_shell_settings (shell);
/* Express mode does not honor this setting. */
- if (!e_shell_get_express_mode (shell)) {
+ if (!e_shell_get_express_mode (shell))
active = e_shell_settings_get_boolean (
shell_settings, "composer-format-html");
- }
e_editor_widget_set_html_mode (editor_widget, active);
}
diff --git a/modules/mail/em-composer-prefs.c b/modules/mail/em-composer-prefs.c
index b9f5486..f9083f8 100644
--- a/modules/mail/em-composer-prefs.c
+++ b/modules/mail/em-composer-prefs.c
@@ -125,7 +125,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);
@@ -211,8 +214,8 @@ spell_setup (EMComposerPrefs *prefs)
store = GTK_LIST_STORE (prefs->language_model);
- available_languages = e_spell_checker_list_available_dicts (
- prefs->spell_checker);
+ available_languages =
+ e_spell_checker_list_available_dicts (prefs->spell_checker);
active_languages = e_load_spell_languages (prefs->spell_checker);
@@ -330,8 +333,7 @@ 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();
+ prefs->spell_checker = e_spell_checker_instance ();
/** @HookPoint-EMConfig: Mail Composer Preferences
* @Id: org.gnome.evolution.mail.composerPrefs
@@ -511,7 +513,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_object_bind_property (
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/modules/settings/e-settings-web-view.c b/modules/settings/e-settings-web-view.c
index c388868..ceb7f7a 100644
--- a/modules/settings/e-settings-web-view.c
+++ b/modules/settings/e-settings-web-view.c
@@ -45,19 +45,19 @@ G_DEFINE_DYNAMIC_TYPE (
static void
fix_color_string (gchar *color_string)
{
- GdkColor color;
+ GdkColor color;
- if (!color_string || strlen (color_string) < 13)
- return;
+ if (!color_string || strlen (color_string) < 13)
+ return;
- if (!gdk_color_parse (color_string, &color))
- return;
+ if (!gdk_color_parse (color_string, &color))
+ return;
- sprintf (
- color_string, "#%02x%02x%02x",
- (gint) color.red * 256 / 65536,
- (gint) color.green * 256 / 65536,
- (gint) color.blue * 256 / 65536);
+ sprintf (
+ color_string, "#%02x%02x%02x",
+ (gint) color.red * 256 / 65536,
+ (gint) color.green * 256 / 65536,
+ (gint) color.blue * 256 / 65536);
}
static void
diff --git a/plugins/external-editor/external-editor.c b/plugins/external-editor/external-editor.c
index 22661f2..4365c99 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;
@@ -406,8 +402,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]