<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39984 >
William Allen Simpson wrote:
> So, here's a different idea: in addition to the Cancel and OK buttons on
> the various options/settings dialogs, add a Save button. I'm not good at
> GTK2 programming, but it looks relatively easy.
>
The server "settable" options and local options dialogs used standard
GTK2 functions. Here's the code.
The message options dialog is done as one of those switchable tab panes;
not easy to quickly figure that out. It wasn't raised as the issue here,
anyway, so perhaps in the future....
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
--- client/gui-gtk-2.0/repodlgs.c (revision 14221)
+++ client/gui-gtk-2.0/repodlgs.c (working copy)
@@ -1449,9 +1449,17 @@
*****************************************************************/
static void settable_options_callback(GtkWidget *win, gint rid, GtkWidget *w)
{
- if (rid == GTK_RESPONSE_OK) {
+ switch (rid) {
+ case GTK_RESPONSE_ACCEPT:
settable_options_processing(w);
- }
+ save_options();
+ break;
+ case GTK_RESPONSE_APPLY:
+ settable_options_processing(w);
+ break;
+ default:
+ break;
+ };
gtk_widget_destroy(win);
}
@@ -1470,7 +1478,8 @@
gtk_dialog_new_with_buttons(_("Game Settings"),
NULL, 0,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
+ GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
win = settable_options_dialog_shell;
Index: client/gui-gtk-2.0/gamedlgs.c
===================================================================
--- client/gui-gtk-2.0/gamedlgs.c (revision 14221)
+++ client/gui-gtk-2.0/gamedlgs.c (working copy)
@@ -368,12 +368,11 @@
/**************************************************************************
...
**************************************************************************/
-static void option_command_callback(GtkWidget *w, gint response_id)
+static void option_command_processing(void)
{
- if (response_id == GTK_RESPONSE_OK) {
- const char *dp;
- bool b;
- int val;
+ const char *dp;
+ bool b;
+ int val;
client_options_iterate(o) {
switch (o->type) {
@@ -423,10 +422,27 @@
} else {
gtk_window_unfullscreen(GTK_WINDOW(toplevel));
}
- }
- gtk_widget_destroy(option_dialog_shell);
}
+/**************************************************************************
+...
+**************************************************************************/
+static void option_command_callback(GtkWidget *win, gint rid)
+{
+ switch (rid) {
+ case GTK_RESPONSE_ACCEPT:
+ option_command_processing();
+ save_options();
+ break;
+ case GTK_RESPONSE_APPLY:
+ option_command_processing();
+ break;
+ default:
+ break;
+ };
+ gtk_widget_destroy(win);
+}
+
/****************************************************************
...
*****************************************************************/
@@ -440,14 +456,11 @@
option_dialog_shell = gtk_dialog_new_with_buttons(_("Set local options"),
NULL,
0,
- GTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK,
- GTK_RESPONSE_OK,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
setup_dialog(option_dialog_shell, toplevel);
- gtk_dialog_set_default_response(GTK_DIALOG(option_dialog_shell),
- GTK_RESPONSE_OK);
gtk_window_set_position (GTK_WINDOW(option_dialog_shell), GTK_WIN_POS_MOUSE);
notebook = gtk_notebook_new();
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev