Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10672) "quit" and "leave" confirmations
Home

[Freeciv-Dev] (PR#10672) "quit" and "leave" confirmations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10672) "quit" and "leave" confirmations
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Mon, 25 Oct 2004 16:56:13 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10672 >

> [jdorje - Fri Oct 22 02:25:16 2004]:
> 
> If you want to "leave" a local game, you have a confirmation dialog.
> 
> But there is no confirmation dialog for "quit"ting!

Here's simple patch.


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.47
diff -u -r1.47 menu.c
--- client/gui-gtk-2.0/menu.c   23 Oct 2004 20:21:01 -0000      1.47
+++ client/gui-gtk-2.0/menu.c   25 Oct 2004 23:55:40 -0000
@@ -172,7 +172,7 @@
 
 
 /****************************************************************
-  This is response callback for a dialog with a message:
+  This is the response callback for the dialog with the message:
   Leaving a local game will end it!
 ****************************************************************/
 static void leave_local_game_response(GtkWidget* dialog, gint response)
@@ -188,6 +188,18 @@
 }
 
 /****************************************************************
+  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,
@@ -224,10 +236,11 @@
   case MENU_GAME_LEAVE:
     if (is_server_running()) {
       GtkWidget* dialog = gtk_message_dialog_new(NULL,
-                             GTK_DIALOG_DESTROY_WITH_PARENT,
+                             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);
@@ -236,7 +249,18 @@
     }
     break;
   case MENU_GAME_QUIT:
-    exit(EXIT_SUCCESS);
+    {
+      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;
   }
 }
 

[Prev in Thread] Current Thread [Next in Thread]