tThe New/Delete/Up/Down buttons in the Options dialog now become sensitive only when they can be used. - vaccinewars - be a doctor and try to vaccinate the world
git clone git://src.adamsgaard.dk/vaccinewars
Log
Files
Refs
README
LICENSE
---
commit d99cb493d6e232a6fb77a33ad2aa9479776084ec
parent 35f5e56ed32bacc0466fd6cfb5440c24f9523b96
Author: Ben Webb 
Date:   Sat, 16 Mar 2002 19:00:58 +0000

The New/Delete/Up/Down buttons in the Options dialog now become sensitive
only when they can be used.


Diffstat:
  M src/gui_client/optdialog.c          |      25 +++++++++++++++++++++++++

1 file changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/src/gui_client/optdialog.c b/src/gui_client/optdialog.c
t@@ -414,6 +414,15 @@ static void list_row_select(GtkCList *clist, gint row, gint column,
                             GdkEvent *event, gchar *structname)
 {
   GSList *listpt;
+  GtkWidget *delbut, *upbut, *downbut;
+
+  delbut  = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(clist), "delete"));
+  upbut   = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(clist), "up"));
+  downbut = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(clist), "down"));
+  g_assert(delbut && upbut && downbut);
+  gtk_widget_set_sensitive(delbut, TRUE);
+  gtk_widget_set_sensitive(upbut, row > 0);
+  gtk_widget_set_sensitive(downbut, row < clist->rows - 1);
 
   for (listpt = configlist; listpt; listpt = g_slist_next(listpt)) {
     struct ConfigWidget *conf = (struct ConfigWidget *)listpt->data;
t@@ -436,6 +445,16 @@ static void list_row_unselect(GtkCList *clist, gint row, gint column,
                               GdkEvent *event, gchar *structname)
 {
   GSList *listpt;
+  GtkWidget *delbut, *upbut, *downbut;
+
+  delbut  = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(clist), "delete"));
+  upbut   = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(clist), "up"));
+  downbut = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(clist), "down"));
+  g_assert(delbut && upbut && downbut);
+  gtk_widget_set_sensitive(delbut, FALSE);
+  gtk_widget_set_sensitive(upbut, FALSE);
+  gtk_widget_set_sensitive(downbut, FALSE);
+
 
   for (listpt = configlist; listpt; listpt = g_slist_next(listpt)) {
     struct ConfigWidget *conf = (struct ConfigWidget *)listpt->data;
t@@ -605,19 +624,25 @@ static GtkWidget *CreateList(gchar *structname, struct ConfigMembers *members)
   gtk_box_pack_start(GTK_BOX(hbbox), button, TRUE, TRUE, 0);
 
   button = gtk_button_new_with_label(_("Delete"));
+  gtk_widget_set_sensitive(button, FALSE);
   gtk_object_set_data(GTK_OBJECT(button), "clist", clist);
+  gtk_object_set_data(GTK_OBJECT(clist), "delete", button);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(list_delete), structname);
   gtk_box_pack_start(GTK_BOX(hbbox), button, TRUE, TRUE, 0);
 
   button = gtk_button_new_with_label(_("Up"));
+  gtk_widget_set_sensitive(button, FALSE);
   gtk_object_set_data(GTK_OBJECT(button), "clist", clist);
+  gtk_object_set_data(GTK_OBJECT(clist), "up", button);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(list_up), structname);
   gtk_box_pack_start(GTK_BOX(hbbox), button, TRUE, TRUE, 0);
 
   button = gtk_button_new_with_label(_("Down"));
+  gtk_widget_set_sensitive(button, FALSE);
   gtk_object_set_data(GTK_OBJECT(button), "clist", clist);
+  gtk_object_set_data(GTK_OBJECT(clist), "down", button);
   gtk_signal_connect(GTK_OBJECT(button), "clicked",
                      GTK_SIGNAL_FUNC(list_down), structname);
   gtk_box_pack_start(GTK_BOX(hbbox), button, TRUE, TRUE, 0);