[Freeciv-Dev] (PR#8490) Extended connection dialog tweaks+bugfix.
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#8490) Extended connection dialog tweaks+bugfix. |
From: |
"Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx> |
Date: |
Sun, 11 Apr 2004 17:01:35 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8490 >
Howdy. I saw the new extended connection dialog in action today. A fine
piece of work. But it seemed to be missing a few stock items here and
there, mnemonics, it also used radio buttons instead of checkboxes for
boolean values.
This patch changes that.
Regarding the bug, a juicy little critter, in struct options_settable
min/max/val/default_val all were defined as short when they really
should be int. This resulted in unfortunate consequences for certain not
so nice
variable ranges such as those of seed, randseed and timeout. No protocol
change was required since those fields were defined in there as int32
already.
So this is a two for one, feature adding and bug fixing, patch. Just
like champoo. Enjoy.
Index: client/repodlgs_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/repodlgs_common.h,v
retrieving revision 1.5
diff -u -r1.5 repodlgs_common.h
--- client/repodlgs_common.h 10 Apr 2004 03:47:48 -0000 1.5
+++ client/repodlgs_common.h 11 Apr 2004 23:49:43 -0000
@@ -55,10 +55,10 @@
int type;
unsigned char category;
- short val;
- short default_val;
- short min;
- short max;
+ int val;
+ int default_val;
+ int min;
+ int max;
char *strval;
char *default_strval;
Index: client/gui-gtk-2.0/connectdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/connectdlg.c,v
retrieving revision 1.30
diff -u -r1.30 connectdlg.c
--- client/gui-gtk-2.0/connectdlg.c 10 Apr 2004 03:47:48 -0000 1.30
+++ client/gui-gtk-2.0/connectdlg.c 11 Apr 2004 23:49:44 -0000
@@ -120,7 +120,7 @@
{
gtk_widget_grab_focus(iinput);
gtk_entry_set_text(GTK_ENTRY(iinput), "");
- gtk_button_set_label(GTK_BUTTON(nextw), _("Next >"));
+ gtk_button_set_label(GTK_BUTTON(nextw), GTK_STOCK_GO_FORWARD);
gtk_widget_set_sensitive(nextw, TRUE);
gtk_label_set_text(GTK_LABEL(imsg), message);
@@ -599,7 +599,7 @@
case FIRST_PAGE:
client_kill_server();
gtk_widget_set_sensitive(prevw, FALSE);
- gtk_button_set_label(GTK_BUTTON(nextw), _("Next >"));
+ gtk_button_set_label(GTK_BUTTON(nextw), GTK_STOCK_GO_FORWARD);
break;
case NEW_PAGE:
break;
@@ -616,11 +616,11 @@
switch(page_num) {
case LOGIN_PAGE:
gtk_button_set_label(GTK_BUTTON(nextw),
- dialog_config == LOGIN_TYPE ? _("Connect") : _("Next
>"));
+ dialog_config == LOGIN_TYPE ? _("_Connect") : GTK_STOCK_GO_FORWARD);
break;
case METASERVER_PAGE:
case LAN_PAGE:
- gtk_button_set_label(GTK_BUTTON(nextw), _("Select"));
+ gtk_button_set_label(GTK_BUTTON(nextw), _("_Select"));
break;
default:
break;
@@ -683,7 +683,9 @@
**************************************************************************/
static void next_command_callback(GtkWidget *w, gpointer data)
{
- const char *next_labels[4] = { "", N_("Start"), N_("Resume"), N_("Connect")
};
+ const char *next_labels[4] = {
+ "", N_("_Start"), N_("_Resume"), N_("_Connect")
+ };
char buf[512];
if (gtk_notebook_get_current_page(GTK_NOTEBOOK(uberbook)) == FIRST_PAGE) {
@@ -764,18 +766,18 @@
/* create the action area buttons */
- loadw = gtk_button_new_with_label(_("Load..."));
+ loadw = gtk_button_new_with_mnemonic(_("_Load..."));
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
loadw, TRUE, TRUE, 0);
g_signal_connect(loadw, "clicked", G_CALLBACK(load_callback), NULL);
- prevw = gtk_button_new_with_label(_("< Prev"));
+ prevw = gtk_button_new_from_stock(GTK_STOCK_GO_BACK);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
prevw, TRUE, TRUE, 0);
gtk_widget_set_sensitive(prevw, FALSE);
g_signal_connect(prevw, "clicked", G_CALLBACK(prev_command_callback), NULL);
- nextw = gtk_button_new_with_label(_("Next >"));
+ nextw = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->action_area),
nextw, TRUE, TRUE, 0);
g_signal_connect(nextw, "clicked", G_CALLBACK(next_command_callback), NULL);
@@ -795,21 +797,22 @@
vbox = gtk_vbox_new(FALSE, 2);
gtk_notebook_append_page(GTK_NOTEBOOK(uberbook), vbox, NULL);
- radio = gtk_radio_button_new_with_label(group, _("Start New Game"));
+ radio = gtk_radio_button_new_with_mnemonic(group, _("_Start New Game"));
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio));
gtk_box_pack_start(GTK_BOX(vbox), radio, TRUE, FALSE, 2);
g_signal_connect(radio, "toggled",G_CALLBACK(radio_command_callback),
GINT_TO_POINTER(NEW_PAGE));
- radio = gtk_radio_button_new_with_label(group, _("Load Saved Game"));
+ radio = gtk_radio_button_new_with_mnemonic(group, _("_Load Saved Game"));
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio));
gtk_box_pack_start(GTK_BOX(vbox), radio, TRUE, FALSE, 2);
g_signal_connect(radio, "toggled",G_CALLBACK(radio_command_callback),
GINT_TO_POINTER(LOAD_PAGE));
- radio = gtk_radio_button_new_with_label(group, _("Connect to Network Game"));
+ radio = gtk_radio_button_new_with_mnemonic(group,
+ _("_Connect to Network Game"));
gtk_box_pack_start(GTK_BOX(vbox), radio, TRUE, FALSE, 2);
g_signal_connect(radio, "toggled",G_CALLBACK(radio_command_callback),
@@ -862,7 +865,7 @@
hbox = gtk_hbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 20);
- button = gtk_button_new_with_label(_("Change Server Options"));
+ button = gtk_button_new_with_mnemonic(_("Change Server _Options"));
g_signal_connect_swapped(G_OBJECT(button), "clicked",
G_CALLBACK(send_report_request),
(gpointer)REPORT_SERVER_OPTIONS2);
Index: client/gui-gtk-2.0/repodlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/repodlgs.c,v
retrieving revision 1.46
diff -u -r1.46 repodlgs.c
--- client/gui-gtk-2.0/repodlgs.c 10 Apr 2004 03:47:48 -0000 1.46
+++ client/gui-gtk-2.0/repodlgs.c 11 Apr 2004 23:49:45 -0000
@@ -16,6 +16,7 @@
#endif
#include <assert.h>
+#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -1480,17 +1481,26 @@
tmp = (GtkWidget *)g_object_get_data(G_OBJECT(w), "prev");
if (tmp) {
set_options(tmp);
- } else {
- gtk_widget_destroy(gtk_widget_get_toplevel(w));
}
}
+/****************************************************************
+...
+*****************************************************************/
+static void settable_options_callback(GtkWidget *win, gint rid, GtkWidget *w)
+{
+ if (rid == GTK_RESPONSE_OK) {
+ set_options(w);
+ }
+ gtk_widget_destroy(win);
+}
+
/*************************************************************************
Server options dialog
*************************************************************************/
void popup_settable_options_dialog(void)
{
- GtkWidget *win, *book, **vbox, *but, *label, *prev_widget = NULL;
+ GtkWidget *win, *book, **vbox, *label, *prev_widget = NULL;
GtkTooltips *tips;
bool *used = fc_malloc(num_options_categories * sizeof(bool));
int i;
@@ -1502,6 +1512,7 @@
tips = gtk_tooltips_new();
win = gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(win), _("Server Options"));
+ gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_MOUSE);
/* create a notebook for the options */
book = gtk_notebook_new();
@@ -1512,9 +1523,9 @@
for (i = 0; i < num_options_categories; i++) {
vbox[i] = gtk_vbox_new(FALSE, 2);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox[i]), 6);
label = gtk_label_new(options_categories[i]);
gtk_notebook_append_page(GTK_NOTEBOOK(book), vbox[i], label);
- gtk_box_pack_end(GTK_BOX(vbox[i]), gtk_label_new(""), FALSE, FALSE, 0);
}
/* fill each category */
@@ -1543,42 +1554,37 @@
/* create the proper entry method depending on the type */
if (settable_options[i].type == 0) {
/* boolean */
- GtkWidget *no;
-
- ent = gtk_radio_button_new_with_label(NULL, _("Yes"));
- no = gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(ent),
- _("No"));
+ ent = gtk_check_button_new();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ent),
settable_options[i].val);
- gtk_box_pack_end(GTK_BOX(hbox), no, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(ent), "toggled",
+ g_signal_connect(ent, "toggled",
G_CALLBACK(option_changed_callback), NULL);
} else if (settable_options[i].type == 1) {
/* integer */
- int step, max, min;
- GtkObject *adj;
+ double step, max, min;
min = settable_options[i].min;
max = settable_options[i].max;
/* pick a reasonable step size */
- step = (max - min) / 101 + 1;
- if (step > 100) {
+ step = ceil((max - min) / 100.0);
+ if (step > 100.0) {
/* this is ridiculous, the bounds must be meaningless */
- step = 5;
+ step = 5.0;
}
- adj = gtk_adjustment_new(settable_options[i].val, min, max, step, 0, 0);
- ent = gtk_spin_button_new(GTK_ADJUSTMENT(adj), 1, 0);
- g_signal_connect(G_OBJECT(ent), "changed",
+ ent = gtk_spin_button_new_with_range(min, max, step);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(ent), settable_options[i].val);
+
+ g_signal_connect(ent, "changed",
G_CALLBACK(option_changed_callback), NULL);
} else {
/* string */
ent = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(ent), settable_options[i].strval);
- g_signal_connect(G_OBJECT(ent), "changed",
+ g_signal_connect(ent, "changed",
G_CALLBACK(option_changed_callback), NULL);
}
gtk_box_pack_end(GTK_BOX(hbox), ent, FALSE, FALSE, 0);
@@ -1598,15 +1604,13 @@
}
free(used);
- but = gtk_button_new_with_label(_("OK"));
- g_signal_connect_swapped(G_OBJECT(but), "clicked",
- G_CALLBACK(set_options), prev_widget);
- gtk_box_pack_end(GTK_BOX(GTK_DIALOG(win)->action_area), but, TRUE, TRUE, 2);
-
- but = gtk_button_new_with_label(_("Cancel"));
- g_signal_connect_swapped(G_OBJECT(but), "clicked",
- G_CALLBACK(gtk_widget_destroy), win);
- gtk_box_pack_end(GTK_BOX(GTK_DIALOG(win)->action_area), but, TRUE, TRUE, 2);
+ g_signal_connect(win, "response",
+ G_CALLBACK(settable_options_callback), prev_widget);
+
+ gtk_dialog_add_buttons(GTK_DIALOG(win),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
- gtk_widget_show_all(win);
+ gtk_widget_show_all(GTK_DIALOG(win)->vbox);
+ gtk_window_present(GTK_WINDOW(win));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#8490) Extended connection dialog tweaks+bugfix.,
Vasco Alexandre da Silva Costa <=
|
|