[uim-commit] r1285 - in branches/r5rs: . helper scm uim xim

tkng at freedesktop.org tkng at freedesktop.org
Mon Aug 22 12:32:37 PDT 2005


Author: tkng
Date: 2005-08-22 12:32:35 -0700 (Mon, 22 Aug 2005)
New Revision: 1285

Modified:
   branches/r5rs/
   branches/r5rs/helper/pref-gtk-custom-widgets.c
   branches/r5rs/helper/pref-gtk.c
   branches/r5rs/scm/anthy.scm
   branches/r5rs/scm/canna.scm
   branches/r5rs/scm/skk.scm
   branches/r5rs/uim/plugin.c
   branches/r5rs/xim/convdisp.cpp
Log:
 r2920 at t42 (orig r1269):  ekato | 2005-08-22 00:33:57 +0900
 * xim/convdisp.cpp (update_default_xftfont) : Plug leak.
 
 r2922 at t42 (orig r1271):  omote | 2005-08-22 02:20:15 +0900
 * plugin.c: Enable debug outputs. This commit does not harm when built without
   --enable-debug.
 
 r2923 at t42 (orig r1272):  yamaken | 2005-08-22 07:12:25 +0900
 * This commit cleanups the result of a bad coding habit
   (copy-and-pasting) appeared in r1254. As I said in [Anthy-dev 2251],
   this loosely written code naturally had a bug. Hiroyuki, please keep
   in mind good coding habit.
 
 * helper/pref-gtk.c
   - (USE_CHANGES_SENSITIVE_OK_BUTTON): New macro. Defaults to 0 since
     changes-sensitive OK button looks strange
   - (pref_apply_button, pref_ok_button): Make static
   - (uim_pref_gtk_mark_value_changed,
     uim_pref_gtk_unmark_value_changed): New function
   - (ok_button_clicked, apply_button_clicked, set_to_default_cb):
     * Replace the value-changed status handling with
       uim_pref_gtk_unmark_value_changed() and
       uim_pref_gtk_unmark_value_changed()
     * It has also fixed broken value-changed status handling
   - (create_setting_button_box):
     * Modify some messages
     * Make initial state of pref_ok_button configurable through
       USE_CHANGES_SENSITIVE_OK_BUTTON
 * helper/pref-gtk-custom-widgets.c
   - Remove external reference to pref_apply_button and pref_ok_button
   - Add external reference to uim_pref_gtk_mark_value_changed()
   - (custom_check_button_toggled_cb, custom_spin_button_value_changed,
     custom_entry_changed_cb, custom_combo_box_changed,
     olist_pref_up_button_clicked_cb,
     olist_pref_down_button_clicked_cb,
     olist_pref_left_button_clicked_cb,
     olist_pref_right_button_clicked_cb,
     key_pref_add_button_clicked_cb,
     key_pref_remove_button_clicked_cb): Unify the copy-and-pasted code
     with uim_pref_gtk_mark_value_changed()
 
 r2925 at t42 (orig r1274):  yamaken | 2005-08-22 15:10:51 +0900
 * uim/uim-util.c
   - (iterate_lists): Fix the fast path case permanently disabled. This
     fix only affects about performance in single-list cases. Former
     codes are slow, but safe.
 * test/test-uim-util.scm
   - (test iterate-lists): Add some tests for single-list cases, and
     single-null-list, multiple-null-list cases. All tests are passed
 
 r2931 at t42 (orig r1280):  yamamoto | 2005-08-22 21:39:24 +0900
 * scm/canna.scm
   (canna-reset-handler) : Clear preedit and call canna-flush.
   (canna-flush) : Deactive candidate selector.
 
 * scm/anthy.scm (anthy-reset-handler) : Clear preedit.
 
 * scm/skk.scm (skk-reset-handler) : Clear preedit.
 
 r2933 at t42 (orig r1282):  ekato | 2005-08-23 02:20:00 +0900
  * scm/skk.scm (skk-flush) : Flush its child context too.
 (skk-begin-conversion) : Bind res as #f according to [anthy-dev
   2259].
 (skk-proc-state-okuri) : Ditto.
 
 r2934 at t42 (orig r1283):  ekato | 2005-08-23 03:24:24 +0900
 * scm/skk.scm (skk-flush) : Reset skk-context-child-context and
   skk-context-child-type after flushing the child context.
 



