Commit 34816709 authored by Xavier Claessens's avatar Xavier Claessens Committed by Xavier Claessens

Adding spellcheck support.

2007-06-10 Xavier Claessens  <xclaesse@gmail.com>

	* libempathy-gtk/gossip-spell-dialog.glade:
	* libempathy-gtk/gossip-spell-dialog.c:
	* libempathy-gtk/gossip-spell-dialog.h:
	* libempathy-gtk/gossip-chat.c:
	* libempathy-gtk/Makefile.am:
	* configure.ac: Adding spellcheck support.

	* libempathy-gtk/gossip-spell.c:
	* libempathy/gossip-conf.c: Remove useless debug messages.


svn path=/trunk/; revision=144
parent 7011153c
2007-06-10 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/gossip-spell-dialog.glade:
* libempathy-gtk/gossip-spell-dialog.c:
* libempathy-gtk/gossip-spell-dialog.h:
* libempathy-gtk/gossip-chat.c:
* libempathy-gtk/Makefile.am:
* configure.ac: Adding spellcheck support.
* libempathy-gtk/gossip-spell.c:
* libempathy/gossip-conf.c: Remove useless debug messages.
2007-06-10 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/gossip-chat-view.c: Smooth scrolling.
......
......@@ -75,14 +75,52 @@ PKG_CHECK_MODULES(EMPATHY,
libgnomeui-2.0
])
PKG_CHECK_MODULES(MISSION_CONTROL_PLUGINS,
[
mission-control >= $MISSION_CONTROL_REQUIRED
glib-2.0 >= $GLIB_REQUIRED
gobject-2.0
dbus-glib-1
libtelepathy >= $TELEPATHY_REQUIRED
])
dnl -----------------------------------------------------------
dnl ISO codes, used for aspell support
dnl -----------------------------------------------------------
AC_MSG_CHECKING([whether iso-codes exists and has iso-639 domain])
if $PKG_CONFIG --variable=domains iso-codes | grep -q 639 ; then
AC_MSG_RESULT([yes])
iso_codes_prefix=`$PKG_CONFIG --variable=prefix iso-codes`
iso_codes_pkgconfig=iso-codes
have_iso_codes=yes
else
AC_MSG_RESULT([no])
iso_codes_prefix=
iso_codes_pkgconfig=
have_iso_codes=no
fi
AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["$iso_codes_prefix"],[ISO codes prefix])
dnl -----------------------------------------------------------
dnl ASpell
dnl -----------------------------------------------------------
AC_ARG_ENABLE(aspell,
AS_HELP_STRING([--enable-aspell=@<:@no/yes/auto@:>@],
[compile with aspell support]), ,
enable_aspell=auto)
if test "x$enable_aspell" = "xyes" -a "x$have_iso_codes" != "xyes"; then
AC_MSG_ERROR([You must have iso-codes with the iso-639 domain to use aspell.])
fi
if test "x$enable_aspell" != "xno" -a "x$have_iso_codes" = "xyes"; then
AC_CHECK_LIB(aspell, aspell_speller_check,have_aspell=yes,have_aspell=no,)
if test "x$have_aspell" = "xyes"; then
AC_DEFINE(HAVE_ASPELL, 1, [Define if we have aspell])
EMPATHY_LIBS="$EMPATHY_LIBS -laspell"
else
have_aspell=no
fi
else
have_aspell=no
fi
if test "x$enable_aspell" = "xyes" -a "x$have_aspell" != "xyes"; then
AC_MSG_ERROR([Couldn't find aspell.])
fi
dnl -----------------------------------------------------------
AC_OUTPUT([
......
......@@ -21,6 +21,7 @@ libempathy_gtk_la_SOURCES = \
gossip-cell-renderer-expander.c gossip-cell-renderer-expander.h \
gossip-cell-renderer-text.c gossip-cell-renderer-text.h \
gossip-spell.c gossip-spell.h \
gossip-spell-dialog.c gossip-spell-dialog.h \
gossip-contact-groups.c gossip-contact-groups.h \
gossip-contact-list-store.c gossip-contact-list-store.h \
gossip-contact-list-view.c gossip-contact-list-view.h \
......@@ -59,6 +60,7 @@ glade_DATA = \
gossip-new-chatroom-dialog.glade \
gossip-group-chat.glade \
gossip-chatrooms-window.glade \
gossip-spell-dialog.glade \
gossip-chat.glade
dtddir = $(datadir)/empathy
......
......@@ -47,7 +47,7 @@
#include "gossip-geometry.h"
#include "gossip-preferences.h"
#include "gossip-spell.h"
//#include "gossip-spell-dialog.h"
#include "gossip-spell-dialog.h"
#include "gossip-ui-utils.h"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GOSSIP_TYPE_CHAT, GossipChatPriv))
......@@ -936,10 +936,10 @@ static void
chat_text_check_word_spelling_cb (GtkMenuItem *menuitem,
GossipChatSpell *chat_spell)
{
/*FIXME: gossip_spell_dialog_show (chat_spell->chat,
gossip_spell_dialog_show (chat_spell->chat,
chat_spell->start,
chat_spell->end,
chat_spell->word);*/
chat_spell->word);
}
static GossipChatSpell *
......
/* -*- 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.h>
#include <gtk/gtkcellrenderertext.h>
#include <gtk/gtkdialog.h>
#include <gtk/gtklabel.h>
#include <gtk/gtkliststore.h>
#include <gtk/gtktreeview.h>
#include <gtk/gtktreeselection.h>
#include <gtk/gtksizegroup.h>
#include <glade/glade.h>
#include "gossip-chat.h"
#include "gossip-spell-dialog.h"
#include "gossip-ui-utils.h"
typedef struct {
GtkWidget *window;
GtkWidget *button_replace;
GtkWidget *label_word;
GtkWidget *treeview_words;
GossipChat *chat;
gchar *word;
GtkTextIter start;
GtkTextIter end;
} GossipSpellDialog;
enum {
COL_SPELL_WORD,
COL_SPELL_COUNT
};
static void spell_dialog_model_populate_columns (GossipSpellDialog *dialog);
static void spell_dialog_model_populate_suggestions (GossipSpellDialog *dialog);
static void spell_dialog_model_row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
GossipSpellDialog *dialog);
static void spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection,
GossipSpellDialog *dialog);
static void spell_dialog_model_setup (GossipSpellDialog *dialog);
static void spell_dialog_response_cb (GtkWidget *widget,
gint response,
GossipSpellDialog *dialog);
static void spell_dialog_destroy_cb (GtkWidget *widget,
GossipSpellDialog *dialog);
static void
spell_dialog_model_populate_columns (GossipSpellDialog *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 (GossipSpellDialog *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 = gossip_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);
}
gossip_spell_free_suggestions (suggestions);
}
static void
spell_dialog_model_row_activated_cb (GtkTreeView *tree_view,
GtkTreePath *path,
GtkTreeViewColumn *column,
GossipSpellDialog *dialog)
{
spell_dialog_response_cb (dialog->window, GTK_RESPONSE_OK, dialog);
}
static void
spell_dialog_model_selection_changed_cb (GtkTreeSelection *treeselection,
GossipSpellDialog *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 (GossipSpellDialog *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,
GossipSpellDialog *dialog)
{
g_object_unref (dialog->chat);
g_free (dialog->word);
g_free (dialog);
}
static void
spell_dialog_response_cb (GtkWidget *widget,
gint response,
GossipSpellDialog *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);
gossip_chat_correct_word (dialog->chat,
dialog->start,
dialog->end,
new_word);
g_free (new_word);
}
gtk_widget_destroy (dialog->window);
}
void
gossip_spell_dialog_show (GossipChat *chat,
GtkTextIter start,
GtkTextIter end,
const gchar *word)
{
GossipSpellDialog *dialog;
GladeXML *gui;
gchar *str;
g_return_if_fail (chat != NULL);
g_return_if_fail (word != NULL);
dialog = g_new0 (GossipSpellDialog, 1);
dialog->chat = g_object_ref (chat);
dialog->word = g_strdup (word);
dialog->start = start;
dialog->end = end;
gui = gossip_glade_get_file ("gossip-spell-dialog.glade",
"spell_dialog",
NULL,
"spell_dialog", &dialog->window,
"button_replace", &dialog->button_replace,
"label_word", &dialog->label_word,
"treeview_words", &dialog->treeview_words,
NULL);
gossip_glade_connect (gui,
dialog,
"spell_dialog", "response", spell_dialog_response_cb,
"spell_dialog", "destroy", spell_dialog_destroy_cb,
NULL);
g_object_unref (gui);
str = g_strdup_printf ("%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);
}
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkDialog" id="spell_dialog">
<property name="border_width">5</property>
<property name="title" translatable="yes">Spell Checker</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="modal">True</property>
<property name="default_width">275</property>
<property name="default_height">225</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox7">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area7">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button_cancel">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button_replace">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<child>
<widget class="GtkAlignment" id="alignment6">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox135">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image245">
<property name="visible">True</property>
<property name="stock">gtk-convert</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label594">
<property name="visible">True</property>
<property name="label">_Replace</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox128">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="label_word">
<property name="visible">True</property>
<property name="label" translatable="yes">Suggestions for the word:</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow9">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_words">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
/* -*- 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 __GOSSIP_SPELL_DIALOG_H__
#define __GOSSIP_SPELL_DIALOG_H__
#include <gtk/gtktextiter.h>
#include "gossip-chat.h"
G_BEGIN_DECLS
void gossip_spell_dialog_show (GossipChat *chat,
GtkTextIter start,
GtkTextIter end,
const gchar *word);
G_END_DECLS
#endif /* __GOSSIP_SPELL_DIALOG_H__ */
......@@ -204,7 +204,6 @@ spell_setup_languages (void)
}
if (languages) {
gossip_debug (DEBUG_DOMAIN, "No languages to setup");
return;
}
......@@ -393,8 +392,6 @@ gossip_spell_supported (void)
return FALSE;
}
gossip_debug (DEBUG_DOMAIN, "Support enabled");
return TRUE;
}
......@@ -403,8 +400,6 @@ gossip_spell_supported (void)
gboolean
gossip_spell_supported (void)
{
gossip_debug (DEBUG_DOMAIN, "Support disabled");
return FALSE;
}
......
......@@ -159,9 +159,6 @@ gossip_conf_get_int (GossipConf *conf,
key,
&error);
gossip_debug (DEBUG_DOMAIN, "Getting int:'%s' (=%d), error:'%s'",
key, *value, error ? error->message : "None");
if (error) {
g_error_free (error);
return FALSE;
......@@ -209,10 +206,6 @@ gossip_conf_get_bool (GossipConf *conf,
key,
&error);
gossip_debug (DEBUG_DOMAIN, "Getting bool:'%s' (=%d ---> %s), error:'%s'",
key, *value, *value ? "true" : "false",
error ? error->message : "None");
if (error) {
g_error_free (error);
return FALSE;
......@@ -259,9 +252,6 @@ gossip_conf_get_string (GossipConf *conf,
key,
&error);
gossip_debug (DEBUG_DOMAIN, "Getting string:'%s' (='%s'), error:'%s'",
key, *value, error ? error->message : "None");
if (error) {
g_error_free (error);
return FALSE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment