Author: sveinung
Date: Thu May 12 13:34:55 2016
New Revision: 32676

URL: http://svn.gna.org/viewcvs/freeciv?rev=32676&view=rev
Log:
Add function to get UI name with mnemonic.

Introduce the new function action_get_ui_name_mnemonic(). Have it replace
calls to action_prepare_ui_name() that only add mnemonics to the action UI
name. This reduces the amount of repetition.

See patch #7214

Modified:
    trunk/client/gui-gtk-2.0/citydlg.c
    trunk/client/gui-gtk-2.0/menu.c
    trunk/common/actions.c
    trunk/common/actions.h

Modified: trunk/client/gui-gtk-2.0/citydlg.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/citydlg.c?rev=32676&r1=32675&r2=32676&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/citydlg.c  (original)
+++ trunk/client/gui-gtk-2.0/citydlg.c  Thu May 12 13:34:55 2016
@@ -2278,7 +2278,7 @@
     }
 
     item = gtk_menu_item_new_with_mnemonic(
-          action_prepare_ui_name(ACTION_HOME_CITY, "_", ACTPROB_NA, NULL));
+          action_get_ui_name_mnemonic(ACTION_HOME_CITY, "_"));
     g_signal_connect(item, "activate",
       G_CALLBACK(unit_homecity_callback),
       GINT_TO_POINTER(punit->id));

Modified: trunk/client/gui-gtk-2.0/menu.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/menu.c?rev=32676&r1=32675&r2=32676&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/menu.c     (original)
+++ trunk/client/gui-gtk-2.0/menu.c     Thu May 12 13:34:55 2016
@@ -2317,8 +2317,7 @@
 
   if (units_can_do_action(punits, ACTION_HELP_WONDER, TRUE)) {
     menus_rename(unit_group, "BUILD_CITY",
-                 action_prepare_ui_name(ACTION_HELP_WONDER,
-                                        "_", ACTPROB_NA, NULL));
+                 action_get_ui_name_mnemonic(ACTION_HELP_WONDER, "_"));
   } else {
     bool city_on_tile = FALSE;
 
@@ -2334,20 +2333,17 @@
     if (city_on_tile && units_can_do_action(punits, ACTION_JOIN_CITY,
                                             TRUE)) {
       menus_rename(unit_group, "BUILD_CITY",
-                   action_prepare_ui_name(ACTION_JOIN_CITY,
-                                          "_", ACTPROB_NA, NULL));
+                   action_get_ui_name_mnemonic(ACTION_JOIN_CITY, "_"));
     } else {
       /* refresh default order */
       menus_rename(unit_group, "BUILD_CITY",
-                   action_prepare_ui_name(ACTION_FOUND_CITY,
-                                          "_", ACTPROB_NA, NULL));
+                   action_get_ui_name_mnemonic(ACTION_FOUND_CITY, "_"));
     }
   }
 
   if (units_can_do_action(punits, ACTION_TRADE_ROUTE, TRUE)) {
     menus_rename(unit_group, "BUILD_ROAD",
-                 action_prepare_ui_name(ACTION_TRADE_ROUTE,
-                                        "_", ACTPROB_NA, NULL));
+                 action_get_ui_name_mnemonic(ACTION_TRADE_ROUTE, "_"));
   } else if (units_have_type_flag(punits, UTYF_SETTLERS, TRUE)) {
     char road_item[500];
     struct extra_type *pextra = NULL;
@@ -2502,8 +2498,7 @@
 
   menus_rename(unit_group, "EXPLODE_NUKE", action_get_ui_name(ACTION_NUKE));
   menus_rename(unit_group, "UNIT_HOMECITY",
-               action_prepare_ui_name(ACTION_HOME_CITY,
-                                      "_", ACTPROB_NA, NULL));
+               action_get_ui_name_mnemonic(ACTION_HOME_CITY, "_"));
 }
 
 /**************************************************************************

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=32676&r1=32675&r2=32676&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Thu May 12 13:34:55 2016
@@ -486,6 +486,15 @@
 }
 
 /**************************************************************************
+  Get the action name with a mnemonic ready to display in the UI.
+**************************************************************************/
+const char *action_get_ui_name_mnemonic(int action_id,
+                                        const char* mnemonic)
+{
+  return action_prepare_ui_name(action_id, mnemonic, ACTPROB_NA, NULL);
+}
+
+/**************************************************************************
   Get the UI name ready to show the action in the UI. It is possible to
   add a client specific mnemonic. Success probability information is
   interpreted and added to the text. A custom text can be inserted before

Modified: trunk/common/actions.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.h?rev=32676&r1=32675&r2=32676&view=diff
==============================================================================
--- trunk/common/actions.h      (original)
+++ trunk/common/actions.h      Thu May 12 13:34:55 2016
@@ -342,6 +342,8 @@
 
 const char *action_get_rule_name(int action_id);
 const char *action_get_ui_name(int action_id);
+const char *action_get_ui_name_mnemonic(int action_id,
+                                        const char* mnemonic);
 const char *action_prepare_ui_name(int action_id, const char* mnemonic,
                                    const action_probability prob,
                                    const char *custom);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to