Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12207) gui-xaw: Allow to override dialog_message trans
Home

[Freeciv-Dev] (PR#12207) gui-xaw: Allow to override dialog_message trans

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12207) gui-xaw: Allow to override dialog_message translation table.
From: "Egor Vyscrebentsov" <evyscr@xxxxxxxxx>
Date: Thu, 10 Feb 2005 12:35:30 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12207 >

Good daytime!

CVS S2_0 20040210, Xaw client.

Attached patch (xaw_popup_dialog_msg.diff) allows to override
popup_message_dialog widgets' translation table procedure
"wm_window_exit". In current code, if you pressed (x) button of these
dialogs, you'll get all civclient closing.
This patch follows the PR#10756 problem.

The second patch demonstrates overriding on a revolution dialog.

Thanks, evyscr.
--- freeciv-s2_0.orig/client/gui-xaw/actions.c  2005-01-20 18:22:12 +0300
+++ freeciv-s2_0/client/gui-xaw/actions.c       2005-02-07 22:44:48 +0300
@@ -717,6 +717,11 @@
   activeunits_msg_close(w);
 }
 
+static void xaw_msg_close_revolution(Widget w, XEvent *event, String *argv, 
Cardinal *argc)
+{
+  revolution_dialog_msg_close(w);
+}
+
 static void xaw_msg_quit_freeciv(Widget w, XEvent *event, String *argv, 
Cardinal *argc)
 {
   xaw_ui_exit();
@@ -820,6 +825,7 @@
   { "msg-close-science-report", xaw_msg_close_science_report },
   { "msg-close-spaceship", xaw_msg_close_spaceship },
   { "msg-close-units-report", xaw_msg_close_units_report },
+  { "msg-close-revolution", xaw_msg_close_revolution },
   { "msg-quit-freeciv", xaw_msg_quit_freeciv }
 };
 
--- freeciv-s2_0.orig/client/gui-xaw/dialogs.c  2005-02-10 22:10:30 +0300
+++ freeciv-s2_0/client/gui-xaw/dialogs.c       2005-02-10 21:49:16 +0300
@@ -1243,21 +1243,29 @@
   destroy_message_dialog(w);
 }
 
-
-
 /****************************************************************
 ...
 *****************************************************************/
 void popup_revolution_dialog(int government)
 {
   popup_message_dialog(toplevel, "revolutiondialog", 
-                      _("You say you wanna revolution?"), "",
+                      _("You say you wanna revolution?"),
+                      "msg-close-revolution",
                       revolution_callback_yes,
                       INT_TO_XTPOINTER(government), 0,
                       revolution_callback_no, 0, 0,
                       NULL);
 }
 
