Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2004:
[Freeciv-Dev] (PR#9319) remove specialist callbacks in gui-xaw
Home

[Freeciv-Dev] (PR#9319) remove specialist callbacks in gui-xaw

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9319) remove specialist callbacks in gui-xaw
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 8 Jul 2004 11:41:02 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9319 >

This patch removes the specialized specialist callbacks in gui-xaw, 
replacing them with a single ugly callback.

jason

? diff
? data/tridenthex
? data/tridenthex.tilespec
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.115
diff -u -r1.115 citydlg.c
--- client/gui-xaw/citydlg.c    5 May 2004 20:39:16 -0000       1.115
+++ client/gui-xaw/citydlg.c    8 Jul 2004 18:38:40 -0000
@@ -177,10 +177,6 @@
                                    XtPointer call_data);
 static void upgrade_callback(Widget w, XtPointer client_data, XtPointer 
call_data);
 
-static void elvis_callback(Widget w, XtPointer client_data, XtPointer 
call_data);
-static void scientist_callback(Widget w, XtPointer client_data, XtPointer 
call_data);
-static void taxman_callback(Widget w, XtPointer client_data, XtPointer 
call_data);
-
 static void present_units_callback(Widget w, XtPointer client_data, 
                                   XtPointer call_data);
 static void cityopt_callback(Widget w, XtPointer client_data, 
@@ -1519,6 +1515,26 @@
   xaw_set_label(pdialog->output_label, buf);
 }
 
+/****************************************************************************
+  Handle the callback when a citizen sprite widget is clicked.
+****************************************************************************/
+static void citizen_callback(Widget w, XtPointer client_data,
+                            XtPointer call_data)
+{
+  struct city_dialog *pdialog = client_data;
+  int i;
+
+  /* HACK: figure out which figure was clicked. */
+  for (i = 0; i < pdialog->pcity->size; i++) {
+    if (pdialog->citizen_labels[i] == w) {
+      break;
+    }
+  }
+  assert(i < pdialog->pcity->size);
+
+  city_rotate_specialist(pdialog->pcity, i);
+}
+
 /****************************************************************
 ...
 *****************************************************************/
@@ -1536,27 +1552,9 @@
 
     /* HACK: set sensitivity/callbacks on the widget */
     XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
-    switch (citizens[i]) {
-    case CITIZEN_ELVIS:
-      XtAddCallback(pdialog->citizen_labels[i], XtNcallback,
-                   elvis_callback, (XtPointer)pdialog);
-      XtSetSensitive(pdialog->citizen_labels[i], TRUE);
-      break;
-    case CITIZEN_SCIENTIST:
-      XtAddCallback(pdialog->citizen_labels[i], XtNcallback,
-                   scientist_callback, (XtPointer)pdialog);
-      XtSetSensitive(pdialog->citizen_labels[i], TRUE);
-      break;
-    case CITIZEN_TAXMAN:
-      XtAddCallback(pdialog->citizen_labels[i], XtNcallback, taxman_callback,
-                   (XtPointer)pdialog);
-      XtSetSensitive(pdialog->citizen_labels[i], TRUE);
-      break;      
-    default:
-      XtSetSensitive(pdialog->citizen_labels[i], FALSE);
-      XtRemoveAllCallbacks(pdialog->citizen_labels[i], XtNcallback);
-      break;
-    }
+    XtAddCallback(pdialog->citizen_labels[i], XtNcallback,
+                 citizen_callback, (XtPointer)pdialog);
+    XtSetSensitive(pdialog->citizen_labels[i], TRUE);
   }
 
   if (i >= pdialog->num_citizens_shown && i < pcity->size) {
@@ -1859,36 +1857,6 @@
 /****************************************************************
 ...
 *****************************************************************/
-void elvis_callback(Widget w, XtPointer client_data, XtPointer call_data)
-{
-  struct city_dialog *pdialog = client_data;
-
-  city_change_specialist(pdialog->pcity, SP_ELVIS, SP_SCIENTIST);
-}
-
-/****************************************************************
-...
-*****************************************************************/
-void scientist_callback(Widget w, XtPointer client_data, XtPointer call_data)
-{
-  struct city_dialog *pdialog = client_data;
-
-  city_change_specialist(pdialog->pcity, SP_SCIENTIST, SP_TAXMAN);
-}
-
-/****************************************************************
-...
-*****************************************************************/
-void taxman_callback(Widget w, XtPointer client_data, XtPointer call_data)
-{
-  struct city_dialog *pdialog = client_data;
-
-  city_change_specialist(pdialog->pcity, SP_TAXMAN, SP_ELVIS);
-}
-
-/****************************************************************
-...
-*****************************************************************/
 static void buy_callback_yes(Widget w, XtPointer client_data,
                             XtPointer call_data)
 {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9319) remove specialist callbacks in gui-xaw, Jason Short <=