Bug #2442 » 0001-gtk-Allow-activating-units-that-are-not-idle.patch
| client/control.c | ||
|---|---|---|
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Try to set unit to focus directly. Won't set unit to focus if
|
||
|
unit can't currently be at focus.
|
||
|
**************************************************************************/
|
||
|
void unit_focus_try(struct unit *punit)
|
||
|
{
|
||
|
if (punit->activity == ACTIVITY_IDLE) {
|
||
|
/* Only idle units can be at focus. */
|
||
|
unit_focus_set(punit);
|
||
|
}
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
|
Sets the focus unit directly. The unit given will be given the
|
||
|
focus; if NULL the focus will be cleared.
|
||
| client/gui-gtk-4.0/citydlg.c | ||
|---|---|---|
|
} else {
|
||
|
for (i = m; i < n; i++) {
|
||
|
GtkWidget *cmd, *pix;
|
||
|
GtkGesture *gesture;
|
||
|
struct unit_node node;
|
||
|
cmd = gtk_button_new();
|
||
| ... | ... | |
|
gtk_box_append(GTK_BOX(pdialog->overview.supported_unit_table),
|
||
|
cmd);
|
||
|
node.left = NULL;
|
||
|
node.middle = NULL;
|
||
|
node.right = NULL;
|
||
|
/* Set up the event controllers for the three mouse buttons */
|
||
|
node.left = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 2);
|
||
|
node.middle = GTK_EVENT_CONTROLLER(gesture);
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
|
||
|
node.right = GTK_EVENT_CONTROLLER(gesture);
|
||
|
gtk_widget_add_controller(cmd, node.left);
|
||
|
gtk_widget_add_controller(cmd, node.middle);
|
||
|
gtk_widget_add_controller(cmd, node.right);
|
||
|
unit_node_vector_append(nodes, node);
|
||
|
}
|
||
| ... | ... | |
|
pnode = unit_node_vector_get(nodes, i);
|
||
|
if (pnode) {
|
||
|
GtkWidget *cmd, *pix;
|
||
|
GtkGesture *gesture;
|
||
|
GtkEventController *controller;
|
||
|
cmd = pnode->cmd;
|
||
|
pix = pnode->pix;
|
||
| ... | ... | |
|
put_unit_picture_city_overlays(punit, GTK_PICTURE(pix), pnode->height,
|
||
|
punit->upkeep, happy_cost);
|
||
|
if (pnode->left != NULL) {
|
||
|
gtk_widget_remove_controller(cmd, pnode->left);
|
||
|
gtk_widget_remove_controller(cmd, pnode->middle);
|
||
|
gtk_widget_remove_controller(cmd, pnode->right);
|
||
|
}
|
||
|
gtk_event_controller_reset(pnode->left);
|
||
|
gtk_event_controller_reset(pnode->middle);
|
||
|
gtk_event_controller_reset(pnode->right);
|
||
|
gtk_widget_set_tooltip_text(cmd, unit_description(punit));
|
||
|
controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
|
||
|
g_signal_connect(controller, "pressed",
|
||
|
g_signal_connect(pnode->left, "pressed",
|
||
|
G_CALLBACK(supported_unit_callback),
|
||
|
GINT_TO_POINTER(punit->id));
|
||
|
gtk_widget_add_controller(cmd, controller);
|
||
|
pnode->left = controller;
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 2);
|
||
|
controller = GTK_EVENT_CONTROLLER(gesture);
|
||
|
g_signal_connect(controller, "released",
|
||
|
g_signal_connect(pnode->middle, "released",
|
||
|
G_CALLBACK(middle_supported_unit_release),
|
||
|
GINT_TO_POINTER(punit->id));
|
||
|
gtk_widget_add_controller(cmd, controller);
|
||
|
pnode->middle = controller;
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
|
||
|
controller = GTK_EVENT_CONTROLLER(gesture);
|
||
|
g_signal_connect(controller, "released",
|
||
|
g_signal_connect(pnode->right, "released",
|
||
|
G_CALLBACK(right_unit_release),
|
||
|
GINT_TO_POINTER(punit->id));
|
||
|
gtk_widget_add_controller(cmd, controller);
|
||
|
pnode->right = controller;
|
||
|
if (city_owner(pdialog->pcity) != client.conn.playing) {
|
||
|
gtk_widget_set_sensitive(cmd, FALSE);
|
||
| ... | ... | |
|
} else {
|
||
|
for (i = m; i < n; i++) {
|
||
|
GtkWidget *cmd, *pix;
|
||
|
GtkGesture *gesture;
|
||
|
struct unit_node node;
|
||
|
cmd = gtk_button_new();
|
||
| ... | ... | |
|
gtk_box_append(GTK_BOX(pdialog->overview.present_unit_table),
|
||
|
cmd);
|
||
|
node.left = NULL;
|
||
|
node.middle = NULL;
|
||
|
node.right = NULL;
|
||
|
/* Set up the event controllers for the three mouse buttons */
|
||
|
node.left = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 2);
|
||
|
node.middle = GTK_EVENT_CONTROLLER(gesture);
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
|
||
|
node.right = GTK_EVENT_CONTROLLER(gesture);
|
||
|
gtk_widget_add_controller(cmd, node.left);
|
||
|
gtk_widget_add_controller(cmd, node.middle);
|
||
|
gtk_widget_add_controller(cmd, node.right);
|
||
|
unit_node_vector_append(nodes, node);
|
||
|
}
|
||
| ... | ... | |
|
pnode = unit_node_vector_get(nodes, i);
|
||
|
if (pnode) {
|
||
|
GtkWidget *cmd, *pix;
|
||
|
GtkEventController *controller;
|
||
|
GtkGesture *gesture;
|
||
|
cmd = pnode->cmd;
|
||
|
pix = pnode->pix;
|
||
|
put_unit_picture(punit, GTK_PICTURE(pix), pnode->height);
|
||
|
if (pnode->left != NULL) {
|
||
|
gtk_widget_remove_controller(cmd, pnode->left);
|
||
|
gtk_widget_remove_controller(cmd, pnode->middle);
|
||
|
gtk_widget_remove_controller(cmd, pnode->right);
|
||
|
}
|
||
|
gtk_event_controller_reset(pnode->left);
|
||
|
gtk_event_controller_reset(pnode->middle);
|
||
|
gtk_event_controller_reset(pnode->right);
|
||
|
gtk_widget_set_tooltip_text(cmd, unit_description(punit));
|
||
|
controller = GTK_EVENT_CONTROLLER(gtk_gesture_click_new());
|
||
|
g_signal_connect(controller, "pressed",
|
||
|
g_signal_connect(pnode->left, "pressed",
|
||
|
G_CALLBACK(present_unit_callback),
|
||
|
GINT_TO_POINTER(punit->id));
|
||
|
gtk_widget_add_controller(cmd, controller);
|
||
|
pnode->left = controller;
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 2);
|
||
|
controller = GTK_EVENT_CONTROLLER(gesture);
|
||
|
g_signal_connect(controller, "released",
|
||
|
g_signal_connect(pnode->middle, "released",
|
||
|
G_CALLBACK(middle_present_unit_release),
|
||
|
GINT_TO_POINTER(punit->id));
|
||
|
gtk_widget_add_controller(cmd, controller);
|
||
|
pnode->middle = controller;
|
||
|
gesture = gtk_gesture_click_new();
|
||
|
gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
|
||
|
controller = GTK_EVENT_CONTROLLER(gesture);
|
||
|
g_signal_connect(controller, "released",
|
||
|
g_signal_connect(pnode->right, "released",
|
||
|
G_CALLBACK(right_unit_release),
|
||
|
GINT_TO_POINTER(punit->id));
|
||
|
gtk_widget_add_controller(cmd, controller);
|
||
|
pnode->right = controller;
|
||
|
if (city_owner(pdialog->pcity) != client.conn.playing) {
|
||
|
gtk_widget_set_sensitive(cmd, FALSE);
|
||
| ... | ... | |
|
&& NULL != (pcity = tile_city(unit_tile(punit)))
|
||
|
&& NULL != (pdialog = get_city_dialog(pcity))
|
||
|
&& can_client_issue_orders()) {
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
close_city_dialog(pdialog);
|
||
|
}
|
||
| ... | ... | |
|
&& NULL != (pcity = game_city_by_number(punit->homecity))
|
||
|
&& NULL != (pdialog = get_city_dialog(pcity))
|
||
|
&& can_client_issue_orders()) {
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
close_city_dialog(pdialog);
|
||
|
}
|
||
| ... | ... | |
|
if (NULL != punit
|
||
|
&& can_client_issue_orders()) {
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
}
|
||
|
return TRUE;
|
||
| ... | ... | |
|
player_unit_by_number(client_player(), GPOINTER_TO_INT(data));
|
||
|
if (NULL != punit) {
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
}
|
||
|
close_citydlg_unit_popover(g_object_get_data(G_OBJECT(action), "dlg"));
|
||
| ... | ... | |
|
struct city *pcity =
|
||
|
player_city_by_number(client_player(), punit->homecity);
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
if (NULL != pcity) {
|
||
|
struct city_dialog *pdialog = get_city_dialog(pcity);
|
||
| ... | ... | |
|
if (NULL != punit) {
|
||
|
struct city *pcity = tile_city(unit_tile(punit));
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
if (NULL != pcity) {
|
||
|
struct city_dialog *pdialog = get_city_dialog(pcity);
|
||
| client/gui-gtk-4.0/unitselect.c | ||
|---|---|---|
|
punit = player_unit_by_number(client_player(), uid);
|
||
|
if (punit && unit_owner(punit) == client_player()) {
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
usdlg_destroy();
|
||
|
}
|
||
|
}
|
||
| client/gui-gtk-5.0/citydlg.c | ||
|---|---|---|
|
&& NULL != (pcity = tile_city(unit_tile(punit)))
|
||
|
&& NULL != (pdialog = get_city_dialog(pcity))
|
||
|
&& can_client_issue_orders()) {
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
close_city_dialog(pdialog);
|
||
|
}
|
||
| ... | ... | |
|
&& NULL != (pcity = game_city_by_number(punit->homecity))
|
||
|
&& NULL != (pdialog = get_city_dialog(pcity))
|
||
|
&& can_client_issue_orders()) {
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
close_city_dialog(pdialog);
|
||
|
}
|
||
| ... | ... | |
|
if (NULL != punit
|
||
|
&& can_client_issue_orders()) {
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
}
|
||
|
return TRUE;
|
||
| ... | ... | |
|
player_unit_by_number(client_player(), GPOINTER_TO_INT(data));
|
||
|
if (NULL != punit) {
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
}
|
||
|
close_citydlg_unit_popover(g_object_get_data(G_OBJECT(action), "dlg"));
|
||
| ... | ... | |
|
struct city *pcity =
|
||
|
player_city_by_number(client_player(), punit->homecity);
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
if (NULL != pcity) {
|
||
|
struct city_dialog *pdialog = get_city_dialog(pcity);
|
||
| ... | ... | |
|
if (NULL != punit) {
|
||
|
struct city *pcity = tile_city(unit_tile(punit));
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
if (NULL != pcity) {
|
||
|
struct city_dialog *pdialog = get_city_dialog(pcity);
|
||
| client/gui-gtk-5.0/unitselect.c | ||
|---|---|---|
|
punit = player_unit_by_number(client_player(), uid);
|
||
|
if (punit && unit_owner(punit) == client_player()) {
|
||
|
/* FIXME: If unit is not idle to begin with, we can only request
|
||
|
* idling, and as we have no server reply yet,
|
||
|
* the unit_focus_try() below will fail. */
|
||
|
request_new_unit_activity(punit, ACTIVITY_IDLE);
|
||
|
unit_focus_try(punit);
|
||
|
unit_focus_set(punit);
|
||
|
usdlg_destroy();
|
||
|
}
|
||
|
}
|
||
- « Previous
- 1
- 2
- 3
- Next »