summaryrefslogtreecommitdiffstats
path: root/input-methods/sulekha/src
diff options
context:
space:
mode:
Diffstat (limited to 'input-methods/sulekha/src')
-rw-r--r--input-methods/sulekha/src/Makefile4
-rw-r--r--input-methods/sulekha/src/Makefile.am4
-rw-r--r--input-methods/sulekha/src/Makefile.am~2
-rw-r--r--input-methods/sulekha/src/Makefile.in4
-rw-r--r--input-methods/sulekha/src/sulekha.c285
-rw-r--r--input-methods/sulekha/src/sulekha.c~284
-rw-r--r--input-methods/sulekha/src/sulekhaspell.c256
-rw-r--r--input-methods/sulekha/src/sulekhaspell.c~361
-rw-r--r--input-methods/sulekha/src/trans.c231
-rw-r--r--input-methods/sulekha/src/trans.c~8
-rw-r--r--input-methods/sulekha/src/transliteration.c8
-rw-r--r--input-methods/sulekha/src/transliteration.c~8
12 files changed, 742 insertions, 713 deletions
diff --git a/input-methods/sulekha/src/Makefile b/input-methods/sulekha/src/Makefile
index 1ea073a..4d5cb39 100644
--- a/input-methods/sulekha/src/Makefile
+++ b/input-methods/sulekha/src/Makefile
@@ -151,9 +151,9 @@ sysconfdir = ${prefix}/etc
target_alias =
top_builddir = ..
top_srcdir = ..
-AM_CFLAGS = @GTKSPELL_CFLAGS@ -laspell
+AM_CFLAGS = -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -laspell
INCLUDES = -I$(top_srcdir)
-LDADD = @GTKSPELL_LIBS@
+LDADD = -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
sulekha_SOURCES = sulekha.c sulekhaspell.c sulekhaspell.h transliteration.c transliteration.h
all: all-am
diff --git a/input-methods/sulekha/src/Makefile.am b/input-methods/sulekha/src/Makefile.am
index 3039d02..68e3dd1 100644
--- a/input-methods/sulekha/src/Makefile.am
+++ b/input-methods/sulekha/src/Makefile.am
@@ -1,7 +1,7 @@
noinst_PROGRAMS = sulekha
-AM_CFLAGS = @GTKSPELL_CFLAGS@ -laspell
+AM_CFLAGS = @SULEKHA_CFLAGS@ -laspell
INCLUDES = -I$(top_srcdir)
-LDADD = @GTKSPELL_LIBS@
+LDADD = @SULEKHA_LIBS@
sulekha_SOURCES =sulekha.c sulekhaspell.c sulekhaspell.h transliteration.c transliteration.h
diff --git a/input-methods/sulekha/src/Makefile.am~ b/input-methods/sulekha/src/Makefile.am~
index 820c2b8..3039d02 100644
--- a/input-methods/sulekha/src/Makefile.am~
+++ b/input-methods/sulekha/src/Makefile.am~
@@ -1,5 +1,5 @@
noinst_PROGRAMS = sulekha
-AM_CFLAGS = @GTKSPELL_CFLAGS@ -I/usr/local/include/gtkspell-2.0/ -laspell
+AM_CFLAGS = @GTKSPELL_CFLAGS@ -laspell
INCLUDES = -I$(top_srcdir)
LDADD = @GTKSPELL_LIBS@
sulekha_SOURCES =sulekha.c sulekhaspell.c sulekhaspell.h transliteration.c transliteration.h
diff --git a/input-methods/sulekha/src/Makefile.in b/input-methods/sulekha/src/Makefile.in
index 9ac8814..89f5cb8 100644
--- a/input-methods/sulekha/src/Makefile.in
+++ b/input-methods/sulekha/src/Makefile.in
@@ -151,9 +151,9 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AM_CFLAGS = @GTKSPELL_CFLAGS@ -laspell
+AM_CFLAGS = @SULEKHA_CFLAGS@ -laspell
INCLUDES = -I$(top_srcdir)
-LDADD = @GTKSPELL_LIBS@
+LDADD = @SULEKHA_LIBS@
sulekha_SOURCES = sulekha.c sulekhaspell.c sulekhaspell.h transliteration.c transliteration.h
all: all-am
diff --git a/input-methods/sulekha/src/sulekha.c b/input-methods/sulekha/src/sulekha.c
index 93b4fbf..31eabea 100644
--- a/input-methods/sulekha/src/sulekha.c
+++ b/input-methods/sulekha/src/sulekha.c
@@ -24,7 +24,8 @@
#include "../config.h"
#include "sulekhaspell.h"
-const char *langs[] = { "ml", "en_US", "de_DE", "ja_JP", NULL };
+const char *langs[] =
+ { "ml", "hi", "kn", "or", "ta", "en_US", "de_DE", "ja_JP", NULL };
GtkWidget *window, *languagelist, *attached, *view;
@@ -52,18 +53,14 @@ activate_action (GtkAction * action)
}
-static void
-activate_email (GtkAboutDialog *about,
- const gchar *link,
- gpointer data)
+static void
+activate_email (GtkAboutDialog * about, const gchar * link, gpointer data)
{
g_print ("send mail to %s\n", link);
}
-static void
-activate_url (GtkAboutDialog *about,
- const gchar *link,
- gpointer data)
+static void
+activate_url (GtkAboutDialog * about, const gchar * link, gpointer data)
{
g_print ("show url %s\n", link);
}
@@ -74,21 +71,21 @@ about (GtkAction * action, GtkWidget * window)
gchar *filename;
const gchar *authors[] = {
- "Santhosh Thottongal",
- "Praveen Arimbrathodiyil",
+ "Santhosh Thottongal <santhosh00@gmail.com>",
+ "Praveen Arimbrathodiyil <pravi.a@gmail.com>",
NULL
};
const gchar *documentors[] = {
- "Santhosh Thottongal",
- "Praveen Arimbrathodiyil",
+ "Santhosh Thottongal <santhosh00@gmail.com>",
+ "Praveen Arimbrathodiyil <pravi.a@gmail.com>",
NULL
};
const gchar *license =
"This library is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU Library General Public License as\n"
- "published by the Free Software Foundation; either version 2 of the\n"
+ "published by the Free Software Foundation; either version 3 of the\n"
"License, or (at your option) any later version.\n"
"\n"
"This library is distributed in the hope that it will be useful,\n"
@@ -101,8 +98,8 @@ about (GtkAction * action, GtkWidget * window)
"write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n"
"Boston, MA 02111-1307, USA.\n";
- // gtk_about_dialog_set_email_hook (activate_email, NULL, NULL);
- //gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
+ gtk_about_dialog_set_email_hook (activate_email, NULL, NULL);
+ gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
gtk_show_about_dialog (GTK_WINDOW (window),
"name", "Sulekha",
"version", PACKAGE_VERSION,
@@ -116,100 +113,99 @@ about (GtkAction * action, GtkWidget * window)
//g_object_unref (transparent);
}
static GtkActionEntry entries[] = {
- { "FileMenu", NULL, "_File" }, /* name, stock id, label */
- { "EditMenu", NULL, "_Edit" }, /* name, stock id, label */
- { "OptionsMenu", NULL, "_Options" }, /* name, stock id, label */
- { "HelpMenu", NULL, "_Help" }, /* name, stock id, label */
- { "New", GTK_STOCK_NEW, /* name, stock id */
- "_New", "<control>N", /* label, accelerator */
- "Create a new file", /* tooltip */
- G_CALLBACK (activate_action) },
- { "Open", GTK_STOCK_OPEN, /* name, stock id */
- "_Open","<control>O", /* label, accelerator */
- "Open a file", /* tooltip */
- G_CALLBACK (activate_action ) },
- { "Save", GTK_STOCK_SAVE, /* name, stock id */
- "_Save","<control>S", /* label, accelerator */
- "Save current file", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SaveAs", GTK_STOCK_SAVE, /* name, stock id */
- "Save _As...", NULL, /* label, accelerator */
- "Save to a file", /* tooltip */
- G_CALLBACK (activate_action) },
- { "ClearSessionDictionary", NULL, /* name, stock id */
- "Clear Session Dictionary", NULL, /* label, accelerator */
- "Clear Session Dictionary", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SynchronizeDictionaries", NULL, /* name, stock id */
- "Synchronize Dictionaries", NULL, /* label, accelerator */
- "Synchronize Dictionaries", /* tooltip */
- G_CALLBACK (activate_action) },
- { "Quit", GTK_STOCK_QUIT, /* name, stock id */
- "_Quit", "<control>Q", /* label, accelerator */
- "Quit", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SelectAll", NULL, /* name, stock id */
- "Select _All", "<control>A", /* label, accelerator */
- "Select All", /* tooltip */
- G_CALLBACK (activate_action) },
- { "ClearAll", NULL, /* name, stock id */
- "Clear All", "<control>C", /* label, accelerator */
- "Clear All", /* tooltip */
- G_CALLBACK (activate_action) },
- { "PasePrimary", NULL, /* name, stock id */
- "Pase Primary", "<control>V", /* label, accelerator */
- "Pase Primary", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SaveDictionariesonExit", NULL, /* name, stock id */
- "Save Dictionaries on Exit", "<control>V", /* label, accelerator */
- "Save Dictionaries on Exit", /* tooltip */
- G_CALLBACK (activate_action) },
- { "About", GTK_STOCK_ABOUT, /* name, stock id */
- "_About", "<control>B", /* label, accelerator */
- "About", /* tooltip */
- G_CALLBACK (about) },
- { "Logo", "demo-gtk-logo", /* name, stock id */
- NULL, NULL, /* label, accelerator */
- "GTK+", /* tooltip */
- G_CALLBACK (activate_action) },
- };
- static guint n_entries = G_N_ELEMENTS (entries);
-
-
- static const gchar *ui_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <menu action='FileMenu'>"
- " <menuitem action='New'/>"
- " <menuitem action='Open'/>"
- " <menuitem action='Save'/>"
- " <menuitem action='SaveAs'/>"
- " <separator/>"
- " <menuitem action='ClearSessionDictionary'/>"
- " <menuitem action='SynchronizeDictionaries'/>"
- " <separator/>"
- " <menuitem action='Quit'/>"
- " </menu>"
-
- " <menu action='EditMenu'>"
- " <menuitem action='SelectAll'/>"
- " <menuitem action='ClearAll'/>"
- " <menuitem action='PasePrimary'/>"
- " </menu>"
- " <menu action='OptionsMenu'>"
- " <menuitem action='SaveDictionariesonExit'/>"
- " </menu>"
- " <menu action='HelpMenu'>"
- " <menuitem action='About'/>"
- " </menu>"
- " </menubar>"
- " <toolbar name='ToolBar'>"
- " <toolitem action='Open'/>"
- " <toolitem action='Quit'/>"
- " <separator action='Sep1'/>"
- " <toolitem action='Logo'/>"
- " </toolbar>"
- "</ui>";
+ {"FileMenu", NULL, "_File"}, /* name, stock id, label */
+ {"EditMenu", NULL, "_Edit"}, /* name, stock id, label */
+ {"OptionsMenu", NULL, "_Options"}, /* name, stock id, label */
+ {"HelpMenu", NULL, "_Help"}, /* name, stock id, label */
+ {"New", GTK_STOCK_NEW, /* name, stock id */
+ "_New", "<control>N", /* label, accelerator */
+ "Create a new file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"Open", GTK_STOCK_OPEN, /* name, stock id */
+ "_Open", "<control>O", /* label, accelerator */
+ "Open a file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"Save", GTK_STOCK_SAVE, /* name, stock id */
+ "_Save", "<control>S", /* label, accelerator */
+ "Save current file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SaveAs", GTK_STOCK_SAVE, /* name, stock id */
+ "Save _As...", NULL, /* label, accelerator */
+ "Save to a file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"ClearSessionDictionary", NULL, /* name, stock id */
+ "Clear Session Dictionary", NULL, /* label, accelerator */
+ "Clear Session Dictionary", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SynchronizeDictionaries", NULL, /* name, stock id */
+ "Synchronize Dictionaries", NULL, /* label, accelerator */
+ "Synchronize Dictionaries", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"Quit", GTK_STOCK_QUIT, /* name, stock id */
+ "_Quit", "<control>Q", /* label, accelerator */
+ "Quit", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SelectAll", NULL, /* name, stock id */
+ "Select _All", "<control>A", /* label, accelerator */
+ "Select All", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"ClearAll", NULL, /* name, stock id */
+ "Clear All", "<control>C", /* label, accelerator */
+ "Clear All", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"Paste", NULL, /* name, stock id */
+ "Paste", "<control>V", /* label, accelerator */
+ "Paste", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SaveDictionariesonExit", NULL, /* name, stock id */
+ "Save Dictionaries on Exit", "<control>V", /* label, accelerator */
+ "Save Dictionaries on Exit", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"About", GTK_STOCK_ABOUT, /* name, stock id */
+ "_About", "<control>B", /* label, accelerator */
+ "About", /* tooltip */
+ G_CALLBACK (about)},
+ {"Logo", "demo-gtk-logo", /* name, stock id */
+ NULL, NULL, /* label, accelerator */
+ "GTK+", /* tooltip */
+ G_CALLBACK (activate_action)},
+};
+static guint n_entries = G_N_ELEMENTS (entries);
+
+
+static const gchar *ui_info =
+ "<ui>"
+ " <menubar name='MenuBar'>"
+ " <menu action='FileMenu'>"
+ " <menuitem action='New'/>"
+ " <menuitem action='Open'/>"
+ " <menuitem action='Save'/>"
+ " <menuitem action='SaveAs'/>"
+ " <separator/>"
+ " <menuitem action='ClearSessionDictionary'/>"
+ " <menuitem action='SynchronizeDictionaries'/>"
+ " <separator/>"
+ " <menuitem action='Quit'/>"
+ " </menu>"
+ " <menu action='EditMenu'>"
+ " <menuitem action='SelectAll'/>"
+ " <menuitem action='ClearAll'/>"
+ " <menuitem action='Paste'/>"
+ " </menu>"
+ " <menu action='OptionsMenu'>"
+ " <menuitem action='SaveDictionariesonExit'/>"
+ " </menu>"
+ " <menu action='HelpMenu'>"
+ " <menuitem action='About'/>"
+ " </menu>"
+ " </menubar>"
+ " <toolbar name='ToolBar'>"
+ " <toolitem action='New'/>"
+ " <toolitem action='Open'/>"
+ " <toolitem action='Save'/>"
+ " <toolitem action='Quit'/>"
+ " <separator action='Sep1'/>"
+ " <toolitem action='Logo'/>" " </toolbar>" "</ui>";
static void
@@ -295,15 +291,15 @@ int
main (int argc, char *argv[])
{
GtkWidget *box, *hbox, *scroll;
- GtkUIManager *ui;
- GtkActionGroup *actions;
- GtkWidget *menu;
- GtkWidget *menuitem;
- GtkWidget *sw;
- GtkWidget *menubar;
- GtkWidget *menubox;
- GError *error = NULL;
-
+ GtkUIManager *ui;
+ GtkActionGroup *actions;
+ GtkWidget *menu;
+ GtkWidget *menuitem;
+ GtkWidget *sw;
+ GtkWidget *menubar;
+ GtkWidget *menubox;
+ GError *error = NULL;
+ GtkWidget *label;
if (argc > 1)
{
printf ("%s-->%s\n", argv[1],
@@ -314,29 +310,34 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- actions = gtk_action_group_new ("Actions");
- gtk_action_group_add_actions (actions, entries, n_entries, NULL);
- ui = gtk_ui_manager_new ();
- gtk_ui_manager_insert_action_group (ui, actions, 0);
- g_object_unref (actions);
- gtk_window_add_accel_group (GTK_WINDOW (window),
- gtk_ui_manager_get_accel_group (ui));
+ actions = gtk_action_group_new ("Actions");
+ gtk_action_group_add_actions (actions, entries, n_entries, NULL);
+ ui = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (ui, actions, 0);
+ g_object_unref (actions);
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ gtk_ui_manager_get_accel_group (ui));
- if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
- {
- g_message ("building menus failed: %s", error->message);
- g_error_free (error);
- }
- menubox = gtk_vbox_new (FALSE, 0);
-// gtk_container_add (GTK_CONTAINER (box), menubox);
- gtk_widget_show (menubox);
+ if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
+ {
+ g_message ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+ menubox = gtk_vbox_new (FALSE, 0);
+ menubar = gtk_vbox_new (FALSE, 0);
+// gtk_container_add (GTK_CONTAINER (box), menubox);
+ gtk_widget_show (menubox);
// gtk_container_add (GTK_CONTAINER (box), box1);
- gtk_box_pack_start (GTK_BOX (menubox), gtk_ui_manager_get_widget (ui, "/MenuBar"),
- FALSE, FALSE, 0);
-
+ gtk_box_pack_start (GTK_BOX (menubox),
+ gtk_ui_manager_get_widget (ui, "/MenuBar"), FALSE,
+ FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (menubar),
+ gtk_ui_manager_get_widget (ui, "/ToolBar"), FALSE,
+ FALSE, 0);
+
view = gtk_text_view_new ();
@@ -352,19 +353,20 @@ main (int argc, char *argv[])
build_languagelist ();
hbox = gtk_hbox_new (FALSE, 5);
+ label = gtk_label_new ("Languages");
attached = gtk_toggle_button_new_with_label ("Attached");
g_signal_connect (G_OBJECT (attached), "toggled",
G_CALLBACK (attach_cb), NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (attached), TRUE);
gtk_box_pack_start (GTK_BOX (hbox), attached, FALSE, FALSE, 0);
-
gtk_box_pack_end (GTK_BOX (hbox), languagelist, FALSE, FALSE, 0);
-
+ gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
box = gtk_vbox_new (FALSE, 5);
-gtk_box_pack_start (GTK_BOX (box), menubox,FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), menubox, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), menubar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
+
gtk_widget_show_all (box);
gtk_window_set_default_size (GTK_WINDOW (window), 1200, 800);
@@ -375,6 +377,7 @@ gtk_box_pack_start (GTK_BOX (box), menubox,FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show (window);
+ gtk_window_maximize (window);
gtk_main ();
return 0;
diff --git a/input-methods/sulekha/src/sulekha.c~ b/input-methods/sulekha/src/sulekha.c~
index c27d366..26d1342 100644
--- a/input-methods/sulekha/src/sulekha.c~
+++ b/input-methods/sulekha/src/sulekha.c~
@@ -2,6 +2,7 @@
*
* Copyright (C) 2007-2008
* Santhosh Thottingal<santhosh00@gmail.com>,
+ * Praveen Arimprathodiyil <pravi.a@gmail.com>
* Swathanthra Malayalam Computing.
*
* This program is free software; you can redistribute it and/or modify
@@ -23,7 +24,8 @@
#include "../config.h"
#include "sulekhaspell.h"
-const char *langs[] = { "ml", "en_US", "de_DE", "ja_JP", NULL };
+const char *langs[] =
+ { "ml", "hi", "kn", "or", "ta", "en_US", "de_DE", "ja_JP", NULL };
GtkWidget *window, *languagelist, *attached, *view;
@@ -51,18 +53,14 @@ activate_action (GtkAction * action)
}
-static void
-activate_email (GtkAboutDialog *about,
- const gchar *link,
- gpointer data)
+static void
+activate_email (GtkAboutDialog * about, const gchar * link, gpointer data)
{
g_print ("send mail to %s\n", link);
}
-static void
-activate_url (GtkAboutDialog *about,
- const gchar *link,
- gpointer data)
+static void
+activate_url (GtkAboutDialog * about, const gchar * link, gpointer data)
{
g_print ("show url %s\n", link);
}
@@ -73,21 +71,21 @@ about (GtkAction * action, GtkWidget * window)
gchar *filename;
const gchar *authors[] = {
- "Santhosh Thottongal",
- "Praveen Arimbrathodiyil",
+ "Santhosh Thottongal <santhosh00@gmail.com>",
+ "Praveen Arimbrathodiyil <pravi.a@gmail.com>",
NULL
};
const gchar *documentors[] = {
- "Santhosh Thottongal",
- "Praveen Arimbrathodiyil",
+ "Santhosh Thottongal <santhosh00@gmail.com>",
+ "Praveen Arimbrathodiyil <pravi.a@gmail.com>",
NULL
};
const gchar *license =
"This library is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU Library General Public License as\n"
- "published by the Free Software Foundation; either version 2 of the\n"
+ "published by the Free Software Foundation; either version 3 of the\n"
"License, or (at your option) any later version.\n"
"\n"
"This library is distributed in the hope that it will be useful,\n"
@@ -100,8 +98,8 @@ about (GtkAction * action, GtkWidget * window)
"write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n"
"Boston, MA 02111-1307, USA.\n";
- // gtk_about_dialog_set_email_hook (activate_email, NULL, NULL);
- //gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
+ gtk_about_dialog_set_email_hook (activate_email, NULL, NULL);
+ gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
gtk_show_about_dialog (GTK_WINDOW (window),
"name", "Sulekha",
"version", PACKAGE_VERSION,
@@ -115,100 +113,99 @@ about (GtkAction * action, GtkWidget * window)
//g_object_unref (transparent);
}
static GtkActionEntry entries[] = {
- { "FileMenu", NULL, "_File" }, /* name, stock id, label */
- { "EditMenu", NULL, "_Edit" }, /* name, stock id, label */
- { "OptionsMenu", NULL, "_Options" }, /* name, stock id, label */
- { "HelpMenu", NULL, "_Help" }, /* name, stock id, label */
- { "New", GTK_STOCK_NEW, /* name, stock id */
- "_New", "<control>N", /* label, accelerator */
- "Create a new file", /* tooltip */
- G_CALLBACK (activate_action) },
- { "Open", GTK_STOCK_OPEN, /* name, stock id */
- "_Open","<control>O", /* label, accelerator */
- "Open a file", /* tooltip */
- G_CALLBACK (activate_action ) },
- { "Save", GTK_STOCK_SAVE, /* name, stock id */
- "_Save","<control>S", /* label, accelerator */
- "Save current file", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SaveAs", GTK_STOCK_SAVE, /* name, stock id */
- "Save _As...", NULL, /* label, accelerator */
- "Save to a file", /* tooltip */
- G_CALLBACK (activate_action) },
- { "ClearSessionDictionary", NULL, /* name, stock id */
- "Clear Session Dictionary", NULL, /* label, accelerator */
- "Clear Session Dictionary", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SynchronizeDictionaries", NULL, /* name, stock id */
- "Synchronize Dictionaries", NULL, /* label, accelerator */
- "Synchronize Dictionaries", /* tooltip */
- G_CALLBACK (activate_action) },
- { "Quit", GTK_STOCK_QUIT, /* name, stock id */
- "_Quit", "<control>Q", /* label, accelerator */
- "Quit", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SelectAll", NULL, /* name, stock id */
- "Select _All", "<control>A", /* label, accelerator */
- "Select All", /* tooltip */
- G_CALLBACK (activate_action) },
- { "ClearAll", NULL, /* name, stock id */
- "Clear All", "<control>C", /* label, accelerator */
- "Clear All", /* tooltip */
- G_CALLBACK (activate_action) },
- { "PasePrimary", NULL, /* name, stock id */
- "Pase Primary", "<control>V", /* label, accelerator */
- "Pase Primary", /* tooltip */
- G_CALLBACK (activate_action) },
- { "SaveDictionariesonExit", NULL, /* name, stock id */
- "Save Dictionaries on Exit", "<control>V", /* label, accelerator */
- "Save Dictionaries on Exit", /* tooltip */
- G_CALLBACK (activate_action) },
- { "About", GTK_STOCK_ABOUT, /* name, stock id */
- "_About", "<control>B", /* label, accelerator */
- "About", /* tooltip */
- G_CALLBACK (about) },
- { "Logo", "demo-gtk-logo", /* name, stock id */
- NULL, NULL, /* label, accelerator */
- "GTK+", /* tooltip */
- G_CALLBACK (activate_action) },
- };
- static guint n_entries = G_N_ELEMENTS (entries);
-
-
- static const gchar *ui_info =
- "<ui>"
- " <menubar name='MenuBar'>"
- " <menu action='FileMenu'>"
- " <menuitem action='New'/>"
- " <menuitem action='Open'/>"
- " <menuitem action='Save'/>"
- " <menuitem action='SaveAs'/>"
- " <separator/>"
- " <menuitem action='ClearSessionDictionary'/>"
- " <menuitem action='SynchronizeDictionaries'/>"
- " <separator/>"
- " <menuitem action='Quit'/>"
- " </menu>"
-
- " <menu action='EditMenu'>"
- " <menuitem action='SelectAll'/>"
- " <menuitem action='ClearAll'/>"
- " <menuitem action='PasePrimary'/>"
- " </menu>"
- " <menu action='OptionsMenu'>"
- " <menuitem action='SaveDictionariesonExit'/>"
- " </menu>"
- " <menu action='HelpMenu'>"
- " <menuitem action='About'/>"
- " </menu>"
- " </menubar>"
- " <toolbar name='ToolBar'>"
- " <toolitem action='Open'/>"
- " <toolitem action='Quit'/>"
- " <separator action='Sep1'/>"
- " <toolitem action='Logo'/>"
- " </toolbar>"
- "</ui>";
+ {"FileMenu", NULL, "_File"}, /* name, stock id, label */
+ {"EditMenu", NULL, "_Edit"}, /* name, stock id, label */
+ {"OptionsMenu", NULL, "_Options"}, /* name, stock id, label */
+ {"HelpMenu", NULL, "_Help"}, /* name, stock id, label */
+ {"New", GTK_STOCK_NEW, /* name, stock id */
+ "_New", "<control>N", /* label, accelerator */
+ "Create a new file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"Open", GTK_STOCK_OPEN, /* name, stock id */
+ "_Open", "<control>O", /* label, accelerator */
+ "Open a file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"Save", GTK_STOCK_SAVE, /* name, stock id */
+ "_Save", "<control>S", /* label, accelerator */
+ "Save current file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SaveAs", GTK_STOCK_SAVE, /* name, stock id */
+ "Save _As...", NULL, /* label, accelerator */
+ "Save to a file", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"ClearSessionDictionary", NULL, /* name, stock id */
+ "Clear Session Dictionary", NULL, /* label, accelerator */
+ "Clear Session Dictionary", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SynchronizeDictionaries", NULL, /* name, stock id */
+ "Synchronize Dictionaries", NULL, /* label, accelerator */
+ "Synchronize Dictionaries", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"Quit", GTK_STOCK_QUIT, /* name, stock id */
+ "_Quit", "<control>Q", /* label, accelerator */
+ "Quit", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SelectAll", NULL, /* name, stock id */
+ "Select _All", "<control>A", /* label, accelerator */
+ "Select All", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"ClearAll", NULL, /* name, stock id */
+ "Clear All", "<control>C", /* label, accelerator */
+ "Clear All", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"PasePrimary", NULL, /* name, stock id */
+ "Pase Primary", "<control>V", /* label, accelerator */
+ "Pase Primary", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"SaveDictionariesonExit", NULL, /* name, stock id */
+ "Save Dictionaries on Exit", "<control>V", /* label, accelerator */
+ "Save Dictionaries on Exit", /* tooltip */
+ G_CALLBACK (activate_action)},
+ {"About", GTK_STOCK_ABOUT, /* name, stock id */
+ "_About", "<control>B", /* label, accelerator */
+ "About", /* tooltip */
+ G_CALLBACK (about)},
+ {"Logo", "demo-gtk-logo", /* name, stock id */
+ NULL, NULL, /* label, accelerator */
+ "GTK+", /* tooltip */
+ G_CALLBACK (activate_action)},
+};
+static guint n_entries = G_N_ELEMENTS (entries);
+
+
+static const gchar *ui_info =
+ "<ui>"
+ " <menubar name='MenuBar'>"
+ " <menu action='FileMenu'>"
+ " <menuitem action='New'/>"
+ " <menuitem action='Open'/>"
+ " <menuitem action='Save'/>"
+ " <menuitem action='SaveAs'/>"
+ " <separator/>"
+ " <menuitem action='ClearSessionDictionary'/>"
+ " <menuitem action='SynchronizeDictionaries'/>"
+ " <separator/>"
+ " <menuitem action='Quit'/>"
+ " </menu>"
+ " <menu action='EditMenu'>"
+ " <menuitem action='SelectAll'/>"
+ " <menuitem action='ClearAll'/>"
+ " <menuitem action='PasePrimary'/>"
+ " </menu>"
+ " <menu action='OptionsMenu'>"
+ " <menuitem action='SaveDictionariesonExit'/>"
+ " </menu>"
+ " <menu action='HelpMenu'>"
+ " <menuitem action='About'/>"
+ " </menu>"
+ " </menubar>"
+ " <toolbar name='ToolBar'>"
+ " <toolitem action='Open'/>"
+ " <toolitem action='Quit'/>"
+ " <separator action='Sep1'/>"
+ " <toolitem action='Logo'/>"
+ " </toolbar>"
+"</ui>";
static void
@@ -294,15 +291,15 @@ int
main (int argc, char *argv[])
{
GtkWidget *box, *hbox, *scroll;
- GtkUIManager *ui;
- GtkActionGroup *actions;
- GtkWidget *menu;
- GtkWidget *menuitem;
- GtkWidget *sw;
- GtkWidget *menubar;
- GtkWidget *menubox;
- GError *error = NULL;
-
+ GtkUIManager *ui;
+ GtkActionGroup *actions;
+ GtkWidget *menu;
+ GtkWidget *menuitem;
+ GtkWidget *sw;
+ GtkWidget *menubar;
+ GtkWidget *menubox;
+ GError *error = NULL;
+ GtkWidget *label;
if (argc > 1)
{
printf ("%s-->%s\n", argv[1],
@@ -313,28 +310,33 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- actions = gtk_action_group_new ("Actions");
- gtk_action_group_add_actions (actions, entries, n_entries, NULL);
- ui = gtk_ui_manager_new ();
- gtk_ui_manager_insert_action_group (ui, actions, 0);
- g_object_unref (actions);
- gtk_window_add_accel_group (GTK_WINDOW (window),
- gtk_ui_manager_get_accel_group (ui));
+ actions = gtk_action_group_new ("Actions");
+ gtk_action_group_add_actions (actions, entries, n_entries, NULL);
+ ui = gtk_ui_manager_new ();
+ gtk_ui_manager_insert_action_group (ui, actions, 0);
+ g_object_unref (actions);
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ gtk_ui_manager_get_accel_group (ui));
- if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
- {
- g_message ("building menus failed: %s", error->message);
- g_error_free (error);
- }
- menubox = gtk_vbox_new (FALSE, 0);
-// gtk_container_add (GTK_CONTAINER (box), menubox);
- gtk_widget_show (menubox);
+ if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, -1, &error))
+ {
+ g_message ("building menus failed: %s", error->message);
+ g_error_free (error);
+ }
+ menubox = gtk_vbox_new (FALSE, 0);
+menubar = gtk_vbox_new (FALSE, 0);
+// gtk_container_add (GTK_CONTAINER (box), menubox);
+ gtk_widget_show (menubox);
// gtk_container_add (GTK_CONTAINER (box), box1);
- gtk_box_pack_start (GTK_BOX (menubox), gtk_ui_manager_get_widget (ui, "/MenuBar"),
- FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (menubox),
+ gtk_ui_manager_get_widget (ui, "/MenuBar"), FALSE,
+ FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (menubar),
+ gtk_ui_manager_get_widget (ui, "/ToolBar"), FALSE,
+ FALSE, 0);
@@ -351,19 +353,20 @@ main (int argc, char *argv[])
build_languagelist ();
hbox = gtk_hbox_new (FALSE, 5);
+ label = gtk_label_new ("Languages");
attached = gtk_toggle_button_new_with_label ("Attached");
g_signal_connect (G_OBJECT (attached), "toggled",
G_CALLBACK (attach_cb), NULL);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (attached), TRUE);
gtk_box_pack_start (GTK_BOX (hbox), attached, FALSE, FALSE, 0);
-
gtk_box_pack_end (GTK_BOX (hbox), languagelist, FALSE, FALSE, 0);
-
+ gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
box = gtk_vbox_new (FALSE, 5);
-gtk_box_pack_start (GTK_BOX (box), menubox,FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (box), menubox, FALSE, FALSE, 0);
+gtk_box_pack_start (GTK_BOX (box), menubar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (box), scroll, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
-
+
gtk_widget_show_all (box);
gtk_window_set_default_size (GTK_WINDOW (window), 1200, 800);
@@ -374,6 +377,7 @@ gtk_box_pack_start (GTK_BOX (box), menubox,FALSE, FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show (window);
+ gtk_window_maximize(window) ;
gtk_main ();
return 0;
diff --git a/input-methods/sulekha/src/sulekhaspell.c b/input-methods/sulekha/src/sulekhaspell.c
index 58032f5..4ced302 100644
--- a/input-methods/sulekha/src/sulekhaspell.c
+++ b/input-methods/sulekha/src/sulekhaspell.c
@@ -64,8 +64,10 @@
#define aspell pspell
#endif
-const int debug = 0;
+const int debug = 1;
const int quiet = 0;
+int check = 1;
+int replace = 0;
struct _SulekhaSpell
{
@@ -79,6 +81,7 @@ struct _SulekhaSpell
};
static void sulekhaspell_free (SulekhaSpell * spell);
+static void replace_by_transliterated_word (SulekhaSpell * spell);
#define SULEKHASPELL_OBJECT_KEY "sulekhaspell"
@@ -153,16 +156,14 @@ check_word (SulekhaSpell * spell, GtkTextBuffer * buffer,
GtkTextIter * start, GtkTextIter * end)
{
char *text;
- char *oldword;
text = gtk_text_buffer_get_text (buffer, start, end, FALSE);
if (debug)
g_print ("checking: %s\n", text);
- g_print ("[santhosh]checking: %s\n", text);
text = transliterate_ml (text, 0, strlen (text));
- g_print ("[santhosh]After transliteration checking: %s\n", text);
if (g_unichar_isdigit (*text) == FALSE) /* don't check numbers */
if (aspell_speller_check (spell->speller, text, -1) == FALSE)
gtk_text_buffer_apply_tag (buffer, spell->tag_highlight, start, end);
+
g_free (text);
}
@@ -185,6 +186,7 @@ check_range (SulekhaSpell * spell, GtkTextBuffer * buffer,
GtkTextIter wstart, wend, cursor, precursor;
gboolean inword, highlight;
+
if (debug)
{
g_print ("check_range: ");
@@ -194,28 +196,39 @@ check_range (SulekhaSpell * spell, GtkTextBuffer * buffer,
}
-
+//inside word
if (gtk_text_iter_inside_word (&end))
- gtk_text_iter_forward_word_end (&end);
- if (!gtk_text_iter_starts_word (&start))
+ gtk_text_iter_forward_word_end (&end); //move the end to the end of the word
+//start of the word
+ if (!gtk_text_iter_starts_word (&start)) //not at the beginning of the word
{
- if (gtk_text_iter_inside_word (&start) ||
- gtk_text_iter_ends_word (&start))
+ if (gtk_text_iter_inside_word (&start)
+ || gtk_text_iter_ends_word (&start))
{
- gtk_text_iter_backward_word_start (&start);
+ gtk_text_iter_backward_word_start (&start); //move the start to the start of the word
}
else
{
/* if we're neither at the beginning nor inside a word,
* me must be in some spaces.
- * skip forward to the beginning of the next word. */
- //gtk_text_buffer_remove_tag(buffer, tag_highlight, &start, &end);
+ * skip forward to the beginning of the next word.
+ */
if (gtk_text_iter_forward_word_end (&start))
gtk_text_iter_backward_word_start (&start);
}
}
+ /*
+ * Now start is at the start of the word and end is at the end of the word
+ * Initializes iter with the current position of mark.
+ */
gtk_text_buffer_get_iter_at_mark (buffer, &cursor,
gtk_text_buffer_get_insert (buffer));
+/*gtk_text_buffer_get_insert: Returns the mark that represents the cursor (insertion point). Equivalent to calling
+ * gtk_text_buffer_get_mark() to get the mark named "insert",
+ * but very slightly more efficient, and involves less typing.
+ */
+
+
precursor = cursor;
gtk_text_iter_backward_char (&precursor);
@@ -250,6 +263,7 @@ check_range (SulekhaSpell * spell, GtkTextBuffer * buffer,
inword = (gtk_text_iter_compare (&wstart, &cursor) < 0) &&
(gtk_text_iter_compare (&cursor, &wend) <= 0);
+ //i.e start is before cursor and cursor is less than end--> cursor in between the word
if (inword && !force_all)
{
@@ -260,11 +274,14 @@ check_range (SulekhaSpell * spell, GtkTextBuffer * buffer,
check_word (spell, buffer, &wstart, &wend);
else
spell->deferred_check = TRUE;
+
}
- else
+ else //cursor at the end of the word. now check the spelling
{
+ g_print ("checking\n");
check_word (spell, buffer, &wstart, &wend);
spell->deferred_check = FALSE;
+
}
/* now move wend to the beginning of the next word, */
@@ -277,6 +294,7 @@ check_range (SulekhaSpell * spell, GtkTextBuffer * buffer,
/* and then pick this as the new next word beginning. */
wstart = wend;
}
+
}
static void
@@ -307,16 +325,38 @@ static void
insert_text_after (GtkTextBuffer * buffer, GtkTextIter * iter,
gchar * text, gint len, SulekhaSpell * spell)
{
- GtkTextIter start;
+ GtkTextIter start, end;
if (debug)
- g_print ("insert\n");
+ g_print ("insert %s\n", text );
+ /*-----------------------------------*/
+
+ if (!gtk_text_iter_ends_word (iter))
+ {
+ g_print ("ivideyaanu mone kali\n");
+
+ replace_by_transliterated_word (spell);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end, spell->mark_insert_end);
+ gtk_text_buffer_get_iter_at_mark (buffer, &start,
+ spell->mark_insert_start);
+
+
+ check_range (spell, buffer, start, end, FALSE);
+
+ // gtk_text_buffer_move_mark (buffer, spell->mark_insert_end, &end);
+ }
+/*-----------------------------------*/
+ else
+ {
+ /* we need to check a range of text. */
+ gtk_text_buffer_get_iter_at_mark (buffer, &start,
+ spell->mark_insert_start);
- /* we need to check a range of text. */
- gtk_text_buffer_get_iter_at_mark (buffer, &start, spell->mark_insert_start);
- check_range (spell, buffer, start, *iter, FALSE);
- gtk_text_buffer_move_mark (buffer, spell->mark_insert_end, iter);
+ check_range (spell, buffer, start, *iter, FALSE);
+
+ gtk_text_buffer_move_mark (buffer, spell->mark_insert_end, iter);
+ }
}
/* deleting is more simple: we're given the range of deleted text.
@@ -369,7 +409,7 @@ add_to_dictionary (GtkWidget * menuitem, SulekhaSpell * spell)
get_word_extents_from_mark (buffer, &start, &end, spell->mark_click);
word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
-
+ word = transliterate_ml (word, 0, strlen (word));
aspell_speller_add_to_personal (spell->speller, word, strlen (word));
aspell_speller_save_all_word_lists (spell->speller);
@@ -429,24 +469,99 @@ replace_word (GtkWidget * menuitem, SulekhaSpell * spell)
g_free (oldword);
}
-GtkWidget *
-build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
- const char *word)
+static void
+replace_by_transliterated_word (SulekhaSpell * spell)
{
- const char *suggestion;
- GtkWidget *topmenu, *menu;
- GtkWidget *mi;
- GtkWidget *hbox;
- int count = 0;
- void *spelldata;
+ char *oldword;
+ const char *newword;
+ GtkTextIter start, end;
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (spell->view);
+
+ get_word_extents_from_mark (buffer, &start, &end,spell->mark_insert_end);
+ oldword = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+ // newword = gtk_label_get_text (GTK_LABEL (GTK_BIN (menuitem)->child));
+ newword = transliterate_ml (oldword, 0, strlen (oldword));
+ // if (debug)
+ if (1)
+ {
+ g_print ("old word: '%s'\n", oldword);
+ print_iter ("s", &start);
+ print_iter ("e", &end);
+ g_print ("\nnew word: '%s'\n", newword);
+ }
+
+ gtk_text_buffer_delete (buffer, &start, &end);
+ gtk_text_buffer_insert (buffer, &start, newword, -1);
+
+
+ g_free (oldword);
+ g_print ("\nReplaced\n");
+}
+
+
+static void
+populate_popup (GtkTextView * textview, GtkMenu * menu, SulekhaSpell * spell)
+{
+ GtkWidget *img, *mi;
const AspellWordList *suggestions;
+ GtkWidget *topmenu;
AspellStringEnumeration *elements;
+ int count = 0;
char *label;
- //santhosh
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (textview);
+ GtkTextIter start, end;
+ char *word;
+ const char *suggestion;
+ topmenu = menu;
+ /* we need to figure out if they picked a misspelled word. */
+ get_word_extents_from_mark (buffer, &start, &end, spell->mark_click);
+
+ /* if our highlight algorithm ever messes up,
+ * this isn't correct, either. */
+ if (!gtk_text_iter_has_tag (&start, spell->tag_highlight))
+ return; /* word wasn't misspelled. */
+
+ /* menu separator comes first. */
+ mi = gtk_menu_item_new ();
+ gtk_widget_show (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
+
+ word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
+ /* - Ignore All */
+ mi = gtk_image_menu_item_new_with_label (_("Ignore All"));
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
+ gtk_image_new_from_stock (GTK_STOCK_REMOVE,
+ GTK_ICON_SIZE_MENU));
+ g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (ignore_all),
+ spell);
+ gtk_widget_show_all (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (topmenu), mi);
+
word = transliterate_ml (word, 0, strlen (word));
+/* + Add to Dictionary */
+ label = g_strdup_printf (_("Add \"%s\" to Dictionary"), word);
+ mi = gtk_image_menu_item_new_with_label (label);
+ g_free (label);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
+ gtk_image_new_from_stock (GTK_STOCK_ADD,
+ GTK_ICON_SIZE_MENU));
+ g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (add_to_dictionary),
+ spell);
+ gtk_widget_show_all (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (topmenu), mi);
+ /* menu separator comes first. */
+ mi = gtk_menu_item_new ();
+ gtk_widget_show (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
+ /* then, on top of it, the suggestions menu. */
+ img = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU);
+ mi = gtk_image_menu_item_new_with_label (_("Spelling Suggestions"));
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+
- //end santhosh
- topmenu = menu = gtk_menu_new ();
suggestions = aspell_speller_suggest (spell->speller, word, -1);
elements = aspell_word_list_elements (suggestions);
@@ -469,15 +584,15 @@ build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
/* build a set of menus with suggestions. */
while (suggestion != NULL)
{
- if (count == 10)
+ if (count == 5)
{
- mi = gtk_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+// mi = gtk_menu_item_new ();
+// gtk_widget_show (mi);
+// gtk_menu_shell_insert (GTK_MENU_SHELL (menu), mi,count+1);
mi = gtk_menu_item_new_with_label (_("More..."));
gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), mi, count + 1);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
@@ -487,7 +602,7 @@ build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
g_signal_connect (G_OBJECT (mi), "activate",
G_CALLBACK (replace_word), spell);
gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), mi, count);
count++;
suggestion = aspell_string_enumeration_next (elements);
}
@@ -495,72 +610,16 @@ build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
delete_aspell_string_enumeration (elements);
- /* Separator */
- mi = gtk_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- /* + Add to Dictionary */
- label = g_strdup_printf (_("Add \"%s\" to Dictionary"), word);
- mi = gtk_image_menu_item_new_with_label (label);
- g_free (label);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
- gtk_image_new_from_stock (GTK_STOCK_ADD,
- GTK_ICON_SIZE_MENU));
- g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (add_to_dictionary),
- spell);
- gtk_widget_show_all (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- /* - Ignore All */
- mi = gtk_image_menu_item_new_with_label (_("Ignore All"));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
- gtk_image_new_from_stock (GTK_STOCK_REMOVE,
- GTK_ICON_SIZE_MENU));
- g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (ignore_all),
- spell);
- gtk_widget_show_all (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- return topmenu;
-}
-
-static void
-populate_popup (GtkTextView * textview, GtkMenu * menu, SulekhaSpell * spell)
-{
- GtkWidget *img, *mi;
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (textview);
- GtkTextIter start, end;
- char *word;
-
- /* we need to figure out if they picked a misspelled word. */
- get_word_extents_from_mark (buffer, &start, &end, spell->mark_click);
-
- /* if our highlight algorithm ever messes up,
- * this isn't correct, either. */
- if (!gtk_text_iter_has_tag (&start, spell->tag_highlight))
- return; /* word wasn't misspelled. */
-
- /* menu separator comes first. */
- mi = gtk_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
-
- /* then, on top of it, the suggestions menu. */
- img = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU);
- mi = gtk_image_menu_item_new_with_label (_("Spelling Suggestions"));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
-
- word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi),
- build_suggestion_menu (spell, buffer, word));
g_free (word);
+
gtk_widget_show_all (mi);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
}
+
+
/* when the user right-clicks on a word, they want to check that word.
* here, we do NOT move the cursor to the location of the clicked-upon word
* since that prevents the use of edit functions on the context menu. */
@@ -627,6 +686,9 @@ sulekhaspell_set_language_internal (SulekhaSpell * spell, const gchar * lang,
if (lang)
aspell_config_replace (config, "language-tag", lang);
aspell_config_replace (config, "encoding", "utf-8");
+ //aspell_config_replace (config, "sug-edit-dist", "2");
+ aspell_config_replace (config, "sug-mode", "ultra");
+
err = new_aspell_speller (config);
delete_aspell_config (config);
diff --git a/input-methods/sulekha/src/sulekhaspell.c~ b/input-methods/sulekha/src/sulekhaspell.c~
index 143d989..9d9368e 100644
--- a/input-methods/sulekha/src/sulekhaspell.c~
+++ b/input-methods/sulekha/src/sulekhaspell.c~
@@ -1,8 +1,25 @@
/* sulekhaspell - a transliteratio - spell-checking addon for GTK's TextView widget
- * Copyright (c) 2007-2008 Santhosh Thottingal
* Based on gtkspell by Evan Martin.
- */
-
+ *
+ * Copyright (C) 2007-2008
+ * Santhosh Thottingal<santhosh00@gmail.com>,
+ * Praveen Arimprathodiyil <pravi.a@gmail.com>
+ * Swathanthra Malayalam Computing.
+ *
+ * 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 3 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 <gtk/gtk.h>
#include <libintl.h>
@@ -62,7 +79,7 @@ struct _SulekhaSpell
};
static void sulekhaspell_free (SulekhaSpell * spell);
-
+ static void replace_by_transliterated_word (SulekhaSpell * spell);
#define SULEKHASPELL_OBJECT_KEY "sulekhaspell"
GQuark
@@ -137,16 +154,20 @@ check_word (SulekhaSpell * spell, GtkTextBuffer * buffer,
{
char *text;
char *oldword;
+// replace_by_transliterated_word (spell);
+// g_print ("replaced");
+//
text = gtk_text_buffer_get_text (buffer, start, end, FALSE);
if (debug)
g_print ("checking: %s\n", text);
- g_print ("[santhosh]checking: %s\n", text);
- text = transliterate_ml (text, 0, strlen (text));
- g_print ("[santhosh]After transliteration checking: %s\n", text);
+ // g_print ("[santhosh]checking: %s\n", text);
+ // text = transliterate_ml (text, 0, strlen (text));
+ g_print ("[santhosh]After transliteration checking: %s\n", transliterate_ml (text, 0, strlen (text)));
if (g_unichar_isdigit (*text) == FALSE) /* don't check numbers */
if (aspell_speller_check (spell->speller, text, -1) == FALSE)
gtk_text_buffer_apply_tag (buffer, spell->tag_highlight, start, end);
- g_free (text);
+
+ // g_free (text);
}
static void
@@ -246,9 +267,10 @@ check_range (SulekhaSpell * spell, GtkTextBuffer * buffer,
}
else
{
+ g_print ("checking\n");
check_word (spell, buffer, &wstart, &wend);
spell->deferred_check = FALSE;
- }
+ }
/* now move wend to the beginning of the next word, */
gtk_text_iter_forward_word_end (&wend);
@@ -293,8 +315,7 @@ insert_text_after (GtkTextBuffer * buffer, GtkTextIter * iter,
GtkTextIter start;
if (debug)
- g_print ("insert\n");
-
+ g_print ("insert\n");
/* we need to check a range of text. */
gtk_text_buffer_get_iter_at_mark (buffer, &start, spell->mark_insert_start);
check_range (spell, buffer, start, *iter, FALSE);
@@ -412,24 +433,239 @@ replace_word (GtkWidget * menuitem, SulekhaSpell * spell)
g_free (oldword);
}
-GtkWidget *
-build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
- const char *word)
+static void
+replace_by_transliterated_word (SulekhaSpell * spell)
{
- const char *suggestion;
- GtkWidget *topmenu, *menu;
- GtkWidget *mi;
- GtkWidget *hbox;
- int count = 0;
- void *spelldata;
+ char *oldword;
+ const char *newword;
+ GtkTextIter start, end;
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (spell->view);
+
+ get_word_extents_from_mark (buffer, &start, &end, spell->mark_click);
+ oldword = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+ // newword = gtk_label_get_text (GTK_LABEL (GTK_BIN (menuitem)->child));
+ newword = transliterate_ml (oldword,0, strlen(oldword));
+ // if (debug)
+ if (1)
+ {
+ g_print ("old word: '%s'\n", oldword);
+ print_iter ("s", &start);
+ print_iter ("e", &end);
+ g_print ("\nnew word: '%s'\n", newword);
+ }
+
+ gtk_text_buffer_delete (buffer, &start, &end);
+ gtk_text_buffer_insert (buffer, &start, newword, -1);
+
+ aspell_speller_store_replacement (spell->speller,
+ oldword, strlen (oldword),
+ newword, strlen (newword));
+
+ g_free (oldword);
+}
+
+
+// GtkWidget *
+// build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
+// const char *word)
+// {
+// const char *suggestion;
+// GtkWidget *topmenu, *menu;
+// GtkWidget *mi;
+// GtkWidget *hbox;
+// int count = 0;
+// void *spelldata;
+// const AspellWordList *suggestions;
+// AspellStringEnumeration *elements;
+// char *label;
+// //santhosh
+// // word = transliterate_ml (word, 0, strlen (word));
+//
+// //end santhosh
+// topmenu = menu = gtk_menu_new ();
+//
+// suggestions = aspell_speller_suggest (spell->speller, word, -1);
+// elements = aspell_word_list_elements (suggestions);
+//
+// suggestion = aspell_string_enumeration_next (elements);
+// if (suggestion == NULL)
+// {
+// /* no suggestions. put something in the menu anyway... */
+// GtkWidget *label;
+// label = gtk_label_new ("");
+// gtk_label_set_markup (GTK_LABEL (label), _("<i>(no suggestions)</i>"));
+//
+// mi = gtk_menu_item_new ();
+// gtk_container_add (GTK_CONTAINER (mi), label);
+// gtk_widget_show_all (mi);
+// gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
+// }
+// else
+// {
+// /* build a set of menus with suggestions. */
+// while (suggestion != NULL)
+// {
+// if (count == 10)
+// {
+// mi = gtk_menu_item_new ();
+// gtk_widget_show (mi);
+// gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+//
+// mi = gtk_menu_item_new_with_label (_("More..."));
+// gtk_widget_show (mi);
+// gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+//
+// menu = gtk_menu_new ();
+// gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
+// count = 0;
+// }
+// mi = gtk_menu_item_new_with_label (suggestion);
+// g_signal_connect (G_OBJECT (mi), "activate",
+// G_CALLBACK (replace_word), spell);
+// gtk_widget_show (mi);
+// gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+// count++;
+// suggestion = aspell_string_enumeration_next (elements);
+// }
+// }
+//
+// delete_aspell_string_enumeration (elements);
+//
+// /* Separator */
+// mi = gtk_menu_item_new ();
+// gtk_widget_show (mi);
+// gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
+//
+// /* + Add to Dictionary */
+// label = g_strdup_printf (_("Add \"%s\" to Dictionary"), word);
+// mi = gtk_image_menu_item_new_with_label (label);
+// g_free (label);
+// gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
+// gtk_image_new_from_stock (GTK_STOCK_ADD,
+// GTK_ICON_SIZE_MENU));
+// g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (add_to_dictionary),
+// spell);
+// gtk_widget_show_all (mi);
+// gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
+//
+// /* - Ignore All */
+// mi = gtk_image_menu_item_new_with_label (_("Ignore All"));
+// gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
+// gtk_image_new_from_stock (GTK_STOCK_REMOVE,
+// GTK_ICON_SIZE_MENU));
+// g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (ignore_all),
+// spell);
+// gtk_widget_show_all (mi);
+// gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
+//
+// return topmenu;
+// }
+
+// static void
+// populate_popup1 (GtkTextView * textview, GtkMenu * menu, SulekhaSpell * spell)
+// {
+// GtkWidget *img, *mi;
+// GtkTextBuffer *buffer = gtk_text_view_get_buffer (textview);
+// GtkTextIter start, end;
+// char *word;
+//
+// /* we need to figure out if they picked a misspelled word. */
+// get_word_extents_from_mark (buffer, &start, &end, spell->mark_click);
+//
+// /* if our highlight algorithm ever messes up,
+// * this isn't correct, either. */
+// if (!gtk_text_iter_has_tag (&start, spell->tag_highlight))
+// return; /* word wasn't misspelled. */
+//
+// /* menu separator comes first. */
+// mi = gtk_menu_item_new ();
+// gtk_widget_show (mi);
+// gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
+//
+// /* then, on top of it, the suggestions menu. */
+// img = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU);
+// mi = gtk_image_menu_item_new_with_label (_("Spelling Suggestions"));
+// gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+//
+// word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+// /* gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi),
+// build_suggestion_menu (spell, buffer, word));*/
+//
+// gtk_menu_item_set_submenu (GTK_MENU_SHELL (menu),
+// build_suggestion_menu (spell, buffer, word));
+//
+//
+//
+// g_free (word);
+//
+// gtk_widget_show_all (mi);
+// gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
+// }
+
+
+static void
+populate_popup (GtkTextView * textview, GtkMenu * menu, SulekhaSpell * spell)
+{
+ GtkWidget *img, *mi;
const AspellWordList *suggestions;
+ GtkWidget *topmenu;
AspellStringEnumeration *elements;
+ int count = 0;
char *label;
- //santhosh
- word = transliterate_ml (word, 0, strlen (word));
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer (textview);
+ GtkTextIter start, end;
+ char *word;
+ const char *suggestion;
+ topmenu = menu;
+ /* we need to figure out if they picked a misspelled word. */
+ get_word_extents_from_mark (buffer, &start, &end, spell->mark_click);
+
+ /* if our highlight algorithm ever messes up,
+ * this isn't correct, either. */
+ if (!gtk_text_iter_has_tag (&start, spell->tag_highlight))
+ return; /* word wasn't misspelled. */
+
+ /* menu separator comes first. */
+ mi = gtk_menu_item_new ();
+ gtk_widget_show (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
+
+ word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
+ /* - Ignore All */
+ mi = gtk_image_menu_item_new_with_label (_("Ignore All"));
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
+ gtk_image_new_from_stock (GTK_STOCK_REMOVE,
+ GTK_ICON_SIZE_MENU));
+ g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (ignore_all),
+ spell);
+ gtk_widget_show_all (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (topmenu), mi);
+
+/* + Add to Dictionary */
+ label = g_strdup_printf (_("Add \"%s\" to Dictionary"), word);
+ mi = gtk_image_menu_item_new_with_label (label);
+ g_free (label);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
+ gtk_image_new_from_stock (GTK_STOCK_ADD,
+ GTK_ICON_SIZE_MENU));
+ g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (add_to_dictionary),
+ spell);
+ gtk_widget_show_all (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (topmenu), mi);
+ /* menu separator comes first. */
+ mi = gtk_menu_item_new ();
+ gtk_widget_show (mi);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
+ /* then, on top of it, the suggestions menu. */
+ img = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU);
+ mi = gtk_image_menu_item_new_with_label (_("Spelling Suggestions"));
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
+
+
- //end santhosh
- topmenu = menu = gtk_menu_new ();
suggestions = aspell_speller_suggest (spell->speller, word, -1);
elements = aspell_word_list_elements (suggestions);
@@ -452,15 +688,15 @@ build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
/* build a set of menus with suggestions. */
while (suggestion != NULL)
{
- if (count == 10)
+ if (count == 5)
{
- mi = gtk_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+// mi = gtk_menu_item_new ();
+// gtk_widget_show (mi);
+// gtk_menu_shell_insert (GTK_MENU_SHELL (menu), mi,count+1);
mi = gtk_menu_item_new_with_label (_("More..."));
gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), mi, count + 1);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
@@ -470,7 +706,7 @@ build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
g_signal_connect (G_OBJECT (mi), "activate",
G_CALLBACK (replace_word), spell);
gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
+ gtk_menu_shell_insert (GTK_MENU_SHELL (menu), mi, count);
count++;
suggestion = aspell_string_enumeration_next (elements);
}
@@ -478,72 +714,16 @@ build_suggestion_menu (SulekhaSpell * spell, GtkTextBuffer * buffer,
delete_aspell_string_enumeration (elements);
- /* Separator */
- mi = gtk_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- /* + Add to Dictionary */
- label = g_strdup_printf (_("Add \"%s\" to Dictionary"), word);
- mi = gtk_image_menu_item_new_with_label (label);
- g_free (label);
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
- gtk_image_new_from_stock (GTK_STOCK_ADD,
- GTK_ICON_SIZE_MENU));
- g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (add_to_dictionary),
- spell);
- gtk_widget_show_all (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- /* - Ignore All */
- mi = gtk_image_menu_item_new_with_label (_("Ignore All"));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
- gtk_image_new_from_stock (GTK_STOCK_REMOVE,
- GTK_ICON_SIZE_MENU));
- g_signal_connect (G_OBJECT (mi), "activate", G_CALLBACK (ignore_all),
- spell);
- gtk_widget_show_all (mi);
- gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
-
- return topmenu;
-}
-
-static void
-populate_popup (GtkTextView * textview, GtkMenu * menu, SulekhaSpell * spell)
-{
- GtkWidget *img, *mi;
- GtkTextBuffer *buffer = gtk_text_view_get_buffer (textview);
- GtkTextIter start, end;
- char *word;
-
- /* we need to figure out if they picked a misspelled word. */
- get_word_extents_from_mark (buffer, &start, &end, spell->mark_click);
-
- /* if our highlight algorithm ever messes up,
- * this isn't correct, either. */
- if (!gtk_text_iter_has_tag (&start, spell->tag_highlight))
- return; /* word wasn't misspelled. */
-
- /* menu separator comes first. */
- mi = gtk_menu_item_new ();
- gtk_widget_show (mi);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
-
- /* then, on top of it, the suggestions menu. */
- img = gtk_image_new_from_stock (GTK_STOCK_SPELL_CHECK, GTK_ICON_SIZE_MENU);
- mi = gtk_image_menu_item_new_with_label (_("Spelling Suggestions"));
- gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), img);
-
- word = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi),
- build_suggestion_menu (spell, buffer, word));
g_free (word);
+
gtk_widget_show_all (mi);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
}
+
+
/* when the user right-clicks on a word, they want to check that word.
* here, we do NOT move the cursor to the location of the clicked-upon word
* since that prevents the use of edit functions on the context menu. */
@@ -610,6 +790,9 @@ sulekhaspell_set_language_internal (SulekhaSpell * spell, const gchar * lang,
if (lang)
aspell_config_replace (config, "language-tag", lang);
aspell_config_replace (config, "encoding", "utf-8");
+ //aspell_config_replace (config, "sug-edit-dist", "2");
+aspell_config_replace (config, "sug-mode", "ultra");
+
err = new_aspell_speller (config);
delete_aspell_config (config);
diff --git a/input-methods/sulekha/src/trans.c b/input-methods/sulekha/src/trans.c
deleted file mode 100644
index 18e48e1..0000000
--- a/input-methods/sulekha/src/trans.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* Transliteration.c
- *
- * Copyright (C) 2007-2008
- * Santhosh Thottingal<santhosh00@gmail.com>,
- * Swathanthra Malayalam Computing.
- *
- * 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 3 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<stdio.h>
-#include<string.h>
-#include<stdlib.h>
-#include "Transliteration.h"
-/*
-Transliterate the a dhvani phonetic string to malayalam.
-Algorithm:
-1)For all vowels, if it is at the 0th position print as it is
-2)If the vowel is in between/end of the string print the sign of the vowel except for A
-3)For all consonants print the malayalam character
-4)If a phonetic character is not identified print '?'
-5)Octal C escaped strings are used for printing the Unicode Malayalam string
-*/
-
-
-char *
-transliterate_ml (char *phonetic_string, int start, int end)
-{
- char *ml_string;
- int length = 0;
- int i = start;
- length = end - start;
- ml_string = (char *) malloc (length * 4 * sizeof (char));
- printf (":%s:\n", phonetic_string);
- while (i < end)
- {
-
- switch (phonetic_string[i])
- {
- //Vowels
- case 'a':
- if (i == 0)
- strcat (ml_string, "\340\264\205");
- break;
- case 'A':
- (i == 0) ? strcat (ml_string, "\340\264\206") : strcat (ml_string,
- "\340\264\276");
- break;
- case 'i':
- (i == 0) ? strcat (ml_string, "\340\264\207") : strcat (ml_string,
- "\340\264\277");
- break;
- case 'I':
- (i == 0) ? strcat (ml_string, "\340\264\210") : strcat (ml_string,
- "\340\265\200");
- break;
- case 'u':
- (i == 0) ? strcat (ml_string, "\340\264\211") : strcat (ml_string,
- "\340\265\201");
- break;
- case 'U':
- (i == 0) ? strcat (ml_string, "\340\264\212") : strcat (ml_string,
- "\340\265\202");
- break;
- case '^':
- (i == 0) ? strcat (ml_string, "\340\264\213") : strcat (ml_string,
- "\340\265\203");
- break;
- case 'e':
- (i == 0) ? strcat (ml_string, "\340\264\216") : strcat (ml_string,
- "\340\265\206");
- break;
- case 'E':
- (i == 0) ? strcat (ml_string, "\340\264\217") : strcat (ml_string,
- "\340\265\207");
- break;
- case '@':
- (i == 0) ? strcat (ml_string, "\340\264\220") : strcat (ml_string,
- "\340\265\210");
- break;
- case 'o':
- (i == 0) ? strcat (ml_string, "\340\264\222") : strcat (ml_string,
- "\340\265\212");
- break;
- case 'O':
- (i == 0) ? strcat (ml_string, "\340\264\223") : strcat (ml_string,
- "\340\265\213");
- break;
- case '`':
- (i == 0) ? strcat (ml_string, "\340\264\224") : strcat (ml_string,
- "\340\265\227");
- break;
- case '.': //am
- strcat (ml_string, "\340\264\202");
- break;
- case '~': //chandrakkala
- strcat (ml_string, "\340\265\215");
- break;
- case ':': //Ah
- strcat (ml_string, "\340\264\203");
- break;
- //Consonants
- case 'k':
- strcat (ml_string, "\340\264\225");
- break;
- case 'K':
- strcat (ml_string, "\340\264\226");
- break;
- case 'g':
- strcat (ml_string, "\340\264\227");
- break;
- case '-':
- strcat (ml_string, "\340\264\231");
- break;
- case 'G':
- strcat (ml_string, "\340\264\230");
- break;
- case 'c':
- strcat (ml_string, "\340\264\232");
- break;
- case 'C':
- strcat (ml_string, "\340\264\233");
- break;
- case 'j':
- strcat (ml_string, "\340\264\234");
- break;
- case 'J':
- strcat (ml_string, "\340\264\235");
- break;
- case '#':
- strcat (ml_string, "\340\264\236");
- break;
- case 't':
- strcat (ml_string, "\340\264\237");
- break;
- case 'T':
- strcat (ml_string, "\340\264\240");
- break;
- case 'd':
- strcat (ml_string, "\340\264\241");
- break;
- case 'D':
- strcat (ml_string, "\340\264\242");
- break;
- case 'N':
- strcat (ml_string, "\340\264\243");
- break;
- case 'x':
- strcat (ml_string, "\340\264\244");
- break;
- case 'X':
- strcat (ml_string, "\340\264\245");
- break;
- case 'w':
- strcat (ml_string, "\340\264\246");
- break;
- case 'W':
- strcat (ml_string, "\340\264\247");
- break;
- case 'n':
- strcat (ml_string, "\340\264\250");
- break;
- case 'p':
- strcat (ml_string, "\340\264\252");
- break;
- case 'f':
- strcat (ml_string, "\340\264\253");
- break;
- case 'b':
- strcat (ml_string, "\340\264\254");
- break;
- case 'B':
- strcat (ml_string, "\340\264\255");
- break;
- case 'm':
- strcat (ml_string, "\340\264\256");
- break;
- case 'y':
- strcat (ml_string, "\340\264\257");
- break;
- case 'r':
- strcat (ml_string, "\340\264\260");
- break;
- case 'l':
- strcat (ml_string, "\340\264\262");
- break;
- case 'v':
- strcat (ml_string, "\340\264\265");
- break;
- case '$':
- strcat (ml_string, "\340\264\266");
- break;
- case 's':
- strcat (ml_string, "\340\264\270");
- break;
- case 'S':
- strcat (ml_string, "\340\264\267");
- break;
- case 'h':
- strcat (ml_string, "\340\264\271");
- break;
- case 'L':
- strcat (ml_string, "\340\264\263");
- break;
- case 'z':
- strcat (ml_string, "\340\264\264");
- break;
- case 'R':
- strcat (ml_string, "\340\264\261");
- break;
- default:
- strcat (ml_string, "?"); //Not recognized
- break;
- }
-
- i++;
- }
- printf (":%s:\n", ml_string);
- return ml_string;
-}
diff --git a/input-methods/sulekha/src/trans.c~ b/input-methods/sulekha/src/trans.c~
index c30900d..18e48e1 100644
--- a/input-methods/sulekha/src/trans.c~
+++ b/input-methods/sulekha/src/trans.c~
@@ -6,7 +6,7 @@
*
* 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
+ * the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
@@ -14,10 +14,10 @@
* 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
+ * 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
#include<stdio.h>
#include<string.h>
diff --git a/input-methods/sulekha/src/transliteration.c b/input-methods/sulekha/src/transliteration.c
index 4cb1222..e6999de 100644
--- a/input-methods/sulekha/src/transliteration.c
+++ b/input-methods/sulekha/src/transliteration.c
@@ -79,11 +79,12 @@ transliterate_ml (char *phonetic_string, int start, int end)
int length = 0;
int i = start;
length = end - start;
+// printf("length %d\n", length);
ml_string = (char *) malloc (length * 4 * sizeof (char));
ml_string[0] = '\0';
while (i < end)
{
-
+// printf("i %d\n", i);
switch (phonetic_string[i])
{
//Vowels
@@ -879,7 +880,9 @@ transliterate_ml (char *phonetic_string, int start, int end)
strcat (ml_string, "\340\264\261");
break;
default:
- strcat (ml_string, phonetic_string[i]); //Not recognized
+
+ // strcat (ml_string, phonetic_string[i]); //Not recognized
+ return phonetic_string; // it is not a maglish, return the string and stop this work
break;
}
@@ -896,6 +899,7 @@ transliterate_ml (char *phonetic_string, int start, int end)
strcat (ml_string, "\340\265\215"); //virama - implicit virama for conjuct formation
}
+
i++;
diff --git a/input-methods/sulekha/src/transliteration.c~ b/input-methods/sulekha/src/transliteration.c~
index 4cb1222..0d1c751 100644
--- a/input-methods/sulekha/src/transliteration.c~
+++ b/input-methods/sulekha/src/transliteration.c~
@@ -79,11 +79,12 @@ transliterate_ml (char *phonetic_string, int start, int end)
int length = 0;
int i = start;
length = end - start;
+ printf("length %d\n", length);
ml_string = (char *) malloc (length * 4 * sizeof (char));
ml_string[0] = '\0';
while (i < end)
{
-
+printf("i %d\n", i);
switch (phonetic_string[i])
{
//Vowels
@@ -879,7 +880,9 @@ transliterate_ml (char *phonetic_string, int start, int end)
strcat (ml_string, "\340\264\261");
break;
default:
- strcat (ml_string, phonetic_string[i]); //Not recognized
+
+ // strcat (ml_string, phonetic_string[i]); //Not recognized
+ return phonetic_string; // it is not a maglish, return the string and stop this work
break;
}
@@ -896,6 +899,7 @@ transliterate_ml (char *phonetic_string, int start, int end)
strcat (ml_string, "\340\265\215"); //virama - implicit virama for conjuct formation
}
+
i++;