Hiroyuki Ikezoe
ikezo****@users*****
2006年 11月 22日 (水) 20:24:45 JST
Index: libtomoe-gtk/src/tomoe-canvas.c diff -u libtomoe-gtk/src/tomoe-canvas.c:1.16 libtomoe-gtk/src/tomoe-canvas.c:1.17 --- libtomoe-gtk/src/tomoe-canvas.c:1.16 Wed Nov 22 16:22:25 2006 +++ libtomoe-gtk/src/tomoe-canvas.c Wed Nov 22 20:24:45 2006 @@ -477,7 +477,8 @@ TomoeCanvasPriv *priv; GtkWidget *widget = GTK_WIDGET (canvas); const GList *strokes, *list; - TomoeWriting *g; + TomoeWriting *writing; + TomoeQuery *query; GdkColor color = { 0, 0x8000, 0x0000, 0x0000}; g_return_if_fail (TOMOE_IS_CANVAS (canvas)); @@ -486,10 +487,10 @@ priv = TOMOE_CANVAS_GET_PRIVATE (canvas); /* create a new writing which has more sparse points */ - g = create_sparse_writing (canvas); + writing = create_sparse_writing (canvas); /* draw thin red lines and annotations for sparse points */ - strokes = tomoe_writing_get_strokes (g); + strokes = tomoe_writing_get_strokes (writing); for (list = strokes; list; list = g_list_next (list)) { GList *points = (GList *) list->data; GList *point; @@ -511,9 +512,11 @@ _g_list_free_all (priv->candidates, g_object_unref); priv->candidates = NULL; } - priv->candidates = tomoe_context_search_by_strokes (priv->context, g); - - g_object_unref (g); + query = tomoe_query_new (); + tomoe_query_set_writing (query, writing); + priv->candidates = tomoe_context_search (priv->context, query); + g_object_unref (query); + g_object_unref (writing); gdk_draw_drawable(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], Index: libtomoe-gtk/src/tomoe-dictionary-page.c diff -u libtomoe-gtk/src/tomoe-dictionary-page.c:1.17 libtomoe-gtk/src/tomoe-dictionary-page.c:1.18 --- libtomoe-gtk/src/tomoe-dictionary-page.c:1.17 Wed Nov 22 16:23:28 2006 +++ libtomoe-gtk/src/tomoe-dictionary-page.c Wed Nov 22 20:24:45 2006 @@ -34,7 +34,7 @@ }; enum { - CHAR_COLUMN, + CODE_POINT_COLUMN, STROKECOUNT_COLUMN, READING_COLUMN, COLUMN_COUNT @@ -78,13 +78,13 @@ static void tomoe_dictionary_page_set_sensitive (TomoeDictionaryPage *page); -static int _get_selection (TomoeDictionaryPage *page); +static const gchar * _get_code_point_of_selected_character + (TomoeDictionaryPage *page); static void _populate (TomoeDictionaryPage *page); static void _populate_dict_list (TomoeDictionaryPage *page); static TomoeDict *_get_active_dict (TomoeDictionaryPage *page); -static void _show_details_window_for_character_index (TomoeDictionaryPage *page, - gint index); - +static void _show_details_window_for_character (TomoeDictionaryPage *page, + const gchar *code_point); static void on_dict_list_changed (GtkComboBox *dict_list, gpointer user_data); static void on_selection_changed (GtkTreeSelection *selection, @@ -190,9 +190,9 @@ gtk_widget_show (scrolled_window); renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Character"), + column = gtk_tree_view_column_new_with_attributes (_("Code point"), renderer, - "text", CHAR_COLUMN, + "text", CODE_POINT_COLUMN, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); renderer = gtk_cell_renderer_text_new (); @@ -335,7 +335,7 @@ tomoe_dictionary_page_set_sensitive (TomoeDictionaryPage *page) { TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (page); - gboolean selected = (0 <= _get_selection (page)); + gboolean selected = TRUE; gboolean editable; editable = tomoe_dict_is_editable (_get_active_dict (page)); @@ -345,30 +345,31 @@ gtk_widget_set_sensitive (priv->add_button, editable); } -static int -_get_selection (TomoeDictionaryPage *page) +static const gchar* +_get_code_point_of_selected_character (TomoeDictionaryPage *page) { TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (page); GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->char_list)); GtkTreeModel *model = NULL; GtkTreeIter iter; + const gchar *code_point = NULL; if (gtk_tree_selection_get_selected (sel, &model, &iter)) { - GtkTreePath *path = gtk_tree_model_get_path (model, &iter); - gint *ind = gtk_tree_path_get_indices (path); - return ind ? ind[0] : -1; - } else { - return -1; + gtk_tree_model_get(GTK_TREE_MODEL (priv->store), &iter, + CODE_POINT_COLUMN, &code_point, + -1); } + return code_point; } static void _populate (TomoeDictionaryPage *page) { - int i; + guint i; GtkTreeIter iter; TomoeDict *dict; TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (page); + const GPtrArray *letters; if (!priv->store) return; @@ -377,9 +378,10 @@ if (!dict) return; gtk_list_store_clear (priv->store); + letters = tomoe_dict_get_letters (dict); for (i = 0; i < tomoe_dict_get_size (dict); i++) { - TomoeChar *chr = (TomoeChar*)tomoe_dict_char_by_index (dict, i); + TomoeChar *chr = TOMOE_CHAR (g_ptr_array_index (letters, i)); gchar *readings_buf = NULL; gchar strokes_text[32]; gint strokes = 0; @@ -405,7 +407,7 @@ } gtk_list_store_append (priv->store, &iter); gtk_list_store_set (priv->store, &iter, - CHAR_COLUMN, tomoe_char_get_code (chr), + CODE_POINT_COLUMN, tomoe_char_get_code (chr), STROKECOUNT_COLUMN, strokes_text, READING_COLUMN, readings_buf, -1); @@ -451,7 +453,7 @@ } static void -_show_details_window_for_character_index (TomoeDictionaryPage *page, gint index) +_show_details_window_for_character (TomoeDictionaryPage *page, const gchar *code_point) { GtkWidget *wnd; TomoeChar *chr; @@ -461,7 +463,7 @@ g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (page)); dict = _get_active_dict (page); - chr = tomoe_dict_char_by_index (dict, index); + chr = tomoe_dict_get_char (dict, code_point); wnd = tomoe_details_new (chr, dict); result = gtk_dialog_run (GTK_DIALOG (wnd)); @@ -503,7 +505,7 @@ dict = _get_active_dict (page); chr = tomoe_char_new (); tomoe_char_set_code (chr, "??"); - tomoe_dict_add_char (dict, chr); + tomoe_dict_register_char (dict, chr); _populate (page); } @@ -511,16 +513,15 @@ on_delete_button_clicked (GtkButton *button, gpointer user_data) { TomoeDictionaryPage *page = TOMOE_DICTIONARY_PAGE (user_data); - int index; TomoeDict *dict; + const gchar *code_point; g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (page)); - index = _get_selection (page); - if (index < 0) return; + code_point = _get_code_point_of_selected_character (page); dict = _get_active_dict (page); - tomoe_dict_remove_by_index (dict, index); + tomoe_dict_unregister_char (dict, code_point); _populate (page); } @@ -528,15 +529,14 @@ on_details_button_clicked (GtkButton *button, gpointer user_data) { TomoeDictionaryPage *page; - gint index; + const gchar *code_point; g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (user_data)); page = TOMOE_DICTIONARY_PAGE (user_data); - index = _get_selection (page); - if (index < 0) return; + code_point = _get_code_point_of_selected_character (page); - _show_details_window_for_character_index (page, index); + _show_details_window_for_character (page, code_point); } static gboolean @@ -551,12 +551,18 @@ &path, NULL, NULL, NULL); if (path) { - gint index; + GtkTreeIter iter; + const gchar *code_point = NULL; TomoeDictionaryPage *page = TOMOE_DICTIONARY_PAGE (user_data); + TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (user_data); - index = gtk_tree_path_get_indices (path)[0]; + gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->store), &iter, path); gtk_tree_path_free (path); - _show_details_window_for_character_index (page, index); + gtk_tree_model_get(GTK_TREE_MODEL (priv->store), &iter, + CODE_POINT_COLUMN, &code_point, + -1); + if (code_point) + _show_details_window_for_character (page, code_point); } } return FALSE; Index: libtomoe-gtk/src/tomoe-reading-search-page.c diff -u libtomoe-gtk/src/tomoe-reading-search-page.c:1.11 libtomoe-gtk/src/tomoe-reading-search-page.c:1.12 --- libtomoe-gtk/src/tomoe-reading-search-page.c:1.11 Wed Nov 22 15:58:07 2006 +++ libtomoe-gtk/src/tomoe-reading-search-page.c Wed Nov 22 20:24:45 2006 @@ -192,7 +192,9 @@ tomoe_reading_search_page_start_search (TomoeReadingSearchPage *page) { GList *result, *list; - const gchar *reading; + const gchar *reading_text; + TomoeQuery *query; + TomoeReading *reading; TomoeReadingSearchPagePrivate *priv = TOMOE_READING_SEARCH_PAGE_GET_PRIVATE (page); g_return_if_fail (GTK_IS_LIST_STORE (priv->result_store)); @@ -200,8 +202,14 @@ gtk_list_store_clear (priv->result_store); - reading = gtk_entry_get_text (GTK_ENTRY (priv->input)); - result = tomoe_context_search_by_reading (priv->context, reading); + reading_text = gtk_entry_get_text (GTK_ENTRY (priv->input)); +#warning FIXME! there is no ui for selection of on-reading or kun-reading. + reading = tomoe_reading_new (TOMOE_READING_ON, reading_text); + query = tomoe_query_new (); + tomoe_query_add_reading (query, reading); + result = tomoe_context_search (priv->context, query); + g_object_unref (query); + g_object_unref (reading); for (list = result; list; list = g_list_next (list)) {