Revision: 7335
Author:   deton.kih
Date:     Sat Oct 22 19:29:57 2011
Log:      * Extract vertical candwin from uim-cand-win-gtk.c
  to uim-cand-win-vertical-gtk.c.
* gtk2/immodule/uim-cand-win-gtk.c
  - (uim_cand_win_gtk_init):
    Move initialization of TreeView to uim_cand_win_vertical_gtk_init().
  - (tree_selection_change,
     tree_selection_changed,
     tree_view_button_press): Move to uim-cand-win-vertical-gtk.c.
  - (uim_cand_win_gtk_real_set_index):
    Move TreeView dependent codes to uim-cand-win-vertical-gtk.c.
  - (uim_cand_win_gtk_real_set_page):
    Comment out TreeView dependent code.
* gtk2/immodule/gtk-im-uim.c
  - (im_uim_create_cand_win_gtk):
    Change to call uim_cand_win_vertical_gtk_new()
    on creating vertical candwin.
* gtk2/immodule/uim-cand-win-vertical-gtk.c
  - New file extracted from uim-cand-win-gtk.c
* gtk2/immodule/uim-cand-win-vertical-gtk.h
  - New file.
* gtk2/immodule/uim-cand-win-horizontal-gtk.c
  - (uim_cand_win_horizontal_gtk_init):
    Remove destroy of vertical view.
* gtk2/immodule/uim-cand-win-tbl-gtk.c
  - (uim_cand_win_tbl_gtk_init):
    Remove destroy of vertical view.
* gtk2/immodule/Makefile.am
  - (IM_UIM_SOURCES): Add uim-cand-win-vertical-gtk.[ch]
* gtk3/immodule/Makefile.am
  - (IM_UIM_SOURCES): Add uim-cand-win-vertical-gtk.[ch]

http://code.google.com/p/uim/source/detail?r=7335

Added:
 /trunk/gtk2/immodule/uim-cand-win-vertical-gtk.c
 /trunk/gtk2/immodule/uim-cand-win-vertical-gtk.h
Modified:
 /trunk/gtk2/immodule/Makefile.am
 /trunk/gtk2/immodule/gtk-im-uim.c
 /trunk/gtk2/immodule/uim-cand-win-gtk.c
 /trunk/gtk2/immodule/uim-cand-win-horizontal-gtk.c
 /trunk/gtk2/immodule/uim-cand-win-tbl-gtk.c
 /trunk/gtk3/immodule/Makefile.am

