Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#10887) gtk2: no confirmation dialog for targeted revol
Home

[Freeciv-Dev] (PR#10887) gtk2: no confirmation dialog for targeted revol

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10887) gtk2: no confirmation dialog for targeted revolutions
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Sat, 13 Nov 2004 15:34:59 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Sat Nov 13 01:42:53 2004]:
> 
> This function isn't (and never will be) called from the common code so 
> its prototype can just be removed from dialogs_g.h.

Here's a new patch then. I will commit it ASAP.

Index: client/gui-gtk-2.0/dialogs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.c,v
retrieving revision 1.79
diff -u -u -r1.79 dialogs.c
--- client/gui-gtk-2.0/dialogs.c        13 Nov 2004 23:22:43 -0000      1.79
+++ client/gui-gtk-2.0/dialogs.c        13 Nov 2004 23:34:18 -0000
@@ -1004,22 +1004,49 @@
 /****************************************************************
 ...
 *****************************************************************/
-void popup_revolution_dialog(void)
+static void revolution_response(GtkWidget *w, gint response, gpointer data)
 {
-  GtkWidget *shell;
+  int government = GPOINTER_TO_INT(data);
 
-  shell = gtk_message_dialog_new(NULL,
-    GTK_DIALOG_MODAL,
-    GTK_MESSAGE_WARNING,
-    GTK_BUTTONS_YES_NO,
-    _("You say you wanna revolution?"));
-  gtk_window_set_title(GTK_WINDOW(shell), _("Revolution!"));
-  setup_dialog(shell, toplevel);
+  if (response == GTK_RESPONSE_YES) {
+    if (government == -1) {
+      start_revolution();
+    } else {
+      set_government_choice(government);
+    }
+  }
+  if (w) {
+    gtk_widget_destroy(w);
+  }
+}
 
-  if (gtk_dialog_run(GTK_DIALOG(shell)) == GTK_RESPONSE_YES) {
-    start_revolution();
+/****************************************************************
+...
+*****************************************************************/
+void popup_revolution_dialog(int government)
+{
+  static GtkWidget *shell = NULL;
+
+  if (game.player_ptr->revolution_finishes < game.turn) {
+    if (!shell) {
+      shell = gtk_message_dialog_new(NULL,
+         0,
+         GTK_MESSAGE_WARNING,
+         GTK_BUTTONS_YES_NO,
+         _("You say you wanna revolution?"));
+      gtk_window_set_title(GTK_WINDOW(shell), _("Revolution!"));
+      setup_dialog(shell, toplevel);
+
+      g_signal_connect(shell, "destroy",
+         G_CALLBACK(gtk_widget_destroyed), &shell);
+    }
+    g_signal_connect(shell, "response",
+       G_CALLBACK(revolution_response), GINT_TO_POINTER(government));
+
+    gtk_window_present(GTK_WINDOW(shell));
+  } else {
+    revolution_response(shell, GTK_RESPONSE_YES, GINT_TO_POINTER(government));
   }
-  gtk_widget_destroy(shell);
 }
 
 
Index: client/gui-gtk-2.0/dialogs.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/dialogs.h,v
retrieving revision 1.6
diff -u -u -r1.6 dialogs.h
--- client/gui-gtk-2.0/dialogs.h        24 Feb 2003 02:33:04 -0000      1.6
+++ client/gui-gtk-2.0/dialogs.h        13 Nov 2004 23:34:18 -0000
@@ -19,6 +19,7 @@
 
 struct tile;
 
+void popup_revolution_dialog(int government);
 void message_dialog_button_set_sensitive(GtkWidget *shl, int button,
                                         gboolean state);
 GtkWidget *popup_message_dialog(GtkWindow *parent, const gchar *dialogname,
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.52
diff -u -u -r1.52 menu.c
--- client/gui-gtk-2.0/menu.c   13 Nov 2004 23:22:43 -0000      1.52
+++ client/gui-gtk-2.0/menu.c   13 Nov 2004 23:34:19 -0000
@@ -262,7 +262,7 @@
     popup_worklists_report();
     break;
   case MENU_GOVERNMENT_REVOLUTION:
-    popup_revolution_dialog();
+    popup_revolution_dialog(-1);
     break;
   }
 }
@@ -679,7 +679,7 @@
        NULL,                   0,                                      
"<Separator>"   },
   { "/" N_("Government") "/" N_("_Change Government"),           NULL,
        NULL,                   0,                                      
"<Branch>"      },
-  { "/" N_("Government") "/" N_("_Change Government") "/" N_("_Revolution"),
+  { "/" N_("Government") "/" N_("_Change Government") "/" N_("_Revolution..."),
                                                         "<shift>r",
        government_menu_callback,       MENU_GOVERNMENT_REVOLUTION              
        },
   { "/" N_("_Government") "/" N_("_Change Government") "/sep1", NULL,
@@ -1094,7 +1094,7 @@
 *****************************************************************/
 static void government_callback(GtkMenuItem *item, gpointer data)
 {
-  set_government_choice(GPOINTER_TO_INT(data));
+  popup_revolution_dialog(GPOINTER_TO_INT(data));
 }
 
 /****************************************************************************
@@ -1198,8 +1198,10 @@
         if (i != game.government_when_anarchy) {
           GtkWidget *item, *image;
           struct Sprite *gsprite;
+         char buf[256];
 
-          item = gtk_image_menu_item_new_with_label(g->name);
+         my_snprintf(buf, sizeof(buf), _("%s..."), g->name);
+          item = gtk_image_menu_item_new_with_label(buf);
 
           gsprite = get_government(g->index)->sprite;
           image = gtk_image_new_from_pixmap(gsprite->pixmap, gsprite->mask);
Index: client/include/dialogs_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/dialogs_g.h,v
retrieving revision 1.21
diff -u -u -r1.21 dialogs_g.h
--- client/include/dialogs_g.h  29 Sep 2004 02:24:22 -0000      1.21
+++ client/include/dialogs_g.h  13 Nov 2004 23:34:19 -0000
@@ -33,7 +33,6 @@
 
 void races_toggles_set_sensitive(bool *nations_used);
 
-void popup_revolution_dialog(void);
 void popup_caravan_dialog(struct unit *punit,
                          struct city *phomecity, struct city *pdestcity);
 bool caravan_dialog_is_open(void);

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