[Freeciv-Dev] (PR#10899) quit confirmation
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10899 >
> [chrisk - Fri Nov 05 21:12:27 2004]:
>
>
> CVS 05 NOV 2004 S2 GTK2
>
> On leaving or quitting civclient via menu you are presented a confirmation
> dialog. On leaving it with the window close button (the X) you are not.
>
> It may be debatable whether there should be such a thing or not. At
least it
> cost me half an hour of game 'work' today.
Here's the patch. I'm a sucker for consistency.
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.88
diff -u -r1.88 gui_main.c
--- client/gui-gtk-2.0/gui_main.c 7 Nov 2004 06:30:29 -0000 1.88
+++ client/gui-gtk-2.0/gui_main.c 7 Nov 2004 23:47:09 -0000
@@ -181,6 +181,7 @@
gpointer data);
static gint timer_callback(gpointer data);
gboolean show_conn_popup(GtkWidget *view, GdkEventButton *ev, gpointer data);
+static gboolean quit_dialog_callback(void);
/**************************************************************************
...
@@ -1052,7 +1053,8 @@
gtk_window_set_title(GTK_WINDOW (toplevel), _("Freeciv"));
- g_signal_connect(toplevel, "delete_event", G_CALLBACK(gtk_main_quit), NULL);
+ g_signal_connect(toplevel, "delete_event",
+ G_CALLBACK(quit_dialog_callback), NULL);
/* Disable GTK+ cursor key focus movement */
sig = g_signal_lookup("focus", GTK_TYPE_WIDGET);
@@ -1443,3 +1445,53 @@
gtk_input_remove(input_id);
gdk_window_set_cursor(root_window, NULL);
}
+
+/****************************************************************
+ This is the response callback for the dialog with the message:
+ Are you sure you want to quit?
+****************************************************************/
+static void quit_dialog_response(GtkWidget *dialog, gint response)
+{
+ gtk_widget_destroy(dialog);
+ if (response == GTK_RESPONSE_YES) {
+ exit(EXIT_SUCCESS);
+ }
+}
+
+/****************************************************************
+ Popups the dialog with the message:
+ Are you sure you want to quit?
+****************************************************************/
+void popup_quit_dialog(void)
+{
+ static GtkWidget *dialog;
+
+ if (!dialog) {
+ dialog = gtk_message_dialog_new(NULL,
+ 0,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_YES_NO,
+ _("Are you sure you want to quit?"));
+ setup_dialog(dialog, toplevel);
+
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
+
+ g_signal_connect(dialog, "response",
+ G_CALLBACK(quit_dialog_response), NULL);
+ g_signal_connect(dialog, "destroy",
+ G_CALLBACK(gtk_widget_destroyed), &dialog);
+ }
+
+ gtk_window_present(GTK_WINDOW(dialog));
+}
+
+/****************************************************************
+ Popups the quit dialog.
+****************************************************************/
+static gboolean quit_dialog_callback(void)
+{
+ popup_quit_dialog();
+ /* Stop emission of event. */
+ return TRUE;
+}
+
Index: client/gui-gtk-2.0/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.h,v
retrieving revision 1.16
diff -u -r1.16 gui_main.h
--- client/gui-gtk-2.0/gui_main.h 31 Oct 2004 20:45:54 -0000 1.16
+++ client/gui-gtk-2.0/gui_main.h 7 Nov 2004 23:47:09 -0000
@@ -95,5 +95,6 @@
gboolean show_conn_popup(GtkWidget *view, GdkEventButton *ev, gpointer data);
void reset_unit_table(void);
+void popup_quit_dialog(void);
#endif /* FC__GUI_MAIN_H */
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.49
diff -u -r1.49 menu.c
--- client/gui-gtk-2.0/menu.c 31 Oct 2004 20:45:54 -0000 1.49
+++ client/gui-gtk-2.0/menu.c 7 Nov 2004 23:47:12 -0000
@@ -188,79 +188,57 @@
}
/****************************************************************
- This is the response callback for the dialog with the message:
- Are you sure you want to quit?
-****************************************************************/
-static void quit_client_response(GtkWidget* dialog, gint response)
-{
- gtk_widget_destroy(dialog);
- if (response == GTK_RESPONSE_OK) {
- exit(EXIT_SUCCESS);
- }
-}
-
-/****************************************************************
-...
-*****************************************************************/
+ ...
+ *****************************************************************/
static void game_menu_callback(gpointer callback_data,
- guint callback_action, GtkWidget *widget)
+ guint callback_action, GtkWidget *widget)
{
switch(callback_action) {
- case MENU_GAME_OPTIONS:
- popup_option_dialog();
- break;
- case MENU_GAME_MSG_OPTIONS:
- popup_messageopt_dialog();
- break;
- case MENU_GAME_SAVE_SETTINGS:
- save_options();
- break;
- case MENU_GAME_SERVER_OPTIONS1:
- send_report_request(REPORT_SERVER_OPTIONS1);
- break;
- case MENU_GAME_SERVER_OPTIONS2:
- send_report_request(REPORT_SERVER_OPTIONS2);
- break;
- case MENU_GAME_SAVE_GAME:
- popup_save_dialog();
- break;
- case MENU_GAME_SAVE_QUICK:
- send_save_game(NULL);
- break;
- case MENU_GAME_OUTPUT_LOG:
- log_output_window();
- break;
- case MENU_GAME_CLEAR_OUTPUT:
- clear_output_window();
- break;
- case MENU_GAME_LEAVE:
- if (is_server_running()) {
- GtkWidget* dialog = gtk_message_dialog_new(NULL,
- 0,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK_CANCEL,
- _("Leaving a local game will end it!"));
- gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
- g_signal_connect(dialog, "response",
- G_CALLBACK(leave_local_game_response), NULL);
- gtk_widget_show_all(dialog);
- } else {
- disconnect_from_server();
- }
- break;
- case MENU_GAME_QUIT:
- {
- GtkWidget* dialog = gtk_message_dialog_new(NULL,
- 0,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK_CANCEL,
- _("Are you sure you want to quit?"));
- gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
- g_signal_connect(dialog, "response",
- G_CALLBACK(quit_client_response), NULL);
- gtk_widget_show_all(dialog);
- }
- break;
+ case MENU_GAME_OPTIONS:
+ popup_option_dialog();
+ break;
+ case MENU_GAME_MSG_OPTIONS:
+ popup_messageopt_dialog();
+ break;
+ case MENU_GAME_SAVE_SETTINGS:
+ save_options();
+ break;
+ case MENU_GAME_SERVER_OPTIONS1:
+ send_report_request(REPORT_SERVER_OPTIONS1);
+ break;
+ case MENU_GAME_SERVER_OPTIONS2:
+ send_report_request(REPORT_SERVER_OPTIONS2);
+ break;
+ case MENU_GAME_SAVE_GAME:
+ popup_save_dialog();
+ break;
+ case MENU_GAME_SAVE_QUICK:
+ send_save_game(NULL);
+ break;
+ case MENU_GAME_OUTPUT_LOG:
+ log_output_window();
+ break;
+ case MENU_GAME_CLEAR_OUTPUT:
+ clear_output_window();
+ break;
+ case MENU_GAME_LEAVE:
+ if (is_server_running()) {
+ GtkWidget* dialog = gtk_message_dialog_new(NULL,
+ 0,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK_CANCEL,
+ _("Leaving a local game will end it!"));
+ gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE);
+ g_signal_connect(dialog, "response",
+ G_CALLBACK(leave_local_game_response), NULL);
+ gtk_widget_show_all(dialog);
+ } else {
+ disconnect_from_server();
+ }
+ break;
+ case MENU_GAME_QUIT:
+ popup_quit_dialog();
+ break;
}
}
Index: data/helpdata.txt
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/helpdata.txt,v
retrieving revision 1.128
diff -u -r1.128 helpdata.txt
--- data/helpdata.txt 19 Jul 2004 14:06:48 -0000 1.128
+++ data/helpdata.txt 7 Nov 2004 23:47:12 -0000
@@ -505,10 +505,10 @@
9: move north-east F11: open Demographics\n\
F12: open Spaceship\n\
\n\
- home: center on capital\n\
- arrows: scroll map Control-g: grid lines on/off\n\
- space: unit stay put Control-n: city names on/off\n\
- return: turn done Control-p: city production on/off\n\
+ Shift-home: center on capital\n\
+ Shift-arrows: scroll map Control-g: grid lines on/off\n\
+ space: unit stay put Control-n: city names on/off\n\
+ Shift-return: turn done Control-p: city production on/off\n\
")
[help_chatline]
|
|