=======================================
--- /dev/null
+++ /trunk/gtk2/immodule/uim-cand-win-vertical-gtk.c Sat Oct 22 19:29:57 2011
@@ -0,0 +1,375 @@
+/*
+
+  copyright (c) 2011 uim Project http://code.google.com/p/uim/
+
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  3. Neither the name of authors nor the names of its contributors
+     may be used to endorse or promote products derived from this software
+     without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
+
+*/
+
+#include <config.h>
+
+#include "uim-cand-win-vertical-gtk.h"
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <uim/uim.h>
+#include <uim/uim-scm.h>
+
+enum {
+  INDEX_CHANGED_SIGNAL,
+  NR_SIGNALS
+};
+
+enum {
+  TERMINATOR = -1,
+  COLUMN_HEADING,
+  COLUMN_CANDIDATE,
+  COLUMN_ANNOTATION,
+  LISTSTORE_NR_COLUMNS
+};
+
+static void uim_cand_win_vertical_gtk_init(UIMCandWinVerticalGtk *cwin);
+static void uim_cand_win_vertical_gtk_class_init(UIMCandWinGtkClass *klass);
+static void uim_cand_win_vertical_gtk_dispose(GObject *obj);
+
+static gboolean        tree_selection_change           (GtkTreeSelection 
*selection,
+                                                GtkTreeModel *model,
+                                                GtkTreePath *path,
+                                                gboolean 
path_currently_selected,
+                                                gpointer data);
+static gboolean tree_selection_changed         (GtkTreeSelection *selection,
+                                                gpointer data);
+static gboolean tree_view_button_press         (GtkWidget *widget,
+                                                GdkEventButton *event,
+                                                gpointer data);
+
+
+static GType cand_win_vertical_type = 0;
+static GTypeInfo const object_info = {
+  sizeof (UIMCandWinVerticalGtkClass),
+  (GBaseInitFunc) NULL,
+  (GBaseFinalizeFunc) NULL,
+  (GClassInitFunc) uim_cand_win_vertical_gtk_class_init,
+  (GClassFinalizeFunc) NULL,
+  NULL,                       /* class_data */
+  sizeof (UIMCandWinVerticalGtk),
+  0,                          /* n_preallocs */
+  (GInstanceInitFunc) uim_cand_win_vertical_gtk_init,
+};
+
+static UIMCandWinGtkClass *parent_class = NULL;
+
+GType
+uim_cand_win_vertical_gtk_get_type(void)
+{
+  if (!cand_win_vertical_type)
+ cand_win_vertical_type = g_type_register_static(UIM_TYPE_CAND_WIN_GTK, "UIMCandWinVerticalGtk",
+                                          &object_info, (GTypeFlags)0);
+  return cand_win_vertical_type;
+}
+
+GType
+uim_cand_win_vertical_gtk_register_type(GTypeModule *module)
+{
+  if (!cand_win_vertical_type)
+    cand_win_vertical_type = g_type_module_register_type(module,
+                                               UIM_TYPE_CAND_WIN_GTK,
+                                               "UIMCandWinVerticalGtk",
+                                               &object_info, 0);
+  return cand_win_vertical_type;
+}
+
+static void
+uim_cand_win_vertical_gtk_class_init (UIMCandWinGtkClass *klass)
+{
+  GObjectClass *object_class = (GObjectClass *) klass;
+
+  parent_class = g_type_class_peek_parent (klass);
+  object_class->dispose = uim_cand_win_vertical_gtk_dispose;
+
+ klass->set_index = (void (*)(UIMCandWinGtk *, gint))uim_cand_win_vertical_gtk_set_index; + klass->set_page = (void (*)(UIMCandWinGtk *, gint))uim_cand_win_vertical_gtk_set_page;
+}
+
+static void
+uim_cand_win_vertical_gtk_init (UIMCandWinVerticalGtk *vertical_cwin)
+{
+  UIMCandWinGtk *cwin;
+  GtkCellRenderer *renderer;
+  GtkTreeViewColumn *column;
+  GtkTreeSelection *selection;
+
+  cwin = UIM_CAND_WIN_GTK(vertical_cwin);
+
+  cwin->view = gtk_tree_view_new();
+  gtk_container_add(GTK_CONTAINER(cwin->scrolled_window), cwin->view);
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(cwin->view));
+
+  gtk_tree_selection_set_select_function(selection,
+                                        tree_selection_change,
+                                        cwin,
+                                        NULL);
+  g_signal_connect (G_OBJECT(selection), "changed",
+                   G_CALLBACK(tree_selection_changed), cwin);
+
+  renderer = gtk_cell_renderer_text_new();
+  g_object_set(renderer, "scale", 0.8, (const gchar *)NULL);
+
+  column = gtk_tree_view_column_new_with_attributes("No",
+                                                   renderer,
+                                                   "text", COLUMN_HEADING,
+                                                   (const gchar *)NULL);
+  gtk_tree_view_append_column(GTK_TREE_VIEW(cwin->view), column);
+  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+
+  renderer = gtk_cell_renderer_text_new();
+  g_object_set(renderer, "scale", 1.2, (const gchar *)NULL);
+  /*  g_object_set(renderer, "size-points", 20.0, NULL); */
+  column = gtk_tree_view_column_new_with_attributes("Text",
+                                                   renderer,
+                                                   "text", COLUMN_CANDIDATE,
+                                                   (const gchar *)NULL);
+  gtk_tree_view_append_column(GTK_TREE_VIEW(cwin->view), column);
+  gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cwin->view), TRUE);
+  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(cwin->view), FALSE);
+  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+
+  g_signal_connect(G_OBJECT(cwin->view), "button-press-event",
+                  G_CALLBACK(tree_view_button_press), cwin);
+
+  gtk_widget_show(cwin->view);
+}
+
+static void
+uim_cand_win_vertical_gtk_dispose (GObject *obj)
+{
+  if (G_OBJECT_CLASS (parent_class)->dispose)
+    G_OBJECT_CLASS (parent_class)->dispose(obj);
+}
+
+UIMCandWinVerticalGtk *
+uim_cand_win_vertical_gtk_new (void)
+{
+  GObject *obj = g_object_new(UIM_TYPE_CAND_WIN_VERTICAL_GTK,
+                             "type", GTK_WINDOW_POPUP,
+                             NULL);
+
+  return UIM_CAND_WIN_VERTICAL_GTK(obj);
+}
+
+static gboolean
+tree_selection_change(GtkTreeSelection *selection,
+                     GtkTreeModel *model,
+                     GtkTreePath *path,
+                     gboolean path_currently_selected,
+                     gpointer data)
+{
+  UIMCandWinVerticalGtk *vertical_cwin = UIM_CAND_WIN_VERTICAL_GTK(data);
+  UIMCandWinGtk *cwin = UIM_CAND_WIN_GTK(vertical_cwin);
+  gint *indicies;
+  gint idx;
+
+  if (!cwin)
+    return TRUE;
+
+  indicies = gtk_tree_path_get_indices(path);
+  g_return_val_if_fail(indicies, TRUE);
+  idx = *indicies + cwin->display_limit * cwin->page_index;
+
+  if (!path_currently_selected && cwin->candidate_index != idx) {
+    if (cwin->candidate_index >= 0) {
+      cwin->candidate_index = idx;
+      g_signal_emit_by_name(G_OBJECT(cwin), "index-changed");
+    }
+
+    uim_cand_win_gtk_update_label(cwin);
+
+    if (cwin->candidate_index < 0)
+      return FALSE;
+    else
+      return TRUE;
+  } else {
+    uim_cand_win_gtk_update_label(cwin);
+
+    return TRUE;
+  }
+}
+
+static gboolean
+tree_selection_changed(GtkTreeSelection *selection,
+                      gpointer data)
+{
+  GtkTreeModel *model;
+  GtkTreeIter iter;
+  UIMCandWinVerticalGtk *vertical_cwin = UIM_CAND_WIN_VERTICAL_GTK(data);
+  UIMCandWinGtk *cwin = UIM_CAND_WIN_GTK(vertical_cwin);
+
+  if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+    char *annotation = NULL;
+
+    gtk_tree_model_get(model, &iter,
+                      COLUMN_ANNOTATION, &annotation,
+                      -1);
+
+    if (annotation && *annotation) {
+      if (!cwin->sub_window.window)
+       uim_cand_win_gtk_create_sub_window(cwin);
+      gtk_text_buffer_set_text(
+       gtk_text_view_get_buffer(GTK_TEXT_VIEW(cwin->sub_window.text_view)),
+       annotation, -1);
+      uim_cand_win_gtk_layout_sub_window(cwin);
+      gtk_widget_show(cwin->sub_window.window);
+      cwin->sub_window.active = TRUE;
+    } else {
+      if (cwin->sub_window.window) {
+       gtk_widget_hide(cwin->sub_window.window);
+       cwin->sub_window.active = FALSE;
+      }
+    }
+    free(annotation);
+  } else {
+    if (cwin->sub_window.window) {
+      gtk_widget_hide(cwin->sub_window.window);
+      cwin->sub_window.active = FALSE;
+    }
+  }
+
+  return TRUE;
+}
+
+static gboolean
+tree_view_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+  UIMCandWinVerticalGtk *vertical_cwin;
+  UIMCandWinGtk *cwin;
+  GtkTreePath *path;
+  gboolean exist, retval = FALSE;
+  gint *indicies;
+
+  g_return_val_if_fail(GTK_IS_TREE_VIEW(widget), FALSE);
+  g_return_val_if_fail(UIM_CAND_WIN_VERTICAL_GTK(data), FALSE);
+
+  vertical_cwin = UIM_CAND_WIN_VERTICAL_GTK(data);
+  cwin = UIM_CAND_WIN_GTK(vertical_cwin);
+
+  exist = gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
+                                       event->x, event->y,
+                                       &path, NULL, NULL, NULL);
+  if (!exist)
+    return FALSE;
+
+  indicies = gtk_tree_path_get_indices(path);
+
+  /* don't relay button press event to empty row */
+ if (cwin->display_limit * cwin->page_index + *indicies >= cwin->nr_candidates)
+    retval = TRUE;
+
+  gtk_tree_path_free(path);
+
+  return retval;
+}
+
+
+void
+uim_cand_win_vertical_gtk_set_index(UIMCandWinVerticalGtk *vertical_cwin, gint index)
+{
+  UIMCandWinGtk *cwin;
+  UIMCandWinVerticalGtkClass *vertical_cwin_class;
+  UIMCandWinGtkClass *cwin_class;
+
+  g_return_if_fail(UIM_IS_CAND_WIN_VERTICAL_GTK(vertical_cwin));
+  cwin = UIM_CAND_WIN_GTK(vertical_cwin);
+
+  /* call parent method */
+  vertical_cwin_class = UIM_CAND_WIN_VERTICAL_GTK_GET_CLASS(vertical_cwin);
+  cwin_class = g_type_class_peek_parent(vertical_cwin_class);
+  cwin_class->set_index(cwin, index);
+
+  if (cwin->candidate_index >= 0) {
+    GtkTreePath *path;
+    gint pos = index;
+
+    if (cwin->display_limit)
+      pos = cwin->candidate_index % cwin->display_limit;
+
+    path = gtk_tree_path_new_from_indices(pos, -1);
+    gtk_tree_view_set_cursor(GTK_TREE_VIEW(cwin->view),
+                            path, NULL, FALSE);
+    gtk_tree_path_free(path);
+
+  } else {
+ GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cwin->view));
+
+    gtk_tree_selection_unselect_all(selection);
+    uim_cand_win_gtk_update_label(cwin);
+  }
+}
+
+void
+uim_cand_win_vertical_gtk_set_page(UIMCandWinVerticalGtk *vertical_cwin, gint page)
+{
+  guint len, new_page;
+  gint new_index;
+  UIMCandWinGtk *cwin;
+
+  g_return_if_fail(UIM_IS_CAND_WIN_VERTICAL_GTK(vertical_cwin));
+  cwin = UIM_CAND_WIN_GTK(vertical_cwin);
+  g_return_if_fail(cwin->stores);
+
+  len = cwin->stores->len;
+  g_return_if_fail(len);
+
+  if (page < 0)
+    new_page = len - 1;
+  else if (page >= (gint) len)
+    new_page = 0;
+  else
+    new_page = page;
+
+  gtk_tree_view_set_model(GTK_TREE_VIEW(cwin->view),
+                         GTK_TREE_MODEL(cwin->stores->pdata[new_page]));
+
+  cwin->page_index = new_page;
+
+  if (cwin->display_limit) {
+    if (cwin->candidate_index >= 0)
+      new_index
+ = (new_page * cwin->display_limit) + (cwin->candidate_index % cwin->display_limit);
+    else
+      new_index = -1;
+  } else {
+    new_index = cwin->candidate_index;
+  }
+
+  if (new_index >= (gint) cwin->nr_candidates)
+    new_index = cwin->nr_candidates - 1;
+
+  uim_cand_win_gtk_set_index(cwin, new_index);
+}
=======================================
--- /dev/null
+++ /trunk/gtk2/immodule/uim-cand-win-vertical-gtk.h Sat Oct 22 19:29:57 2011
@@ -0,0 +1,70 @@
+/*
+
+  Copyright (c) 2011 uim Project http://code.google.com/p/uim/
+
+  All rights reserved.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  1. Redistributions of source code must retain the above copyright
+     notice, this list of conditions and the following disclaimer.
+  2. Redistributions in binary form must reproduce the above copyright
+     notice, this list of conditions and the following disclaimer in the
+     documentation and/or other materials provided with the distribution.
+  3. Neither the name of authors nor the names of its contributors
+     may be used to endorse or promote products derived from this software
+     without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  SUCH DAMAGE.
+
+*/
+
+#ifndef UIM_GTK_UIM_CAND_WIN_VERTICAL_GTK_H
+#define UIM_GTK_UIM_CAND_WIN_VERTICAL_GTK_H
+
+#include "uim-cand-win-gtk.h"
+
+G_BEGIN_DECLS
+
+#define UIM_TYPE_CAND_WIN_VERTICAL_GTK (uim_cand_win_vertical_gtk_get_type ()) +#define UIM_CAND_WIN_VERTICAL_GTK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), UIM_TYPE_CAND_WIN_VERTICAL_GTK, UIMCandWinVerticalGtk)) +#define UIM_CAND_WIN_VERTICAL_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), UIM_TYPE_CAND_WIN_VERTICAL_GTK, UIMCandWinVerticalGtkClass)) +#define UIM_IS_CAND_WIN_VERTICAL_GTK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), UIM_TYPE_CAND_WIN_VERTICAL_GTK)) +#define UIM_IS_CAND_WIN_VERTICAL_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), UIM_TYPE_CAND_WIN_VERTICAL_GTK)) +#define UIM_CAND_WIN_VERTICAL_GTK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), UIM_TYPE_CAND_WIN_VERTICAL_GTK, UIMCandWinVerticalGtkClass))
+
+typedef struct _UIMCandWinVerticalGtk UIMCandWinVerticalGtk;
+typedef struct _UIMCandWinVerticalGtkClass UIMCandWinVerticalGtkClass;
+
+struct _UIMCandWinVerticalGtk {
+  UIMCandWinGtk parent;
+};
+
+struct _UIMCandWinVerticalGtkClass {
+  UIMCandWinGtkClass parent_class;
+};
+
+GType uim_cand_win_vertical_gtk_register_type(GTypeModule *module);
+GType uim_cand_win_vertical_gtk_get_type(void);
+UIMCandWinVerticalGtk  *uim_cand_win_vertical_gtk_new(void);
+
+void uim_cand_win_vertical_gtk_set_index(UIMCandWinVerticalGtk *cwin, gint index); +void uim_cand_win_vertical_gtk_set_page(UIMCandWinVerticalGtk *cwin, gint page); +void uim_cand_win_vertical_gtk_create_sub_window(UIMCandWinVerticalGtk *cwin); +void uim_cand_win_vertical_gtk_layout_sub_window(UIMCandWinVerticalGtk *cwin);
+
+G_END_DECLS
+
+#endif /*UIM_GTK_UIM_CAND_WIN_VERTICAL_GTK_H */
=======================================
--- /trunk/gtk2/immodule/Makefile.am    Thu Jun 16 23:54:38 2011
+++ /trunk/gtk2/immodule/Makefile.am    Sat Oct 22 19:29:57 2011
@@ -23,6 +23,7 @@
 IM_UIM_SOURCES = \
        gtk-im-uim.c gtk-im-uim.h key-util-gtk.c key-util-gtk.h \
        uim-cand-win-gtk.c uim-cand-win-gtk.h \
