aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--docs/libempathy-gtk/libempathy-gtk-docs.sgml1
-rw-r--r--libempathy-gtk/Makefile.am3
-rw-r--r--libempathy-gtk/empathy-chat.c50
-rw-r--r--libempathy-gtk/empathy-spell-dialog.c264
-rw-r--r--libempathy-gtk/empathy-spell-dialog.h39
-rw-r--r--python/pyempathygtk/pyempathygtk.override2
6 files changed, 37 insertions, 322 deletions
diff --git a/docs/libempathy-gtk/libempathy-gtk-docs.sgml b/docs/libempathy-gtk/libempathy-gtk-docs.sgml
index 033ebf018..f265de20b 100644
--- a/docs/libempathy-gtk/libempathy-gtk-docs.sgml
+++ b/docs/libempathy-gtk/libempathy-gtk-docs.sgml
@@ -45,7 +45,6 @@
<xi:include href="xml/empathy-presence-chooser.xml"/>
<xi:include href="xml/empathy-profile-chooser.xml"/>
<xi:include href="xml/empathy-smiley-manager.xml"/>
- <xi:include href="xml/empathy-spell-dialog.xml"/>
<xi:include href="xml/empathy-spell.xml"/>
<xi:include href="xml/empathy-theme-boxes.xml"/>
<xi:include href="xml/empathy-theme-irc.xml"/>
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 6f3b99ba6..470d44ea5 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -49,7 +49,6 @@ libempathy_gtk_la_SOURCES = \
empathy-profile-chooser.c \
empathy-smiley-manager.c \
empathy-spell.c \
- empathy-spell-dialog.c \
empathy-theme-boxes.c \
empathy-theme-irc.c \
empathy-theme-manager.c \
@@ -102,7 +101,6 @@ libempathy_gtk_headers = \
empathy-profile-chooser.h \
empathy-smiley-manager.h \
empathy-spell.h \
- empathy-spell-dialog.h \
empathy-theme-boxes.h \
empathy-theme-irc.h \
empathy-theme-manager.h \
@@ -128,7 +126,6 @@ ui_DATA = \
empathy-account-widget-yahoo.ui \
empathy-account-widget-groupwise.ui \
empathy-account-widget-aim.ui \
- empathy-spell-dialog.ui \
empathy-log-window.ui \
empathy-chat.ui \
empathy-new-message-dialog.ui
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);
}
diff --git a/libempathy-gtk/empathy-spell-dialog.c b/libempathy-gtk/empathy-spell-dialog.c
deleted file mode 100644
index 9ce80eebb..000000000
--- a/libempathy-gtk/empathy-spell-dialog.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004-2007 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <glib/gi18n-lib.h>
-#include <gtk/gtk.h>
-
-#include <libempathy/empathy-utils.h>
-
-#include "empathy-chat.h"
-#include "empathy-spell.h"
-#include "empathy-spell-dialog.h"
-#include "empathy-ui-utils.h"
-
-typedef struct {
- GtkWidget *window;
- GtkWidget *button_replace;
- GtkWidget *label_word;
- GtkWidget *treeview_words;
-
- EmpathyChat *chat;
-
- gchar *word;
- GtkTextIter start;
- GtkTextIter end;
-} EmpathySpellDialog;
-
-enum {
- COL_SPELL_WORD,
- COL_SPELL_COUNT
-};
-
-static void spell_dialog_model_populate_columns (EmpathySpellDialog *dialog);
-static void spell_dialog_model_populate_suggestions (EmpathySpellDialog *dialog);
-static void spell_dialog_model_row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EmpathySpellDialog *dialog);
-static void spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection,
- EmpathySpellDialog *dialog);
-static void spell_dialog_model_setup (EmpathySpellDialog *dialog);
-static void spell_dialog_response_cb (GtkWidget *widget,
- gint response,
- EmpathySpellDialog *dialog);
-static void spell_dialog_destroy_cb (GtkWidget *widget,
- EmpathySpellDialog *dialog);
-
-static void
-spell_dialog_model_populate_columns (EmpathySpellDialog *dialog)
-{
- GtkTreeModel *model;
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer;
- guint col_offset;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_words));
-
- renderer = gtk_cell_renderer_text_new ();
- col_offset = gtk_tree_view_insert_column_with_attributes (
- GTK_TREE_VIEW (dialog->treeview_words),
- -1, _("Word"),
- renderer,
- "text", COL_SPELL_WORD,
- NULL);
-
- g_object_set_data (G_OBJECT (renderer),
- "column", GINT_TO_POINTER (COL_SPELL_WORD));
-
- column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_words), col_offset - 1);
- gtk_tree_view_column_set_sort_column_id (column, COL_SPELL_WORD);
- gtk_tree_view_column_set_resizable (column, FALSE);
- gtk_tree_view_column_set_clickable (GTK_TREE_VIEW_COLUMN (column), TRUE);
-}
-
-static void
-spell_dialog_model_populate_suggestions (EmpathySpellDialog *dialog)
-{
- GtkTreeModel *model;
- GtkListStore *store;
- GList *suggestions, *l;
-
- model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->treeview_words));
- store = GTK_LIST_STORE (model);
-
- suggestions = empathy_spell_get_suggestions (dialog->word);
- for (l = suggestions; l; l=l->next) {
- GtkTreeIter iter;
- gchar *word;
-
- word = l->data;
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- COL_SPELL_WORD, word,
- -1);
- }
-
- empathy_spell_free_suggestions (suggestions);
-}
-
-static void
-spell_dialog_model_row_activated_cb (GtkTreeView *tree_view,
- GtkTreePath *path,
- GtkTreeViewColumn *column,
- EmpathySpellDialog *dialog)
-{
- spell_dialog_response_cb (dialog->window, GTK_RESPONSE_OK, dialog);
-}
-
-static void
-spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection,
- EmpathySpellDialog *dialog)
-{
- gint count;
-
- count = gtk_tree_selection_count_selected_rows (treeselection);
- gtk_widget_set_sensitive (dialog->button_replace, (count == 1));
-}
-
-static void
-spell_dialog_model_setup (EmpathySpellDialog *dialog)
-{
- GtkTreeView *view;
- GtkListStore *store;
- GtkTreeSelection *selection;
-
- view = GTK_TREE_VIEW (dialog->treeview_words);
-
- g_signal_connect (view, "row-activated",
- G_CALLBACK (spell_dialog_model_row_activated_cb),
- dialog);
-
- store = gtk_list_store_new (COL_SPELL_COUNT,
- G_TYPE_STRING); /* word */
-
- gtk_tree_view_set_model (view, GTK_TREE_MODEL (store));
-
- selection = gtk_tree_view_get_selection (view);
- gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-
- g_signal_connect (selection, "changed",
- G_CALLBACK (spell_dialog_model_selection_changed_cb),
- dialog);
-
- spell_dialog_model_populate_columns (dialog);
- spell_dialog_model_populate_suggestions (dialog);
-
- g_object_unref (store);
-}
-
-static void
-spell_dialog_destroy_cb (GtkWidget *widget,
- EmpathySpellDialog *dialog)
-{
- g_object_unref (dialog->chat);
- g_free (dialog->word);
-
- g_free (dialog);
-}
-
-static void
-spell_dialog_response_cb (GtkWidget *widget,
- gint response,
- EmpathySpellDialog *dialog)
-{
- if (response == GTK_RESPONSE_OK) {
- GtkTreeView *view;
- GtkTreeModel *model;
- GtkTreeSelection *selection;
- GtkTreeIter iter;
-
- gchar *new_word;
-
- view = GTK_TREE_VIEW (dialog->treeview_words);
- selection = gtk_tree_view_get_selection (view);
-
- if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
- return;
- }
-
- gtk_tree_model_get (model, &iter, COL_SPELL_WORD, &new_word, -1);
-
- empathy_chat_correct_word (dialog->chat,
- &dialog->start,
- &dialog->end,
- new_word);
-
- g_free (new_word);
- }
-
- gtk_widget_destroy (dialog->window);
-}
-
-void
-empathy_spell_dialog_show (EmpathyChat *chat,
- GtkTextIter *start,
- GtkTextIter *end,
- const gchar *word)
-{
- EmpathySpellDialog *dialog;
- GtkBuilder *gui;
- gchar *str;
- gchar *filename;
-
- g_return_if_fail (chat != NULL);
- g_return_if_fail (word != NULL);
-
- dialog = g_new0 (EmpathySpellDialog, 1);
-
- dialog->chat = g_object_ref (chat);
-
- dialog->word = g_strdup (word);
-
- dialog->start = *start;
- dialog->end = *end;
-
- filename = empathy_file_lookup ("empathy-spell-dialog.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "spell_dialog", &dialog->window,
- "button_replace", &dialog->button_replace,
- "label_word", &dialog->label_word,
- "treeview_words", &dialog->treeview_words,
- NULL);
- g_free (filename);
-
- empathy_builder_connect (gui, dialog,
- "spell_dialog", "response", spell_dialog_response_cb,
- "spell_dialog", "destroy", spell_dialog_destroy_cb,
- NULL);
-
- g_object_unref (gui);
-
- str = g_markup_printf_escaped ("%s:\n<b>%s</b>",
- _("Suggestions for the word"),
- word);
-
- gtk_label_set_markup (GTK_LABEL (dialog->label_word), str);
- g_free (str);
-
- spell_dialog_model_setup (dialog);
-
- gtk_widget_show (dialog->window);
-}
diff --git a/libempathy-gtk/empathy-spell-dialog.h b/libempathy-gtk/empathy-spell-dialog.h
deleted file mode 100644
index ce0218812..000000000
--- a/libempathy-gtk/empathy-spell-dialog.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2004-2007 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program 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
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- * Authors: Martyn Russell <martyn@imendio.com>
- * Richard Hult <richard@imendio.com>
- */
-
-#ifndef __EMPATHY_SPELL_DIALOG_H__
-#define __EMPATHY_SPELL_DIALOG_H__
-
-#include <gtk/gtktextiter.h>
-#include "empathy-chat.h"
-
-G_BEGIN_DECLS
-
-void empathy_spell_dialog_show (EmpathyChat *chat,
- GtkTextIter *start,
- GtkTextIter *end,
- const gchar *word);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_SPELL_DIALOG_H__ */
diff --git a/python/pyempathygtk/pyempathygtk.override b/python/pyempathygtk/pyempathygtk.override
index 1480cef66..3af554ec4 100644
--- a/python/pyempathygtk/pyempathygtk.override
+++ b/python/pyempathygtk/pyempathygtk.override
@@ -29,7 +29,6 @@ headers
#include "empathy-presence-chooser.h"
#include "empathy-profile-chooser.h"
#include "empathy-smiley-manager.h"
-#include "empathy-spell-dialog.h"
#include "empathy-spell.h"
#include "empathy-theme-boxes.h"
#include "empathy-theme-irc.h"
@@ -76,6 +75,5 @@ ignore
empathy_chat_correct_word
empathy_chat_view_set_margin
empathy_chat_get_view
- empathy_spell_dialog_show
empathy_window_iconify
%%