+/****************************************************************
+...
+*****************************************************************/
+void revolution_dialog_msg_close(Widget w)
+{
+  XtSetSensitive(XtParent(w), TRUE);
+
+  XtDestroyWidget(w);
+}
 
 /****************************************************************
 ...
--- freeciv-s2_0.orig/client/gui-xaw/dialogs.h  2005-02-07 22:17:20 +0300
+++ freeciv-s2_0/client/gui-xaw/dialogs.h       2005-02-07 22:51:39 +0300
@@ -20,6 +20,7 @@
 struct tile;
 
 void popup_revolution_dialog(int government);
+void revolution_dialog_msg_close(Widget w);
 Widget popup_message_dialog(Widget parent, const char *shellname,
                            const char *text, const char *msg, ...);
 void destroy_message_dialog(Widget button);
Index: client/gui-xaw/citydlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/citydlg.c,v
retrieving revision 1.123
diff -u -r1.123 citydlg.c
--- client/gui-xaw/citydlg.c    29 Sep 2004 02:24:22 -0000      1.123
+++ client/gui-xaw/citydlg.c    10 Feb 2005 19:31:33 -0000
@@ -1324,6 +1324,7 @@
     wd=popup_message_dialog(pdialog->shell, 
                            "presentunitsdialog", 
                            unit_description(punit),
+                           "",
                            present_units_activate_callback, punit->id, 1,
                            present_units_activate_close_callback, punit->id, 1,
                            present_units_sentry_callback, punit->id, 1,
@@ -1440,6 +1441,7 @@
   popup_message_dialog(pdialog->shell, 
                       "citytradedialog", 
                       buf, 
+                      "",
                       trade_message_dialog_callback, 0, 0,
                       NULL);
 }
@@ -1596,6 +1598,7 @@
        wd = popup_message_dialog(pdialog->shell,
                             "supportunitsdialog", 
                             unit_description(punit),
+                            "",
                             supported_units_activate_callback, punit->id, 1,
                             supported_units_activate_close_callback,
                                                             punit->id, 1,
@@ -1899,7 +1902,7 @@
     my_snprintf(buf, sizeof(buf),
                _("Buy %s for %d gold?\nTreasury contains %d gold."), 
                name, value, game.player_ptr->economic.gold);
-    popup_message_dialog(pdialog->shell, "buydialog", buf,
+    popup_message_dialog(pdialog->shell, "buydialog", buf, "",
                         buy_callback_yes, pdialog, 0,
                         buy_callback_no, 0, 0,
                         NULL);
@@ -1908,7 +1911,7 @@
     my_snprintf(buf, sizeof(buf),
                _("%s costs %d gold.\nTreasury contains %d gold."), 
                name, value, game.player_ptr->economic.gold);
-    popup_message_dialog(pdialog->shell, "buynodialog", buf,
+    popup_message_dialog(pdialog->shell, "buynodialog", buf, "",
                         buy_callback_no, 0, 0,
                         NULL);
   }
@@ -1953,12 +1956,12 @@
   }
 
   if (get_unit_upgrade_info(buf, sizeof(buf), punit) == UR_OK) {
-    popup_message_dialog(toplevel, "upgradedialog", buf,
+    popup_message_dialog(toplevel, "upgradedialog", buf, "",
                         unitupgrade_callback_yes,
                         INT_TO_XTPOINTER(punit->id), 0,
                         unitupgrade_callback_no, 0, 0, NULL);
   } else {
-    popup_message_dialog(toplevel, "upgradenodialog", buf,
+    popup_message_dialog(toplevel, "upgradenodialog", buf, "",
                         unitupgrade_callback_no, 0, 0,
                         NULL);
   }
@@ -2297,7 +2300,7 @@
                    get_impr_name_ex(pdialog->pcity, i),
                    impr_sell_gold(i));
 
-       popup_message_dialog(pdialog->shell, "selldialog", buf,
+       popup_message_dialog(pdialog->shell, "selldialog", buf, "",
                             sell_callback_yes, pdialog, 0,
                             sell_callback_no, pdialog, 0, NULL);
 
Index: client/gui-xaw/cma_fe.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/cma_fe.c,v
retrieving revision 1.2.2.2
diff -u -r1.2.2.2 cma_fe.c
--- client/gui-xaw/cma_fe.c     26 Nov 2004 22:17:43 -0000      1.2.2.2
+++ client/gui-xaw/cma_fe.c     10 Feb 2005 19:31:33 -0000
@@ -452,7 +452,7 @@
                 cmafec_preset_get_descr(ret->list_index));
 
     popup_message_dialog(cma_dialog, "cmaremovepreset",
-                         buf, remove_preset_yes, 
+                         buf, "", remove_preset_yes,
                          INT_TO_XTPOINTER(ret->list_index), 0,
                          remove_preset_no, 0, 0,
                          NULL);
Index: client/gui-xaw/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.c,v
retrieving revision 1.104.2.2
diff -u -r1.104.2.2 dialogs.c
--- client/gui-xaw/dialogs.c    20 Nov 2004 20:02:50 -0000      1.104.2.2
+++ client/gui-xaw/dialogs.c    10 Feb 2005 19:31:37 -0000
@@ -444,14 +444,14 @@
 
   if (unit_flag(punit, F_UNBRIBABLE)) {
     popup_message_dialog(toplevel, "diplomatbribedialog",
-                         _("This unit cannot be bribed!"),
+                         _("This unit cannot be bribed!"), "",
                          diplomat_bribe_no_callback, 0, 0, NULL);
   } else if(game.player_ptr->economic.gold>=punit->bribe_cost) {
     my_snprintf(buf, sizeof(buf),
                _("Bribe unit for %d gold?\n"
                  "Treasury contains %d gold."), 
                punit->bribe_cost, game.player_ptr->economic.gold);
-    popup_message_dialog(toplevel, "diplomatbribedialog", buf,
+    popup_message_dialog(toplevel, "diplomatbribedialog", buf, "",
                         diplomat_bribe_yes_callback, 0, 0,
                         diplomat_bribe_no_callback, 0, 0,
                         NULL);
@@ -460,7 +460,7 @@
                _("Bribing the unit costs %d gold.\n"
                  "Treasury contains %d gold."), 
                punit->bribe_cost, game.player_ptr->economic.gold);
-    popup_message_dialog(toplevel, "diplomatnogolddialog", buf,
+    popup_message_dialog(toplevel, "diplomatnogolddialog", buf, "",
                         diplomat_bribe_no_callback, 0, 0,
                         NULL);
   }
@@ -976,7 +976,7 @@
   if (pcity->incite_revolt_cost == INCITE_IMPOSSIBLE_COST) {
     my_snprintf(buf, sizeof(buf), _("You can't incite a revolt in %s."),
                pcity->name);
-    popup_message_dialog(toplevel, "diplomatnogolddialog", buf,
+    popup_message_dialog(toplevel, "diplomatnogolddialog", buf, "",
                         diplomat_incite_no_callback, 0, 0, NULL);
   } else if (game.player_ptr->economic.gold >= pcity->incite_revolt_cost) {
     my_snprintf(buf, sizeof(buf),
@@ -984,7 +984,7 @@
                  "Treasury contains %d gold."), 
                pcity->incite_revolt_cost, game.player_ptr->economic.gold);
    diplomat_target_id = pcity->id;
-   popup_message_dialog(toplevel, "diplomatrevoltdialog", buf,
+   popup_message_dialog(toplevel, "diplomatrevoltdialog", buf, "",
                        diplomat_incite_yes_callback, 0, 0,
                        diplomat_incite_no_callback, 0, 0,
                        NULL);
@@ -993,7 +993,7 @@
               _("Inciting a revolt costs %d gold.\n"
                 "Treasury contains %d gold."), 
               pcity->incite_revolt_cost, game.player_ptr->economic.gold);
-   popup_message_dialog(toplevel, "diplomatnogolddialog", buf,
+   popup_message_dialog(toplevel, "diplomatnogolddialog", buf, "",
                        diplomat_incite_no_callback, 0, 0,
                        NULL);
   }
@@ -1055,7 +1055,7 @@
                unit_name(punit->type), pcity->name);
 
     if(!unit_flag(punit, F_SPY)){
-      shl=popup_message_dialog(toplevel, "diplomatdialog", buf,
+      shl=popup_message_dialog(toplevel, "diplomatdialog", buf, "",
                               diplomat_embassy_callback, 0, 1,
                               diplomat_investigate_callback, 0, 1,
                               diplomat_sabotage_callback, 0, 1,
@@ -1078,7 +1078,7 @@
       if(!diplomat_can_do_action(punit, DIPLOMAT_MOVE, dest_tile))
        XtSetSensitive(XtNameToWidget(shl, "*button5"), FALSE);
     }else{
-      shl=popup_message_dialog(toplevel, "spydialog", buf,
+      shl=popup_message_dialog(toplevel, "spydialog", buf, "",
                               diplomat_embassy_callback, 0,  1,
                               diplomat_investigate_callback, 0, 1,
                               spy_poison_callback,0, 1,
@@ -1117,7 +1117,7 @@
       diplomat_target_id=ptunit->id;
 
       shl=popup_message_dialog(toplevel, "spybribedialog",
-                              message,
+                              message, "",
                               diplomat_bribe_callback, 0, 0,
                               spy_sabotage_unit_callback, 0, 0,
                               diplomat_cancel_callback, 0, 0,
@@ -1196,7 +1196,7 @@
   caravan_unit_id=punit->id;
   
   caravan_dialog=popup_message_dialog(toplevel, "caravandialog", 
-                          buf,
+                          buf, "",
                           caravan_establish_trade_callback, 0, 0,
                           caravan_help_build_wonder_callback, 0, 0,
                           caravan_keep_moving_callback, 0, 0,
@@ -1251,7 +1251,7 @@
 void popup_revolution_dialog(int government)
 {
   popup_message_dialog(toplevel, "revolutiondialog", 
-                      _("You say you wanna revolution?"),
+                      _("You say you wanna revolution?"), "",
                       revolution_callback_yes,
                       INT_TO_XTPOINTER(government), 0,
                       revolution_callback_no, 0, 0,
@@ -1333,7 +1333,7 @@
   - callback, callback_data, fixed_width 
 *****************************************************************/
 Widget popup_message_dialog(Widget parent, const char *dialogname,
-                           const char *text, ...)
+                           const char *text, const char *msg, ...)
 {
   va_list args;
   Widget dshell, dform, button;
@@ -1341,7 +1341,7 @@
   Dimension width, height;
   void (*fcb)(Widget, XtPointer, XtPointer);
   XtPointer client_data;
-  char button_name[512];
+  char button_name[512], msg_protocol[128];
   int i, fixed_width;
 
   XtSetSensitive(parent, FALSE);
@@ -1357,7 +1357,7 @@
                          NULL);   
 
   i=0;
