Revision: 6451
Author: deton.kih
Date: Wed Jun 16 02:58:53 2010
Log: * Change usage of GtkListStore in
uim-cand-win-tbl-gtk.c/candwin-tbl-gtk.c
to same as uim-cand-win-gtk.c/candwin-gtk.c
to reduce override functions and to remember candidate index in page.
* gtk/uim-cand-win-gtk.h
- (_UIMCandWinGtkClass): Remove set_candidates and set_page_candidates
to make non-virtual
* gtk/uim-cand-win-gtk.c
- (uim_cand_win_gtk_real_set_candidates): Remove
- (uim_cand_win_gtk_real_set_page_candidates): Remove
- (uim_cand_win_gtk_class_init): Remove override
of set_candidates and set_page_candidates
* gtk/uim-cand-win-tbl-gtk.h
- (uim_cand_win_tbl_gtk_set_candidates): Remove
- (uim_cand_win_tbl_gtk_set_page_candidates): Remove
* gtk/uim-cand-win-tbl-gtk.c
- (uim_cand_win_tbl_gtk_class_init): Remove override
of set_candidates and set_page_candidates
- (set_candidate): Remove
- (uim_cand_win_tbl_gtk_set_candidates): Remove
- (uim_cand_win_tbl_gtk_set_page_candidates): Remove
- (clear_buttons): New function
- (update_table_button): Follow the change of GtkListStore usage
* helper/candwin-tbl-gtk.c
- (set_candidate): Remove
- (candwin_activate): Change usage of GtkListStore
- (uim_cand_win_gtk_set_page_candidates): Ditto
- (clear_buttons): New function
- (update_table_button): Follow the change of GtkListStore usage
http://code.google.com/p/uim/source/detail?r=6451
Modified:
/trunk/gtk/uim-cand-win-gtk.c
/trunk/gtk/uim-cand-win-gtk.h
/trunk/gtk/uim-cand-win-tbl-gtk.c
/trunk/gtk/uim-cand-win-tbl-gtk.h
/trunk/helper/candwin-tbl-gtk.c
=======================================
--- /trunk/gtk/uim-cand-win-gtk.c Sun Jun 13 00:30:03 2010
+++ /trunk/gtk/uim-cand-win-gtk.c Wed Jun 16 02:58:53 2010
@@ -62,12 +62,6 @@
static void uim_cand_win_gtk_unmap (GtkWidget *widget);
static void uim_cand_win_gtk_create_sub_window(UIMCandWinGtk *cwin);
static void uim_cand_win_gtk_layout_sub_window(UIMCandWinGtk *cwin);
-static void uim_cand_win_gtk_real_set_candidates (UIMCandWinGtk *cwin,
- guint disp_limit,
- GSList *candidates);
-static void uim_cand_win_gtk_real_set_page_candidates(UIMCandWinGtk *cwin,
- guint page,
- GSList *candidates);
static void uim_cand_win_gtk_real_set_index (UIMCandWinGtk *cwin,
gint index);
static void uim_cand_win_gtk_real_set_page (UIMCandWinGtk *cwin,
@@ -142,8 +136,6 @@
widget_class->map = uim_cand_win_gtk_map;
widget_class->unmap = uim_cand_win_gtk_unmap;
- klass->set_candidates = uim_cand_win_gtk_real_set_candidates;
- klass->set_page_candidates = uim_cand_win_gtk_real_set_page_candidates;
klass->set_index = uim_cand_win_gtk_real_set_index;
klass->set_page = uim_cand_win_gtk_real_set_page;
}
@@ -490,14 +482,6 @@
uim_cand_win_gtk_set_candidates(UIMCandWinGtk *cwin,
guint display_limit,
GSList *candidates)
-{
- UIM_CAND_WIN_GTK_GET_CLASS (cwin)->set_candidates(cwin, display_limit,
candidates);
-}
-
-static void
-uim_cand_win_gtk_real_set_candidates(UIMCandWinGtk *cwin,
- guint display_limit,
- GSList *candidates)
{
gint i, nr_stores = 1;
@@ -589,14 +573,6 @@
uim_cand_win_gtk_set_page_candidates(UIMCandWinGtk *cwin,
guint page,
GSList *candidates)
-{
- UIM_CAND_WIN_GTK_GET_CLASS (cwin)->set_page_candidates(cwin, page,
candidates);
-}
-
-static void
-uim_cand_win_gtk_real_set_page_candidates(UIMCandWinGtk *cwin,
- guint page,
- GSList *candidates)
{
GtkListStore *store;
GSList *node;
=======================================
--- /trunk/gtk/uim-cand-win-gtk.h Sun Jun 13 00:30:03 2010
+++ /trunk/gtk/uim-cand-win-gtk.h Wed Jun 16 02:58:53 2010
@@ -88,12 +88,6 @@
void (*index_changed) (UIMCandWinGtkClass *cwin);
/* member functions */
- void (*set_candidates) (UIMCandWinGtk *cwin,
- guint disp_limit,
- GSList *candidates);
- void (*set_page_candidates) (UIMCandWinGtk *cwin,
- guint page,
- GSList *candidates);
void (*set_index) (UIMCandWinGtk *cwin, gint index);
void (*set_page) (UIMCandWinGtk *cwin, gint page);
};
=======================================
--- /trunk/gtk/uim-cand-win-tbl-gtk.c Sun Jun 13 01:28:24 2010
+++ /trunk/gtk/uim-cand-win-tbl-gtk.c Wed Jun 16 02:58:53 2010
@@ -44,19 +44,8 @@
enum {
TERMINATOR = -1,
COLUMN_HEADING,
- COLUMN_CANDIDATE1,
- COLUMN_CANDIDATE2,
- COLUMN_CANDIDATE3,
- COLUMN_CANDIDATE4,
- COLUMN_CANDIDATE5,
- COLUMN_CANDIDATE6,
- COLUMN_CANDIDATE7,
- COLUMN_CANDIDATE8,
- COLUMN_CANDIDATE9,
- COLUMN_CANDIDATE10,
- COLUMN_CANDIDATE11,
- COLUMN_CANDIDATE12,
- COLUMN_CANDIDATE13,
+ COLUMN_CANDIDATE,
+ COLUMN_ANNOTATION,
NR_COLUMNS
};
@@ -159,8 +148,6 @@
parent_class = g_type_class_peek_parent (klass);
object_class->dispose = uim_cand_win_tbl_gtk_dispose;
- klass->set_candidates = (void (*)(UIMCandWinGtk *, guint, GSList
*))uim_cand_win_tbl_gtk_set_candidates;
- klass->set_page_candidates = (void (*)(UIMCandWinGtk *, guint, GSList
*))uim_cand_win_tbl_gtk_set_page_candidates;
klass->set_index = (void (*)(UIMCandWinGtk *,
gint))uim_cand_win_tbl_gtk_set_index;
klass->set_page = (void (*)(UIMCandWinGtk *,
gint))uim_cand_win_tbl_gtk_set_page;
}
@@ -352,152 +339,6 @@
*row = 0;
*col = 0;
}
-
-static void
-set_candidate(UIMCandWinTblGtk *ctblwin, GSList *node, GtkListStore
*store, gint idx)
-{
- if (node) {
- GtkTreeIter ti;
- gint row = 0;
- gint col = 0;
- gint i;
- const char *heading_label = NULL;
- const char *cand_str = NULL;
- uim_candidate cand = node->data;
- struct index_button *idxbutton;
-
- heading_label = uim_candidate_get_heading_label(cand);
- cand_str = uim_candidate_get_cand_str(cand);
-
- get_row_column(ctblwin->labelchar_table, heading_label[0], &row, &col);
- gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &ti);
- for (i = 0; i < row; i++) {
- gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &ti);
- }
- gtk_list_store_set(store, &ti, col, cand_str, TERMINATOR);
-
- idxbutton = g_ptr_array_index(ctblwin->buttons, INDEX(row, col));
- if (idxbutton) {
- idxbutton->cand_index_in_page = idx;
- }
- } else {
- /* No need to set any data for empty row. */
- }
-}
-
-void
-uim_cand_win_tbl_gtk_set_candidates(UIMCandWinTblGtk *ctblwin,
- guint display_limit,
- GSList *candidates)
-{
- gint i, nr_stores = 1;
- UIMCandWinGtk *cwin;
-
- g_return_if_fail(UIM_IS_CAND_WIN_TBL_GTK(ctblwin));
- cwin = UIM_CAND_WIN_GTK(ctblwin);
-
- if (cwin->stores == NULL)
- cwin->stores = g_ptr_array_new();
-
- /* remove old data */
- if (cwin->page_index >= 0 && cwin->page_index < (int) cwin->stores->len)
{
- /* Remove data from current page to shrink the window */
- if (cwin->stores->pdata[cwin->page_index])
- gtk_list_store_clear(cwin->stores->pdata[cwin->page_index]);
- }
- for (i = cwin->stores->len - 1; i >= 0; i--) {
- GtkListStore *store = g_ptr_array_remove_index(cwin->stores, i);
- if (store)
- g_object_unref(G_OBJECT(store));
- }
-
- cwin->candidate_index = -1;
- cwin->nr_candidates = g_slist_length(candidates);
- cwin->display_limit = display_limit;
-
- cwin->sub_window.active = FALSE;
-
- if (candidates == NULL)
- return;
-
- /* calculate number of GtkListStores to create */
- if (display_limit) {
- nr_stores = cwin->nr_candidates / display_limit;
- if (cwin->nr_candidates > display_limit * nr_stores)
- nr_stores++;
- }
-
- /* create GtkListStores, and set candidates */
- for (i = 0; i < nr_stores; i++) {
- GtkListStore *store = gtk_list_store_new(LABELCHAR_NR_COLUMNS,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING);
- GSList *node;
- guint j;
-
- g_ptr_array_add(cwin->stores, store);
-
- for (j = 0; j < LABELCHAR_NR_ROWS; j++) {
- GtkTreeIter ti;
- gtk_list_store_append(store, &ti);
- }
-
- /* set candidates */
- for (j = i * display_limit, node = g_slist_nth(candidates, j);
- display_limit ? j < display_limit * (i + 1) : j < cwin->nr_candidates;
- j++, node = g_slist_next(node))
- {
- set_candidate(ctblwin, node, store, j);
- }
- }
-
- uim_cand_win_gtk_set_page(cwin, 0);
-
- uim_cand_win_gtk_update_label(cwin);
-}
-
-void
-uim_cand_win_tbl_gtk_set_page_candidates(UIMCandWinTblGtk *ctblwin,
- guint page,
- GSList *candidates)
-{
- GtkListStore *store;
- GSList *node;
- gint j, len;
- UIMCandWinGtk *cwin;
-
- g_return_if_fail(UIM_IS_CAND_WIN_TBL_GTK(ctblwin));
- cwin = UIM_CAND_WIN_GTK(ctblwin);
-
- if (candidates == NULL)
- return;
-
- cwin->sub_window.active = FALSE;
- len = g_slist_length(candidates);
-
- /* create GtkListStores, and set candidates */
- store = gtk_list_store_new(LABELCHAR_NR_COLUMNS, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
-
- cwin->stores->pdata[page] = store;
-
- for (j = 0; j < LABELCHAR_NR_ROWS; j++) {
- GtkTreeIter ti;
- gtk_list_store_append(store, &ti);
- }
-
- /* set candidates */
- for (j = 0, node = g_slist_nth(candidates, j);
- j < len;
- j++, node = g_slist_next(node))
- {
- set_candidate(ctblwin, node, store, j);
- }
-}
void
uim_cand_win_tbl_gtk_set_index(UIMCandWinTblGtk *ctblwin, gint index)
@@ -523,44 +364,74 @@
uim_cand_win_gtk_update_label(cwin);
}
+
+static void
+clear_buttons(GPtrArray *buttons, gchar *labelchar_table)
+{
+ gint i;
+
+ for (i = 0; i < LABELCHAR_NR_CELLS; i++) {
+ GtkButton *button = NULL;
+ struct index_button *idxbutton;
+
+ idxbutton = g_ptr_array_index(buttons, i);
+ if (idxbutton) {
+ button = idxbutton->button;
+ idxbutton->cand_index_in_page = -1;
+
+ if (labelchar_table[i] == '\0') {
+ gtk_button_set_relief(button, GTK_RELIEF_NONE);
+ } else {
+ gtk_button_set_relief(button, GTK_RELIEF_HALF);
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ gtk_button_set_label(button, " ");
+ }
+ }
+}
static void
update_table_button(GtkTreeModel *model, GPtrArray *buttons, gchar
*labelchar_table)
{
GtkTreeIter ti;
- gint row, col;
- gboolean hasValue = TRUE;
- gtk_tree_model_get_iter_first(model, &ti);
- for (row = 0; row < LABELCHAR_NR_ROWS; row++) {
- for (col = 0; col < LABELCHAR_NR_COLUMNS; col++) {
- GValue value = {0};
- const gchar *str = NULL;
- GtkButton *button = NULL;
- button = get_button(buttons, INDEX(row, col));
- if (hasValue) {
- gtk_tree_model_get_value(model, &ti, col, &value);
- str = g_value_get_string(&value);
- }
- if (str == NULL) {
- str = " ";
- if (labelchar_table[INDEX(row, col)] == '\0') {
- gtk_button_set_relief(button, GTK_RELIEF_NONE);
- } else {
- gtk_button_set_relief(button, GTK_RELIEF_HALF);
- }
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ gboolean hasNext;
+ gint cand_index = 0;
+
+ clear_buttons(buttons, labelchar_table);
+ hasNext = gtk_tree_model_get_iter_first(model, &ti);
+ while (hasNext) {
+ gchar *heading = NULL;
+ gchar *cand_str = NULL;
+ GtkButton *button = NULL;
+ struct index_button *idxbutton;
+ gint row = 0, col = 0;
+
+ gtk_tree_model_get(model, &ti, COLUMN_HEADING, &heading,
+ COLUMN_CANDIDATE, &cand_str, TERMINATOR);
+ get_row_column(labelchar_table, heading[0], &row, &col);
+
+ idxbutton = g_ptr_array_index(buttons, INDEX(row, col));
+ if (idxbutton) {
+ button = idxbutton->button;
+ idxbutton->cand_index_in_page = cand_index;
+ }
+ if (cand_str == NULL) {
+ if (labelchar_table[INDEX(row, col)] == '\0') {
+ gtk_button_set_relief(button, GTK_RELIEF_NONE);
} else {
- gtk_button_set_relief(button, GTK_RELIEF_NORMAL);
- gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE);
- }
- gtk_button_set_label(button, str);
- if (hasValue) {
- g_value_unset(&value);
- }
- }
- if (hasValue) {
- hasValue = gtk_tree_model_iter_next(model, &ti);
- }
+ gtk_button_set_relief(button, GTK_RELIEF_HALF);
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ } else {
+ gtk_button_set_relief(button, GTK_RELIEF_NORMAL);
+ gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE);
+ }
+ gtk_button_set_label(button, (cand_str == NULL) ? " " : cand_str);
+
+ g_free(cand_str);
+ g_free(heading);
+ cand_index++;
+ hasNext = gtk_tree_model_iter_next(model, &ti);
}
}
=======================================
--- /trunk/gtk/uim-cand-win-tbl-gtk.h Sun Jun 13 00:30:03 2010
+++ /trunk/gtk/uim-cand-win-tbl-gtk.h Wed Jun 16 02:58:53 2010
@@ -63,10 +63,6 @@
GType uim_cand_win_tbl_gtk_get_type(void);
UIMCandWinTblGtk *uim_cand_win_tbl_gtk_new(void);
-void uim_cand_win_tbl_gtk_set_candidates(UIMCandWinTblGtk *cwin,
- guint disp_limit, GSList *candidates);
-void uim_cand_win_tbl_gtk_set_page_candidates(UIMCandWinTblGtk *cwin,
- guint page, GSList *candidates);
void uim_cand_win_tbl_gtk_set_index(UIMCandWinTblGtk *cwin, gint index);
void uim_cand_win_tbl_gtk_set_page(UIMCandWinTblGtk *cwin, gint page);
=======================================
--- /trunk/helper/candwin-tbl-gtk.c Sun Jun 13 01:28:24 2010
+++ /trunk/helper/candwin-tbl-gtk.c Wed Jun 16 02:58:53 2010
@@ -117,19 +117,10 @@
enum {
TERMINATOR = -1,
- COLUMN_CANDIDATE1,
- COLUMN_CANDIDATE2,
- COLUMN_CANDIDATE3,
- COLUMN_CANDIDATE4,
- COLUMN_CANDIDATE5,
- COLUMN_CANDIDATE6,
- COLUMN_CANDIDATE7,
- COLUMN_CANDIDATE8,
- COLUMN_CANDIDATE9,
- COLUMN_CANDIDATE10,
- COLUMN_CANDIDATE11,
- COLUMN_CANDIDATE12,
- COLUMN_CANDIDATE13
+ COLUMN_HEADING,
+ COLUMN_CANDIDATE,
+ COLUMN_ANNOTATION,
+ NR_COLUMNS
};
#define LABELCHAR_NR_COLUMNS 13
@@ -164,8 +155,6 @@
#define BLOCK_AS_COLUMN_START BLOCK_LRS_COLUMN_END
#define BLOCK_AS_COLUMN_END LABELCHAR_NR_COLUMNS
-#define BLOCK_SPACING 20
-#define HOMEPOSITION_SPACING 2
#define BLOCK_SPACING 20
#define HOMEPOSITION_SPACING 2
#define SPACING_LEFT_BLOCK_COLUMN 4
@@ -479,38 +468,6 @@
*row = 0;
*col = 0;
}
-
-static void
-set_candidate(UIMCandidateWindow *cwin, GSList *node, GtkListStore *store,
gint idx)
-{
- if (node) {
- GtkTreeIter ti;
- gint row = 0;
- gint col = 0;
- gint i;
- struct index_button *idxbutton;
- gchar *str = node->data;
- /* "heading label char\acandidate\aannotation" */
- gchar **column = g_strsplit(str, "\a", 3);
-
- get_row_column(cwin->labelchar_table, column[0][0], &row, &col);
- gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &ti);
- for (i = 0; i < row; i++) {
- gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &ti);
- }
- gtk_list_store_set(store, &ti, col, column[1], TERMINATOR);
-
- idxbutton = g_ptr_array_index(cwin->buttons, INDEX(row, col));
- if (idxbutton) {
- idxbutton->cand_index_in_page = idx;
- }
-
- g_strfreev(column);
- g_free(str);
- } else {
- /* No need to set any data for empty row. */
- }
-}
static void
candwin_activate(gchar **str)
@@ -580,26 +537,31 @@
/* create GtkListStores, and set candidates */
for (i = 0; i < nr_stores; i++) {
- GtkListStore *store = gtk_list_store_new(LABELCHAR_NR_COLUMNS,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING);
+ GtkListStore *store = gtk_list_store_new(NR_COLUMNS, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING);
GSList *node;
g_ptr_array_add(cwin->stores, store);
- for (j = 0; j < LABELCHAR_NR_ROWS; j++) {
- GtkTreeIter ti;
- gtk_list_store_append(store, &ti);
- }
-
/* set candidates */
for (j = i * display_limit, node = g_slist_nth(candidates, j);
display_limit ? j < display_limit * (i + 1) : j < cwin->nr_candidates;
j++, node = g_slist_next(node))
{
- set_candidate(cwin, node, store, j);
+ GtkTreeIter ti;
+ if (node) {
+ gchar *str = node->data;
+ gchar **column = g_strsplit(str, "\a", 3);
+ gtk_list_store_append(store, &ti);
+ gtk_list_store_set(store, &ti,
+ COLUMN_HEADING, column[0],
+ COLUMN_CANDIDATE, column[1],
+ COLUMN_ANNOTATION, column[2],
+ TERMINATOR);
+ g_strfreev(column);
+ g_free(str);
+ } else {
+ /* No need to set any data for empty row. */
+ }
}
}
g_slist_free(candidates);
@@ -894,44 +856,74 @@
update_label(cwin);
}
+
+static void
+clear_buttons(GPtrArray *buttons, gchar *labelchar_table)
+{
+ gint i;
+
+ for (i = 0; i < LABELCHAR_NR_CELLS; i++) {
+ GtkButton *button = NULL;
+ struct index_button *idxbutton;
+
+ idxbutton = g_ptr_array_index(buttons, i);
+ if (idxbutton) {
+ button = idxbutton->button;
+ idxbutton->cand_index_in_page = -1;
+
+ if (labelchar_table[i] == '\0') {
+ gtk_button_set_relief(button, GTK_RELIEF_NONE);
+ } else {
+ gtk_button_set_relief(button, GTK_RELIEF_HALF);
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ gtk_button_set_label(button, " ");
+ }
+ }
+}
static void
update_table_button(GtkTreeModel *model, GPtrArray *buttons, gchar
*labelchar_table)
{
GtkTreeIter ti;
- gint row, col;
- gboolean hasValue = TRUE;
- gtk_tree_model_get_iter_first(model, &ti);
- for (row = 0; row < LABELCHAR_NR_ROWS; row++) {
- for (col = 0; col < LABELCHAR_NR_COLUMNS; col++) {
- GValue value = {0};
- const gchar *str = NULL;
- GtkButton *button = NULL;
- button = get_button(buttons, INDEX(row, col));
- if (hasValue) {
- gtk_tree_model_get_value(model, &ti, col, &value);
- str = g_value_get_string(&value);
- }
- if (str == NULL) {
- str = " ";
- if (labelchar_table[INDEX(row, col)] == '\0') {
- gtk_button_set_relief(button, GTK_RELIEF_NONE);
- } else {
- gtk_button_set_relief(button, GTK_RELIEF_HALF);
- }
- gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ gboolean hasNext;
+ gint cand_index = 0;
+
+ clear_buttons(buttons, labelchar_table);
+ hasNext = gtk_tree_model_get_iter_first(model, &ti);
+ while (hasNext) {
+ gchar *heading = NULL;
+ gchar *cand_str = NULL;
+ GtkButton *button = NULL;
+ struct index_button *idxbutton;
+ gint row = 0, col = 0;
+
+ gtk_tree_model_get(model, &ti, COLUMN_HEADING, &heading,
+ COLUMN_CANDIDATE, &cand_str, TERMINATOR);
+ get_row_column(labelchar_table, heading[0], &row, &col);
+
+ idxbutton = g_ptr_array_index(buttons, INDEX(row, col));
+ if (idxbutton) {
+ button = idxbutton->button;
+ idxbutton->cand_index_in_page = cand_index;
+ }
+ if (cand_str == NULL) {
+ if (labelchar_table[INDEX(row, col)] == '\0') {
+ gtk_button_set_relief(button, GTK_RELIEF_NONE);
} else {
- gtk_button_set_relief(button, GTK_RELIEF_NORMAL);
- gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE);
- }
- gtk_button_set_label(button, str);
- if (hasValue) {
- g_value_unset(&value);
- }
- }
- if (hasValue) {
- hasValue = gtk_tree_model_iter_next(model, &ti);
- }
+ gtk_button_set_relief(button, GTK_RELIEF_HALF);
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
+ } else {
+ gtk_button_set_relief(button, GTK_RELIEF_NORMAL);
+ gtk_widget_set_sensitive(GTK_WIDGET(button), TRUE);
+ }
+ gtk_button_set_label(button, (cand_str == NULL) ? " " : cand_str);
+
+ g_free(cand_str);
+ g_free(heading);
+ cand_index++;
+ hasNext = gtk_tree_model_iter_next(model, &ti);
}
}
@@ -997,22 +989,29 @@
len = g_slist_length(candidates);
/* create GtkListStores, and set candidates */
- store = gtk_list_store_new(LABELCHAR_NR_COLUMNS, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ store = gtk_list_store_new(NR_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING);
cwin->stores->pdata[page] = store;
- for (j = 0; j < LABELCHAR_NR_ROWS; j++) {
- GtkTreeIter ti;
- gtk_list_store_append(store, &ti);
- }
/* set candidates */
for (j = 0, node = g_slist_nth(candidates, j);
j < len;
j++, node = g_slist_next(node))
{
- set_candidate(cwin, node, store, j);
+ GtkTreeIter ti;
+
+ if (node) {
+ gchar *str = node->data;
+ gchar **column = g_strsplit(str, "\a", 3);
+ gtk_list_store_append(store, &ti);
+ gtk_list_store_set(store, &ti,
+ COLUMN_HEADING, column[0],
+ COLUMN_CANDIDATE, column[1],
+ COLUMN_ANNOTATION, column[2],
+ TERMINATOR);
+
+ g_strfreev(column);
+ g_free(str);
+ }
}
}