+       uim-cand-win-vertical-gtk.c uim-cand-win-vertical-gtk.h \
        uim-cand-win-tbl-gtk.c uim-cand-win-tbl-gtk.h \
        uim-cand-win-horizontal-gtk.c uim-cand-win-horizontal-gtk.h \
        caret-state-indicator.c caret-state-indicator.h \
=======================================
--- /trunk/gtk2/immodule/gtk-im-uim.c   Fri Oct 14 16:12:44 2011
+++ /trunk/gtk2/immodule/gtk-im-uim.c   Sat Oct 22 19:29:57 2011
@@ -59,6 +59,7 @@

 #include "gtk-im-uim.h"
 #include "uim-cand-win-gtk.h"
+#include "uim-cand-win-vertical-gtk.h"
 #include "uim-cand-win-tbl-gtk.h"
 #include "uim-cand-win-horizontal-gtk.h"
 #include "caret-state-indicator.h"
@@ -1521,7 +1522,7 @@
   free(style);

   if (!cwin)
-    cwin = uim_cand_win_gtk_new(); /* vertical */
+    cwin = UIM_CAND_WIN_GTK(uim_cand_win_vertical_gtk_new());

   return cwin;
 }
=======================================
--- /trunk/gtk2/immodule/uim-cand-win-gtk.c     Thu Jun 16 23:54:38 2011
+++ /trunk/gtk2/immodule/uim-cand-win-gtk.c     Sat Oct 22 19:29:57 2011
@@ -67,17 +67,6 @@
 static void    uim_cand_win_gtk_real_create_sub_window(UIMCandWinGtk *cwin);
 static void    uim_cand_win_gtk_real_layout_sub_window (UIMCandWinGtk *cwin);

