diff options
author | Davyd Madeley <davyd@madeley.id.au> | 2009-04-24 09:07:25 +0800 |
---|---|---|
committer | Davyd Madeley <davyd@madeley.id.au> | 2009-04-24 09:07:25 +0800 |
commit | b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4 (patch) | |
tree | f6fd31036a541cd09f81154487926a1928e7490e /libempathy-gtk/empathy-chat.c | |
parent | 055e2787d98e48a51eb4345c6e375776ec615072 (diff) | |
parent | e792e16499f942c6669ce12417118968a71a75c0 (diff) | |
download | gsoc2013-empathy-b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4.tar gsoc2013-empathy-b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4.tar.gz gsoc2013-empathy-b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4.tar.bz2 gsoc2013-empathy-b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4.tar.lz gsoc2013-empathy-b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4.tar.xz gsoc2013-empathy-b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4.tar.zst gsoc2013-empathy-b8a72ca6c86a001e6c7f8ff6fb761cfe8221b6b4.zip |
Merge branch 'spelling-578399'
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 61 |
1 files changed, 45 insertions, 16 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 985eaa4cf..425a1c555 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -45,7 +45,6 @@ #include "empathy-chat.h" #include "empathy-conf.h" #include "empathy-spell.h" -#include "empathy-spell-dialog.h" #include "empathy-contact-list-store.h" #include "empathy-contact-list-view.h" #include "empathy-contact-menu.h" @@ -595,7 +594,7 @@ chat_property_changed_cb (EmpathyTpChat *tp_chat, static void chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer, - EmpathyChat *chat) + EmpathyChat *chat) { EmpathyChatPriv *priv; GtkTextIter start, end; @@ -611,8 +610,8 @@ chat_input_text_buffer_changed_cb (GtkTextBuffer *buffer, } empathy_conf_get_bool (empathy_conf_get (), - EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED, - &spell_checker); + EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED, + &spell_checker); gtk_text_buffer_get_start_iter (buffer, &start); @@ -931,13 +930,42 @@ chat_spell_free (EmpathyChatSpell *chat_spell) } static void -chat_text_check_word_spelling_cb (GtkMenuItem *menuitem, - EmpathyChatSpell *chat_spell) +chat_spelling_menu_activate_cb (GtkMenuItem *menu_item, + EmpathyChatSpell *chat_spell) { - empathy_spell_dialog_show (chat_spell->chat, - &chat_spell->start, - &chat_spell->end, - chat_spell->word); + empathy_chat_correct_word (chat_spell->chat, + &(chat_spell->start), + &(chat_spell->end), + gtk_menu_item_get_label (menu_item)); +} + +static GtkWidget* +chat_spelling_build_menu (EmpathyChatSpell *chat_spell) +{ + GtkWidget *menu, *menu_item; + GList *suggestions, *l; + + menu = gtk_menu_new (); + suggestions = empathy_spell_get_suggestions (chat_spell->word); + if (suggestions == NULL) { + menu_item = gtk_menu_item_new_with_label (_("(No Suggestions)")); + gtk_widget_set_sensitive (menu_item, FALSE); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + } else { + for (l = suggestions; l; l = l->next) { + menu_item = gtk_menu_item_new_with_label (l->data); + g_signal_connect (G_OBJECT (menu_item), + "activate", + G_CALLBACK (chat_spelling_menu_activate_cb), + chat_spell); + gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); + } + } + empathy_spell_free_suggestions (suggestions); + + gtk_widget_show_all (menu); + + return menu; } static void @@ -960,7 +988,8 @@ chat_input_populate_popup_cb (GtkTextView *view, GtkTextIter iter, start, end; GtkWidget *item; gchar *str = NULL; - EmpathyChatSpell *chat_spell; + EmpathyChatSpell *chat_spell; + GtkWidget *spell_menu; EmpathySmileyManager *smiley_manager; GtkWidget *smiley_menu; GtkWidget *image; @@ -1025,14 +1054,14 @@ chat_input_populate_popup_cb (GtkTextView *view, gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); - item = gtk_image_menu_item_new_with_mnemonic (_("_Check Word Spelling...")); + item = gtk_image_menu_item_new_with_mnemonic (_("_Spelling Suggestions")); image = gtk_image_new_from_icon_name (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); - g_signal_connect (item, - "activate", - G_CALLBACK (chat_text_check_word_spelling_cb), - chat_spell); + + spell_menu = chat_spelling_build_menu (chat_spell); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), spell_menu); + gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), item); gtk_widget_show (item); } |