*
* @Copyright (C) 2004-2006 Christian Hammond.
* Some of this code is from gtkspell, Copyright (C) 2002 Evan Martin.
- * Adapted for Claws Mail (c) 2009 Pawel Pekala and the Claws Mail team
+ * Adapted for Claws Mail (c) 2009-2011 Pawel Pekala and the Claws Mail team
*
* 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
#include "prefs_common.h"
#include "codeconv.h"
#include "defs.h"
+#include "gtkutils.h"
static void claws_spell_entry_init (ClawsSpellEntry *entry);
static void claws_spell_entry_editable_init (GtkEditableClass *iface);
static void claws_spell_entry_finalize (GObject *object);
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void claws_spell_entry_destroy (GtkObject *object);
static gint claws_spell_entry_expose (GtkWidget *widget,
GdkEventExpose *event);
+#else
+static void claws_spell_entry_destroy (GtkWidget *object);
+static gint claws_spell_entry_expose (GtkWidget *widget,
+ cairo_t *cr);
+#endif
static gint claws_spell_entry_button_press (GtkWidget *widget,
GdkEventButton *event);
static gboolean claws_spell_entry_popup_menu (GtkWidget *widget,
static void claws_spell_entry_class_init(ClawsSpellEntryClass *klass)
{
GObjectClass *g_object_class;
+#if !GTK_CHECK_VERSION(3, 0, 0)
GtkObjectClass *gtk_object_class;
+#endif
GtkWidgetClass *widget_class;
parent_class = g_type_class_peek_parent(klass);
g_object_class = G_OBJECT_CLASS(klass);
g_object_class->finalize = claws_spell_entry_finalize;
+#if !GTK_CHECK_VERSION(3, 0, 0)
gtk_object_class = GTK_OBJECT_CLASS(klass);
gtk_object_class->destroy = claws_spell_entry_destroy;
+#endif
widget_class = GTK_WIDGET_CLASS(klass);
- widget_class->expose_event = claws_spell_entry_expose;
widget_class->button_press_event = claws_spell_entry_button_press;
+#if !GTK_CHECK_VERSION(3, 0, 0)
+ widget_class->expose_event = claws_spell_entry_expose;
+#else
+ widget_class->draw = claws_spell_entry_expose;
+ widget_class->destroy = claws_spell_entry_destroy;
+#endif
g_type_class_add_private(g_object_class,
sizeof(struct _ClawsSpellEntryPriv));
G_OBJECT_CLASS(parent_class)->finalize(object);
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void claws_spell_entry_destroy(GtkObject *object)
{
GTK_OBJECT_CLASS(parent_class)->destroy(object);
}
+#else
+static void claws_spell_entry_destroy(GtkWidget *object)
+{
+ GTK_WIDGET_CLASS(parent_class)->destroy(object);
+}
+#endif
GtkWidget *claws_spell_entry_new(void)
{
void claws_spell_entry_set_gtkaspell(ClawsSpellEntry *entry, GtkAspell *gtkaspell)
{
cm_return_if_fail(CLAWS_IS_SPELL_ENTRY(entry));
- cm_return_if_fail(gtkaspell != NULL);
entry->gtkaspell = gtkaspell;
}
gboolean ret;
word = get_word(entry, start, end);
- if (word == NULL)
+ if (word == NULL || g_unichar_isdigit(word[0]))
return FALSE;
ret = gtkaspell_misspelled_test(entry->gtkaspell, word);
return ret;
}
+static gboolean is_word_end (GtkEntry *entry, const int offset)
+{
+ gchar *p = gtk_editable_get_chars(GTK_EDITABLE(entry), offset, offset+1);
+ gunichar ch;
+
+ ch = g_utf8_get_char(p);
+ g_free(p);
+
+ if (ch == '\0')
+ return TRUE;
+
+ if (ch == '\'') {
+ p = gtk_editable_get_chars(GTK_EDITABLE(entry), offset+1, offset+2);
+ ch = g_utf8_get_char(p);
+ g_free(p);
+
+ return (g_unichar_isspace(ch) || g_unichar_ispunct(ch)
+ || g_unichar_isdigit(ch));
+ }
+
+ return (g_unichar_isspace(ch) || g_unichar_ispunct(ch));
+}
+
static void entry_strsplit_utf8(GtkEntry *entry, gchar ***set, gint **starts, gint **ends)
{
PangoLayout *layout;
/* Find the end of this string */
cend = i;
- while (!(log_attrs[cend].is_word_end))
+ while (!is_word_end(entry, cend))
cend++;
/* Copy sub-string */
layout = gtk_entry_get_layout(GTK_ENTRY(entry));
pango_layout_set_attributes(layout, entry->priv->attr_list);
- if (GTK_WIDGET_REALIZED(GTK_WIDGET(entry))) {
+ if (gtkut_widget_get_realized(GTK_WIDGET(entry))) {
rect.x = 0; rect.y = 0;
rect.width = GTK_WIDGET(entry)->allocation.width;
rect.height = GTK_WIDGET(entry)->allocation.height;
}
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
static gint claws_spell_entry_expose(GtkWidget *widget, GdkEventExpose *event)
+#else
+static gint claws_spell_entry_expose(GtkWidget *widget, cairo_t *cr)
+#endif
{
ClawsSpellEntry *entry = CLAWS_SPELL_ENTRY(widget);
GtkEntry *gtk_entry = GTK_ENTRY(widget);
pango_layout_set_attributes(layout, entry->priv->attr_list);
}
+#if !GTK_CHECK_VERSION(3, 0, 0)
return GTK_WIDGET_CLASS(parent_class)->expose_event (widget, event);
+#else
+ return GTK_WIDGET_CLASS(parent_class)->draw (widget, cr);
+#endif
}
static gint claws_spell_entry_button_press(GtkWidget *widget, GdkEventButton *event)