-static gboolean        tree_selection_change           (GtkTreeSelection 
*selection,
-                                                GtkTreeModel *model,
-                                                GtkTreePath *path,
-                                                gboolean 
path_currently_selected,
-                                                gpointer data);
-static gboolean tree_selection_changed         (GtkTreeSelection *selection,
-                                                gpointer data);
-static gboolean tree_view_button_press         (GtkWidget *widget,
-                                                GdkEventButton *event,
-                                                gpointer data);
-

 static GType cand_win_type = 0;
 static GTypeInfo const object_info = {
@@ -161,15 +150,11 @@
 static void
 uim_cand_win_gtk_init (UIMCandWinGtk *cwin)
 {
-  GtkCellRenderer *renderer;
-  GtkTreeViewColumn *column;
   GtkWidget *frame;
   GtkWidget *vbox;
-  GtkTreeSelection *selection;

   /* init struct */
   cwin->scrolled_window = gtk_scrolled_window_new(NULL, NULL);
-  cwin->view = gtk_tree_view_new();
   cwin->num_label = gtk_label_new("");

   cwin->stores = g_ptr_array_new();
@@ -195,7 +180,6 @@
   gtk_box_pack_start(GTK_BOX(vbox), cwin->scrolled_window, TRUE, TRUE, 0);
   uim_cand_win_gtk_set_scrollable(cwin, FALSE);

-  gtk_container_add(GTK_CONTAINER(cwin->scrolled_window), cwin->view);
   gtk_box_pack_start(GTK_BOX(vbox), cwin->num_label, FALSE, FALSE, 0);

   frame = gtk_frame_new(NULL);
@@ -204,46 +188,11 @@
   gtk_container_add(GTK_CONTAINER(cwin), frame);
   gtk_container_set_border_width(GTK_CONTAINER(cwin), 0);

-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(cwin->view));
-
-  gtk_tree_selection_set_select_function(selection,
-                                        tree_selection_change,
-                                        cwin,
-                                        NULL);
-  g_signal_connect (G_OBJECT(selection), "changed",
-                   G_CALLBACK(tree_selection_changed), cwin);
-
-  renderer = gtk_cell_renderer_text_new();
-  g_object_set(renderer, "scale", 0.8, (const gchar *)NULL);
-
-  column = gtk_tree_view_column_new_with_attributes("No",
-                                                   renderer,
-                                                   "text", COLUMN_HEADING,
-                                                   (const gchar *)NULL);
-  gtk_tree_view_append_column(GTK_TREE_VIEW(cwin->view), column);
-  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
-  renderer = gtk_cell_renderer_text_new();
-  g_object_set(renderer, "scale", 1.2, (const gchar *)NULL);
-  /*  g_object_set(renderer, "size-points", 20.0, NULL); */
-  column = gtk_tree_view_column_new_with_attributes("Text",
-                                                   renderer,
-                                                   "text", COLUMN_CANDIDATE,
-                                                   (const gchar *)NULL);
-  gtk_tree_view_append_column(GTK_TREE_VIEW(cwin->view), column);
-  gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(cwin->view), TRUE);
-  gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(cwin->view), FALSE);
-  gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-
-  g_signal_connect(G_OBJECT(cwin->view), "button-press-event",
-                  G_CALLBACK(tree_view_button_press), cwin);
-
   /* set size */
   /* gtk_widget_set_size_request(cwin->view, -1, -1); */

   /* show children */
   gtk_widget_show(cwin->scrolled_window);
