diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2008-11-24 13:14:44 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2008-11-24 13:14:44 +0800 |
commit | 4f4615a46d5ba518c1e6a0c2412b1edf1e268d99 (patch) | |
tree | 828acaa7b76aa12a490a3238b0ec4a7086b8be16 /composer/e-msg-composer.c | |
parent | 076b7c45131482b87d18963d34d035435491ee8d (diff) | |
download | gsoc2013-evolution-4f4615a46d5ba518c1e6a0c2412b1edf1e268d99.tar.gz gsoc2013-evolution-4f4615a46d5ba518c1e6a0c2412b1edf1e268d99.tar.zst gsoc2013-evolution-4f4615a46d5ba518c1e6a0c2412b1edf1e268d99.zip |
Merge revisions 36737:36810 from trunk.
svn path=/branches/kill-bonobo/; revision=36811
Diffstat (limited to 'composer/e-msg-composer.c')
-rw-r--r-- | composer/e-msg-composer.c | 132 |
1 files changed, 115 insertions, 17 deletions
diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 6f1b10d7d4..5d2c8b8c73 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -2085,10 +2085,9 @@ msg_composer_constructor (GType type, GObject *object; EMsgComposer *composer; GtkToggleAction *action; - GList *spell_languages = NULL; + GList *spell_languages; GConfClient *client; GArray *array; - GSList *list; gboolean active; guint binding_id; @@ -2155,21 +2154,7 @@ msg_composer_constructor (GType type, client, COMPOSER_GCONF_REQUEST_RECEIPT_KEY, NULL); gtk_toggle_action_set_active (action, active); - list = gconf_client_get_list ( - client, COMPOSER_GCONF_SPELL_LANGUAGES_KEY, - GCONF_VALUE_STRING, NULL); - while (list != NULL) { - gchar *language_code = list->data; - const GtkhtmlSpellLanguage *language; - - language = gtkhtml_spell_language_lookup (language_code); - if (language != NULL) - spell_languages = g_list_prepend ( - spell_languages, (gpointer) language); - - list = g_slist_delete_link (list, list); - g_free (language_code); - } + spell_languages = e_load_spell_languages (); gtkhtml_editor_set_spell_languages ( GTKHTML_EDITOR (composer), spell_languages); g_list_free (spell_languages); @@ -2791,6 +2776,27 @@ msg_composer_init (EMsgComposer *composer) drop_types, G_N_ELEMENTS (drop_types), GDK_ACTION_COPY | GDK_ACTION_ASK | GDK_ACTION_MOVE); + /* XXX I'm not sure why we have to explicitly configure the + * attachment bar as a drag destination when CompEditor + * doesn't and previous Evolution releases (2.22 and + * prior) don't, but this is the only way I could figure + * out how to get drag-and-drop to the attachment bar + * working again. I'm probably overlooking something + * simple... */ + + gtk_drag_dest_set ( + composer->priv->attachment_bar, GTK_DEST_DEFAULT_ALL, + drop_types, G_N_ELEMENTS (drop_types), + GDK_ACTION_COPY | GDK_ACTION_ASK | GDK_ACTION_MOVE); + + g_signal_connect ( + composer->priv->attachment_bar, "drag-motion", + G_CALLBACK (msg_composer_drag_motion), NULL); + + g_signal_connect ( + composer->priv->attachment_bar, "drag-data-received", + G_CALLBACK (msg_composer_drag_data_received), NULL); + g_signal_connect ( html, "drag-data-received", G_CALLBACK (msg_composer_drag_data_received), NULL); @@ -4791,3 +4797,95 @@ e_msg_composer_set_send_options (EMsgComposer *composer, composer->priv->send_invoked = send_enable; } + +GList * +e_load_spell_languages (void) +{ + GConfClient *client; + GList *spell_languages = NULL; + GSList *list; + const gchar *key; + GError *error = NULL; + + /* Ask GConf for a list of spell check language codes. */ + client = gconf_client_get_default (); + key = COMPOSER_GCONF_SPELL_LANGUAGES_KEY; + list = gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error); + g_object_unref (client); + + /* Convert the codes to spell language structs. */ + while (list != NULL) { + gchar *language_code = list->data; + const GtkhtmlSpellLanguage *language; + + language = gtkhtml_spell_language_lookup (language_code); + if (language != NULL) + spell_languages = g_list_prepend ( + spell_languages, (gpointer) language); + + list = g_slist_delete_link (list, list); + g_free (language_code); + } + + spell_languages = g_list_reverse (spell_languages); + + /* Pick a default spell language if GConf came back empty. */ + if (spell_languages == NULL) { + const GtkhtmlSpellLanguage *language; + + language = gtkhtml_spell_language_lookup (NULL); + + if (language) { + spell_languages = g_list_prepend ( + spell_languages, (gpointer) language); + + /* Don't overwrite the stored spell check language + * codes if there was a problem retrieving them. */ + if (error == NULL) + e_save_spell_languages (spell_languages); + } + } + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } + + return spell_languages; +} + +void +e_save_spell_languages (GList *spell_languages) +{ + GConfClient *client; + GSList *list = NULL; + const gchar *key; + GError *error = NULL; + + /* Build a list of spell check language codes. */ + while (spell_languages != NULL) { + const GtkhtmlSpellLanguage *language; + const gchar *language_code; + + language = spell_languages->data; + language_code = gtkhtml_spell_language_get_code (language); + list = g_slist_prepend (list, (gpointer) language_code); + + spell_languages = g_list_next (spell_languages); + } + + list = g_slist_reverse (list); + + /* Save the language codes to GConf. */ + client = gconf_client_get_default (); + key = COMPOSER_GCONF_SPELL_LANGUAGES_KEY; + gconf_client_set_list (client, key, GCONF_VALUE_STRING, list, &error); + g_object_unref (client); + + g_slist_free (list); + + if (error != NULL) { + g_warning ("%s", error->message); + g_error_free (error); + } +} |