Property changes on: branches/r5rs
___________________________________________________________________
Name: svk:merge
   - fb73e508-85ea-0310-95c3-a85c473e0941:/trunk:1263
   + fb73e508-85ea-0310-95c3-a85c473e0941:/trunk:1283

Modified: branches/r5rs/helper/pref-gtk-custom-widgets.c
===================================================================
--- branches/r5rs/helper/pref-gtk-custom-widgets.c	2005-08-22 18:27:02 UTC (rev 1284)
+++ branches/r5rs/helper/pref-gtk-custom-widgets.c	2005-08-22 19:32:35 UTC (rev 1285)
@@ -46,9 +46,9 @@
 #define OBJECT_DATA_UIM_CUSTOM_SYM    "uim-pref-gtk::uim-custom-sym"
 
 extern gboolean uim_pref_gtk_value_changed;
-extern GtkWidget *pref_apply_button;
-extern GtkWidget *pref_ok_button;
 
+extern void uim_pref_gtk_mark_value_changed(void);
+
 static GtkSizeGroup *spin_button_sgroup = NULL;
 
 static struct OListPrefWin {
@@ -95,9 +95,7 @@
   rv = uim_custom_set(custom);
 
   if (rv) {
-    uim_pref_gtk_value_changed = TRUE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_mark_value_changed();
   } else {
     g_printerr("Failed to set bool value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -179,9 +177,7 @@
   rv = uim_custom_set(custom);
 
   if (rv) {
-    uim_pref_gtk_value_changed = TRUE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_mark_value_changed();
   } else {
     g_printerr("Failed to set int value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -305,9 +301,7 @@
   }
 
   if (rv) {
-    uim_pref_gtk_value_changed = TRUE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_mark_value_changed();
   } else {
     g_printerr("Failed to set str value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -484,9 +478,7 @@
   rv = uim_custom_set(custom);
 
   if (rv) {
-    uim_pref_gtk_value_changed = TRUE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_mark_value_changed();
   } else {
     g_printerr("Failed to set str value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -813,9 +805,7 @@
   if (urv == UIM_FALSE)
     return;
 
-  uim_pref_gtk_value_changed = TRUE;
-  gtk_widget_set_sensitive(pref_apply_button, TRUE);
-  gtk_widget_set_sensitive(pref_ok_button, TRUE);
+  uim_pref_gtk_mark_value_changed();
 
   /* sync the view */
   rv = gtk_tree_model_get_iter(model, &iter2, path);
@@ -898,9 +888,7 @@
   if (urv == UIM_FALSE)
     goto ERROR;
 
-  uim_pref_gtk_value_changed = TRUE;
-  gtk_widget_set_sensitive(pref_apply_button, TRUE);
-  gtk_widget_set_sensitive(pref_ok_button, TRUE);
+  uim_pref_gtk_mark_value_changed();
 
   /* sync the view */
   gtk_list_store_swap(GTK_LIST_STORE(model), &iter1, &iter2);
@@ -990,9 +978,7 @@
   if (urv != UIM_FALSE) {
     sync_value_olist(GTK_ENTRY(olist_entry));
     olist_pref_tree_view_set_value(GTK_ENTRY(olist_entry), TRUE, TRUE);
-    uim_pref_gtk_value_changed = TRUE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_mark_value_changed();
   } else {
     /* error message */
   }
@@ -1059,9 +1045,7 @@
   if (urv != UIM_FALSE) {
     sync_value_olist(GTK_ENTRY(olist_entry));
     olist_pref_tree_view_set_value(GTK_ENTRY(olist_entry), TRUE, TRUE);
-    uim_pref_gtk_value_changed = TRUE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_mark_value_changed();
     /* FIXME! reset the selection */
   } else {
     /* error message */
@@ -1600,9 +1584,7 @@
   rv = uim_custom_set(custom);
 
   if (rv != UIM_FALSE) {
-    uim_pref_gtk_value_changed = TRUE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_mark_value_changed();
     model = gtk_tree_view_get_model(GTK_TREE_VIEW(key_pref_win.tree_view));
     gtk_list_store_append(GTK_LIST_STORE(model), &iter);
     gtk_list_store_set(GTK_LIST_STORE(model), &iter,
@@ -1666,9 +1648,7 @@
     rv = uim_custom_set(custom);
 
     if (rv != UIM_FALSE) {
-      uim_pref_gtk_value_changed = TRUE;
-      gtk_widget_set_sensitive(pref_apply_button, TRUE);
-      gtk_widget_set_sensitive(pref_ok_button, TRUE);
+      uim_pref_gtk_mark_value_changed();
       gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
 
       sync_value_key(key_entry);

Modified: branches/r5rs/helper/pref-gtk.c
===================================================================
--- branches/r5rs/helper/pref-gtk.c	2005-08-22 18:27:02 UTC (rev 1284)
+++ branches/r5rs/helper/pref-gtk.c	2005-08-22 19:32:35 UTC (rev 1285)
@@ -47,6 +47,7 @@
 
 #define DEFAULT_WINDOW_WIDTH_MAX 800
 #define DEFAULT_WINDOW_HEIGHT_MAX 600
+#define USE_CHANGES_SENSITIVE_OK_BUTTON 0
 
 static GtkWidget *pref_window = NULL;
 static GtkWidget *pref_tree_view = NULL;
@@ -54,8 +55,8 @@
 static GtkWidget *current_group_widget = NULL;
 
 gboolean uim_pref_gtk_value_changed = FALSE;
-GtkWidget *pref_apply_button = NULL;
-GtkWidget *pref_ok_button = NULL;
+static GtkWidget *pref_apply_button = NULL;
+static GtkWidget *pref_ok_button = NULL;
 
 enum
 {
@@ -64,6 +65,9 @@
   NUM_COLUMNS
 };
 
+void uim_pref_gtk_mark_value_changed(void);
+void uim_pref_gtk_unmark_value_changed(void);
+
 static gboolean	pref_tree_selection_changed(GtkTreeSelection *selection,
 					     gpointer data);
 static GtkWidget *create_pref_treeview(void);
@@ -71,6 +75,26 @@
 static void create_sub_group_widgets(GtkWidget *parent_widget,
 				     const char *parent_group);
 
+void
+uim_pref_gtk_mark_value_changed(void)
+{
+  uim_pref_gtk_value_changed = TRUE;
+  gtk_widget_set_sensitive(pref_apply_button, TRUE);
+#if USE_CHANGES_SENSITIVE_OK_BUTTON
+  gtk_widget_set_sensitive(pref_ok_button, TRUE);
+#endif
+}
+
+void
+uim_pref_gtk_unmark_value_changed(void)
+{
+  uim_pref_gtk_value_changed = FALSE;
+  gtk_widget_set_sensitive(pref_apply_button, FALSE);
+#if USE_CHANGES_SENSITIVE_OK_BUTTON
+  gtk_widget_set_sensitive(pref_ok_button, FALSE);
+#endif
+}
+
 /*
  *  2005-02-10 Takuro Ashie <ashie at homa.ne.jp>
  *    This feature is disabled according to [Anthy-dev 1795].
@@ -272,7 +296,7 @@
   if (uim_pref_gtk_value_changed) {
     uim_custom_save();
     uim_custom_broadcast_reload_request();
-    uim_pref_gtk_value_changed = FALSE;
+    uim_pref_gtk_unmark_value_changed();
   }
 
   gtk_main_quit();
@@ -286,9 +310,7 @@
   if (uim_pref_gtk_value_changed) {
     uim_custom_save();
     uim_custom_broadcast_reload_request();
-    uim_pref_gtk_value_changed = FALSE;
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
+    uim_pref_gtk_unmark_value_changed();
   }
 }
 
@@ -300,12 +322,7 @@
   if (GTK_IS_CONTAINER(widget))
     gtk_container_foreach(GTK_CONTAINER(widget),
 			  (GtkCallback) (set_to_default_cb), NULL);
-
-  if (uim_pref_gtk_value_changed) {
-    gtk_widget_set_sensitive(pref_apply_button, TRUE);
-    gtk_widget_set_sensitive(pref_ok_button, TRUE);
-  }
-
+  uim_pref_gtk_mark_value_changed();
 }
 
 static void
@@ -333,8 +350,8 @@
   gtk_box_pack_start(GTK_BOX(setting_button_box), button, TRUE, TRUE, 8);
   tooltip = gtk_tooltips_new();
   gtk_tooltips_set_tip(tooltip, button, _("Revert all changes to default"), NULL);
-  
 
+
   /* Apply button */
   pref_apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
   g_signal_connect(G_OBJECT(pref_apply_button), "clicked",
@@ -342,7 +359,7 @@
   gtk_widget_set_sensitive(pref_apply_button, FALSE);
   gtk_box_pack_start(GTK_BOX(setting_button_box), pref_apply_button, TRUE, TRUE, 8);
   tooltip = gtk_tooltips_new();
-  gtk_tooltips_set_tip(tooltip, pref_apply_button, _("Apply all new setting"), NULL);
+  gtk_tooltips_set_tip(tooltip, pref_apply_button, _("Apply all changes"), NULL);
 
   /* Cancel button */
   button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
@@ -350,16 +367,18 @@
 		   G_CALLBACK(quit_confirm), NULL);
   gtk_box_pack_start(GTK_BOX(setting_button_box), button, TRUE, TRUE, 8);
   tooltip = gtk_tooltips_new();
-  gtk_tooltips_set_tip(tooltip, button, _("Quit this application without new preference applying"), NULL);   
+  gtk_tooltips_set_tip(tooltip, button, _("Quit this application without applying changes"), NULL);
 
   /* OK button */
   pref_ok_button = gtk_button_new_from_stock(GTK_STOCK_OK);
   g_signal_connect(G_OBJECT(pref_ok_button), "clicked",
 		   G_CALLBACK(ok_button_clicked), (gpointer) group_name);
   gtk_box_pack_start(GTK_BOX(setting_button_box), pref_ok_button, TRUE, TRUE, 8);
+#if USE_CHANGES_SENSITIVE_OK_BUTTON
   gtk_widget_set_sensitive(pref_ok_button, FALSE);
+#endif
   tooltip = gtk_tooltips_new();
-  gtk_tooltips_set_tip(tooltip, pref_ok_button, _("Quit this application with new preference applying"), NULL);
+  gtk_tooltips_set_tip(tooltip, pref_ok_button, _("Quit this application with applying changes"), NULL);
 
   return setting_button_box;
 }

Modified: branches/r5rs/scm/anthy.scm
===================================================================
--- branches/r5rs/scm/anthy.scm	2005-08-22 18:27:02 UTC (rev 1284)
+++ branches/r5rs/scm/anthy.scm	2005-08-22 19:32:35 UTC (rev 1285)
@@ -975,7 +975,10 @@
 (define anthy-reset-handler
   (lambda (ac)
     (if (anthy-context-on ac)
-	(anthy-flush ac))
+        (begin
+          (anthy-flush ac)
+          (im-clear-preedit ac)
+          (im-update-preedit ac)))
     ;; code to commit pending string must not be added to here.
     ;; -- YamaKen 2004-10-21
     ))

Modified: branches/r5rs/scm/canna.scm
===================================================================
--- branches/r5rs/scm/canna.scm	2005-08-22 18:27:02 UTC (rev 1284)
+++ branches/r5rs/scm/canna.scm	2005-08-22 19:32:35 UTC (rev 1285)
@@ -249,6 +249,8 @@
   (canna-context-set-state! cc #f)
   (canna-context-set-index-list! cc ())
   (canna-context-set-transposing! cc #f)
+  (if (canna-context-candidate-window cc)
+        (im-deactivate-candidate-selector cc))
   (canna-context-set-candidate-window! cc #f)
   (canna-context-set-candidate-op-count! cc 0))
 
@@ -872,8 +874,14 @@
       (canna-commit-raw cc)))
 ;;;
 (define (canna-reset-handler cc)
-  (let ((cc-id (canna-context-cc-id cc)))
-    (canna-lib-reset-conversion cc-id)))
+  (if (canna-context-on cc)
+      (begin
+        (canna-flush cc)
+        (im-clear-preedit cc)
+        (im-update-preedit cc)
+        (if (canna-context-state cc)
+          (let ((cc-id (canna-context-cc-id cc)))
+            (canna-lib-reset-conversion cc-id))))))
 
 ;;;
 (define (canna-get-candidate-handler cc idx accel-enum-hint)

Modified: branches/r5rs/scm/skk.scm
===================================================================
--- branches/r5rs/scm/skk.scm	2005-08-22 18:27:02 UTC (rev 1284)
+++ branches/r5rs/scm/skk.scm	2005-08-22 19:32:35 UTC (rev 1285)
@@ -341,19 +341,25 @@
 
 (define skk-flush
   (lambda (sc)
-    (rk-flush (skk-context-rk-context sc))
-    (if skk-use-recursive-learning?
-	(skk-editor-flush (skk-context-editor sc)))
-    (skk-dialog-flush (skk-context-dialog sc))
-    (if (not (skk-latin-state? sc))
-	(skk-context-set-state! sc 'skk-state-direct))
-    (skk-context-set-head! sc '())
-    (skk-context-set-okuri-head! sc "")
-    (skk-context-set-okuri! sc '())
-    (skk-context-set-appendix! sc '())
-    (skk-reset-candidate-window sc)
-    (skk-context-set-nr-candidates! sc 0)
-    (skk-context-set-latin-conv! sc #f)))
+    (let ((csc (skk-context-child-context sc)))
+      (rk-flush (skk-context-rk-context sc))
+      (if skk-use-recursive-learning?
+	  (skk-editor-flush (skk-context-editor sc)))
+      (skk-dialog-flush (skk-context-dialog sc))
+      (if (not (skk-latin-state? sc))
+	  (skk-context-set-state! sc 'skk-state-direct))
+      (skk-context-set-head! sc '())
+      (skk-context-set-okuri-head! sc "")
+      (skk-context-set-okuri! sc '())
+      (skk-context-set-appendix! sc '())
+      (skk-reset-candidate-window sc)
+      (skk-context-set-nr-candidates! sc 0)
+      (skk-context-set-latin-conv! sc #f)
+      (if (not (null? csc))
+	  (begin
+	    (skk-flush csc)
+	    (skk-context-set-child-context! sc '())
+	    (skk-context-set-child-type! sc '()))))))
 
 (define skk-context-new
   (lambda (id im)
@@ -676,7 +682,7 @@
 
 (define skk-begin-completion
   (lambda (sc)
-    (let ((res))
+    (let ((res #f))
       ;; get residual 'n'
       (if (= (skk-context-state sc) 'skk-state-kanji)
 	  (skk-append-residual-kana sc))
@@ -1705,7 +1711,7 @@
   (lambda (c key key-state)
     (let* ((sc (skk-find-descendant-context c))
 	   (rkc (skk-context-rk-context sc))
-	   (res))
+	   (res #f))
       (and
        (if (skk-cancel-key? key key-state)
 	   (begin
@@ -1838,7 +1844,9 @@
 
 (define skk-reset-handler
   (lambda (sc)
-    (skk-flush sc)))
+    (skk-flush sc)
+    (im-clear-preedit sc)
+    (im-update-preedit sc)))
 
 (define skk-get-candidate-handler
   (lambda (sc idx accel-enum-hint)

Modified: branches/r5rs/uim/plugin.c
===================================================================
--- branches/r5rs/uim/plugin.c	2005-08-22 18:27:02 UTC (rev 1284)
+++ branches/r5rs/uim/plugin.c	2005-08-22 19:32:35 UTC (rev 1285)
@@ -60,6 +60,13 @@
 #define PLUGIN_PREFIX "libuim-"
 #define PLUGIN_SUFFIX ".so"
 
+#ifdef DEBUG_SCM
+static int debug_scm = DEBUG_SCM;
+#define DPRINTFN(n,x)  if (debug_scm>(n)) fprintf x;
+#else
+#define DPRINTFN(n,x)
+#endif
+
 static uim_lisp 
 plugin_load(uim_lisp _name)
 {
@@ -80,6 +87,8 @@
     return uim_scm_f();
   }
 
+  DPRINTFN(0, (stderr, "Searching libuim-%s.so.\n", plugin_name));
+
   for (path_cdr = lib_path;
        !uim_scm_nullp(path_cdr);
        path_cdr = uim_scm_cdr(path_cdr))
@@ -95,12 +104,14 @@
     fd = open(plugin_lib_filename, O_RDONLY);
     if (fd >= 0) {
       close(fd);
+      DPRINTFN(0, (stderr, "Found %s.\n", plugin_lib_filename));
       break;
     }
     free(plugin_lib_filename);
     plugin_lib_filename = NULL;
   }
 
+  DPRINTFN(0, (stderr, "Searching %s.scm.\n", plugin_name));
   for (path_cdr = scm_path;
        !uim_scm_nullp(path_cdr);
        path_cdr = uim_scm_cdr(path_cdr))
@@ -115,6 +126,7 @@
     fd = open(plugin_scm_filename, O_RDONLY);
     if (fd >= 0) {
       close(fd);
+      DPRINTFN(0, (stderr, "Found %s.\n", plugin_scm_filename));
       break;
     }
     free(plugin_scm_filename);
@@ -125,7 +137,8 @@
     free(plugin_scm_filename);
     return uim_scm_f();
   }
-    
+
+  DPRINTFN(0, (stderr, "Loading libuim-%s.so.\n", plugin_name));
   library = dlopen(plugin_lib_filename, RTLD_NOW);
   free(plugin_lib_filename);
 
@@ -145,6 +158,7 @@
     return uim_scm_f();
   }
 
+  DPRINTFN(0, (stderr, "Calling plugin_instance_init().\n", plugin_name));
   (plugin_instance_init)();
   if (plugin_scm_filename) {
     uim_bool succeeded;

Modified: branches/r5rs/xim/convdisp.cpp
===================================================================
--- branches/r5rs/xim/convdisp.cpp	2005-08-22 18:27:02 UTC (rev 1284)
+++ branches/r5rs/xim/convdisp.cpp	2005-08-22 19:32:35 UTC (rev 1285)
@@ -99,7 +99,7 @@
 
 void
 update_default_xftfont() {
-    const char *fontname;
+    char *fontname;
     
     if (!uim_scm_symbol_value_bool("uim-xim-use-xft-font?"))
       return;
@@ -118,8 +118,10 @@
 	    free(gXftFontName);
 	    free(gXftFontLocale);
 	    gXftFont = xftfont;
-	    gXftFontName = strdup(fontname);
+	    gXftFontName = fontname;
 	    gXftFontLocale = strdup(setlocale(LC_CTYPE, NULL));
+	} else {
+	    free(fontname);
 	}
     }
 }



More information about the uim-commit mailing list