[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]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=10887 >
> [jdorje - Fri Nov 05 15:40:31 2004]:
>
> If you choose "revolution" you get a confirmation dialog.
>
> But if you choose a particular government to change to there is no
> dialog.
>
> This is inconsistent and should be changed. Probably all actions
> should get the confirmation dialog. (And according to HIG should
> have a ... in their menu entries.)
Here is a patch. It will break the other clients though. I'll leave
that for someone else to fix.
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.78
diff -u -u -r1.78 dialogs.c
--- client/gui-gtk-2.0/dialogs.c 7 Nov 2004 14:17:31 -0000 1.78
+++ client/gui-gtk-2.0/dialogs.c 13 Nov 2004 01:35:45 -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/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.51
diff -u -u -r1.51 menu.c
--- client/gui-gtk-2.0/menu.c 8 Nov 2004 01:25:03 -0000 1.51
+++ client/gui-gtk-2.0/menu.c 13 Nov 2004 01:35:46 -0000
@@ -261,7 +261,7 @@
popup_worklists_report();
break;
case MENU_GOVERNMENT_REVOLUTION:
- popup_revolution_dialog();
+ popup_revolution_dialog(-1);
break;
}
}
@@ -678,7 +678,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,
@@ -1093,7 +1093,7 @@
*****************************************************************/
static void government_callback(GtkMenuItem *item, gpointer data)
{
- set_government_choice(GPOINTER_TO_INT(data));
+ popup_revolution_dialog(GPOINTER_TO_INT(data));
}
/****************************************************************************
@@ -1197,8 +1197,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 01:35:46 -0000
@@ -33,7 +33,7 @@
void races_toggles_set_sensitive(bool *nations_used);
-void popup_revolution_dialog(void);
+void popup_revolution_dialog(int government);
void popup_caravan_dialog(struct unit *punit,
struct city *phomecity, struct city *pdestcity);
bool caravan_dialog_is_open(void);
|
|