-  va_start(args, text);
+  va_start(args, msg);
 
   while((fcb=((void(*)(Widget, XtPointer, XtPointer))(va_arg(args, void *))))) 
{
     client_data=va_arg(args, XtPointer);
@@ -1381,6 +1381,16 @@
                    &x, &y);
   XtVaSetValues(dshell, XtNx, x, XtNy, y, NULL);
   
+
+  if (strlen(msg) > 0) {
+    XtRealizeWidget(dshell);
+    sprintf(msg_protocol, "<Message>WM_PROTOCOLS: %s()", msg);
+    XSetWMProtocols(display, XtWindow(dshell),
+                   &wm_delete_window, 1);
+    XtOverrideTranslations(dshell,
+      XtParseTranslationTable(msg_protocol));
+  }
+
   XtPopup(dshell, XtGrabNone);
 
   return dshell;
Index: client/gui-xaw/dialogs.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/dialogs.h,v
retrieving revision 1.8.6.2
diff -u -r1.8.6.2 dialogs.h
--- client/gui-xaw/dialogs.h    20 Nov 2004 20:02:50 -0000      1.8.6.2
+++ client/gui-xaw/dialogs.h    10 Feb 2005 19:31:37 -0000
@@ -21,7 +21,7 @@
 
 void popup_revolution_dialog(int government);
 Widget popup_message_dialog(Widget parent, const char *shellname,
-                           const char *text, ...);
+                           const char *text, const char *msg, ...);
 void destroy_message_dialog(Widget button);
 
 void popup_about_dialog(void);
Index: client/gui-xaw/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/repodlgs.c,v
retrieving revision 1.62.2.1
diff -u -r1.62.2.1 repodlgs.c
--- client/gui-xaw/repodlgs.c   10 Nov 2004 17:02:03 -0000      1.62.2.1
+++ client/gui-xaw/repodlgs.c   10 Feb 2005 19:31:37 -0000
@@ -1003,7 +1003,7 @@
            unit_upgrade_price(game.player_ptr, ut1, ut2),
            game.player_ptr->economic.gold);
 
-    popup_message_dialog(toplevel, "upgradedialog", buf,
+    popup_message_dialog(toplevel, "upgradedialog", buf, "",
                         upgrade_callback_yes,
                         INT_TO_XTPOINTER(activeunits_type[ret->list_index]),
                         0, upgrade_callback_no, 0, 0, NULL);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12207) gui-xaw: Allow to override dialog_message translation table., Egor Vyscrebentsov <=