aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
Diffstat (limited to 'mail')
-rw-r--r--mail/.cvsignore4
-rw-r--r--mail/ChangeLog5
-rw-r--r--mail/Makefile.am20
-rw-r--r--mail/Spell.idl71
-rw-r--r--mail/mail-callbacks.c1
-rw-r--r--mail/mail-composer-prefs.c281
-rw-r--r--mail/mail-composer-prefs.h14
-rw-r--r--mail/mail-config.glade20
8 files changed, 378 insertions, 38 deletions
diff --git a/mail/.cvsignore b/mail/.cvsignore
index dd1d902aa2..6c0ad659cf 100644
--- a/mail/.cvsignore
+++ b/mail/.cvsignore
@@ -17,3 +17,7 @@ test-thread
*.da
*.gcov
GNOME_Evolution_Mail.oaf
+Spell-common.c
+Spell-skels.c
+Spell-stubs.c
+Spell.h
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 83e8b92d66..d9cd2763e8 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,8 @@
+2002-05-08 Radek Doulik <rodo@ximian.com>
+
+ * mail-composer-prefs.c: implemented (c'n'p-ed and updated) spell
+ checking settings
+
2002-05-08 Iain Holmes <iain@ximian.com>
* component-factory.c (owner_set_cb): Tell the folder info listeners
diff --git a/mail/Makefile.am b/mail/Makefile.am
index dba25abaf8..0cb4c3f378 100644
--- a/mail/Makefile.am
+++ b/mail/Makefile.am
@@ -40,10 +40,24 @@ EVOLUTION_MAIL_NNTP = \
mail-account-editor-news.h
endif
+SPELL_IDL = Spell.idl
+
+IDL_GENERATED = \
+ Spell.h \
+ Spell-common.c \
+ Spell-skels.c \
+ Spell-stubs.c
+
+$(IDL_GENERATED): $(SPELL_IDL)
+ $(ORBIT_IDL) -I $(srcdir) -I $(datadir)/idl -I `$(GNOME_CONFIG) --cflags idl` \
+ -I `$(GNOME_CONFIG) --datadir`/idl $(srcdir)/Spell.idl
+
+Spell-impl.o: Spell.h
evolution_mail_SOURCES = \
$(EVOLUTION_MAIL_CORBA_GENERATED) \
$(EVOLUTION_MAIL_NNTP) \
+ $(IDL_GENERATED) \
component-factory.c \
component-factory.h \
e-searching-tokenizer.c \
@@ -183,8 +197,8 @@ evolution-mail.pure: evolution-mail
endif
-BUILT_SOURCES = $(EVOLUTION_MAIL_CORBA_GENERATED)
-CLEANFILES = $(BUILT_SOURCES)
-
dist-hook:
cd $(distdir); rm -f $(BUILT_SOURCES)
+
+BUILT_SOURCES = $(EVOLUTION_MAIL_CORBA_GENERATED)
+CLEANFILES = $(BUILT_SOURCES) $(IDL_GENERATED)
diff --git a/mail/Spell.idl b/mail/Spell.idl
new file mode 100644
index 0000000000..1f0efc2870
--- /dev/null
+++ b/mail/Spell.idl
@@ -0,0 +1,71 @@
+/* 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., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include <Bonobo.idl>
+
+module GNOME {
+ module Spell {
+
+ typedef sequence<string> StringSeq;
+ struct Language {
+ string name;
+ string abrev;
+ };
+ 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) raises (Error);
+
+ /**
+ * informs dictionary, that word 'word' will be replaced/corrected by word 'replacement'
+ */
+ void setCorrection (in string word, in string replacement);
+ };
+ };
+};
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index f57a30e7bb..2f45311152 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -2861,6 +2861,7 @@ do_mail_print (FolderBrowser *fb, gboolean preview)
if (printer)
gnome_print_master_set_printer (print_master, printer);
paper = (GnomePaper *) gnome_paper_with_name (_("US-Letter"));
+
if (!paper)
paper = (GnomePaper *) gnome_paper_with_name (gnome_paper_name_default ());
gnome_print_master_set_paper (print_master, paper);
diff --git a/mail/mail-composer-prefs.c b/mail/mail-composer-prefs.c
index 08afa547dd..8b2491e5d6 100644
--- a/mail/mail-composer-prefs.c
+++ b/mail/mail-composer-prefs.c
@@ -29,6 +29,7 @@
#include "composer/e-msg-composer.h"
#include <bonobo/bonobo-generic-factory.h>
+#include <bonobo/bonobo-object-client.h>
#include <gal/widgets/e-gui-utils.h>
@@ -111,29 +112,6 @@ mail_composer_prefs_destroy (GtkObject *obj)
}
static void
-colorpicker_set_color (GnomeColorPicker *color, guint32 rgb)
-{
- gnome_color_picker_set_i8 (color, (rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff, 0xff);
-}
-
-static guint32
-colorpicker_get_color (GnomeColorPicker *color)
-{
- guint8 r, g, b, a;
- guint32 rgb = 0;
-
- gnome_color_picker_get_i8 (color, &r, &g, &b, &a);
-
- rgb = r;
- rgb <<= 8;
- rgb |= g;
- rgb <<= 8;
- rgb |= b;
-
- return rgb;
-}
-
-static void
attach_style_info (GtkWidget *item, gpointer user_data)
{
int *style = user_data;
@@ -512,6 +490,243 @@ sig_event_client (MailConfigSigEvent event, MailConfigSignature *sig, MailCompos
}
}
+/*
+ *
+ * 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.2"
+
+static void
+spell_select_lang (MailComposerPrefs *prefs, const gchar *abrev)
+{
+ gint i;
+
+ for (i = 0; i < prefs->language_seq->_length; i ++) {
+ if (!strcasecmp (abrev, prefs->language_seq->_buffer [i].abrev)) {
+ gtk_clist_select_row (GTK_CLIST (prefs->language), i, 0);
+ }
+ }
+}
+
+static void
+spell_set_ui_language (MailComposerPrefs *prefs)
+{
+ gchar *l, *last, *lang;
+
+ gtk_clist_freeze (GTK_CLIST (prefs->language));
+ gtk_clist_unselect_all (GTK_CLIST (prefs->language));
+ last = prefs->language_str;
+ while ((l = strchr (last, ' '))) {
+ if (l != last) {
+ lang = g_strndup (last, l - last);
+ spell_select_lang (prefs, lang);
+ g_free (lang);
+ }
+
+ last = l + 1;
+ }
+ if (last)
+ spell_select_lang (prefs, last);
+ gtk_clist_thaw (GTK_CLIST (prefs->language));
+}
+
+static void
+spell_set_ui (MailComposerPrefs *prefs)
+{
+ prefs->spell_active = FALSE;
+
+ spell_set_ui_language (prefs);
+ gnome_color_picker_set_i16 (GNOME_COLOR_PICKER (prefs->colour),
+ prefs->spell_error_color.red, prefs->spell_error_color.green, prefs->spell_error_color.blue, 0xffff);
+
+ prefs->spell_active = TRUE;
+}
+
+static gchar *
+spell_get_language_str (MailComposerPrefs *prefs)
+{
+ GList *selection = GTK_CLIST (prefs->language)->selection;
+ GString *str = g_string_new (NULL);
+ gchar *rv;
+
+ for (; selection; selection = selection->next) {
+ g_string_append (str, gtk_clist_get_row_data (GTK_CLIST (prefs->language),
+ GPOINTER_TO_INT (selection->data)));
+ if (selection->next)
+ g_string_append_c (str, ' ');
+ }
+
+ rv = str->str;
+ g_string_free (str, FALSE);
+
+ return rv;
+}
+
+static void
+spell_get_ui (MailComposerPrefs *prefs)
+{
+ gnome_color_picker_get_i16 (GNOME_COLOR_PICKER (prefs->colour),
+ &prefs->spell_error_color.red,
+ &prefs->spell_error_color.green,
+ &prefs->spell_error_color.blue, NULL);
+ g_free (prefs->language_str);
+ prefs->language_str = spell_get_language_str (prefs);
+}
+
+#define GET(t,x,prop,f,c) \
+ val = gconf_client_get_without_default (prefs->gconf, GNOME_SPELL_GCONF_DIR x, NULL); \
+ if (val) { f; prop = c (gconf_value_get_ ## t (val)); \
+ gconf_value_free (val); }
+
+static void
+spell_save_orig (MailComposerPrefs *prefs)
+{
+ g_free (prefs->language_str_orig);
+ prefs->language_str_orig = g_strdup (prefs->language_str);
+ prefs->spell_error_color_orig = prefs->spell_error_color;
+}
+
+/* static void
+spell_load_orig (MailComposerPrefs *prefs)
+{
+ g_free (prefs->language_str);
+ prefs->language_str = g_strdup (prefs->language_str_orig);
+ prefs->spell_error_color = prefs->spell_error_color_orig;
+} */
+
+static void
+spell_load_values (MailComposerPrefs *prefs)
+{
+ GConfValue *val;
+
+ g_free (prefs->language_str);
+ prefs->language_str = g_strdup (_("en"));
+ prefs->spell_error_color.red = 0xffff;
+ prefs->spell_error_color.green = 0;
+ prefs->spell_error_color.blue = 0;
+
+ GET (int, "/spell_error_color_red", prefs->spell_error_color.red,,);
+ GET (int, "/spell_error_color_green", prefs->spell_error_color.green,,);
+ GET (int, "/spell_error_color_blue", prefs->spell_error_color.blue,,);
+ GET (string, "/language", prefs->language_str, g_free (prefs->language_str), g_strdup);
+
+ spell_save_orig (prefs);
+}
+
+#define SET(t,x,prop) \
+ gconf_client_set_ ## t (prefs->gconf, GNOME_SPELL_GCONF_DIR x, prop, NULL);
+
+static void
+spell_save_values (MailComposerPrefs *prefs, gboolean force)
+{
+ if (force || !gdk_color_equal (&prefs->spell_error_color, &prefs->spell_error_color_orig)) {
+ SET (int, "/spell_error_color_red", prefs->spell_error_color.red);
+ SET (int, "/spell_error_color_green", prefs->spell_error_color.green);
+ SET (int, "/spell_error_color_blue", prefs->spell_error_color.blue);
+ }
+ if (force || strcmp (prefs->language_str, prefs->language_str_orig)) {
+ SET (string, "/language", prefs->language_str);
+ }
+
+ gconf_client_suggest_sync (prefs->gconf, NULL);
+}
+
+static void
+spell_apply (MailComposerPrefs *prefs)
+{
+ spell_get_ui (prefs);
+ spell_save_values (prefs, FALSE);
+}
+
+/* static void
+spell_revert (MailComposerPrefs *prefs)
+{
+ spell_load_orig (prefs);
+ spell_set_ui (prefs);
+ spell_save_values (prefs, TRUE);
+} */
+
+static void
+spell_changed (gpointer user_data)
+{
+ MailComposerPrefs *prefs = (MailComposerPrefs *) user_data;
+
+ if (prefs->control)
+ evolution_config_control_changed (prefs->control);
+}
+
+static void
+spell_color_set (GtkWidget *widget, guint r, guint g, guint b, guint a, gpointer user_data)
+{
+ spell_changed (user_data);
+}
+
+static void
+spell_language_changed (GtkWidget *widget, gint row, gint column, GdkEvent *event, gpointer user_data)
+{
+ spell_changed (user_data);
+}
+
+static void
+spell_setup (MailComposerPrefs *prefs)
+{
+ gint i;
+
+ gtk_clist_freeze (GTK_CLIST (prefs->language));
+ for (i = 0; i < prefs->language_seq->_length; i ++) {
+ gchar *texts [1];
+
+ texts [0] = _(prefs->language_seq->_buffer [i].name);
+ gtk_clist_append (GTK_CLIST (prefs->language), texts);
+ gtk_clist_set_row_data (GTK_CLIST (prefs->language), i, prefs->language_seq->_buffer [i].abrev);
+ }
+ gtk_clist_thaw (GTK_CLIST (prefs->language));
+
+ spell_load_values (prefs);
+ spell_set_ui (prefs);
+
+ glade_xml_signal_connect_data (prefs->gui, "spellColorSet", GTK_SIGNAL_FUNC (spell_color_set), prefs);
+ glade_xml_signal_connect_data (prefs->gui, "spellLanguageChanged", GTK_SIGNAL_FUNC (spell_language_changed), prefs);
+}
+
+static gboolean
+spell_setup_check_options (MailComposerPrefs *prefs)
+{
+ BonoboObjectClient *dictionary_client;
+ GNOME_Spell_Dictionary dict;
+ CORBA_Environment ev;
+ gchar *dictionary_id;
+
+ dictionary_id = "OAFIID:GNOME_Spell_Dictionary:" SPELL_API_VERSION;
+ dictionary_client = bonobo_object_activate (dictionary_id, 0);
+
+ if (!dictionary_client) {
+ g_warning ("Cannot activate %s", dictionary_id);
+
+ return FALSE;
+ }
+ dict = bonobo_object_corba_objref (BONOBO_OBJECT (dictionary_client));
+
+ CORBA_exception_init (&ev);
+ prefs->language_seq = GNOME_Spell_Dictionary_getLanguages (dict, &ev);
+ CORBA_exception_free (&ev);
+
+ gconf_client_add_dir (prefs->gconf, GNOME_SPELL_GCONF_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL);
+
+ spell_setup (prefs);
+
+ return TRUE;
+}
+
+/*
+ * End of Spell checking
+ */
+
static void
mail_composer_prefs_construct (MailComposerPrefs *prefs)
{
@@ -521,10 +736,12 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs)
char *names[][2] = {{"live_spell_check", "chkEnableSpellChecking"},
{"gtk_html_prop_keymap_option", "omenuShortcutsType"},
{NULL, NULL}};
-
+
+ prefs->gconf = gconf_client_get_default ();
+
gui = glade_xml_new (EVOLUTION_GLADEDIR "/mail-config.glade", "composer_tab");
prefs->gui = gui;
-
+
/* get our toplevel widget */
toplevel = glade_xml_get_widget (gui, "toplevel");
@@ -557,7 +774,7 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs)
gtk_option_menu_set_menu (prefs->charset, GTK_WIDGET (menu));
option_menu_connect (prefs->charset, prefs);
- /* Spell Checking */
+ /* Spell Checking: GtkHTML part */
prefs->pman = GTK_HTML_PROPMANAGER (gtk_html_propmanager_new (NULL));
gtk_signal_connect (GTK_OBJECT (prefs->pman), "changed", toggle_button_toggled, prefs);
gtk_object_ref (GTK_OBJECT (prefs->pman));
@@ -565,10 +782,14 @@ mail_composer_prefs_construct (MailComposerPrefs *prefs)
gtk_html_propmanager_set_names (prefs->pman, names);
gtk_html_propmanager_set_gui (prefs->pman, gui, NULL);
- /*
+ /* Spell Checking: GNOME Spell part */
prefs->colour = GNOME_COLOR_PICKER (glade_xml_get_widget (gui, "colorpickerSpellCheckColor"));
- prefs->language = GTK_COMBO (glade_xml_get_widget (gui, "cmboSpellCheckLanguage"));
- */
+ prefs->language = GTK_CLIST (glade_xml_get_widget (gui, "clistSpellCheckLanguage"));
+
+ if (!spell_setup_check_options (prefs)) {
+ gtk_widget_hide (GTK_WIDGET (prefs->colour));
+ gtk_widget_hide (GTK_WIDGET (prefs->language));
+ }
/* Forwards and Replies */
prefs->forward_style = GTK_OPTION_MENU (glade_xml_get_widget (gui, "omenuForwardStyle"));
@@ -683,8 +904,8 @@ mail_composer_prefs_apply (MailComposerPrefs *prefs)
}
/* Spell Checking */
- /* FIXME: implement me */
gtk_html_propmanager_apply (prefs->pman);
+ spell_apply (prefs);
/* Forwards and Replies */
menu = gtk_option_menu_get_menu (prefs->forward_style);
diff --git a/mail/mail-composer-prefs.h b/mail/mail-composer-prefs.h
index 89ccd0552a..3c559ea926 100644
--- a/mail/mail-composer-prefs.h
+++ b/mail/mail-composer-prefs.h
@@ -36,12 +36,14 @@ extern "C" {
#include <libgnomeui/gnome-file-entry.h>
#include <gtkhtml/gtkhtml.h>
#include <gtkhtml/gtkhtml-propmanager.h>
+#include <gconf/gconf-client.h>
#include "mail-signature-editor.h"
#include "evolution-config-control.h"
#include <shell/Evolution.h>
+#include "Spell.h"
#define MAIL_COMPOSER_PREFS_TYPE (mail_composer_prefs_get_type ())
#define MAIL_COMPOSER_PREFS(o) (GTK_CHECK_CAST ((o), MAIL_COMPOSER_PREFS_TYPE, MailComposerPrefs))
@@ -56,7 +58,9 @@ struct _MailComposerPrefs {
GtkVBox parent_object;
EvolutionConfigControl *control;
-
+
+ GConfClient *gconf;
+
GladeXML *gui;
/* General tab */
@@ -71,7 +75,13 @@ struct _MailComposerPrefs {
GtkHTMLPropmanager *pman;
GtkToggleButton *spell_check;
GnomeColorPicker *colour;
- GtkCombo *language;
+ GtkCList *language;
+ CORBA_sequence_GNOME_Spell_Language *language_seq;
+ gboolean spell_active;
+ gchar *language_str;
+ gchar *language_str_orig;
+ GdkColor spell_error_color;
+ GdkColor spell_error_color_orig;
/* Forwards and Replies */
GtkOptionMenu *forward_style;
diff --git a/mail/mail-config.glade b/mail/mail-config.glade
index 4f09687bb7..3c6884c5cf 100644
--- a/mail/mail-config.glade
+++ b/mail/mail-config.glade
@@ -4231,6 +4231,11 @@ Baltic (ISO-8859-4)
<class>GnomeColorPicker</class>
<name>colorpickerSpellCheckColor</name>
<can_focus>True</can_focus>
+ <signal>
+ <name>color_set</name>
+ <handler>spellColorSet</handler>
+ <last_modification_time>Wed, 08 May 2002 17:06:36 GMT</last_modification_time>
+ </signal>
<dither>True</dither>
<use_alpha>False</use_alpha>
<title>Pick a color</title>
@@ -4284,12 +4289,21 @@ Baltic (ISO-8859-4)
<widget>
<class>GtkCList</class>
- <name>clist1</name>
- <height>80</height>
+ <name>clistSpellCheckLanguage</name>
<can_focus>True</can_focus>
+ <signal>
+ <name>select_row</name>
+ <handler>spellLanguageChanged</handler>
+ <last_modification_time>Wed, 08 May 2002 17:08:46 GMT</last_modification_time>
+ </signal>
+ <signal>
+ <name>unselect_row</name>
+ <handler>spellLanguageChanged</handler>
+ <last_modification_time>Wed, 08 May 2002 17:08:54 GMT</last_modification_time>
+ </signal>
<columns>1</columns>
<column_widths>80</column_widths>
- <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
+ <selection_mode>GTK_SELECTION_MULTIPLE</selection_mode>
<show_titles>False</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>