Author: sveinung Date: Thu Nov 12 15:58:20 2015 New Revision: 30574 URL: http://svn.gna.org/viewcvs/freeciv?rev=30574&view=rev Log: GTK clients: act sel dlg "Show Location" button
Add a button that focuses the map on the actor unit to the GTK clients' action selection dialog. Requested by Marko Lindqvist <cazfi> See bug #23846 Modified: branches/S2_6/client/gui-gtk-2.0/action_dialog.c branches/S2_6/client/gui-gtk-3.0/action_dialog.c Modified: branches/S2_6/client/gui-gtk-2.0/action_dialog.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-2.0/action_dialog.c?rev=30574&r1=30573&r2=30574&view=diff ============================================================================== --- branches/S2_6/client/gui-gtk-2.0/action_dialog.c (original) +++ branches/S2_6/client/gui-gtk-2.0/action_dialog.c Thu Nov 12 15:58:20 2015 @@ -50,8 +50,9 @@ /* Locations for non action enabler controlled buttons. */ #define BUTTON_MOVE ACTION_MOVE -#define BUTTON_CANCEL BUTTON_MOVE + 1 -#define BUTTON_COUNT BUTTON_MOVE + 2 +#define BUTTON_LOCATION BUTTON_MOVE + 1 +#define BUTTON_CANCEL BUTTON_MOVE + 2 +#define BUTTON_COUNT BUTTON_MOVE + 3 #define BUTTON_NOT_THERE -1 @@ -881,6 +882,20 @@ /************************************************************************** + Callback from action selection dialog for "Show Location". +**************************************************************************/ +static void act_sel_location_callback(GtkWidget *w, gpointer data) +{ + struct action_data *args = (struct action_data *)data; + + struct unit *punit; + + if ((punit = game_unit_by_number(args->actor_unit_id))) { + center_tile_mapcanvas(unit_tile(punit)); + } +} + +/************************************************************************** Callback from diplomat/spy dialog for "keep moving". (This should only occur when entering a tile that has an allied city or an allied unit.) @@ -1152,6 +1167,12 @@ data, FALSE, NULL); } + action_button_map[BUTTON_LOCATION] = + choice_dialog_get_number_of_buttons(shl); + choice_dialog_add(shl, _("Show Location"), + (GCallback)act_sel_location_callback, data, + TRUE, NULL); + action_button_map[BUTTON_CANCEL] = choice_dialog_get_number_of_buttons(shl); choice_dialog_add(shl, GTK_STOCK_CANCEL, Modified: branches/S2_6/client/gui-gtk-3.0/action_dialog.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-gtk-3.0/action_dialog.c?rev=30574&r1=30573&r2=30574&view=diff ============================================================================== --- branches/S2_6/client/gui-gtk-3.0/action_dialog.c (original) +++ branches/S2_6/client/gui-gtk-3.0/action_dialog.c Thu Nov 12 15:58:20 2015 @@ -50,8 +50,9 @@ /* Locations for non action enabler controlled buttons. */ #define BUTTON_MOVE ACTION_MOVE -#define BUTTON_CANCEL BUTTON_MOVE + 1 -#define BUTTON_COUNT BUTTON_MOVE + 2 +#define BUTTON_LOCATION BUTTON_MOVE + 1 +#define BUTTON_CANCEL BUTTON_MOVE + 2 +#define BUTTON_COUNT BUTTON_MOVE + 3 #define BUTTON_NOT_THERE -1 @@ -891,6 +892,20 @@ /************************************************************************** + Callback from action selection dialog for "Show Location". +**************************************************************************/ +static void act_sel_location_callback(GtkWidget *w, gpointer data) +{ + struct action_data *args = (struct action_data *)data; + + struct unit *punit; + + if ((punit = game_unit_by_number(args->actor_unit_id))) { + center_tile_mapcanvas(unit_tile(punit)); + } +} + +/************************************************************************** Callback from diplomat/spy dialog for "keep moving". (This should only occur when entering a tile that has an allied city or an allied unit.) @@ -1162,6 +1177,12 @@ data, FALSE, NULL); } + action_button_map[BUTTON_LOCATION] = + choice_dialog_get_number_of_buttons(shl); + choice_dialog_add(shl, _("Show Location"), + (GCallback)act_sel_location_callback, data, + TRUE, NULL); + action_button_map[BUTTON_CANCEL] = choice_dialog_get_number_of_buttons(shl); choice_dialog_add(shl, GTK_STOCK_CANCEL, _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits