[uim-commit] r1254 - trunk/helper

tkng at freedesktop.org tkng at freedesktop.org
Sun Aug 21 13:27:29 EST 2005


Author: tkng
Date: 2005-08-20 20:27:27 -0700 (Sat, 20 Aug 2005)
New Revision: 1254

Modified:
   trunk/helper/pref-gtk-custom-widgets.c
   trunk/helper/pref-gtk.c
Log:
* This commit aims to disable apply/OK button when it doesn't have a effect.

* helper/pref-gtk.c:
 -(pref_apply_button,pref_ok_button): Global variables which hold a reference
  to apply/OK button.
 -(create_setting_button_box): Changed to use pref_apply_button,pref_ok_button.
 -(create_group_widget): Stop calling of create_setting_button_box.
 -(create_pref_window): Call create_setting_button_box.

* helper/pref-gtk-custom-widgets.c:
 -(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): Enable apply/OK button if value was changed successfully.


Modified: trunk/helper/pref-gtk-custom-widgets.c
===================================================================
--- trunk/helper/pref-gtk-custom-widgets.c	2005-08-21 03:06:28 UTC (rev 1253)
+++ trunk/helper/pref-gtk-custom-widgets.c	2005-08-21 03:27:27 UTC (rev 1254)
@@ -46,6 +46,8 @@
 #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;
 
 static GtkSizeGroup *spin_button_sgroup = NULL;
 
@@ -94,6 +96,8 @@
 
   if (rv) {
     uim_pref_gtk_value_changed = TRUE;
+    gtk_widget_set_sensitive(pref_apply_button, TRUE);
+    gtk_widget_set_sensitive(pref_ok_button, TRUE);
   } else {
     g_printerr("Failed to set bool value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -176,6 +180,8 @@
 
   if (rv) {
     uim_pref_gtk_value_changed = TRUE;
+    gtk_widget_set_sensitive(pref_apply_button, TRUE);
+    gtk_widget_set_sensitive(pref_ok_button, TRUE);
   } else {
     g_printerr("Failed to set int value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -300,6 +306,8 @@
 
   if (rv) {
     uim_pref_gtk_value_changed = TRUE;
+    gtk_widget_set_sensitive(pref_apply_button, TRUE);
+    gtk_widget_set_sensitive(pref_ok_button, TRUE);
   } else {
     g_printerr("Failed to set str value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -477,6 +485,8 @@
 
   if (rv) {
     uim_pref_gtk_value_changed = TRUE;
+    gtk_widget_set_sensitive(pref_apply_button, TRUE);
+    gtk_widget_set_sensitive(pref_ok_button, TRUE);
   } else {
     g_printerr("Failed to set str value for \"%s\".\n", custom->symbol);
     /* FIXME! reset the widget */
@@ -804,6 +814,8 @@
     return;
 
   uim_pref_gtk_value_changed = TRUE;
+  gtk_widget_set_sensitive(pref_apply_button, TRUE);
+  gtk_widget_set_sensitive(pref_ok_button, TRUE);
 
   /* sync the view */
   rv = gtk_tree_model_get_iter(model, &iter2, path);
@@ -887,6 +899,8 @@
     goto ERROR;
 
   uim_pref_gtk_value_changed = TRUE;
+  gtk_widget_set_sensitive(pref_apply_button, TRUE);
+  gtk_widget_set_sensitive(pref_ok_button, TRUE);
 
   /* sync the view */
   gtk_list_store_swap(GTK_LIST_STORE(model), &iter1, &iter2);
@@ -977,6 +991,8 @@
     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);
   } else {
     /* error message */
   }
@@ -1044,6 +1060,8 @@
     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);
     /* FIXME! reset the selection */
   } else {
     /* error message */
@@ -1583,6 +1601,8 @@
 
   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);
     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,
@@ -1647,6 +1667,8 @@
 
     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);
       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 03:06:28 UTC (rev 1253)
+++ trunk/helper/pref-gtk.c	2005-08-21 03:27:27 UTC (rev 1254)
@@ -54,6 +54,8 @@
 static GtkWidget *current_group_widget = NULL;
 
 gboolean uim_pref_gtk_value_changed = FALSE;
+GtkWidget *pref_apply_button = NULL;
+GtkWidget *pref_ok_button = NULL;
 
 enum
 {
@@ -285,6 +287,8 @@
     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);
   }
 }
 
