diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2008-04-05 23:26:26 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-04-05 23:26:26 +0800 |
commit | 52ba74cef488e616e07b2ae8f5e93df8a9e31081 (patch) | |
tree | 629dd2edcd1f27ccb9b6661e4a95a85ea0656413 /mail | |
parent | 20fca64c5a4d78d11a61b5689d97cf164caea08f (diff) | |
download | gsoc2013-evolution-52ba74cef488e616e07b2ae8f5e93df8a9e31081.tar.gz gsoc2013-evolution-52ba74cef488e616e07b2ae8f5e93df8a9e31081.tar.zst gsoc2013-evolution-52ba74cef488e616e07b2ae8f5e93df8a9e31081.zip |
** Fixes part of bug #526152, plus some tangential code cleanup.
2008-04-05 Matthew Barnes <mbarnes@redhat.com>
** Fixes part of bug #526152, plus some tangential code cleanup.
* mail/Makefile.am:
Remove all the IDL crud for GnomeSpell.
* mail/em-composer-prefs.c:
* mail/evolution-mail.schemas.in:
* mail/mail-config.c:
Define our own GConf keys for active spell checking languages
and the underline color for misspelled words, instead of relying
on GnomeSpell's GConf keys. The new keys are:
/apps/evolution/mail/composer/spell_color (string)
/apps/evolution/mail/composer/spell_languages (list of strings)
* mail/em-composer-prefs.c:
* mail/em-composer-prefs.h:
Cleanup the logic a bit to improve readability.
* mail/mail-config.c:
Cleanup the GConf notification logic:
- We don't need the notification IDs for GConf keys we're watching.
- Minimize the repetition of GConf keys to reduce the risk of typos.
- Reduce the number of notification callback functions.
* mail/Spell.idl:
Remove this file; we don't use GnomeSpell anymore.
* composer/e-msg-composer.c:
* composer/e-composer-private.h:
Initialize a new composer's spell checking language menu via
our new "spell_languages" GConf key.
* tools/killev.c (main):
No need to continue killing the GnomeSpell Bonobo server.
svn path=/trunk/; revision=35322
Diffstat (limited to 'mail')
-rw-r--r-- | mail/ChangeLog | 29 | ||||
-rw-r--r-- | mail/Makefile.am | 22 | ||||
-rw-r--r-- | mail/Spell.idl | 71 | ||||
-rw-r--r-- | mail/em-composer-prefs.c | 970 | ||||
-rw-r--r-- | mail/em-composer-prefs.h | 103 | ||||
-rw-r--r-- | mail/evolution-mail.schemas.in | 48 | ||||
-rw-r--r-- | mail/mail-config.c | 346 |
7 files changed, 785 insertions, 804 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index ae1072687f..adf866479b 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,32 @@ +2008-04-05 Matthew Barnes <mbarnes@redhat.com> + + ** Fixes part of bug #526152, plus some tangential code cleanup. + + * Makefile.am: + Remove all the IDL crud for GnomeSpell. + + * em-composer-prefs.c: + * evolution-mail.schemas.in: + * mail-config.c: + Define our own GConf keys for active spell checking languages + and the underline color for misspelled words, instead of relying + on GnomeSpell's GConf keys. The new keys are: + /apps/evolution/mail/composer/spell_color (string) + /apps/evolution/mail/composer/spell_languages (list of strings) + + * em-composer-prefs.c: + * em-composer-prefs.h: + Cleanup the logic a bit to improve readability. + + * mail-config.c: + Cleanup the GConf notification logic: + - We don't need the notification IDs for GConf keys we're watching. + - Minimize the repetition of GConf keys to reduce the risk of typos. + - Reduce the number of notification callback functions. + + * Spell.idl: + Remove this file; we don't use GnomeSpell anymore. + 2008-04-04 Jeffrey Stedfast <fejj@novell.com> * em-format-quote.c (emfq_format_header): Same as below. diff --git a/mail/Makefile.am b/mail/Makefile.am index ba0ba784db..3cbd23c825 100644 --- a/mail/Makefile.am +++ b/mail/Makefile.am @@ -33,24 +33,6 @@ INCLUDES = \ component_LTLIBRARIES = libevolution-mail.la -# Code generation for Spell.idl - -SPELL_IDL = Spell.idl - -SPELL_IDL_GENERATED_H = \ - Spell.h -SPELL_IDL_GENERATED_C = \ - Spell-common.c \ - Spell-skels.c \ - Spell-stubs.c -SPELL_IDL_GENERATED = $(SPELL_IDL_GENERATED_C) $(SPELL_IDL_GENERATED_H) - -$(SPELL_IDL_GENERATED_H): $(SPELL_IDL) - $(ORBIT_IDL) -I $(srcdir) -I $(datadir)/idl $(IDL_INCLUDES) $(srcdir)/Spell.idl -$(SPELL_IDL_GENERATED_C): $(SPELL_IDL_GENERATED_H) - -Spell-impl.o: Spell.h - # Mail.idl MAIL_IDL = Evolution-Mail.idl MAIL_IDL_GENERATED_H = \ @@ -110,7 +92,6 @@ mailinclude_HEADERS = \ # libevolution-mail libevolution_mail_la_SOURCES = \ - $(SPELL_IDL_GENERATED) \ $(MAIL_IDL_GENERATED) \ $(MARSHAL_GENERATED) \ $(mailinclude_HEADERS) \ @@ -271,7 +252,6 @@ EXTRA_DIST = \ ChangeLog.pre-1-4 \ README.async \ em-marshal.list \ - $(SPELL_IDL) \ $(MAIL_IDL) \ mail.error.xml \ $(glade_DATA) \ @@ -328,7 +308,7 @@ endif dist-hook: cd $(distdir); rm -f $(BUILT_SOURCES) -BUILT_SOURCES = $(SPELL_IDL_GENERATED) $(MAIL_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) $(error_DATA) +BUILT_SOURCES = $(MAIL_IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) $(error_DATA) CLEANFILES = $(BUILT_SOURCES) diff --git a/mail/Spell.idl b/mail/Spell.idl deleted file mode 100644 index 806ffd11b2..0000000000 --- a/mail/Spell.idl +++ /dev/null @@ -1,71 +0,0 @@ -/* This file is part of gnome-spell bonobo component - - Copyright (C) 1999, 2000 Helix Code, Inc. - Authors: Radek Doulik <rodo@helixcode.com> - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include <Bonobo.idl> - -module GNOME { - module Spell { - - typedef sequence<string> StringSeq; - struct Language { - string name; - string abbreviation; - }; - typedef sequence<Language> LanguageSeq; - - interface Dictionary : Bonobo::Unknown { - - exception Error { - string error; - }; - - LanguageSeq getLanguages (); - - /** - * sets language(s), language string could contain more languages separated by space - */ - void setLanguage (in string language); - - /** - * checks word - * - * returns true if word is valid - */ - boolean checkWord (in string word) raises (Error); - - /** - * returns suggestions for word - */ - StringSeq getSuggestions (in string word) raises (Error); - - /** - * add to session/personal dictionary - */ - void addWordToSession (in string word) raises (Error); - void addWordToPersonal (in string word, in string language) raises (Error); - - /** - * informs dictionary, that word 'word' will be replaced/corrected by word 'replacement' - */ - void setCorrection (in string word, in string replacement, in string language); - }; - }; -}; diff --git a/mail/em-composer-prefs.c b/mail/em-composer-prefs.c index 8545e26fa6..52c7d205da 100644 --- a/mail/em-composer-prefs.c +++ b/mail/em-composer-prefs.c @@ -35,176 +35,163 @@ #include "em-composer-prefs.h" #include "composer/e-msg-composer.h" +#include "composer/gconf-bridge.h" #include <bonobo/bonobo-generic-factory.h> #include <libedataserver/e-iconv.h> #include <misc/e-gui-utils.h> +#include <glib/gstdio.h> #include <gdk/gdkkeysyms.h> -#include <gtk/gtkentry.h> -#include <gtk/gtktreemodel.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtkbutton.h> -#include <gtk/gtktogglebutton.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtkcellrenderertoggle.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkcolorbutton.h> -#include <gtk/gtkfilechooserbutton.h> - #include <gtkhtml/gtkhtml.h> - -#include <glib/gstdio.h> +#include <editor/gtkhtml-spell-language.h> #include "misc/e-charset-picker.h" #include "e-util/e-error.h" #include "e-util/e-util-private.h" -#include "e-util/e-icon-factory.h" #include "mail-config.h" #include "mail-signature-editor.h" #include "em-config.h" -#define d(x) +static gpointer parent_class; + +static void +composer_prefs_dispose (GObject *object) +{ + EMComposerPrefs *prefs = (EMComposerPrefs *) object; + ESignatureList *signature_list; + + signature_list = mail_config_get_signatures (); -static void em_composer_prefs_class_init (EMComposerPrefsClass *class); -static void em_composer_prefs_init (EMComposerPrefs *dialog); -static void em_composer_prefs_destroy (GtkObject *obj); -static void em_composer_prefs_finalise (GObject *obj); + if (prefs->sig_added_id != 0) { + g_signal_handler_disconnect ( + signature_list, prefs->sig_added_id); + prefs->sig_added_id = 0; + } + if (prefs->sig_removed_id != 0) { + g_signal_handler_disconnect ( + signature_list, prefs->sig_removed_id); + prefs->sig_removed_id = 0; + } -static GtkVBoxClass *parent_class = NULL; + if (prefs->sig_changed_id != 0) { + g_signal_handler_disconnect ( + signature_list, prefs->sig_changed_id); + prefs->sig_changed_id = 0; + } + /* Chain up to parent's dispose() method. */ + G_OBJECT_CLASS (parent_class)->dispose (object); +} -GType -em_composer_prefs_get_type (void) +static void +composer_prefs_finalize (GObject *object) { - static GType type = 0; + EMComposerPrefs *prefs = (EMComposerPrefs *) object; - if (!type) { - static const GTypeInfo info = { - sizeof (EMComposerPrefsClass), - NULL, NULL, - (GClassInitFunc) em_composer_prefs_class_init, - NULL, NULL, - sizeof (EMComposerPrefs), - 0, - (GInstanceInitFunc) em_composer_prefs_init, - }; + g_object_unref (prefs->gui); - type = g_type_register_static (gtk_vbox_get_type (), "EMComposerPrefs", &info, 0); - } + g_hash_table_destroy (prefs->sig_hash); - return type; + /* Chain up to parent's finalize() method. */ + G_OBJECT_CLASS (parent_class)->finalize (object); } static void -em_composer_prefs_class_init (EMComposerPrefsClass *klass) +composer_prefs_class_init (EMComposerPrefsClass *class) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); + GObjectClass *object_class; - parent_class = g_type_class_ref (gtk_vbox_get_type ()); + parent_class = g_type_class_peek_parent (class); - object_class->destroy = em_composer_prefs_destroy; - gobject_class->finalize = em_composer_prefs_finalise; + object_class = G_OBJECT_CLASS (class); + object_class->dispose = composer_prefs_dispose; + object_class->finalize = composer_prefs_finalize; } static void -em_composer_prefs_init (EMComposerPrefs *prefs) +composer_prefs_init (EMComposerPrefs *prefs) { - prefs->enabled_pixbuf = e_icon_factory_get_icon ("stock_mark", E_ICON_SIZE_MENU); prefs->sig_hash = g_hash_table_new_full ( g_direct_hash, g_direct_equal, (GDestroyNotify) NULL, (GDestroyNotify) gtk_tree_row_reference_free); } -static void -em_composer_prefs_finalise (GObject *obj) -{ - EMComposerPrefs *prefs = (EMComposerPrefs *) obj; - - g_object_unref (prefs->gui); - g_object_unref (prefs->enabled_pixbuf); - - g_hash_table_destroy (prefs->sig_hash); - - G_OBJECT_CLASS (parent_class)->finalize (obj); -} - -static void -em_composer_prefs_destroy (GtkObject *obj) +GType +em_composer_prefs_get_type (void) { - EMComposerPrefs *prefs = (EMComposerPrefs *) obj; - ESignatureList *signatures; - - signatures = mail_config_get_signatures (); - - if (prefs->sig_added_id != 0) { - g_signal_handler_disconnect (signatures, prefs->sig_added_id); - prefs->sig_added_id = 0; - } + static GType type = 0; - if (prefs->sig_removed_id != 0) { - g_signal_handler_disconnect (signatures, prefs->sig_removed_id); - prefs->sig_removed_id = 0; - } + if (G_UNLIKELY (type == 0)) { + static const GTypeInfo type_info = { + sizeof (EMComposerPrefsClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) composer_prefs_class_init, + (GClassFinalizeFunc) NULL, + NULL, /* class_data */ + sizeof (EMComposerPrefs), + 0, /* n_allocs */ + (GInstanceInitFunc) composer_prefs_init, + NULL /* value_table */ + }; - if (prefs->sig_changed_id != 0) { - g_signal_handler_disconnect (signatures, prefs->sig_changed_id); - prefs->sig_changed_id = 0; + type = g_type_register_static ( + GTK_TYPE_VBOX, "EMComposerPrefs", &type_info, 0); } - GTK_OBJECT_CLASS (parent_class)->destroy (obj); + return type; } - static void -sig_load_preview (EMComposerPrefs *prefs, ESignature *sig) +sig_load_preview (EMComposerPrefs *prefs, + ESignature *signature) { - char *str; + GtkHTML *html; + gchar *str; - if (!sig) { - gtk_html_load_from_string (GTK_HTML (prefs->sig_preview), " ", 1); + html = prefs->sig_preview; + + if (signature == NULL) { + gtk_html_load_from_string (html, " ", 1); return; } - if (sig->script) - str = mail_config_signature_run_script (sig->filename); + if (signature->script) + str = mail_config_signature_run_script (signature->filename); else - str = e_msg_composer_get_sig_file_content (sig->filename, sig->html); + str = e_msg_composer_get_sig_file_content ( + signature->filename, signature->html); if (!str) str = g_strdup (""); - /* printf ("HTML: %s\n", str); */ - if (sig->html) { - gtk_html_load_from_string (GTK_HTML (prefs->sig_preview), str, strlen (str)); + if (signature->html) { + gtk_html_load_from_string (html, str, strlen (str)); } else { GtkHTMLStream *stream; int len; len = strlen (str); - stream = gtk_html_begin_content (GTK_HTML (prefs->sig_preview), "text/html; charset=utf-8"); - gtk_html_write (GTK_HTML (prefs->sig_preview), stream, "<PRE>", 5); + stream = gtk_html_begin_content (html, "text/html; charset=utf-8"); + gtk_html_write (html, stream, "<PRE>", 5); if (len) - gtk_html_write (GTK_HTML (prefs->sig_preview), stream, str, len); - gtk_html_write (GTK_HTML (prefs->sig_preview), stream, "</PRE>", 6); - gtk_html_end (GTK_HTML (prefs->sig_preview), stream, GTK_HTML_STREAM_OK); + gtk_html_write (html, stream, str, len); + gtk_html_write (html, stream, "</PRE>", 6); + gtk_html_end (html, stream, GTK_HTML_STREAM_OK); } g_free (str); } static void -signature_added (ESignatureList *signatures, ESignature *sig, EMComposerPrefs *prefs) +signature_added (ESignatureList *signature_list, + ESignature *signature, + EMComposerPrefs *prefs) { GtkTreeRowReference *row; GtkTreeModel *model; @@ -212,34 +199,38 @@ signature_added (ESignatureList *signatures, ESignature *sig, EMComposerPrefs *p GtkTreeIter iter; /* autogen signature is special */ - if (sig->autogen) + if (signature->autogen) return; model = gtk_tree_view_get_model (prefs->sig_list); - gtk_list_store_append ((GtkListStore *) model, &iter); - gtk_list_store_set ((GtkListStore *) model, &iter, 0, sig->name, 1, sig, -1); + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, + 0, signature->name, 1, signature, -1); path = gtk_tree_model_get_path (model, &iter); row = gtk_tree_row_reference_new (model, path); gtk_tree_path_free (path); - g_hash_table_insert (prefs->sig_hash, sig, row); + g_hash_table_insert (prefs->sig_hash, signature, row); } static void -signature_removed (ESignatureList *signatures, ESignature *sig, EMComposerPrefs *prefs) +signature_removed (ESignatureList *signature_list, + ESignature *signature, + EMComposerPrefs *prefs) { GtkTreeRowReference *row; GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; - if (!(row = g_hash_table_lookup (prefs->sig_hash, sig))) + if (!(row = g_hash_table_lookup (prefs->sig_hash, signature))) return; model = gtk_tree_view_get_model (prefs->sig_list); path = gtk_tree_row_reference_get_path (row); - g_hash_table_remove (prefs->sig_hash, sig); + g_hash_table_remove (prefs->sig_hash, signature); if (!gtk_tree_model_get_iter (model, &iter, path)) { gtk_tree_path_free (path); @@ -250,7 +241,9 @@ signature_removed (ESignatureList *signatures, ESignature *sig, EMComposerPrefs } static void -signature_changed (ESignatureList *signatures, ESignature *sig, EMComposerPrefs *prefs) +signature_changed (ESignatureList *signature_list, + ESignature *signature, + EMComposerPrefs *prefs) { GtkTreeSelection *selection; GtkTreeRowReference *row; @@ -259,7 +252,7 @@ signature_changed (ESignatureList *signatures, ESignature *sig, EMComposerPrefs GtkTreeIter iter; ESignature *cur; - if (!(row = g_hash_table_lookup (prefs->sig_hash, sig))) + if (!(row = g_hash_table_lookup (prefs->sig_hash, signature))) return; model = gtk_tree_view_get_model (prefs->sig_list); @@ -272,13 +265,13 @@ signature_changed (ESignatureList *signatures, ESignature *sig, EMComposerPrefs gtk_tree_path_free (path); - gtk_list_store_set ((GtkListStore *) model, &iter, 0, sig->name, -1); + gtk_list_store_set ((GtkListStore *) model, &iter, 0, signature->name, -1); selection = gtk_tree_view_get_selection (prefs->sig_list); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, 1, &cur, -1); - if (cur == sig) - sig_load_preview (prefs, sig); + if (cur == signature) + sig_load_preview (prefs, signature); } } @@ -289,26 +282,26 @@ sig_edit_cb (GtkWidget *widget, EMComposerPrefs *prefs) GtkTreeModel *model; GtkWidget *parent; GtkTreeIter iter; - ESignature *sig; + ESignature *signature; selection = gtk_tree_view_get_selection (prefs->sig_list); if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return; - gtk_tree_model_get (model, &iter, 1, &sig, -1); + gtk_tree_model_get (model, &iter, 1, &signature, -1); - if (!sig->script) { + if (!signature->script) { GtkWidget *editor; /* normal signature */ - if (!sig->filename || *sig->filename == '\0') { - g_free (sig->filename); - sig->filename = g_strdup (_("Unnamed")); + if (!signature->filename || *signature->filename == '\0') { + g_free (signature->filename); + signature->filename = g_strdup (_("Unnamed")); } editor = e_signature_editor_new (); e_signature_editor_set_signature ( - E_SIGNATURE_EDITOR (editor), sig); + E_SIGNATURE_EDITOR (editor), signature); parent = gtk_widget_get_toplevel ((GtkWidget *) prefs); if (GTK_WIDGET_TOPLEVEL (parent)) @@ -321,23 +314,25 @@ sig_edit_cb (GtkWidget *widget, EMComposerPrefs *prefs) GtkWidget *entry; entry = glade_xml_get_widget (prefs->sig_script_gui, "filechooserbutton_add_script"); - gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (entry), sig->filename); + gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (entry), signature->filename); entry = glade_xml_get_widget (prefs->sig_script_gui, "entry_add_script_name"); - gtk_entry_set_text (GTK_ENTRY (entry), sig->name); + gtk_entry_set_text (GTK_ENTRY (entry), signature->name); - g_object_set_data ((GObject *) entry, "sig", sig); + g_object_set_data ((GObject *) entry, "sig", signature); gtk_window_present ((GtkWindow *) prefs->sig_script_dialog); } } void -em_composer_prefs_new_signature (GtkWindow *parent, gboolean html) +em_composer_prefs_new_signature (GtkWindow *parent, + gboolean html_mode) { GtkWidget *editor; editor = e_signature_editor_new (); + gtkhtml_editor_set_html_mode (GTKHTML_EDITOR (editor), html_mode); gtk_window_set_transient_for (GTK_WINDOW (editor), parent); gtk_widget_show (editor); } @@ -348,13 +343,13 @@ sig_delete_cb (GtkWidget *widget, EMComposerPrefs *prefs) GtkTreeSelection *selection; GtkTreeModel *model; GtkTreeIter iter; - ESignature *sig; + ESignature *signature; selection = gtk_tree_view_get_selection (prefs->sig_list); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { - gtk_tree_model_get (model, &iter, 1, &sig, -1); - mail_config_remove_signature (sig); + gtk_tree_model_get (model, &iter, 1, &signature, -1); + mail_config_remove_signature (signature); } gtk_widget_grab_focus ((GtkWidget *)prefs->sig_list); } @@ -362,26 +357,26 @@ sig_delete_cb (GtkWidget *widget, EMComposerPrefs *prefs) static void sig_add_cb (GtkWidget *widget, EMComposerPrefs *prefs) { - GConfClient *gconf; gboolean send_html; GtkWidget *parent; - gconf = mail_config_get_gconf_client (); - send_html = gconf_client_get_bool (gconf, "/apps/evolution/mail/composer/send_html", NULL); + send_html = gconf_client_get_bool ( + mail_config_get_gconf_client (), + "/apps/evolution/mail/composer/send_html", NULL); - parent = gtk_widget_get_toplevel ((GtkWidget *) prefs); + parent = gtk_widget_get_toplevel (GTK_WIDGET (prefs)); parent = GTK_WIDGET_TOPLEVEL (parent) ? parent : NULL; - em_composer_prefs_new_signature ((GtkWindow *) parent, send_html); - gtk_widget_grab_focus ((GtkWidget *)prefs->sig_list); + em_composer_prefs_new_signature (GTK_WINDOW (parent), send_html); + gtk_widget_grab_focus (GTK_WIDGET (prefs->sig_list)); } static void sig_add_script_response (GtkWidget *widget, int button, EMComposerPrefs *prefs) { - char *script, **argv = NULL; + gchar *script, **argv = NULL; GtkWidget *entry; - const char *name; + const gchar *name; int argc; if (button == GTK_RESPONSE_ACCEPT) { @@ -394,21 +389,21 @@ sig_add_script_response (GtkWidget *widget, int button, EMComposerPrefs *prefs) struct stat st; if (g_stat (argv[0], &st) == 0 && S_ISREG (st.st_mode) && g_access (argv[0], X_OK) == 0) { - ESignature *sig; + ESignature *signature; - if ((sig = g_object_get_data ((GObject *) entry, "sig"))) { + if ((signature = g_object_get_data ((GObject *) entry, "sig"))) { /* we're just editing an existing signature script */ - g_free (sig->name); - sig->name = g_strdup (name); - g_free(sig->filename); - sig->filename = g_strdup(script); - e_signature_list_change (mail_config_get_signatures (), sig); + g_free (signature->name); + signature->name = g_strdup (name); + g_free(signature->filename); + signature->filename = g_strdup(script); + e_signature_list_change (mail_config_get_signatures (), signature); } else { - sig = mail_config_signature_new (script, TRUE, TRUE); - sig->name = g_strdup (name); + signature = mail_config_signature_new (script, TRUE, TRUE); + signature->name = g_strdup (name); - e_signature_list_add (mail_config_get_signatures (), sig); - g_object_unref (sig); + e_signature_list_add (mail_config_get_signatures (), signature); + g_object_unref (signature); } mail_config_save_signatures(); @@ -444,66 +439,78 @@ sig_add_script_cb (GtkWidget *widget, EMComposerPrefs *prefs) } static void -sig_selection_changed (GtkTreeSelection *selection, EMComposerPrefs *prefs) +sig_selection_changed (GtkTreeSelection *selection, + EMComposerPrefs *prefs) { + ESignature *signature; GtkTreeModel *model; GtkTreeIter iter; - ESignature *sig; - int state; + gboolean valid; - state = gtk_tree_selection_get_selected (selection, &model, &iter); - if (state) { - gtk_tree_model_get (model, &iter, 1, &sig, -1); - sig_load_preview (prefs, sig); + valid = gtk_tree_selection_get_selected (selection, &model, &iter); + + if (valid) { + gtk_tree_model_get (model, &iter, 1, &signature, -1); + sig_load_preview (prefs, signature); } else sig_load_preview (prefs, NULL); - gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_delete, state); - gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_edit, state); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->sig_delete), valid); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->sig_edit), valid); } static void sig_fill_list (EMComposerPrefs *prefs) { - ESignatureList *signatures; - GtkListStore *model; - EIterator *it; + ESignatureList *signature_list; + GtkTreeModel *model; + EIterator *iterator; - model = (GtkListStore *) gtk_tree_view_get_model (prefs->sig_list); - gtk_list_store_clear (model); + model = gtk_tree_view_get_model (prefs->sig_list); + gtk_list_store_clear (GTK_LIST_STORE (model)); - signatures = mail_config_get_signatures (); - it = e_list_get_iterator ((EList *) signatures); + signature_list = mail_config_get_signatures (); + iterator = e_list_get_iterator ((EList *) signature_list); - while (e_iterator_is_valid (it)) { - ESignature *sig; + while (e_iterator_is_valid (iterator)) { + ESignature *signature; - sig = (ESignature *) e_iterator_get (it); - signature_added (signatures, sig, prefs); + signature = (ESignature *) e_iterator_get (iterator); + signature_added (signature_list, signature, prefs); - e_iterator_next (it); + e_iterator_next (iterator); } - g_object_unref (it); + g_object_unref (iterator); + + gtk_widget_set_sensitive (GTK_WIDGET (prefs->sig_edit), FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (prefs->sig_delete), FALSE); + + prefs->sig_added_id = g_signal_connect ( + signature_list, "signature-added", + G_CALLBACK (signature_added), prefs); - gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_edit, FALSE); - gtk_widget_set_sensitive ((GtkWidget *) prefs->sig_delete, FALSE); + prefs->sig_removed_id = g_signal_connect ( + signature_list, "signature-removed", + G_CALLBACK (signature_removed), prefs); - prefs->sig_added_id = g_signal_connect (signatures, "signature-added", G_CALLBACK (signature_added), prefs); - prefs->sig_removed_id = g_signal_connect (signatures, "signature-removed", G_CALLBACK (signature_removed), prefs); - prefs->sig_changed_id = g_signal_connect (signatures, "signature-changed", G_CALLBACK (signature_changed), prefs); + prefs->sig_changed_id = g_signal_connect ( + signature_list, "signature-changed", + G_CALLBACK (signature_changed), prefs); } static void -url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle) +url_requested (GtkHTML *html, + const gchar *url, + GtkHTMLStream *handle) { GtkHTMLStreamStatus status; - char buf[128]; - ssize_t size; - int fd; - char *filename; + gchar buf[128]; + gssize size; + gint fd; + gchar *filename; - if (!strncmp (url, "file:", 5)) + if (strncmp (url, "file:", 5) == 0) filename = g_filename_from_uri (url, NULL, NULL); else filename = g_strdup (url); @@ -527,318 +534,264 @@ url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle) close (fd); } - -/* - * - * Spell checking cut'n'pasted from gnome-spell/capplet/main.c - * - */ - -#include "Spell.h" - -#define GNOME_SPELL_GCONF_DIR "/GNOME/Spell" -#define SPELL_API_VERSION "0.3" - static void -spell_set_ui (EMComposerPrefs *prefs) +spell_color_set (GtkColorButton *color_button, + EMComposerPrefs *prefs) { - GHashTable *present; - GtkListStore *model; - GtkTreeIter iter; - GError *err = NULL; - char **strv = NULL; + GConfClient *client; + const gchar *key; GdkColor color; - gboolean go; - char *lang; - int i; + gchar *string; - prefs->spell_active = FALSE; - - /* setup the language list */ - if (!(lang = gconf_client_get_string (prefs->gconf, GNOME_SPELL_GCONF_DIR "/language", &err)) || err) { - g_free (lang); - g_clear_error (&err); - lang = g_strdup (e_iconv_locale_language ()); - } - - present = g_hash_table_new (g_str_hash, g_str_equal); - if (lang && (strv = g_strsplit (lang, " ", 0))) { - for (i = 0; strv[i]; i++) - g_hash_table_insert (present, strv[i], strv[i]); - } + gtk_color_button_get_color (color_button, &color); + string = gdk_color_to_string (&color); - g_free (lang); + client = mail_config_get_gconf_client (); + key = "/apps/evolution/mail/composer/spell_color"; + gconf_client_set_string (client, key, string, NULL); - model = (GtkListStore *) gtk_tree_view_get_model (prefs->language); - for (go = gtk_tree_model_get_iter_first ((GtkTreeModel *) model, &iter); go; - go = gtk_tree_model_iter_next ((GtkTreeModel *) model, &iter)) { - char *abbr; - - gtk_tree_model_get ((GtkTreeModel *) model, &iter, 2, &abbr, -1); - gtk_list_store_set (model, &iter, 0, g_hash_table_lookup (present, abbr) != NULL, -1); - } - - g_hash_table_destroy (present); - if (strv != NULL) - g_strfreev (strv); - - color.red = gconf_client_get_int (prefs->gconf, - GNOME_SPELL_GCONF_DIR "/spell_error_color_red", NULL); - color.green = gconf_client_get_int (prefs->gconf, - GNOME_SPELL_GCONF_DIR "/spell_error_color_green", NULL); - color.blue = gconf_client_get_int (prefs->gconf, - GNOME_SPELL_GCONF_DIR "/spell_error_color_blue", NULL); - gtk_color_button_set_color (GTK_COLOR_BUTTON (prefs->color), &color); - - prefs->spell_active = TRUE; + g_free (string); } static void -spell_color_set (GtkColorButton *color_button, EMComposerPrefs *prefs) -{ - GdkColor color; - - gtk_color_button_get_color (GTK_COLOR_BUTTON (color_button), &color); - - gconf_client_set_int (prefs->gconf, - GNOME_SPELL_GCONF_DIR "/spell_error_color_red", - color.red, NULL); - gconf_client_set_int (prefs->gconf, - GNOME_SPELL_GCONF_DIR "/spell_error_color_green", - color.green, NULL); - gconf_client_set_int (prefs->gconf, - GNOME_SPELL_GCONF_DIR "/spell_error_color_blue", - color.blue, NULL); -} - -static char * -spell_get_language_str (EMComposerPrefs *prefs) +spell_language_toggled_cb (GtkCellRendererToggle *renderer, + const gchar *path_string, + EMComposerPrefs *prefs) { - GtkListStore *model; + GSList *list = NULL; + GConfClient *client; + GtkTreeModel *model; + GtkTreePath *path; GtkTreeIter iter; - GString *str; - char *rv; + const gchar *key; + gboolean active; + gboolean valid; + + model = prefs->language_model; - model = (GtkListStore *) gtk_tree_view_get_model (prefs->language); - if (!gtk_tree_model_get_iter_first ((GtkTreeModel *) model, &iter)) - return NULL; + /* Convert the path string to a tree iterator. */ + path = gtk_tree_path_new_from_string (path_string); + valid = gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_path_free (path); + g_return_if_fail (valid); - str = g_string_new (""); + /* Toggle the active state. */ + gtk_tree_model_get (model, &iter, 0, &active, -1); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !active, -1); - do { - gboolean state; - char *abbr; + /* Build a list of active languages. */ + valid = gtk_tree_model_get_iter_first (model, &iter); + while (valid) { + const GtkhtmlSpellLanguage *language; + const gchar *code; + gboolean active; - gtk_tree_model_get ((GtkTreeModel *) model, &iter, 0, &state, 2, &abbr, -1); + gtk_tree_model_get ( + model, &iter, 0, &active, 2, &language, -1); + code = gtkhtml_spell_language_get_code (language); - if (state) { - if (str->len) - g_string_append_c (str, ' '); - g_string_append (str, abbr); - } + if (active) + list = g_slist_prepend (list, (gpointer) code); - if (!gtk_tree_model_iter_next ((GtkTreeModel *) model, &iter)) - break; - } while (1); + valid = gtk_tree_model_iter_next (model, &iter); + } + list = g_slist_reverse (list); - rv = str->str; - g_string_free (str, FALSE); + /* Update the GConf value. */ + client = mail_config_get_gconf_client (); + key = "/apps/evolution/mail/composer/spell_languages"; + gconf_client_set_list (client, key, GCONF_VALUE_STRING, list, NULL); - return rv; + g_slist_free (list); } static void -spell_language_toggled (GtkCellRendererToggle *renderer, const char *path_string, EMComposerPrefs *prefs) +spell_setup (EMComposerPrefs *prefs) { - GtkTreePath *path = gtk_tree_path_new_from_string (path_string); - GtkTreeModel *model; - GtkTreeIter iter; - gboolean enabled; - char *str; + const GList *available_languages; + GSList *active_languages, *iter; + GConfClient *client; + GtkListStore *store; + GdkColor color; + const gchar *key; + gchar *string; - model = gtk_tree_view_get_model (prefs->language); - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, 0, &enabled, -1); - gtk_list_store_set ((GtkListStore *) model, &iter, 0, !enabled, -1); + client = mail_config_get_gconf_client (); + store = GTK_LIST_STORE (prefs->language_model); + available_languages = gtkhtml_spell_language_get_available (); - str = spell_get_language_str (prefs); - gconf_client_set_string (prefs->gconf, GNOME_SPELL_GCONF_DIR "/language", str ? str : "", NULL); - g_free (str); + /* Retrieve a list of language codes from GConf. */ + key = "/apps/evolution/mail/composer/spell_languages"; + active_languages = gconf_client_get_list ( + client, key, GCONF_VALUE_STRING, NULL); - gtk_tree_path_free (path); -} + /* Convert the list to GtkhtmlSpellLanguages. */ + for (iter = active_languages; iter != NULL; iter = iter->next) { + gchar *code = iter->data; -static void -spell_setup (EMComposerPrefs *prefs) -{ - GtkListStore *model; - GtkTreeIter iter; - GtkWidget *widget; - int i; + iter->data = (gpointer) gtkhtml_spell_language_lookup (code); + g_free (code); + } - model = (GtkListStore *) gtk_tree_view_get_model (prefs->language); + /* Make sure we have _something_ active. */ + if (active_languages == NULL) { + const GtkhtmlSpellLanguage *default_language; - if (prefs->language_seq) { - for (i = 0; i < prefs->language_seq->_length; i++) { - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, - 1, _(prefs->language_seq->_buffer[i].name), - 2, prefs->language_seq->_buffer[i].abbreviation, - -1); - } + default_language = gtkhtml_spell_language_lookup (NULL); + active_languages = g_slist_prepend ( + active_languages, (gpointer) default_language); } - spell_set_ui (prefs); + /* Populate the GtkListStore. */ + while (available_languages != NULL) { + const GtkhtmlSpellLanguage *language; + GtkTreeIter tree_iter; + const gchar *name; + gboolean active; - widget = glade_xml_get_widget (prefs->gui, "colorButtonSpellCheckColor"); - g_signal_connect (widget, "color_set", G_CALLBACK (spell_color_set), prefs); -} + language = available_languages->data; + name = gtkhtml_spell_language_get_name (language); + active = (g_slist_find (active_languages, language) != NULL); -static gboolean -spell_setup_check_options (EMComposerPrefs *prefs) -{ - GNOME_Spell_Dictionary dict; - CORBA_Environment ev; - char *dictionary_id; + gtk_list_store_append (store, &tree_iter); - dictionary_id = "OAFIID:GNOME_Spell_Dictionary:" SPELL_API_VERSION; - dict = bonobo_activation_activate_from_id (dictionary_id, 0, NULL, NULL); - if (dict == CORBA_OBJECT_NIL) { - g_warning ("Cannot activate %s", dictionary_id); + gtk_list_store_set ( + store, &tree_iter, + 0, active, 1, name, 2, language, -1); - return FALSE; + available_languages = available_languages->next; } - CORBA_exception_init (&ev); - prefs->language_seq = GNOME_Spell_Dictionary_getLanguages (dict, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - prefs->language_seq = NULL; - CORBA_exception_free (&ev); + g_slist_free (active_languages); - if (prefs->language_seq == NULL) - return FALSE; - - gconf_client_add_dir (prefs->gconf, GNOME_SPELL_GCONF_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL); - - spell_setup (prefs); + key = "/apps/evolution/mail/composer/spell_color"; + string = gconf_client_get_string (client, key, NULL); + if (string == NULL || !gdk_color_parse (string, &color)) + gdk_color_parse ("Red", &color); + gtk_color_button_set_color (GTK_COLOR_BUTTON (prefs->color), &color); - return TRUE; + g_signal_connect ( + prefs->color, "color_set", + G_CALLBACK (spell_color_set), prefs); } -/* - * End of Spell checking - */ - -static int -attach_style_reply_new_order (int style_id, gboolean from_enum_to_option_id) +static gint +attach_style_reply_new_order (gint style_id, + gboolean from_enum_to_option_id) { - int values[] = {MAIL_CONFIG_REPLY_ATTACH, 0, MAIL_CONFIG_REPLY_OUTLOOK, 1, MAIL_CONFIG_REPLY_QUOTED, 2, MAIL_CONFIG_REPLY_DO_NOT_QUOTE, 3, -1, -1}; - int i; - - for (i = from_enum_to_option_id ? 0 : 1; values[i] != -1; i += 2) { - if (values[i] == style_id) - return values [from_enum_to_option_id ? i + 1 : i - 1]; + gint values[] = { + MAIL_CONFIG_REPLY_ATTACH, 0, + MAIL_CONFIG_REPLY_OUTLOOK, 1, + MAIL_CONFIG_REPLY_QUOTED, 2, + MAIL_CONFIG_REPLY_DO_NOT_QUOTE, 3, + -1, -1}; + gint ii; + + for (ii = from_enum_to_option_id ? 0 : 1; values[ii] != -1; ii += 2) { + if (values[ii] == style_id) + return values [from_enum_to_option_id ? ii + 1 : ii - 1]; } return style_id; } static void -attach_style_info (GtkWidget *item, gpointer user_data) +attach_style_info (GtkWidget *item, + gpointer user_data) { - int *style = user_data; + gint *style = user_data; - g_object_set_data ((GObject *) item, "style", GINT_TO_POINTER (*style)); + g_object_set_data ( + G_OBJECT (item), "style", GINT_TO_POINTER (*style)); (*style)++; } static void -attach_style_info_reply (GtkWidget *item, gpointer user_data) +attach_style_info_reply (GtkWidget *item, + gpointer user_data) { - int *style = user_data; + gint *style = user_data; - g_object_set_data ((GObject *) item, "style", GINT_TO_POINTER (attach_style_reply_new_order (*style, FALSE))); + g_object_set_data ( + G_OBJECT (item), "style", GINT_TO_POINTER ( + attach_style_reply_new_order (*style, FALSE))); (*style)++; } static void -toggle_button_toggled (GtkToggleButton *toggle, EMComposerPrefs *prefs) +style_activate (GtkWidget *item, + EMComposerPrefs *prefs) { - const char *key; - - key = g_object_get_data ((GObject *) toggle, "key"); - gconf_client_set_bool (prefs->gconf, key, gtk_toggle_button_get_active (toggle), NULL); + GConfClient *client; + const gchar *key; + gint style; + + client = mail_config_get_gconf_client (); + key = g_object_get_data (G_OBJECT (item), "key"); + style = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "style")); + gconf_client_set_int (client, key, style, NULL); } static void -style_activate (GtkWidget *item, EMComposerPrefs *prefs) -{ - const char *key; - int style; - - key = g_object_get_data ((GObject *) item, "key"); - style = GPOINTER_TO_INT (g_object_get_data ((GObject *) item, "style")); - - gconf_client_set_int (prefs->gconf, key, style, NULL); -} - -static void -charset_activate (GtkWidget *item, EMComposerPrefs *prefs) +charset_activate (GtkWidget *item, + EMComposerPrefs *prefs) { + GConfClient *client; GtkWidget *menu; - char *string; + gchar *string; + client = mail_config_get_gconf_client (); menu = gtk_option_menu_get_menu (prefs->charset); - if (!(string = e_charset_picker_get_charset (menu))) + string = e_charset_picker_get_charset (menu); + + if (string == NULL) string = g_strdup (e_iconv_locale_charset ()); - gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/composer/charset", string, NULL); + gconf_client_set_string ( + client, "/apps/evolution/mail/composer/charset", + string, NULL); + g_free (string); } static void -option_menu_connect (EMComposerPrefs *prefs, GtkOptionMenu *omenu, GCallback callback, const char *key) +option_menu_connect (EMComposerPrefs *prefs, + GtkOptionMenu *omenu, + GCallback callback, + const gchar *key) { - GtkWidget *menu, *item; - GList *items; + GConfClient *client; + GtkWidget *menu; + GList *list; + client = mail_config_get_gconf_client (); menu = gtk_option_menu_get_menu (omenu); + list = GTK_MENU_SHELL (menu)->children; - items = GTK_MENU_SHELL (menu)->children; - while (items) { - item = items->data; - g_object_set_data ((GObject *) item, "key", (void *) key); - g_signal_connect (item, "activate", callback, prefs); - items = items->next; - } - - if (!gconf_client_key_is_writable (prefs->gconf, key, NULL)) - gtk_widget_set_sensitive ((GtkWidget *) omenu, FALSE); -} - -static void -toggle_button_init (EMComposerPrefs *prefs, GtkToggleButton *toggle, int not, const char *key) -{ - gboolean bool; - - bool = gconf_client_get_bool (prefs->gconf, key, NULL); - gtk_toggle_button_set_active (toggle, not ? !bool : bool); + while (list != NULL) { + GtkWidget *widget = list->data; - g_object_set_data ((GObject *) toggle, "key", (void *) key); - g_signal_connect (toggle, "toggled", G_CALLBACK (toggle_button_toggled), prefs); + g_object_set_data (G_OBJECT (widget), "key", (gpointer) key); + g_signal_connect (widget, "activate", callback, prefs); + list = list->next; + } - if (!gconf_client_key_is_writable (prefs->gconf, key, NULL)) - gtk_widget_set_sensitive ((GtkWidget *) toggle, FALSE); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (GTK_WIDGET (omenu), FALSE); } static GtkWidget * -emcp_widget_glade(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data) +emcp_widget_glade (EConfig *ec, + EConfigItem *item, + GtkWidget *parent, + GtkWidget *old, + gpointer data) { EMComposerPrefs *prefs = data; - return glade_xml_get_widget(prefs->gui, item->label); + return glade_xml_get_widget (prefs->gui, item->label); } /* plugin meta-data */ @@ -856,38 +809,37 @@ static EMConfigItem emcp_items[] = { }; static void -emcp_free(EConfig *ec, GSList *items, void *data) +emcp_free (EConfig *ec, GSList *items, gpointer data) { /* the prefs data is freed automagically */ - - g_slist_free(items); + g_slist_free (items); } static gboolean -signature_key_press (GtkTreeView *tree_view, GdkEventKey *event, EMComposerPrefs *prefs) +signature_key_press_cb (GtkTreeView *tree_view, + GdkEventKey *event, + EMComposerPrefs *prefs) { - gboolean ret = FALSE; - /* No need to care about anything other than DEL key */ if (event->keyval == GDK_Delete) { - sig_delete_cb ((GtkWidget *)tree_view, prefs); - ret = TRUE; + sig_delete_cb (GTK_WIDGET (tree_view), prefs); + return TRUE; } - return ret; + return FALSE; } static gboolean -sig_tree_event_cb (GtkTreeView *tree_view, GdkEvent *event, EMComposerPrefs *prefs) +sig_tree_event_cb (GtkTreeView *tree_view, + GdkEvent *event, + EMComposerPrefs *prefs) { - gboolean ret = FALSE; - if (event->type == GDK_2BUTTON_PRESS) { - sig_edit_cb ((GtkWidget *)tree_view, prefs); - ret = TRUE; + sig_edit_cb (GTK_WIDGET (tree_view), prefs); + return TRUE; } - return ret; + return FALSE; } static void @@ -896,18 +848,23 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) GtkWidget *toplevel, *widget, *menu, *info_pixmap; GtkDialog *dialog; GladeXML *gui; - GtkListStore *model; + GtkTreeView *view; + GtkListStore *store; GtkTreeSelection *selection; - GtkCellRenderer *cell_renderer; + GtkCellRenderer *renderer; + GConfBridge *bridge; + GConfClient *client; + const gchar *key; int style; - char *buf; + gchar *buf; EMConfig *ec; EMConfigTargetPrefs *target; GSList *l; int i; - char *gladefile; + gchar *gladefile; - prefs->gconf = mail_config_get_gconf_client (); + bridge = gconf_bridge_get (); + client = mail_config_get_gconf_client (); gladefile = g_build_filename (EVOLUTION_GLADEDIR, "mail-config.glade", @@ -927,77 +884,98 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) */ ec = em_config_new(E_CONFIG_BOOK, "org.gnome.evolution.mail.composerPrefs"); l = NULL; - for (i=0;i<sizeof(emcp_items)/sizeof(emcp_items[0]);i++) + for (i = 0; i < G_N_ELEMENTS (emcp_items); i++) l = g_slist_prepend(l, &emcp_items[i]); e_config_add_items((EConfig *)ec, l, NULL, NULL, emcp_free, prefs); /* General tab */ /* Default Behavior */ - prefs->send_html = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkSendHTML")); - toggle_button_init (prefs, prefs->send_html, FALSE, - "/apps/evolution/mail/composer/send_html"); - - prefs->prompt_empty_subject = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptEmptySubject")); - toggle_button_init (prefs, prefs->prompt_empty_subject, FALSE, - "/apps/evolution/mail/prompts/empty_subject"); - - prefs->prompt_bcc_only = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkPromptBccOnly")); - toggle_button_init (prefs, prefs->prompt_bcc_only, FALSE, - "/apps/evolution/mail/prompts/only_bcc"); - - prefs->auto_smileys = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkAutoSmileys")); - toggle_button_init (prefs, prefs->auto_smileys, FALSE, - "/apps/evolution/mail/composer/magic_smileys"); - - prefs->auto_request_receipt = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkRequestReceipt")); - toggle_button_init (prefs, prefs->auto_request_receipt, FALSE, - "/apps/evolution/mail/composer/request_receipt"); - - prefs->top_signature = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkTopSignature")); - toggle_button_init (prefs, prefs->top_signature, FALSE, - "/apps/evolution/mail/composer/top_signature"); - - prefs->spell_check = GTK_TOGGLE_BUTTON (glade_xml_get_widget (gui, "chkEnableSpellChecking")); - toggle_button_init (prefs, prefs->spell_check, FALSE, - "/apps/evolution/mail/composer/inline_spelling"); - - prefs->charset = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuCharset")); - buf = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/composer/charset", NULL); - menu = e_charset_picker_new (buf && *buf ? buf : e_iconv_locale_charset ()); + key = "/apps/evolution/mail/composer/send_html"; + widget = glade_xml_get_widget (gui, "chkSendHTML"); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (widget, FALSE); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + + key = "/apps/evolution/mail/prompts/empty_subject"; + widget = glade_xml_get_widget (gui, "chkPromptEmptySubject"); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (widget, FALSE); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + + key = "/apps/evolution/mail/prompts/only_bcc"; + widget = glade_xml_get_widget (gui, "chkPromptBccOnly"); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (widget, FALSE); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + + key = "/apps/evolution/mail/composer/magic_smileys"; + widget = glade_xml_get_widget (gui, "chkAutoSmileys"); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (widget, FALSE); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + + key = "/apps/evolution/mail/composer/request_receipt"; + widget = glade_xml_get_widget (gui, "chkRequestReceipt"); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (widget, FALSE); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + + key = "/apps/evolution/mail/composer/top_signature"; + widget = glade_xml_get_widget (gui, "chkTopSignature"); + if (!gconf_client_key_is_writable (client, key, NULL)) + gtk_widget_set_sensitive (widget, FALSE); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + + key = "/apps/evolution/mail/composer/inline_spelling"; + widget = glade_xml_get_widget (gui, "chkEnableSpellChecking"); + gconf_bridge_bind_property (bridge, key, G_OBJECT (widget), "active"); + + prefs->charset = GTK_OPTION_MENU ( + glade_xml_get_widget (gui, "omenuCharset")); + buf = gconf_client_get_string ( + client, "/apps/evolution/mail/composer/charset", NULL); + menu = e_charset_picker_new ( + buf && *buf ? buf : e_iconv_locale_charset ()); gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu)); - option_menu_connect (prefs, prefs->charset, G_CALLBACK (charset_activate), - "/apps/evolution/mail/composer/charset"); + option_menu_connect ( + prefs, prefs->charset, + G_CALLBACK (charset_activate), + "/apps/evolution/mail/composer/charset"); g_free (buf); /* Spell Checking: GNOME Spell part */ - prefs->color = GTK_COLOR_BUTTON (glade_xml_get_widget (gui, "colorButtonSpellCheckColor")); - prefs->language = GTK_TREE_VIEW (glade_xml_get_widget (gui, "listSpellCheckLanguage")); - model = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model (prefs->language, (GtkTreeModel *) model); - cell_renderer = gtk_cell_renderer_toggle_new (); - gtk_tree_view_insert_column_with_attributes (prefs->language, -1, _("Enabled"), - cell_renderer, - "active", 0, - NULL); - g_signal_connect (cell_renderer, "toggled", G_CALLBACK (spell_language_toggled), prefs); - - gtk_tree_view_insert_column_with_attributes (prefs->language, -1, _("Language(s)"), - gtk_cell_renderer_text_new (), - "text", 1, - NULL); - selection = gtk_tree_view_get_selection (prefs->language); + widget = glade_xml_get_widget (gui, "colorButtonSpellCheckColor"); + prefs->color = GTK_COLOR_BUTTON (widget); + widget = glade_xml_get_widget (gui, "listSpellCheckLanguage"); + view = GTK_TREE_VIEW (widget); + store = gtk_list_store_new ( + 3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER); + prefs->language_model = GTK_TREE_MODEL (store); + gtk_tree_view_set_model (view, prefs->language_model); + renderer = gtk_cell_renderer_toggle_new (); + g_signal_connect ( + renderer, "toggled", + G_CALLBACK (spell_language_toggled_cb), prefs); + gtk_tree_view_insert_column_with_attributes ( + view, -1, _("Enabled"), + renderer, "active", 0, NULL); + + gtk_tree_view_insert_column_with_attributes ( + view, -1, _("Language(s)"), + gtk_cell_renderer_text_new (), + "text", 1, NULL); + selection = gtk_tree_view_get_selection (view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE); info_pixmap = glade_xml_get_widget (gui, "pixmapSpellInfo"); - gtk_image_set_from_stock (GTK_IMAGE (info_pixmap), GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON); - if (!spell_setup_check_options (prefs)) { - gtk_widget_hide (GTK_WIDGET (prefs->color)); - gtk_widget_hide (GTK_WIDGET (prefs->language)); - } + gtk_image_set_from_stock ( + GTK_IMAGE (info_pixmap), + GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON); + spell_setup (prefs); /* Forwards and Replies */ prefs->forward_style = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuForwardStyle")); - style = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/format/forward_style", NULL); + style = gconf_client_get_int (client, "/apps/evolution/mail/format/forward_style", NULL); gtk_option_menu_set_history (prefs->forward_style, style); style = 0; gtk_container_foreach (GTK_CONTAINER (gtk_option_menu_get_menu (prefs->forward_style)), @@ -1006,7 +984,7 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) "/apps/evolution/mail/format/forward_style"); prefs->reply_style = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuReplyStyle")); - style = gconf_client_get_int (prefs->gconf, "/apps/evolution/mail/format/reply_style", NULL); + style = gconf_client_get_int (client, "/apps/evolution/mail/format/reply_style", NULL); gtk_option_menu_set_history (prefs->reply_style, attach_style_reply_new_order (style, TRUE)); style = 0; gtk_container_foreach (GTK_CONTAINER (gtk_option_menu_get_menu (prefs->reply_style)), @@ -1043,42 +1021,52 @@ em_composer_prefs_construct (EMComposerPrefs *prefs) g_signal_connect (prefs->sig_delete, "clicked", G_CALLBACK (sig_delete_cb), prefs); prefs->sig_list = GTK_TREE_VIEW (glade_xml_get_widget (gui, "listSignatures")); - model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - gtk_tree_view_set_model (prefs->sig_list, (GtkTreeModel *)model); + store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); + gtk_tree_view_set_model (prefs->sig_list, GTK_TREE_MODEL (store)); gtk_tree_view_insert_column_with_attributes (prefs->sig_list, -1, _("Signature(s)"), gtk_cell_renderer_text_new (), "text", 0, NULL); selection = gtk_tree_view_get_selection (prefs->sig_list); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect (selection, "changed", G_CALLBACK (sig_selection_changed), prefs); - g_signal_connect (prefs->sig_list, "event", G_CALLBACK (sig_tree_event_cb), prefs); + g_signal_connect ( + selection, "changed", + G_CALLBACK (sig_selection_changed), prefs); + g_signal_connect ( + prefs->sig_list, "event", + G_CALLBACK (sig_tree_event_cb), prefs); sig_fill_list (prefs); /* preview GtkHTML widget */ widget = glade_xml_get_widget (gui, "scrolled-sig"); prefs->sig_preview = (GtkHTML *) gtk_html_new (); - g_signal_connect (prefs->sig_preview, "url_requested", G_CALLBACK (url_requested), NULL); + g_signal_connect ( + prefs->sig_preview, "url_requested", + G_CALLBACK (url_requested), NULL); gtk_widget_show (GTK_WIDGET (prefs->sig_preview)); - gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (prefs->sig_preview)); + gtk_container_add ( + GTK_CONTAINER (widget), + GTK_WIDGET (prefs->sig_preview)); /* get our toplevel widget */ - target = em_config_target_new_prefs(ec, prefs->gconf); - e_config_set_target((EConfig *)ec, (EConfigTarget *)target); - toplevel = e_config_create_widget((EConfig *)ec); + target = em_config_target_new_prefs (ec, client); + e_config_set_target ((EConfig *)ec, (EConfigTarget *)target); + toplevel = e_config_create_widget ((EConfig *)ec); gtk_container_add (GTK_CONTAINER (prefs), toplevel); - g_signal_connect (prefs->sig_list, "key-press-event", G_CALLBACK(signature_key_press), prefs); + g_signal_connect ( + prefs->sig_list, "key-press-event", + G_CALLBACK (signature_key_press_cb), prefs); } GtkWidget * em_composer_prefs_new (void) { - EMComposerPrefs *new; + EMComposerPrefs *prefs; - new = (EMComposerPrefs *) g_object_new (em_composer_prefs_get_type (), NULL); - em_composer_prefs_construct (new); + prefs = g_object_new (EM_TYPE_COMPOSER_PREFS, NULL); + em_composer_prefs_construct (prefs); - return (GtkWidget *) new; + return GTK_WIDGET (prefs); } diff --git a/mail/em-composer-prefs.h b/mail/em-composer-prefs.h index 47e4a95e10..d9d4b0c3a8 100644 --- a/mail/em-composer-prefs.h +++ b/mail/em-composer-prefs.h @@ -20,83 +20,69 @@ * */ - #ifndef __EM_COMPOSER_PREFS_H__ #define __EM_COMPOSER_PREFS_H__ -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#include <glib.h> -#include <gtk/gtkvbox.h> -#include "Spell.h" - -#define EM_COMPOSER_PREFS_TYPE (em_composer_prefs_get_type ()) -#define EM_COMPOSER_PREFS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EM_COMPOSER_PREFS_TYPE, EMComposerPrefs)) -#define EM_COMPOSER_PREFS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EM_COMPOSER_PREFS_TYPE, EMComposerPrefsClass)) -#define EM_IS_COMPOSER_PREFS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EM_COMPOSER_PREFS_TYPE)) -#define EM_IS_COMPOSER_PREFS_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EM_COMPOSER_PREFS_TYPE)) +#include <gtk/gtk.h> + +/* Standard GObject macros */ +#define EM_TYPE_COMPOSER_PREFS \ + (em_composer_prefs_get_type ()) +#define EM_COMPOSER_PREFS(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST \ + ((obj), EM_TYPE_COMPOSER_PREFS, EMComposerPrefs)) +#define EM_COMPOSER_PREFS_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_CAST \ + ((cls), EM_TYPE_COMPOSER_PREFS, EMComposerPrefsClass)) +#define EM_IS_COMPOSER_PREFS(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE \ + ((obj), EM_TYPE_COMPOSER_PREFS)) +#define EM_IS_COMPOSER_PREFS_CLASS(cls) \ + (G_TYPE_CHECK_CLASS_TYPE \ + ((cls), EM_TYPE_COMPOSER_PREFS)) +#define EM_COMPOSER_PREFS_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS \ + ((obj), EM_TYPE_COMPOSER_PREFS, EMComposerPrefsClass)) + +G_BEGIN_DECLS typedef struct _EMComposerPrefs EMComposerPrefs; typedef struct _EMComposerPrefsClass EMComposerPrefsClass; struct _ESignature; -struct _GtkToggleButton; -struct _GtkOptionMenu; -struct _GdkPixbuf; -struct _GtkWidget; struct _GladeXML; -struct _GConfClient; -struct _GtkButton; -struct _GtkTreeView; -struct _GtkWindow; struct _EMComposerPrefs { - GtkVBox parent_object; - - struct _GConfClient *gconf; + GtkVBox parent; struct _GladeXML *gui; /* General tab */ /* Default Behavior */ - struct _GtkToggleButton *send_html; - struct _GtkToggleButton *auto_smileys; - struct _GtkToggleButton *auto_request_receipt; - struct _GtkToggleButton *prompt_empty_subject; - struct _GtkToggleButton *prompt_bcc_only; - struct _GtkOptionMenu *charset; - - struct _GtkToggleButton *spell_check; - struct _GtkColorButton *color; - struct _GtkTreeView *language; - CORBA_sequence_GNOME_Spell_Language *language_seq; - gboolean spell_active; + GtkOptionMenu *charset; - struct _GdkPixbuf *enabled_pixbuf; + GtkColorButton *color; + GtkTreeModel *language_model; /* Forwards and Replies */ - struct _GtkOptionMenu *forward_style; - struct _GtkOptionMenu *reply_style; - struct _GtkToggleButton *top_signature; + GtkOptionMenu *forward_style; + GtkOptionMenu *reply_style; /* Keyboard Shortcuts */ - struct _GtkOptionMenu *shortcuts_type; + GtkOptionMenu *shortcuts_type; /* Signatures */ - struct _GtkTreeView *sig_list; + GtkTreeView *sig_list; GHashTable *sig_hash; - struct _GtkButton *sig_add; - struct _GtkButton *sig_add_script; - struct _GtkButton *sig_edit; - struct _GtkButton *sig_delete; + GtkButton *sig_add; + GtkButton *sig_add_script; + GtkButton *sig_edit; + GtkButton *sig_delete; struct _GtkHTML *sig_preview; struct _GladeXML *sig_script_gui; - struct _GtkWidget *sig_script_dialog; + GtkWidget *sig_script_dialog; guint sig_added_id; guint sig_removed_id; @@ -105,22 +91,17 @@ struct _EMComposerPrefs { struct _EMComposerPrefsClass { GtkVBoxClass parent_class; - - /* signals */ - }; -GType em_composer_prefs_get_type (void); - -struct _GtkWidget *em_composer_prefs_new (void); - -void em_composer_prefs_new_signature (struct _GtkWindow *parent, gboolean html); +GType em_composer_prefs_get_type (void); +GtkWidget * em_composer_prefs_new (void); +void em_composer_prefs_new_signature (GtkWindow *parent, + gboolean html_mode); /* needed by global config */ -#define EM_COMPOSER_PREFS_CONTROL_ID "OAFIID:GNOME_Evolution_Mail_ComposerPrefs_ConfigControl:" BASE_VERSION +#define EM_COMPOSER_PREFS_CONTROL_ID \ + "OAFIID:GNOME_Evolution_Mail_ComposerPrefs_ConfigControl:" BASE_VERSION -#ifdef __cplusplus -} -#endif /* __cplusplus */ +G_END_DECLS #endif /* __EM_COMPOSER_PREFS_H__ */ diff --git a/mail/evolution-mail.schemas.in b/mail/evolution-mail.schemas.in index b5a3e579db..2e6785fe6c 100644 --- a/mail/evolution-mail.schemas.in +++ b/mail/evolution-mail.schemas.in @@ -18,15 +18,15 @@ </schema> <schema> - <key>/schemas/apps/evolution/mail/composer/send_html</key> - <applyto>/apps/evolution/mail/composer/send_html</applyto> + <key>/schemas/apps/evolution/mail/composer/inline_spelling</key> + <applyto>/apps/evolution/mail/composer/inline_spelling</applyto> <owner>evolution-mail</owner> <type>bool</type> - <default>false</default> + <default>true</default> <locale name="C"> - <short>Send HTML mail by default</short> + <short>Spell check inline</short> <long> - Send HTML mail by default. + Draw spelling error indicators on words as you type. </long> </locale> </schema> @@ -74,20 +74,48 @@ </schema> <schema> - <key>/schemas/apps/evolution/mail/composer/inline_spelling</key> - <applyto>/apps/evolution/mail/composer/inline_spelling</applyto> + <key>/schemas/apps/evolution/mail/composer/send_html</key> + <applyto>/apps/evolution/mail/composer/send_html</applyto> <owner>evolution-mail</owner> <type>bool</type> - <default>true</default> + <default>false</default> <locale name="C"> - <short>Spell check inline</short> + <short>Send HTML mail by default</short> <long> - Draw spelling error indicators on words as you type. + Send HTML mail by default. </long> </locale> </schema> <schema> + <key>/schemas/apps/evolution/mail/composer/spell_color</key> + <applyto>/apps/evolution/mail/composer/spell_color</applyto> + <owner>evolution-mail</owner> + <type>string</type> + <default>#FFFF00000000</default> + <locale name="C"> + <short>Spell checking color</short> + <long> + Underline color for misspelled words when using inline spelling. + </long> + </locale> + </schema> + + <schema> + <key>/schema/apps/evolution/mail/composer/spell_languages</key> + <applyto>/apps/evolution/mail/composer/spell_languages</applyto> + <owner>evolution-mail</owner> + <type>list</type> + <list_type>string</list_type> + <locale name="C"> + <short>Spell checking languages</short> + <long> + List of dictionary language codes used for spell checking. + </long> + </locale> + </schema> + + <schema> <key>/schemas/apps/evolution/mail/composer/view/From</key> <applyto>/apps/evolution/mail/composer/view/From</applyto> <owner>evolution-mail</owner> diff --git a/mail/mail-config.c b/mail/mail-config.c index a00e00e2d8..09c4cd662c 100644 --- a/mail/mail-config.c +++ b/mail/mail-config.c @@ -88,36 +88,20 @@ typedef struct { ESignatureList *signatures; GSList *labels; - guint label_notify_id; - - guint font_notify_id; - guint spell_notify_id; - guint mark_citations__notify_id; - guint citation_colour_notify_id; - guint address_count_notify_id; - guint address_compress_notify_id; + gboolean address_compress; gint address_count; - guint mlimit_size_notify_id; - guint mlimit_notify_id; gboolean mlimit; gint mlimit_size; - guint magic_spacebar_notify_id; gboolean magic_spacebar; guint error_time; - guint error_notify_id; guint error_level; - guint error_level_id; GPtrArray *mime_types; - guint mime_types_notify_id; GSList *jh_header; gboolean jh_check; - guint jh_header_id; - guint jh_check_id; gboolean book_lookup; - guint book_lookup_id; } MailConfig; static MailConfig *config = NULL; @@ -163,20 +147,16 @@ config_cache_mime_types (void) g_ptr_array_add (config->mime_types, NULL); } -#define CONFIG_GET_SPELL_VALUE(t,x,prop,f,c) G_STMT_START { \ - val = gconf_client_get_without_default (config->gconf, "/GNOME/Spell" x, NULL); \ - if (val) { f; prop = c (gconf_value_get_ ## t (val)); \ - gconf_value_free (val); } } G_STMT_END - static void config_write_style (void) { - int red = 0xffff, green = 0, blue = 0; - GConfValue *val; + GConfClient *client; gboolean custom; - char *fix_font; - char *var_font; - char *citation_color; + gchar *fix_font; + gchar *var_font; + gchar *citation_color; + gchar *spell_color; + const gchar *key; FILE *rc; if (!(rc = g_fopen (config->gtkrc, "wt"))) { @@ -184,17 +164,26 @@ config_write_style (void) return; } - custom = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/fonts/use_custom", NULL); - var_font = gconf_client_get_string (config->gconf, "/apps/evolution/mail/display/fonts/variable", NULL); - fix_font = gconf_client_get_string (config->gconf, "/apps/evolution/mail/display/fonts/monospace", NULL); - citation_color = gconf_client_get_string (config->gconf, "/apps/evolution/mail/display/citation_colour", NULL); - CONFIG_GET_SPELL_VALUE (int, "/spell_error_color_red", red, (void)0, (int)); - CONFIG_GET_SPELL_VALUE (int, "/spell_error_color_green", green, (void)0, (int)); - CONFIG_GET_SPELL_VALUE (int, "/spell_error_color_blue", blue, (void)0, (int)); + client = config->gconf; + + key = "/apps/evolution/mail/display/fonts/use_custom"; + custom = gconf_client_get_bool (client, key, NULL); + + key = "/apps/evolution/mail/display/fonts/variable"; + var_font = gconf_client_get_string (client, key, NULL); + + key = "/apps/evolution/mail/display/fonts/monospace"; + fix_font = gconf_client_get_string (client, key, NULL); + + key = "/apps/evolution/mail/display/citation_colour"; + citation_color = gconf_client_get_string (client, key, NULL); + + key = "/apps/evolution/mail/composer/spell_color"; + spell_color = gconf_client_get_string (client, key, NULL); fprintf (rc, "style \"evolution-mail-custom-fonts\" {\n"); - fprintf (rc, " GtkHTML::spell_error_color = \"#%02x%02x%02x\"\n", - 0xff & (red >> 8), 0xff & (green >> 8), 0xff & (blue >> 8)); + fprintf (rc, " GtkHTML::spell_error_color = \"%s\"\n", spell_color); + g_free (spell_color); if (gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/mark_citations", NULL)) fprintf (rc, " GtkHTML::cite_color = \"%s\"\n", @@ -284,15 +273,8 @@ gconf_jh_check_changed (GConfClient *client, guint cnxn_id, } static void -gconf_lookup_book_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer data) -{ - config->book_lookup = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/lookup_addressbook", NULL); -} - -static void gconf_jh_headers_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) + GConfEntry *entry, gpointer user_data) { config->jh_header = gconf_client_get_list (config->gconf, "/apps/evolution/mail/junk/custom_header", GCONF_VALUE_STRING, NULL); GSList *node = config->jh_header; @@ -309,59 +291,39 @@ gconf_jh_headers_changed (GConfClient *client, guint cnxn_id, mail_session_set_junk_headers ((const char **)name->pdata, (const char **)value->pdata, name->len); } - -static void -gconf_address_count_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - config->address_count = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/address_count", NULL); -} - -static void -gconf_error_time_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - config->error_time = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/error_timeout", NULL); -} - -static void -gconf_error_level_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - config->error_level = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/error_level", NULL); -} - static void -gconf_address_compress_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) +gconf_bool_value_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gboolean *save_location) { - config->address_compress = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/address_compress", NULL); -} + GError *error = NULL; -static void -gconf_mlimit_size_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - config->mlimit_size = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/message_text_part_limit", NULL); + *save_location = gconf_client_get_bool (client, entry->key, &error); + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } } static void -gconf_mlimit_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) +gconf_int_value_changed (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gint *save_location) { - config->mlimit = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/force_message_limit", NULL); -} + GError *error = NULL; -static void -gconf_magic_spacebar_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) -{ - config->magic_spacebar = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/magic_spacebar", NULL); + *save_location = gconf_client_get_int (client, entry->key, &error); + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } } static void gconf_mime_types_changed (GConfClient *client, guint cnxn_id, - GConfEntry *entry, gpointer user_data) + GConfEntry *entry, gpointer user_data) { config_clear_mime_types (); config_cache_mime_types (); @@ -371,89 +333,173 @@ gconf_mime_types_changed (GConfClient *client, guint cnxn_id, void mail_config_init (void) { + GConfClientNotifyFunc func; + const gchar *key; + if (config) return; config = g_new0 (MailConfig, 1); config->gconf = gconf_client_get_default (); config->mime_types = g_ptr_array_new (); - config->gtkrc = g_build_filename (e_get_user_data_dir (), "mail", "config", "gtkrc-mail-fonts", NULL); + config->gtkrc = g_build_filename ( + e_get_user_data_dir (), "mail", + "config", "gtkrc-mail-fonts", NULL); mail_config_clear (); + config->accounts = e_account_list_new (config->gconf); + config->signatures = e_signature_list_new (config->gconf); + gtk_rc_parse (config->gtkrc); - gconf_client_add_dir (config->gconf, "/apps/evolution/mail/display", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_add_dir (config->gconf, "/apps/evolution/mail/display/fonts", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_add_dir (config->gconf, "/GNOME/Spell", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - gconf_client_add_dir (config->gconf, "/apps/evolution/mail/junk", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - - config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/fonts", - gconf_style_changed, NULL, NULL, NULL); - config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/address_compress", - gconf_address_compress_changed, NULL, NULL, NULL); - config->font_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/address_count", - gconf_address_count_changed, NULL, NULL, NULL); - config->error_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/error_timeout", - gconf_error_time_changed, NULL, NULL, NULL); - config->error_level_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/error_level", - gconf_error_level_changed, NULL, NULL, NULL); - - config->mlimit_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/force_message_limit", - gconf_mlimit_changed, NULL, NULL, NULL); - config->mlimit_size_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/message_text_part_limit", - gconf_mlimit_size_changed, NULL, NULL, NULL); - config->magic_spacebar_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/magic_spacebar", - gconf_magic_spacebar_changed, NULL, NULL, NULL); - config->spell_notify_id = gconf_client_notify_add (config->gconf, "/GNOME/Spell", - gconf_style_changed, NULL, NULL, NULL); - config->mark_citations__notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/mark_citations", - gconf_style_changed, NULL, NULL, NULL); - config->citation_colour_notify_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/display/citation_colour", - gconf_style_changed, NULL, NULL, NULL); - - gconf_client_add_dir (config->gconf, E_UTIL_LABELS_GCONF_KEY, - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - config->label_notify_id = - gconf_client_notify_add (config->gconf, E_UTIL_LABELS_GCONF_KEY, - gconf_labels_changed, NULL, NULL, NULL); - - gconf_client_add_dir (config->gconf, "/apps/evolution/mail/mime_types", - GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); - config->mime_types_notify_id = - gconf_client_notify_add (config->gconf, "/apps/evolution/mail/mime_types", - gconf_mime_types_changed, NULL, NULL, NULL); + /* Composer Configuration */ + + gconf_client_add_dir ( + config->gconf, "/apps/evolution/mail/composer", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + key = "/apps/evolution/mail/composer/spell_color"; + func = (GConfClientNotifyFunc) gconf_style_changed; + gconf_client_notify_add ( + config->gconf, key, func, NULL, NULL, NULL); + + /* Display Configuration */ + + gconf_client_add_dir ( + config->gconf, "/apps/evolution/mail/display", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + key = "/apps/evolution/mail/display/address_compress"; + func = (GConfClientNotifyFunc) gconf_bool_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->address_compress, NULL, NULL); + config->address_compress = + gconf_client_get_bool (config->gconf, key, NULL); + + key = "/apps/evolution/mail/display/address_count"; + func = (GConfClientNotifyFunc) gconf_int_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->address_count, NULL, NULL); + config->address_count = + gconf_client_get_int (config->gconf, key, NULL); + + key = "/apps/evolution/mail/display/citation_colour"; + func = (GConfClientNotifyFunc) gconf_style_changed; + gconf_client_notify_add ( + config->gconf, key, func, NULL, NULL, NULL); + + key = "/apps/evolution/mail/display/error_timeout"; + func = (GConfClientNotifyFunc) gconf_int_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->error_time, NULL, NULL); + config->error_time = + gconf_client_get_int (config->gconf, key, NULL); + + key = "/apps/evolution/mail/display/error_level"; + func = (GConfClientNotifyFunc) gconf_int_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->error_level, NULL, NULL); + config->error_level = + gconf_client_get_int (config->gconf, key, NULL); + + key = "/apps/evolution/mail/display/force_message_limit"; + func = (GConfClientNotifyFunc) gconf_bool_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->mlimit, NULL, NULL); + config->mlimit = + gconf_client_get_bool (config->gconf, key, NULL); + + key = "/apps/evolution/mail/display/message_text_part_limit"; + func = (GConfClientNotifyFunc) gconf_int_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->mlimit_size, NULL, NULL); + config->mlimit_size = + gconf_client_get_int (config->gconf, key, NULL); + + key = "/apps/evolution/mail/display/magic_spacebar"; + func = (GConfClientNotifyFunc) gconf_bool_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->magic_spacebar, NULL, NULL); + config->magic_spacebar = + gconf_client_get_bool (config->gconf, key, NULL); + + key = "/apps/evolution/mail/display/mark_citations"; + func = (GConfClientNotifyFunc) gconf_style_changed; + gconf_client_notify_add ( + config->gconf, key, func, NULL, NULL, NULL); + + /* Font Configuration */ + + gconf_client_add_dir ( + config->gconf, "/apps/evolution/mail/display/fonts", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + key = "/apps/evolution/mail/display/fonts"; + func = (GConfClientNotifyFunc) gconf_style_changed; + gconf_client_notify_add ( + config->gconf, key, func, NULL, NULL, NULL); + + /* Label Configuration */ + + gconf_client_add_dir ( + config->gconf, E_UTIL_LABELS_GCONF_KEY, + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + gconf_client_notify_add ( + config->gconf, E_UTIL_LABELS_GCONF_KEY, + gconf_labels_changed, NULL, NULL, NULL); config_cache_labels (config->gconf); + + /* MIME Type Configuration */ + + gconf_client_add_dir ( + config->gconf, "/apps/evolution/mail/mime_types", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); + + key = "/apps/evolution/mail/mime_types"; + func = (GConfClientNotifyFunc) gconf_mime_types_changed, + gconf_client_notify_add ( + config->gconf, key, func, NULL, NULL, NULL); + config_cache_mime_types (); - config->address_compress = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/address_compress", NULL); - config->address_count = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/address_count", NULL); - config->error_time = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/error_timeout", NULL); - config->error_level= gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/error_level", NULL); - - config->mlimit = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/force_message_limit", NULL); - config->mlimit_size = gconf_client_get_int (config->gconf, "/apps/evolution/mail/display/message_text_part_limit", NULL); - config->magic_spacebar = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/display/magic_spacebar", NULL); - config->accounts = e_account_list_new (config->gconf); - config->signatures = e_signature_list_new (config->gconf); - config->jh_check = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/check_custom_header", NULL); - config->jh_check_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/junk/check_custom_header", - gconf_jh_check_changed, NULL, NULL, NULL); - config->jh_header_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/junk/custom_header", - gconf_jh_headers_changed, NULL, NULL, NULL); - config->book_lookup = gconf_client_get_bool (config->gconf, "/apps/evolution/mail/junk/lookup_addressbook", NULL); - config->book_lookup_id = gconf_client_notify_add (config->gconf, "/apps/evolution/mail/junk/lookup_addressbook", - gconf_lookup_book_changed, NULL, NULL, NULL); + /* Junk Configuration */ - gconf_jh_check_changed (config->gconf, 0, NULL, config); + gconf_client_add_dir ( + config->gconf, "/apps/evolution/mail/junk", + GCONF_CLIENT_PRELOAD_ONELEVEL, NULL); -} + key = "/apps/evolution/mail/junk/check_custom_header"; + func = (GConfClientNotifyFunc) gconf_jh_check_changed; + gconf_client_notify_add ( + config->gconf, key, func, NULL, NULL, NULL); + config->jh_check = + gconf_client_get_bool (config->gconf, key, NULL); + + key = "/apps/evolution/mail/junk/custom_header"; + func = (GConfClientNotifyFunc) gconf_jh_headers_changed; + gconf_client_notify_add ( + config->gconf, key, func, NULL, NULL, NULL); + key = "/apps/evolution/mail/junk/lookup_addressbook"; + func = (GConfClientNotifyFunc) gconf_bool_value_changed; + gconf_client_notify_add ( + config->gconf, key, func, + &config->book_lookup, NULL, NULL); + config->book_lookup = + gconf_client_get_bool (config->gconf, key, NULL); + + gconf_jh_check_changed (config->gconf, 0, NULL, config); +} void mail_config_clear (void) |