-  gtk_widget_show(cwin->view);
   gtk_widget_show(cwin->num_label);
   gtk_widget_show(vbox);
   gtk_widget_show(frame);
@@ -332,115 +281,6 @@

   gtk_label_set_text(GTK_LABEL(cwin->num_label), label_str);
 }
-
-static gboolean
-tree_selection_change(GtkTreeSelection *selection,
-                     GtkTreeModel *model,
-                     GtkTreePath *path,
-                     gboolean path_currently_selected,
-                     gpointer data)
-{
-  UIMCandWinGtk *cwin = data;
-  gint *indicies;
-  gint idx;
-
-  if (!cwin)
-    return TRUE;
-
-  indicies = gtk_tree_path_get_indices(path);
-  g_return_val_if_fail(indicies, TRUE);
-  idx = *indicies + cwin->display_limit * cwin->page_index;
-
-  if (!path_currently_selected && cwin->candidate_index != idx) {
-    if (cwin->candidate_index >= 0) {
-      cwin->candidate_index = idx;
-      g_signal_emit(G_OBJECT(cwin),
-                   cand_win_gtk_signals[INDEX_CHANGED_SIGNAL], 0);
-    }
-
-    uim_cand_win_gtk_update_label(cwin);
-
-    if (cwin->candidate_index < 0)
-      return FALSE;
-    else
-      return TRUE;
-  } else {
-    uim_cand_win_gtk_update_label(cwin);
-
-    return TRUE;
-  }
-}
-
-static gboolean
-tree_selection_changed(GtkTreeSelection *selection,
-                      gpointer data)
-{
-  GtkTreeModel *model;
-  GtkTreeIter iter;
-  UIMCandWinGtk *cwin = UIM_CAND_WIN_GTK(data);
-
-  if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
-    char *annotation = NULL;
-
-    gtk_tree_model_get(model, &iter,
-                      COLUMN_ANNOTATION, &annotation,
-                      -1);
-
-    if (annotation && *annotation) {
-      if (!cwin->sub_window.window)
-       uim_cand_win_gtk_create_sub_window(cwin);
-      gtk_text_buffer_set_text(
-       gtk_text_view_get_buffer(GTK_TEXT_VIEW(cwin->sub_window.text_view)),
-       annotation, -1);
-      uim_cand_win_gtk_layout_sub_window(cwin);
-      gtk_widget_show(cwin->sub_window.window);
-      cwin->sub_window.active = TRUE;
-    } else {
-      if (cwin->sub_window.window) {
-       gtk_widget_hide(cwin->sub_window.window);
-       cwin->sub_window.active = FALSE;
-      }
-    }
-    free(annotation);
-  } else {
-    if (cwin->sub_window.window) {
-      gtk_widget_hide(cwin->sub_window.window);
-      cwin->sub_window.active = FALSE;
-    }
-  }
-
-  return TRUE;
-}
-
-static gboolean
-tree_view_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data)
-{
-  UIMCandWinGtk *cwin;
-  GtkTreePath *path;
-  gboolean exist, retval = FALSE;
-  gint *indicies;
-
-  g_return_val_if_fail(GTK_IS_TREE_VIEW(widget), FALSE);
-  g_return_val_if_fail(UIM_CAND_WIN_GTK(data), FALSE);
-
-  cwin = UIM_CAND_WIN_GTK(data);
-
-  exist = gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
-                                       event->x, event->y,
-                                       &path, NULL, NULL, NULL);
-  if (!exist)
-    return FALSE;
-
-  indicies = gtk_tree_path_get_indices(path);
-
-  /* don't relay button press event to empty row */
- if (cwin->display_limit * cwin->page_index + *indicies >= cwin->nr_candidates)
-    retval = TRUE;
-
-  gtk_tree_path_free(path);
-
-  return retval;
-}

 void
 uim_cand_win_gtk_set_nr_candidates(UIMCandWinGtk *cwin,
@@ -662,25 +502,6 @@

   if (cwin->page_index != new_page)
     uim_cand_win_gtk_set_page(cwin, new_page);
-
-  if (cwin->candidate_index >= 0) {
-    GtkTreePath *path;
-    gint pos = index;
-
-    if (cwin->display_limit)
-      pos = cwin->candidate_index % cwin->display_limit;
-
-    path = gtk_tree_path_new_from_indices(pos, -1);
-    gtk_tree_view_set_cursor(GTK_TREE_VIEW(cwin->view),
-                            path, NULL, FALSE);
-    gtk_tree_path_free(path);
-
-  } else {
- GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cwin->view));
-
-    gtk_tree_selection_unselect_all(selection);
-    uim_cand_win_gtk_update_label(cwin);
-  }
 }

 guint