@@ -296,6 +300,12 @@
   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);
+  }
+
 }
 
 static void
@@ -320,24 +330,27 @@
   g_signal_connect(G_OBJECT(button), "clicked",
 		   G_CALLBACK(defaults_button_clicked), (gpointer) group_name);
   gtk_box_pack_start(GTK_BOX(setting_button_box), button, TRUE, TRUE, 8);
-
+  
   /* Apply button */
-  button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
-  g_signal_connect(G_OBJECT(button), "clicked",
+  pref_apply_button = gtk_button_new_from_stock(GTK_STOCK_APPLY);
+  g_signal_connect(G_OBJECT(pref_apply_button), "clicked",
 		   G_CALLBACK(apply_button_clicked), (gpointer) group_name);
-  gtk_box_pack_start(GTK_BOX(setting_button_box), button, TRUE, TRUE, 8);
+  gtk_widget_set_sensitive(pref_apply_button, FALSE);
+  gtk_box_pack_start(GTK_BOX(setting_button_box), pref_apply_button, TRUE, TRUE, 8);
 
   /* Cancel button */
   button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
   g_signal_connect(G_OBJECT(button), "clicked",
 		   G_CALLBACK(quit_confirm), NULL);
   gtk_box_pack_start(GTK_BOX(setting_button_box), button, TRUE, TRUE, 8);
-
+   
   /* OK button */
-  button = gtk_button_new_from_stock(GTK_STOCK_OK);
-  g_signal_connect(G_OBJECT(button), "clicked",
+  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), button, TRUE, TRUE, 8);
+  gtk_box_pack_start(GTK_BOX(setting_button_box), pref_ok_button, TRUE, TRUE, 8);
+  gtk_widget_set_sensitive(pref_ok_button, FALSE);
+
   return setting_button_box;
 }
 
@@ -346,7 +359,6 @@
 {
   GtkWidget *vbox;
   GtkWidget *group_label;
-  GtkWidget *setting_button_box;
   struct uim_custom_group *group;
   char *label_text;
   vbox = gtk_vbox_new(FALSE, 8);
@@ -370,9 +382,6 @@
 
   uim_custom_group_free(group);
 
-  setting_button_box = create_setting_button_box(group_name);
-  gtk_box_pack_end(GTK_BOX(vbox), setting_button_box, FALSE, FALSE, 8);
-
   return vbox;
 }
 
@@ -439,6 +448,7 @@
 {
   GtkWidget *window;
   GtkWidget *scrolled_win; /* treeview container */
+  GtkWidget *vbox;
   GdkPixbuf *icon;
 
   pref_window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -449,6 +459,7 @@
   g_signal_connect(G_OBJECT (window), "delete_event",
 		   G_CALLBACK (delete_event_cb), NULL);
 
+
   pref_hbox = gtk_hbox_new(FALSE, 8);
 
   scrolled_win = gtk_scrolled_window_new(NULL, NULL);
@@ -460,8 +471,13 @@
   gtk_box_pack_start(GTK_BOX(pref_hbox), scrolled_win, FALSE, TRUE, 0);
 
   gtk_container_add(GTK_CONTAINER(scrolled_win), create_pref_treeview());
-  gtk_container_add(GTK_CONTAINER(window), pref_hbox);
 
+  vbox = gtk_vbox_new(FALSE, 8);
+  gtk_container_set_border_width(vbox, 8);
+  gtk_box_pack_start(GTK_BOX(vbox), pref_hbox, TRUE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(vbox), create_setting_button_box("dummy-group-name"), FALSE, TRUE, 0);
+  gtk_container_add(GTK_CONTAINER(window), vbox);
+
   {
     GdkScreen *scr;
     gint w, h;



More information about the uim-commit mailing list