Hiroyuki Ikezoe
ikezo****@users*****
2006年 11月 24日 (金) 11:57:13 JST
Index: libtomoe-gtk/src/Makefile.am diff -u libtomoe-gtk/src/Makefile.am:1.16 libtomoe-gtk/src/Makefile.am:1.17 --- libtomoe-gtk/src/Makefile.am:1.16 Thu Nov 23 16:15:50 2006 +++ libtomoe-gtk/src/Makefile.am Fri Nov 24 11:57:13 2006 @@ -11,8 +11,6 @@ tomoe-canvas.c tomoe-canvas.h \ tomoe-char-table.c tomoe-char-table.h \ tomoe-details.c tomoe-details.h \ - tomoe-dictionaries-page.c tomoe-dictionaries-page.h \ - tomoe-dictionary-page.c tomoe-dictionary-page.h \ tomoe-edit-char.c tomoe-edit-char.h \ tomoe-edit-meta.c tomoe-edit-meta.h \ tomoe-edit-strokes.c tomoe-edit-strokes.h \ @@ -30,8 +28,6 @@ tomoe-canvas.h \ tomoe-char-table.h \ tomoe-details.h \ - tomoe-dictionaries-page.h \ - tomoe-dictionary-page.h \ tomoe-edit-char.h \ tomoe-edit-meta.h \ tomoe-edit-strokes.h \ Index: libtomoe-gtk/src/tomoe-dictionaries-page.c diff -u libtomoe-gtk/src/tomoe-dictionaries-page.c:1.15 libtomoe-gtk/src/tomoe-dictionaries-page.c:removed --- libtomoe-gtk/src/tomoe-dictionaries-page.c:1.15 Thu Nov 23 19:05:20 2006 +++ libtomoe-gtk/src/tomoe-dictionaries-page.c Fri Nov 24 11:57:13 2006 @@ -1,404 +0,0 @@ -/* - * Copyright (C) 2006 Juernjakob Harder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H - #include <config.h> -#endif - -#include <stdlib.h> -#include <glib/gi18n.h> -#include <gtk/gtk.h> -#include <tomoe.h> - -#include "tomoe-dictionaries-page.h" - -enum { - LAST_SIGNAL -}; - -enum { - LOAD_COLUMN, - SAVE_COLUMN, - NAME_COLUMN, - DICT_COLUMN, - COLUMN_COUNT -}; - -enum -{ - PROP_0, - PROP_TOMOE_CONTEXT -}; - -typedef struct _TomoeDictionariesPagePrivate TomoeDictionariesPagePrivate; -struct _TomoeDictionariesPagePrivate -{ - - GtkWidget *dict_list; - GtkListStore *store; - GtkWidget *remove_button; - TomoeContext *context; -}; - -#define TOMOE_DICTIONARIES_PAGE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_DICTIONARIES_PAGE, TomoeDictionariesPagePrivate)) - -G_DEFINE_TYPE (TomoeDictionariesPage, tomoe_dictionaries_page, GTK_TYPE_TABLE) - -static GObject *constructor (GType type, - guint n_props, - GObjectConstructParam *props); -static void dispose (GObject *object); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void _populate (TomoeDictionariesPage *page); - -static void on_selection_changed (GtkTreeSelection *selection, - gpointer user_data); -static void on_add_button_clicked (GtkButton *button, - gpointer user_data); -static void on_remove_button_clicked (GtkButton *button, - gpointer user_data); -static void on_use_check_toggled (GtkCellRendererToggle *cell_renderer, - gchar *path, - gpointer user_data); - -GtkWidget * -tomoe_dictionaries_page_new (TomoeContext *context) -{ - GtkWidget *w = GTK_WIDGET(g_object_new (TOMOE_TYPE_DICTIONARIES_PAGE, - "tomoe-context", context, - NULL)); - return w; -} - -static void -tomoe_dictionaries_page_class_init (TomoeDictionariesPageClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->dispose = dispose; - gobject_class->constructor = constructor; - gobject_class->set_property = set_property; - gobject_class->get_property = get_property; - - g_object_class_install_property (gobject_class, - PROP_TOMOE_CONTEXT, - g_param_spec_object ("tomoe-context", - N_("TomoeContext object"), - N_("The Object of TomoeContext"), - TOMOE_TYPE_CONTEXT, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - g_type_class_add_private (gobject_class, sizeof (TomoeDictionariesPagePrivate)); -} - -static GObject * -constructor (GType type, guint n_props, - GObjectConstructParam *props) -{ - GObject *object; - TomoeDictionariesPage *page; - GtkWidget *vbox, *hbox, *list, *button, *alignment; - GtkWidget *scrolled_window; - GtkWidget *label; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *sel; - GObjectClass *klass = G_OBJECT_CLASS (tomoe_dictionaries_page_parent_class); - - object = klass->constructor (type, n_props, props); - page = TOMOE_DICTIONARIES_PAGE (object); - - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (object); - - gtk_table_resize (GTK_TABLE (page), 1, 1); - gtk_table_set_homogeneous (GTK_TABLE (page), TRUE); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 8); - gtk_table_attach_defaults (GTK_TABLE (page), hbox, - 0, 1, 0, 1); - gtk_widget_show (hbox); - - /* dictionary list */ - priv->store = gtk_list_store_new (COLUMN_COUNT, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_OBJECT); - - list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->store)); - priv->dict_list = list; - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_ALWAYS); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_SHADOW_ETCHED_IN); - - renderer = gtk_cell_renderer_toggle_new (); - column = gtk_tree_view_column_new_with_attributes (_("Use"), - renderer, - "active", LOAD_COLUMN, - NULL); - g_signal_connect (G_OBJECT (renderer), "toggled", - G_CALLBACK (on_use_check_toggled), - (gpointer) page); - gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); - - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Editable"), - renderer, - "text", SAVE_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Name"), - renderer, - "text", NAME_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); - - gtk_container_add (GTK_CONTAINER (scrolled_window), list); - g_signal_connect (G_OBJECT (sel), "changed", - G_CALLBACK (on_selection_changed), - (gpointer) page); - gtk_widget_show (list); - gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 0); - gtk_widget_show (scrolled_window); - - /* button area */ - alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 8, 0); - gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0); - gtk_widget_show (alignment); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (alignment), vbox); - gtk_widget_show (vbox); - - button = gtk_button_new_from_stock (GTK_STOCK_ADD); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_add_button_clicked), - (gpointer) page); - gtk_widget_show (button); - - button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); - priv->remove_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_remove_button_clicked), - (gpointer) page); - gtk_widget_show (button); - - label = gtk_label_new (_("Please restart\nTomoe to apply")); - gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 4); - gtk_widget_show (label); - - _populate (page); - - /* tomoe_dictionaries_page_set_sensitive (page); */ - - return object; -} - -static void -tomoe_dictionaries_page_init (TomoeDictionariesPage *page) -{ -} - -static void -dispose (GObject *object) -{ - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (object); - - if (priv->store) - g_object_unref (priv->store); - - if (priv->context) - g_object_unref (priv->context); - - priv->store = NULL; - priv->context = NULL; - - if (G_OBJECT_CLASS(tomoe_dictionaries_page_parent_class)->dispose) - G_OBJECT_CLASS(tomoe_dictionaries_page_parent_class)->dispose(object); -} - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_TOMOE_CONTEXT: - priv->context = g_object_ref (g_value_get_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_TOMOE_CONTEXT: - g_value_set_object (value, priv->context); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -_populate (TomoeDictionariesPage *page) -{ - GtkTreeIter iter; - GList *dicts, *list; - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (page); - - if (!priv->context || !priv->store) - return; - - dicts = tomoe_context_get_dict_names (priv->context); - gtk_list_store_clear (priv->store); - - for (list = dicts; list; list = g_list_next (list)) { - const gchar *name = list->data; - TomoeDict *dict = tomoe_context_get_dict (priv->context, name); - - gtk_list_store_append (priv->store, &iter); - gtk_list_store_set (priv->store, &iter, - LOAD_COLUMN, tomoe_dict_is_editable (dict), - SAVE_COLUMN, tomoe_dict_is_modified (dict), - NAME_COLUMN, name, - DICT_COLUMN, dict, - -1); - } - g_list_free (list); -} - -static void -on_selection_changed (GtkTreeSelection *selection, gpointer user_data) -{ - TomoeDictionariesPage *page = TOMOE_DICTIONARIES_PAGE (user_data); - - g_return_if_fail (TOMOE_IS_DICTIONARIES_PAGE (page)); - - /* tomoe_dictionaries_page_set_sensitive (page); */ -} - -static void -on_add_button_clicked (GtkButton *button, gpointer user_data) -{ - GtkWidget *dialog; - GtkFileFilter *filter; - TomoeDictionariesPage *page = TOMOE_DICTIONARIES_PAGE (user_data); - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (page); - - dialog = gtk_file_chooser_dialog_new (_("Add TOMOE XML dictionary"), - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (page))), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - NULL); - filter = gtk_file_filter_new (); - gtk_file_filter_set_name (filter, _("XML dictionary")); - gtk_file_filter_add_mime_type (filter, "application/xml"); - gtk_file_filter_add_pattern (filter, "*.xml"); - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter); - - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { - const gchar *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - TomoeDict *dict = tomoe_dict_new (filename, TRUE); - - tomoe_context_add_dict (priv->context, dict); - g_object_unref (dict); - - _populate (page); /* FIXME */ - } - - gtk_widget_destroy (dialog); -} - -static void -on_remove_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeDictionariesPage *page = TOMOE_DICTIONARIES_PAGE (user_data); - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (page); - GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->dict_list)); - GtkTreeModel *model = NULL; - GtkTreeIter iter; - gchar *dict_name = NULL; - - if (gtk_tree_selection_get_selected (sel, &model, &iter)) { - gtk_tree_model_get(GTK_TREE_MODEL (priv->store), &iter, - NAME_COLUMN, &dict_name, - -1); - } - - if (dict_name) { - tomoe_context_remove_dict (priv->context, dict_name); - _populate (page); /* FIXME */ - g_free (dict_name); - } -} - -static void -on_use_check_toggled (GtkCellRendererToggle *cell_renderer, gchar *path, gpointer user_data) -{ - TomoeDictionariesPage *page = TOMOE_DICTIONARIES_PAGE (user_data); - TomoeDictionariesPagePrivate *priv = TOMOE_DICTIONARIES_PAGE_GET_PRIVATE (page); - TomoeDict *dict; - GtkTreeIter iter; - - if(!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (priv->store), &iter, path)) - return; - gtk_tree_model_get(GTK_TREE_MODEL (priv->store), &iter, - DICT_COLUMN, &dict, - -1); - - if (dict) { - /* gboolean active = gtk_cell_renderer_toggle_get_active (cell_renderer);*/ - /* tomoe_dict_set_XX (dict, active); */ - _populate (page); /* FIXME */ - } -} -/* - * vi:ts=4:nowrap:ai:expandtab - */ Index: libtomoe-gtk/src/tomoe-dictionaries-page.h diff -u libtomoe-gtk/src/tomoe-dictionaries-page.h:1.5 libtomoe-gtk/src/tomoe-dictionaries-page.h:removed --- libtomoe-gtk/src/tomoe-dictionaries-page.h:1.5 Tue Nov 21 20:17:22 2006 +++ libtomoe-gtk/src/tomoe-dictionaries-page.h Fri Nov 24 11:57:13 2006 @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2006 Juernjakob Harder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __TOMOE_DICTIONARIES_PAGE_H__ -#define __TOMOE_DICTIONARIES_PAGE_H__ - -#include <glib.h> -#include <glib-object.h> -#include <gtk/gtktable.h> -#include <tomoe.h> - -G_BEGIN_DECLS - -#define TOMOE_TYPE_DICTIONARIES_PAGE (tomoe_dictionaries_page_get_type ()) -#define TOMOE_DICTIONARIES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICTIONARIES_PAGE, TomoeDictionariesPage)) -#define TOMOE_DICTIONARIES_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICTIONARIES_PAGE, TomoeDictionariesPageClass)) -#define TOMOE_IS_DICTIONARIES_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICTIONARIES_PAGE)) -#define TOMOE_IS_DICTIONARIES_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICTIONARIES_PAGE)) -#define TOMOE_DICTIONARIES_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOMOE_TYPE_DICTIONARIES_PAGE, TomoeDictionariesPageClass)) - - -typedef struct _TomoeDictionariesPageClass TomoeDictionariesPageClass; -typedef struct _TomoeDictionariesPage TomoeDictionariesPage; - -struct _TomoeDictionariesPage -{ - GtkTable parent_instance; -}; - -struct _TomoeDictionariesPageClass -{ - GtkTableClass parent_class; -}; - - -GType tomoe_dictionaries_page_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_dictionaries_page_new (TomoeContext *context); - -G_END_DECLS - -#endif /* __TOMOE_DICTIONARIES_PAGE_H__ */ - Index: libtomoe-gtk/src/tomoe-dictionary-page.c diff -u libtomoe-gtk/src/tomoe-dictionary-page.c:1.21 libtomoe-gtk/src/tomoe-dictionary-page.c:removed --- libtomoe-gtk/src/tomoe-dictionary-page.c:1.21 Thu Nov 23 16:05:07 2006 +++ libtomoe-gtk/src/tomoe-dictionary-page.c Fri Nov 24 11:57:13 2006 @@ -1,579 +0,0 @@ -/* - * Copyright (C) 2006 Juernjakob Harder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H - #include <config.h> -#endif - -#include <stdlib.h> -#include <glib/gprintf.h> -#include <glib/gi18n.h> -#include <gtk/gtk.h> -#include <tomoe.h> - -#include "tomoe-dictionary-page.h" -#include "tomoe-details.h" - -enum { - LAST_SIGNAL -}; - -enum { - CODE_POINT_COLUMN, - STROKECOUNT_COLUMN, - READING_COLUMN, - COLUMN_COUNT -}; - -enum -{ - PROP_0, - PROP_TOMOE_CONTEXT -}; - -typedef struct _TomoeDictionaryPagePrivate TomoeDictionaryPagePrivate; -struct _TomoeDictionaryPagePrivate -{ - GtkWidget *char_list; - GtkListStore *store; - GtkWidget *dict_list; - GtkWidget *add_button; - GtkWidget *delete_button; - GtkWidget *details_button; - - TomoeContext *context; -}; - -#define TOMOE_DICTIONARY_PAGE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_DICTIONARY_PAGE, TomoeDictionaryPagePrivate)) - -G_DEFINE_TYPE (TomoeDictionaryPage, tomoe_dictionary_page, GTK_TYPE_TABLE) - -static GObject *constructor (GType type, - guint n_props, - GObjectConstructParam *props); -static void dispose (GObject *object); -static void set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void tomoe_dictionary_page_set_sensitive (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 (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, - gpointer user_data); -static void on_add_button_clicked (GtkButton *button, - gpointer user_data); -static void on_delete_button_clicked (GtkButton *button, - gpointer user_data); -static void on_details_button_clicked (GtkButton *button, - gpointer user_data); -static gboolean on_tree_view_button_press (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -/*static guint dictionary_page_signals[LAST_SIGNAL] = { 0 };*/ -GtkWidget * -tomoe_dictionary_page_new (TomoeContext *context) -{ - GtkWidget *w = GTK_WIDGET(g_object_new (TOMOE_TYPE_DICTIONARY_PAGE, - "tomoe-context", context, - NULL)); - return w; -} - -static void -tomoe_dictionary_page_class_init (TomoeDictionaryPageClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->dispose = dispose; - gobject_class->constructor = constructor; - gobject_class->set_property = set_property; - gobject_class->get_property = get_property; - - g_object_class_install_property (gobject_class, - PROP_TOMOE_CONTEXT, - g_param_spec_object ("tomoe-context", - N_("TomoeContext object"), - N_("The Object of TomoeContext"), - TOMOE_TYPE_CONTEXT, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY)); - g_type_class_add_private (gobject_class, sizeof (TomoeDictionaryPagePrivate)); -} - -static void -tomoe_dictionary_page_init (TomoeDictionaryPage *page) -{ -} - -static GObject * -constructor (GType type, guint n_props, - GObjectConstructParam *props) -{ - GObject *object; - GtkWidget *main_vbox, *vbox, *hbox, *list, *button, *alignment; - GtkWidget *scrolled_window; - GtkWidget *label, *droplist; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *char_sel; - TomoeDictionaryPage *page; - GObjectClass *klass = G_OBJECT_CLASS (tomoe_dictionary_page_parent_class); - - object = klass->constructor (type, n_props, props); - page = TOMOE_DICTIONARY_PAGE (object); - - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (object); - - gtk_table_resize (GTK_TABLE (page), 1, 1); - gtk_table_set_homogeneous (GTK_TABLE (page), TRUE); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 8); - gtk_table_attach_defaults (GTK_TABLE (page), hbox, - 0, 1, 0, 1); - gtk_widget_show (hbox); - - main_vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), main_vbox, - TRUE, TRUE, 0); - gtk_widget_set_size_request (main_vbox, 320, 320); - gtk_widget_show (main_vbox); - - /* dictionary list */ - priv->store = gtk_list_store_new (COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); - - list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (priv->store)); - priv->char_list = list; - g_signal_connect (G_OBJECT (priv->char_list), "button-press-event", - G_CALLBACK (on_tree_view_button_press), page); - char_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); - gtk_tree_selection_set_mode (char_sel, GTK_SELECTION_SINGLE); - g_signal_connect (G_OBJECT (char_sel), "changed", - G_CALLBACK (on_selection_changed), - (gpointer) page); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_ALWAYS); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_SHADOW_ETCHED_IN); - gtk_container_add (GTK_CONTAINER (scrolled_window), list); - gtk_widget_show (scrolled_window); - - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Code point"), - renderer, - "text", CODE_POINT_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Stroke count"), - renderer, - "text", STROKECOUNT_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Reading"), - renderer, - "text", READING_COLUMN, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (list), column); - gtk_box_pack_start (GTK_BOX (main_vbox), scrolled_window, TRUE, TRUE, 0); - gtk_widget_show (list); - - /* button area */ - alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 8, 0); - gtk_box_pack_start (GTK_BOX (hbox), alignment, FALSE, FALSE, 0); - gtk_widget_show (alignment); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (alignment), vbox); - gtk_widget_show (vbox); - - button = gtk_button_new_from_stock (GTK_STOCK_ADD); - priv->add_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_add_button_clicked), - (gpointer) page); - gtk_widget_show (button); - - button = gtk_button_new_from_stock (GTK_STOCK_EDIT); /*FIXME*/ - priv->details_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_details_button_clicked), - (gpointer) page); - gtk_widget_show (button); - - button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); - priv->delete_button = button; - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 4); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (on_delete_button_clicked), - (gpointer) page); - gtk_widget_show (button); - - /* default user context area */ - alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 0, 8, 0); - gtk_box_pack_start (GTK_BOX (main_vbox), alignment, FALSE, FALSE, 0); - gtk_widget_show (alignment); - - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (alignment), hbox); - gtk_widget_show (hbox); - - label = gtk_label_new (_("Dictionary: ")); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 4); - gtk_widget_show (label); - - droplist = gtk_combo_box_new_text (); - priv->dict_list = droplist; - gtk_box_pack_start (GTK_BOX (hbox), droplist, TRUE, TRUE, 4); - gtk_widget_show (droplist); - - _populate_dict_list (page); - _populate (page); - - g_signal_connect (G_OBJECT (droplist), "changed", - G_CALLBACK (on_dict_list_changed), - (gpointer) page); - - tomoe_dictionary_page_set_sensitive (page); - - return object; -} - -static void -dispose (GObject *object) -{ - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (object); - - if (priv->store) - g_object_unref (priv->store); - - if (priv->context) - g_object_unref (priv->context); - priv->context = NULL; - priv->store = NULL; - - if (G_OBJECT_CLASS(tomoe_dictionary_page_parent_class)->dispose) - G_OBJECT_CLASS(tomoe_dictionary_page_parent_class)->dispose(object); -} - -static void -set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_TOMOE_CONTEXT: - priv->context = g_object_ref (g_value_get_object (value)); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (object); - - switch (prop_id) { - case PROP_TOMOE_CONTEXT: - g_value_set_object (value, priv->context); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -tomoe_dictionary_page_set_sensitive (TomoeDictionaryPage *page) -{ - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (page); - gboolean selected = TRUE; - gboolean editable; - - editable = tomoe_dict_is_editable (_get_active_dict (page)); - - gtk_widget_set_sensitive (priv->delete_button, selected & editable); - gtk_widget_set_sensitive (priv->details_button, selected); - gtk_widget_set_sensitive (priv->add_button, editable); -} - -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)) { - gtk_tree_model_get(GTK_TREE_MODEL (priv->store), &iter, - CODE_POINT_COLUMN, &code_point, - -1); - } - return code_point; -} - -static void -_populate (TomoeDictionaryPage *page) -{ - guint i; - GtkTreeIter iter; - TomoeDict *dict; - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (page); - const GPtrArray *letters; - - if (!priv->store) - return; - - dict = _get_active_dict (page); - 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 = TOMOE_CHAR (g_ptr_array_index (letters, i)); - gchar *readings_buf = NULL; - gchar strokes_text[32]; - gint strokes = 0; - gint j; - const GList *readings = tomoe_char_get_readings (chr); - - if (tomoe_char_get_writing (chr)) - strokes = tomoe_writing_get_number_of_strokes (tomoe_char_get_writing (chr)); - - if (strokes > 0) - g_sprintf (strokes_text, "%d", strokes); - else - g_strlcpy (strokes_text, "?", 32); - - if (readings) { - const GList *list; - gint reading_num = g_list_length ((GList *) readings); - gchar **reading_array = g_new0 (gchar*, reading_num + 1); - for (list = readings, j = 0; list; list = g_list_next (list), j++) { - TomoeReading *reading = TOMOE_READING (list->data); - reading_array[j] = (gchar *) tomoe_reading_get_reading (reading); - } - readings_buf = g_strjoinv (" ", reading_array); - g_free (reading_array); - } - gtk_list_store_append (priv->store, &iter); - gtk_list_store_set (priv->store, &iter, - CODE_POINT_COLUMN, tomoe_char_get_code (chr), - STROKECOUNT_COLUMN, strokes_text, - READING_COLUMN, readings_buf, - -1); - g_free (readings_buf); - } - -} - -static void -_populate_dict_list (TomoeDictionaryPage *page) -{ - GList *dicts, *list; - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (page); - - if (!priv->context || !priv->dict_list) - return; - - dicts = tomoe_context_get_dict_names (priv->context); - - for (list = dicts; list; list = g_list_next (list)) { - const gchar *dict_name = list->data; - GtkComboBox *def = GTK_COMBO_BOX (priv->dict_list); - gtk_combo_box_append_text (def, dict_name); - } - g_list_free (dicts); - - gtk_combo_box_set_active (GTK_COMBO_BOX (priv->dict_list), 0); - /* TODO save active in settings */ -} - -static TomoeDict * -_get_active_dict (TomoeDictionaryPage *page) -{ - TomoeDict *dict; - gchar *dict_name; - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (page); - - dict_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (priv->dict_list)); - dict = tomoe_context_get_dict (priv->context, dict_name); - g_free (dict_name); - - return dict; -} - -static void -_show_details_window_for_character (TomoeDictionaryPage *page, const gchar *code_point) -{ - GtkWidget *wnd; - TomoeChar *chr; - TomoeDict *dict; - gint result; - - g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (page)); - - dict = _get_active_dict (page); - chr = tomoe_dict_get_char (dict, code_point); - - wnd = tomoe_details_new (chr, dict); - result = gtk_dialog_run (GTK_DIALOG (wnd)); - gtk_widget_destroy (wnd); - if (result) - _populate (page); /* FIXME */ -} - -static void -on_dict_list_changed (GtkComboBox *dict_list, gpointer user_data) -{ - TomoeDictionaryPage *page = TOMOE_DICTIONARY_PAGE (user_data); - - g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (page)); - - _populate (page); - tomoe_dictionary_page_set_sensitive (page); -} - -static void -on_selection_changed (GtkTreeSelection *selection, gpointer user_data) -{ - TomoeDictionaryPage *page = TOMOE_DICTIONARY_PAGE (user_data); - - g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (page)); - - tomoe_dictionary_page_set_sensitive (page); -} - -static void -on_add_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeChar *chr; - TomoeDictionaryPage *page = TOMOE_DICTIONARY_PAGE (user_data); - TomoeDict *dict; - - g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (page)); - - dict = _get_active_dict (page); - chr = tomoe_char_new (); - tomoe_char_set_code (chr, "??"); - tomoe_dict_register_char (dict, chr); - _populate (page); -} - -static void -on_delete_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeDictionaryPage *page = TOMOE_DICTIONARY_PAGE (user_data); - TomoeDict *dict; - const gchar *code_point; - - g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (page)); - - code_point = _get_code_point_of_selected_character (page); - - dict = _get_active_dict (page); - tomoe_dict_unregister_char (dict, code_point); - _populate (page); -} - -static void -on_details_button_clicked (GtkButton *button, gpointer user_data) -{ - TomoeDictionaryPage *page; - const gchar *code_point; - - g_return_if_fail (TOMOE_IS_DICTIONARY_PAGE (user_data)); - - page = TOMOE_DICTIONARY_PAGE (user_data); - code_point = _get_code_point_of_selected_character (page); - - _show_details_window_for_character (page, code_point); -} - -static gboolean -on_tree_view_button_press (GtkWidget *widget, GdkEventButton *event, gpointer user_data) -{ - GtkTreePath *path = NULL; - - g_return_val_if_fail (TOMOE_IS_DICTIONARY_PAGE (user_data), FALSE); - - if (event->type != GDK_2BUTTON_PRESS || event->button != 1) - return FALSE; - - gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), - (gint) event->x, (gint) event->y, - &path, NULL, - NULL, NULL); - if (path) { - GtkTreeIter iter; - const gchar *code_point = NULL; - TomoeDictionaryPage *page = TOMOE_DICTIONARY_PAGE (user_data); - TomoeDictionaryPagePrivate *priv = TOMOE_DICTIONARY_PAGE_GET_PRIVATE (user_data); - - gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->store), &iter, path); - gtk_tree_path_free (path); - 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; -} - -/* - * vi:ts=4:nowrap:ai:expandtab - */ Index: libtomoe-gtk/src/tomoe-dictionary-page.h diff -u libtomoe-gtk/src/tomoe-dictionary-page.h:1.6 libtomoe-gtk/src/tomoe-dictionary-page.h:removed --- libtomoe-gtk/src/tomoe-dictionary-page.h:1.6 Tue Nov 21 20:17:22 2006 +++ libtomoe-gtk/src/tomoe-dictionary-page.h Fri Nov 24 11:57:13 2006 @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2006 Juernjakob Harder - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __TOMOE_DICTIONARY_PAGE_H__ -#define __TOMOE_DICTIONARY_PAGE_H__ - -#include <glib.h> -#include <glib-object.h> -#include <gtk/gtktable.h> -#include <tomoe.h> - -G_BEGIN_DECLS - -#define TOMOE_TYPE_DICTIONARY_PAGE (tomoe_dictionary_page_get_type ()) -#define TOMOE_DICTIONARY_PAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TOMOE_TYPE_DICTIONARY_PAGE, TomoeDictionaryPage)) -#define TOMOE_DICTIONARY_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TOMOE_TYPE_DICTIONARY_PAGE, TomoeDictionaryPageClass)) -#define TOMOE_IS_DICTIONARY_PAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TOMOE_TYPE_DICTIONARY_PAGE)) -#define TOMOE_IS_DICTIONARY_PAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TOMOE_TYPE_DICTIONARY_PAGE)) -#define TOMOE_DICTIONARY_PAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TOMOE_TYPE_DICTIONARY_PAGE, TomoeDictionaryPageClass)) - - -typedef struct _TomoeDictionaryPageClass TomoeDictionaryPageClass; -typedef struct _TomoeDictionaryPage TomoeDictionaryPage; - -struct _TomoeDictionaryPage -{ - GtkTable parent_instance; -}; - -struct _TomoeDictionaryPageClass -{ - GtkTableClass parent_class; -}; - - -GType tomoe_dictionary_page_get_type (void) G_GNUC_CONST; -GtkWidget *tomoe_dictionary_page_new (TomoeContext *context); - -G_END_DECLS - -#endif /* __TOMOE_DICTIONARY_PAGE_H__ */ - Index: libtomoe-gtk/src/tomoe-window.c diff -u libtomoe-gtk/src/tomoe-window.c:1.15 libtomoe-gtk/src/tomoe-window.c:1.16 --- libtomoe-gtk/src/tomoe-window.c:1.15 Fri Nov 24 10:20:16 2006 +++ libtomoe-gtk/src/tomoe-window.c Fri Nov 24 11:57:13 2006 @@ -29,9 +29,7 @@ #include "tomoe-canvas.h" #include "tomoe-stroke-search.h" #include "tomoe-char-table.h" -#include "tomoe-dictionaries-page.h" #include "tomoe-reading-search.h" -#include "tomoe-dictionary-page.h" #define TOMOE_DATA_VIEW_ICON LIBTOMOEGTKDATADIR"/tomoe-data-view.png" #define TOMOE_DICTIONARY_ICON LIBTOMOEGTKDATADIR"/tomoe-dictionary.png" @@ -44,10 +42,8 @@ TomoeContext *context; GtkWidget *notebook; GtkWidget *handwriting_page; - GtkWidget *dictionaries_page; GtkWidget *reading_search; GtkWidget *character_page; - GtkWidget *dictionary_page; }; #define TOMOE_WINDOW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TOMOE_TYPE_WINDOW, TomoeWindowPrivate)) @@ -69,8 +65,8 @@ static void tomoe_window_init (TomoeWindow *window) { - GtkWidget *handwriting_page, *dictionaries_page, *reading_search; - GtkWidget *notebook, *page; + GtkWidget *handwriting_page, *reading_search; + GtkWidget *notebook; TomoeCanvas *canvas; TomoeWindowPrivate *priv = TOMOE_WINDOW_GET_PRIVATE (window); @@ -119,20 +115,6 @@ tomoe_window_append_page (window, reading_search, gtk_image_new_from_file (TOMOE_SEARCHING_ICON), _("Search with reading ")); - - dictionaries_page = tomoe_dictionaries_page_new (priv->context); - priv->dictionaries_page = dictionaries_page; - gtk_widget_show (dictionaries_page); - tomoe_window_append_page (window, dictionaries_page, - gtk_image_new_from_file (TOMOE_DICTIONARY_ICON), - _("List view of Dictionaries")); - - page = tomoe_dictionary_page_new (priv->context); - priv->dictionary_page = page; - gtk_widget_show (page); - tomoe_window_append_page (window, page, - gtk_image_new_from_file (TOMOE_DATA_VIEW_ICON), - _("List view of contents in each dictionary")); } static void