[uim-commit] r1272 - trunk/helper

yamaken at freedesktop.org yamaken at freedesktop.org
Mon Aug 22 08:12:27 EST 2005


Author: yamaken
Date: 2005-08-21 15:12:25 -0700 (Sun, 21 Aug 2005)
New Revision: 1272

Modified:
   trunk/helper/pref-gtk-custom-widgets.c
   trunk/helper/pref-gtk.c
Log:
* 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()


Modified: trunk/helper/pref-gtk-custom-widgets.c
===================================================================
--- trunk/helper/pref-gtk-custom-widgets.c	2005-08-21 17:20:15 UTC (rev 1271)
+++ trunk/helper/pref-gtk-custom-widgets.c	2005-08-21 22:12:25 UTC (rev 1272)
@@ -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: trunk/helper/pref-gtk.c
===================================================================
--- trunk/helper/pref-gtk.c	2005-08-21 17:20:15 UTC (rev 1271)
+++ trunk/helper/pref-gtk.c	2005-08-21 22:12:25 UTC (rev 1272)
@@ -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;
 }



More information about the uim-commit mailing list