@@ -725,8 +546,10 @@
   else
     new_page = page;

+  /* XXX: change to call virtual update_view()
   gtk_tree_view_set_model(GTK_TREE_VIEW(cwin->view),
                          GTK_TREE_MODEL(cwin->stores->pdata[new_page]));
+  */

   cwin->page_index = new_page;

=======================================
--- /trunk/gtk2/immodule/uim-cand-win-horizontal-gtk.c Sun Jul 3 21:08:27 2011 +++ /trunk/gtk2/immodule/uim-cand-win-horizontal-gtk.c Sat Oct 22 19:29:57 2011
@@ -133,7 +133,6 @@
   horizontal_cwin->buttons = g_ptr_array_new();
   horizontal_cwin->selected = NULL;

-  gtk_widget_destroy(cwin->view);
   cwin->view = gtk_table_new(1, DEFAULT_NR_CELLS, FALSE);
   gtk_table_set_col_spacings(GTK_TABLE(cwin->view), 10);
   viewport = gtk_viewport_new(NULL, NULL);
=======================================
--- /trunk/gtk2/immodule/uim-cand-win-tbl-gtk.c Tue May 24 07:44:08 2011
+++ /trunk/gtk2/immodule/uim-cand-win-tbl-gtk.c Sat Oct 22 19:29:57 2011
@@ -167,7 +167,6 @@
   ctblwin->buttons = g_ptr_array_new();
   ctblwin->tbl_cell2label = init_tbl_cell2label();

-  gtk_widget_destroy(cwin->view);
   cwin->view = gtk_table_new(TABLE_NR_ROWS, TABLE_NR_COLUMNS, FALSE);
   viewport = gtk_viewport_new(NULL, NULL);
   gtk_container_add(GTK_CONTAINER(viewport), cwin->view);
=======================================
--- /trunk/gtk3/immodule/Makefile.am    Thu Jun 16 23:54:38 2011
+++ /trunk/gtk3/immodule/Makefile.am    Sat Oct 22 19:29:57 2011
@@ -25,6 +25,8 @@
        ../../gtk2/immodule/key-util-gtk.c ../../gtk2/immodule/key-util-gtk.h \
        ../../gtk2/immodule/uim-cand-win-gtk.c \
        ../../gtk2/immodule/uim-cand-win-gtk.h \
+       ../../gtk2/immodule/uim-cand-win-vertical-gtk.c \
+       ../../gtk2/immodule/uim-cand-win-vertical-gtk.h \
        ../../gtk2/immodule/uim-cand-win-tbl-gtk.c \
        ../../gtk2/immodule/uim-cand-win-tbl-gtk.h \
        ../../gtk2/immodule/uim-cand-win-horizontal-gtk.c \

Reply via email to