[uim-commit] r224 - in trunk: doc helper
qt/uim-kdehelper/src/candwin xim
ekato@freedesktop.org
ekato@freedesktop.org
Mon Jan 10 10:39:28 PST 2005
Author: ekato
Date: 2005-01-10 10:39:22 -0800 (Mon, 10 Jan 2005)
New Revision: 224
Modified:
trunk/doc/HELPER-CANDWIN
trunk/helper/helper-candwin-gtk.c
trunk/qt/uim-kdehelper/src/candwin/uim-candwin-qt.cpp
trunk/xim/ximserver.cpp
Log:
* xim/ximserver.cpp (InputContext::candidate_activate) : Use
uim_candidate_get_heading_label() to get heading label. Format
of string sent to helper-candidate-window is changed according
to this.
* helper/helper-candwin-gtk.c (candwin_activate) : Change column
type for heading labels as G_TYPE_STRING from G_TYPE_UNIT. Use
heading labels of candidates with supplied string from uim-xim
instead of calculated one.
(str_parse) : Avoid unnecessary loop.
* qt/uim-kdehelper/src/candwin/uim-candwin-qt.cpp
(CandidateWindow::activateCand) : Use heading labels of candidates
with supplied string from uim-xim instead of calculated one.
* doc/HELPER-CANDWIN : Update section about activate command.
Modified: trunk/doc/HELPER-CANDWIN
===================================================================
--- trunk/doc/HELPER-CANDWIN 2005-01-10 16:14:10 UTC (rev 223)
+++ trunk/doc/HELPER-CANDWIN 2005-01-10 18:39:22 UTC (rev 224)
@@ -3,8 +3,8 @@
file describes communication protocol between uim-xim and its helper
program .
-uim-helper-candwin-[xaw|gtk|qt] is executed from uim-xim and
-receives/sends messages via pipe.
+uim-candwin-[xaw|gtk|qt] is executed from uim-xim and receives/sends
+messages via pipe.
Received message format:
@@ -15,8 +15,10 @@
1. activate
purpose: activating the candidate window with display_limit value,
- and add candidates to it. The order of candidates must be as is.
- example: activate\ncharset=UTF-8\ndisplay_limit=$value\ncand1\ncand2\ncand3\n
+ and add heading labels and candidates to it. The order of
+ candidates must be as is.
+ example:
+ activate\ncharset=UTF-8\ndisplay_limit=$value\nhead1\tcand1\nhead2\tcand2\nhead3\tcand3\n
2. select
purpose: selecting the specified candidate
Modified: trunk/helper/helper-candwin-gtk.c
===================================================================
--- trunk/helper/helper-candwin-gtk.c 2005-01-10 16:14:10 UTC (rev 223)
+++ trunk/helper/helper-candwin-gtk.c 2005-01-10 18:39:22 UTC (rev 224)
@@ -436,7 +436,7 @@
/* create GtkListStores, and set candidates */
for (i = 0; i < nr_stores; i++) {
- GtkListStore *store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
+ GtkListStore *store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
GSList *node;
g_ptr_array_add(cwin->stores, store);
@@ -448,13 +448,15 @@
{
GtkTreeIter ti;
if (node) {
- gchar *cand = node->data;
+ gchar *str = node->data;
+ gchar **column = g_strsplit(str, "\t", 0);
gtk_list_store_append(store, &ti);
gtk_list_store_set(store, &ti,
- COLUMN_HEADING, j + 1,
- COLUMN_CANDIDATE, cand,
+ COLUMN_HEADING, column[0],
+ COLUMN_CANDIDATE, column[1],
TERMINATOR);
- g_free(cand);
+ g_strfreev(column);
+ g_free(str);
} else {
/* No need to set any data for empty row. */
}
@@ -503,25 +505,25 @@
static void str_parse(gchar *str)
{
gchar **tmp;
- int i = 0;
+ gchar *command;
tmp = g_strsplit(str, "\n", 0);
+ command = tmp[0];
- while (tmp[i]) {
- if (strcmp("activate", tmp[i]) == 0) {
+ if (command) {
+ if (strcmp("activate", command) == 0) {
candwin_activate(tmp);
- } else if (strcmp("select", tmp[i]) == 0) {
+ } else if (strcmp("select", command) == 0) {
candwin_update(tmp);
- } else if (strcmp("show", tmp[i]) == 0) {
+ } else if (strcmp("show", command) == 0) {
candwin_show();
- } else if (strcmp("hide", tmp[i]) == 0) {
+ } else if (strcmp("hide", command) == 0) {
gtk_widget_hide_all(GTK_WIDGET(cwin));
- } else if (strcmp("move", tmp[i]) == 0) {
+ } else if (strcmp("move", command) == 0) {
candwin_move(tmp);
- } else if (strcmp("deactivate", tmp[i]) == 0) {
+ } else if (strcmp("deactivate", command) == 0) {
candwin_deactivate();
}
- i++;
}
g_strfreev(tmp);
}
Modified: trunk/qt/uim-kdehelper/src/candwin/uim-candwin-qt.cpp
===================================================================
--- trunk/qt/uim-kdehelper/src/candwin/uim-candwin-qt.cpp 2005-01-10 16:14:10 UTC (rev 223)
+++ trunk/qt/uim-kdehelper/src/candwin/uim-candwin-qt.cpp 2005-01-10 18:39:22 UTC (rev 224)
@@ -108,7 +108,7 @@
qDebug( "uim-helper-candwin-qt: activateCand()" );
/**
- * format: activate\ncharset=$charset\ndisplay_limit=$value\ncand1\ncand2\ncand3\n
+ * format: activate\ncharset=$charset\ndisplay_limit=$value\nhead1\tcand1\nhead2\tcand2\nhead3\tcand3\n
*/
// remove old data
@@ -136,19 +136,27 @@
if ( list[ i ].isEmpty() )
break;
+ // split heading_label and cand_str
+ const QStringList l = QStringList::split( "\t", list [ i ] );
+
// store data
CandData d;
- QString headString = QString::number( i - 2 );
- if ( ( i - 2 < 10 && i - 2 + displayLimit > 10 )
- || ( i - 2 < 100 && i - 2 + displayLimit > 100 ) )
+ QString headString;
+ if ( codec )
+ headString = codec->toUnicode( l [ 0 ] );
+ else
+ headString = l [ 0 ];
+
+ if ( ( headString.toInt() < 10 && headString.toInt() + displayLimit > 10 )
+ || ( headString.toInt() < 100 && headString.toInt() + displayLimit > 100 ) )
headString.prepend( "0" );
d.label = headString;
if ( codec )
- d.str = codec->toUnicode( list[ i ] );
+ d.str = codec->toUnicode( l [ 1 ] );
else
- d.str = list[ i ];
+ d.str = l [ 1 ];
stores.append( d );
}
Modified: trunk/xim/ximserver.cpp
===================================================================
--- trunk/xim/ximserver.cpp 2005-01-10 16:14:10 UTC (rev 223)
+++ trunk/xim/ximserver.cpp 2005-01-10 18:39:22 UTC (rev 224)
@@ -653,19 +653,26 @@
{
int i;
const char *cand_str;
+ const char *heading_label;
uim_candidate cand[nr];
std::vector<const char *> candidates;
+ char *str;
Canddisp *disp = canddisp_singleton();
for (i = 0; i < nr; i++) {
cand[i] = uim_get_candidate(mUc, i, i % display_limit);
cand_str = uim_candidate_get_cand_str(cand[i]);
- if (cand_str)
- candidates.push_back((const char *)strdup(cand_str));
+ heading_label = uim_candidate_get_heading_label(cand[i]);
+ //annotation_str = uim_candidate_get_annotation(cand[i]);
+ if (cand_str && heading_label) {
+ str = (char *)malloc(strlen(cand_str) + strlen(heading_label) + 2);
+ sprintf(str, "%s\t%s", heading_label, cand_str);
+ candidates.push_back((const char *)str);
+ }
else {
fprintf(stderr, "Warning: cand_str at %d is NULL\n", i);
- candidates.push_back((const char *)strdup(""));
+ candidates.push_back((const char *)strdup("\t"));
}
}
disp->activate(candidates, display_limit);
More information about the Uim-commit
mailing list