aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-chat.c
diff options
context:
space:
mode:
authorAdam Schreiber <sadam@clemson.edu>2009-04-22 00:42:30 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2009-04-22 17:07:01 +0800
commit814e6198069aaa5df9cf63e51b29afe78ef22dde (patch)
tree16afaccadcf65c9093e4f83bcf2a30f0998979c0 /libempathy-gtk/empathy-chat.c
parent49b228b4d8f488cf667a6b2ba110eba20fb9e73a (diff)
downloadgsoc2013-empathy-814e6198069aaa5df9cf63e51b29afe78ef22dde.tar
gsoc2013-empathy-814e6198069aaa5df9cf63e51b29afe78ef22dde.tar.gz
gsoc2013-empathy-814e6198069aaa5df9cf63e51b29afe78ef22dde.tar.bz2
gsoc2013-empathy-814e6198069aaa5df9cf63e51b29afe78ef22dde.tar.lz
gsoc2013-empathy-814e6198069aaa5df9cf63e51b29afe78ef22dde.tar.xz
gsoc2013-empathy-814e6198069aaa5df9cf63e51b29afe78ef22dde.tar.zst
gsoc2013-empathy-814e6198069aaa5df9cf63e51b29afe78ef22dde.zip
Display spelling suggestions in a submenu instead of in a separate
dialog. Fixes bug #578399
Diffstat (limited to 'libempathy-gtk/empathy-chat.c')
-rw-r--r--libempathy-gtk/empathy-chat.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index 7d9390274..dea3b874c 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"
@@ -932,13 +931,37 @@ 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);
+ 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
@@ -961,7 +984,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;
@@ -1026,14 +1050,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);
}