Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12113) Add local option categories to GTK+ 2.x client.
Home

[Freeciv-Dev] (PR#12113) Add local option categories to GTK+ 2.x client.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12113) Add local option categories to GTK+ 2.x client.
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Fri, 4 Feb 2005 12:55:57 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12113 >

-- 


Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.112
diff -u -r1.112 options.c
--- client/options.c    4 Feb 2005 03:48:48 -0000       1.112
+++ client/options.c    4 Feb 2005 20:54:34 -0000
@@ -77,6 +77,12 @@
 /* This option is currently set by the client - not by the user. */
 bool update_city_text_in_refresh_tile = TRUE;
 
+const char *client_option_class_names[COC_MAX] = {
+  N_("Graphics"),
+  N_("Interface"),
+  N_("Miscellaneous")
+};
+
 static client_option common_options[] = {
   GEN_BOOL_OPTION(save_options_on_exit,
                  N_("Save the options when exiting the game"),
Index: client/options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.43
diff -u -r1.43 options.h
--- client/options.h    7 Dec 2004 22:38:59 -0000       1.43
+++ client/options.h    4 Feb 2005 20:54:34 -0000
@@ -58,7 +58,8 @@
 enum client_option_class {
   COC_GRAPHICS,
   COC_INTERFACE,
-  COC_MISCELLANEOUS
+  COC_MISCELLANEOUS,
+  COC_MAX
 };
 
 extern const char *client_option_class_names[];
Index: client/gui-gtk-2.0/gamedlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gamedlgs.c,v
retrieving revision 1.24
diff -u -r1.24 gamedlgs.c
--- client/gui-gtk-2.0/gamedlgs.c       22 Jan 2005 19:45:40 -0000      1.24
+++ client/gui-gtk-2.0/gamedlgs.c       4 Feb 2005 20:54:34 -0000
@@ -423,8 +423,9 @@
 *****************************************************************/
 static void create_option_dialog(void)
 {
-  GtkWidget *label, *table;
-  int i;
+  GtkWidget *label, *notebook, *align, *table[COC_MAX];
+  int i, len[COC_MAX];
+  GtkSizeGroup *group[COC_MAX];
 
   option_dialog_shell = gtk_dialog_new_with_buttons(_("Set local options"),
        NULL,
@@ -441,58 +442,74 @@
                   G_CALLBACK(option_ok_command_callback), NULL);
   gtk_window_set_position (GTK_WINDOW(option_dialog_shell), GTK_WIN_POS_MOUSE);
 
-  table = gtk_table_new(num_options, 2, FALSE);
+  notebook = gtk_notebook_new();
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(option_dialog_shell)->vbox),
-                    table, FALSE, FALSE, 0);
+                    notebook, FALSE, FALSE, 0);
+
+  for (i = 0; i < COC_MAX; i++) {
+    label = gtk_label_new_with_mnemonic(client_option_class_names[i]);
+    align = gtk_alignment_new(0.0, 0.0, 1.0, 0.0);
+    gtk_container_set_border_width(GTK_CONTAINER(align), 8);
+    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), align, label);
+
+    table[i] = gtk_table_new(num_options, 2, FALSE);
+    gtk_table_set_col_spacings(GTK_TABLE(table[i]), 2);
+    gtk_container_add(GTK_CONTAINER(align), table[i]);
+
+    group[i] = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
+
+    len[i] = 0;
+  }
 
-  i = 0;
   client_options_iterate(o) {
+    i = len[o->category];
     switch (o->type) {
     case COT_BOOL:
       label = gtk_label_new(_(o->description));
       gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-      gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, i+1,
-                      GTK_FILL, GTK_FILL | GTK_EXPAND,
-                      0, 0);
-      o->p_gui_data = (void *)gtk_check_button_new();
-      gtk_table_attach(GTK_TABLE(table), o->p_gui_data, 1, 2, i, i+1,
-                      GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
-                      0, 0);
+      gtk_table_attach(GTK_TABLE(table[o->category]), label,
+                      0, 1, i, i+1,
+                      GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);
+      o->p_gui_data = gtk_check_button_new();
+      gtk_table_attach(GTK_TABLE(table[o->category]), o->p_gui_data,
+                      1, 2, i, i+1,
+                      GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
       break;
     case COT_INT:
       label = gtk_label_new(_(o->description));
       gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-      gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, i+1,
-                      GTK_FILL, GTK_FILL | GTK_EXPAND,
-                      0, 0);
+      gtk_table_attach(GTK_TABLE(table[o->category]), label,
+                      0, 1, i, i+1,
+                      GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);
       o->p_gui_data = gtk_entry_new();
       gtk_entry_set_max_length(GTK_ENTRY(o->p_gui_data), 5);
       gtk_widget_set_size_request(GTK_WIDGET(o->p_gui_data), 45, -1);
-      gtk_table_attach(GTK_TABLE(table), o->p_gui_data, 1, 2, i, i+1,
-                      GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
-                      0, 0);
+      gtk_table_attach(GTK_TABLE(table[o->category]), o->p_gui_data,
+                      1, 2, i, i+1,
+                      GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
       break;
     case COT_STR:
       label = gtk_label_new(_(o->description));
       gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
-      gtk_table_attach(GTK_TABLE(table), label, 0, 1, i, i+1,
-                      GTK_FILL, GTK_FILL | GTK_EXPAND,
-                      0, 0);
+      gtk_table_attach(GTK_TABLE(table[o->category]), label,
+                      0, 1, i, i+1,
+                      GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);
       if (o->p_string_vals) {
         o->p_gui_data = gtk_combo_new();
       } else {
         o->p_gui_data = gtk_entry_new();
       }
       gtk_widget_set_size_request(GTK_WIDGET(o->p_gui_data), 150, -1);
-      gtk_table_attach(GTK_TABLE(table), o->p_gui_data, 1, 2, i, i+1,
-                      GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
-                      0, 0);
+      gtk_table_attach(GTK_TABLE(table[o->category]), o->p_gui_data,
+                      1, 2, i, i+1,
+                      GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0);
       break;
     }
-    i++;
+    gtk_size_group_add_widget(group[o->category], label);
+    len[o->category]++;
   } client_options_iterate_end;
 
-  gtk_widget_show_all( GTK_DIALOG( option_dialog_shell )->vbox );
+  gtk_widget_show_all(GTK_DIALOG(option_dialog_shell)->vbox);
 }
 
 /****************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12113) Add local option categories to GTK+ 2.x client., Vasco Alexandre da Silva Costa <=