Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12131) Move save options and full screen mode to menus
Home

[Freeciv-Dev] (PR#12131) Move save options and full screen mode to menus

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12131) Move save options and full screen mode to menus.
From: "Vasco Alexandre da Silva Costa" <vasc@xxxxxxxxxxxxxx>
Date: Sat, 5 Feb 2005 11:46:06 -0800
Reply-to: bugs@xxxxxxxxxxx

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

It also does some cleanups and renames.

Patch by me.

Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.117
diff -u -u -r1.117 options.c
--- client/options.c    5 Feb 2005 02:39:31 -0000       1.117
+++ client/options.c    5 Feb 2005 19:44:27 -0000
@@ -50,9 +50,11 @@
 char default_sound_set_name[512] = "stdsounds";
 char default_sound_plugin_name[512] = "\0";
 
+bool save_options_on_exit = TRUE;
+bool fullscreen_mode = TRUE;
+
 /** Local Options: **/
 
-bool save_options_on_exit = TRUE;
 bool solid_color_behind_units = FALSE;
 bool sound_bell_at_new_turn = FALSE;
 int  smooth_move_unit_msec = 30;
@@ -84,11 +86,6 @@
 };
 
 static client_option common_options[] = {
-  GEN_BOOL_OPTION(save_options_on_exit,
-                 N_("Save the options when exiting the game"),
-                 N_("If this option is selected, options will be saved "
-                    "automatically when you exit Freeciv."),
-                 COC_NETWORK),
   GEN_STR_OPTION(default_user_name,
                 N_("Login name"),
                 N_("This is the default login username that will be used "
@@ -539,6 +536,13 @@
   sz_strlcpy(password, 
              secfile_lookup_str_default(&sf, "", "%s.password", prefix));
 
+  save_options_on_exit =
+    secfile_lookup_bool_default(&sf, save_options_on_exit,
+                               "%s.save_options_on_exit", prefix);
+  fullscreen_mode =
+    secfile_lookup_bool_default(&sf, fullscreen_mode,
+                               "%s.fullscreen_mode", prefix);
+
   for (i = 0; i < num_options; i++) {
     client_option *o = options + i;
 
@@ -652,6 +656,9 @@
   section_file_init(&sf);
   secfile_insert_str(&sf, VERSION_STRING, "client.version");
 
+  secfile_insert_bool(&sf, save_options_on_exit, 
"client.save_options_on_exit");
+  secfile_insert_bool(&sf, fullscreen_mode, "client.fullscreen_mode");
+
   for (i = 0; i < num_options; i++) {
     client_option *o = options + i;
 
Index: client/options.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.h,v
retrieving revision 1.46
diff -u -u -r1.46 options.h
--- client/options.h    4 Feb 2005 23:00:02 -0000       1.46
+++ client/options.h    5 Feb 2005 19:44:27 -0000
@@ -24,9 +24,11 @@
 extern char default_sound_set_name[512];
 extern char default_sound_plugin_name[512];
 
+extern bool save_options_on_exit;
+extern bool fullscreen_mode;
+
 /** Local Options: **/
 
-extern bool save_options_on_exit;
 extern bool solid_color_behind_units;
 extern bool sound_bell_at_new_turn;
 extern int smooth_move_unit_msec;
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.26
diff -u -u -r1.26 gamedlgs.c
--- client/gui-gtk-2.0/gamedlgs.c       4 Feb 2005 23:00:02 -0000       1.26
+++ client/gui-gtk-2.0/gamedlgs.c       5 Feb 2005 19:44:28 -0000
@@ -204,16 +204,6 @@
 }
 
 
-/**************************************************************************
-...
-**************************************************************************/
-static void rates_destroy_callback(GtkWidget *widget, gpointer data)
-{
-  rates_dialog_shell = NULL;
-}
-
-
-
 /****************************************************************
 ... 
 *****************************************************************/
@@ -303,7 +293,7 @@
   g_signal_connect(shell, "response",
                   G_CALLBACK(rates_command_callback), NULL);
   g_signal_connect(shell, "destroy",
-                  G_CALLBACK(rates_destroy_callback), NULL);
+                  G_CALLBACK(gtk_widget_destroyed), &rates_dialog_shell);
 
   gtk_widget_show_all( GTK_DIALOG( shell )->vbox );
   gtk_widget_show_all( GTK_DIALOG( shell )->action_area );
@@ -360,87 +350,86 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static void option_ok_command_callback(GtkWidget *widget, gpointer data)
+static void option_command_callback(GtkWidget *w, gint response_id)
 {
-  const char *dp;
-  bool b;
-  int val;
-
-  client_options_iterate(o) {
-    switch (o->type) {
-    case COT_BOOL:
-      b = *(o->p_bool_value);
-      *(o->p_bool_value) = GTK_TOGGLE_BUTTON(o->p_gui_data)->active;
-      if (b != *(o->p_bool_value) && o->change_callback) {
-       (o->change_callback)(o);
-      }
-      break;
-    case COT_INT:
-      val = *(o->p_int_value);
-      dp = gtk_entry_get_text(GTK_ENTRY(o->p_gui_data));
-      sscanf(dp, "%d", o->p_int_value);
-      if (val != *(o->p_int_value) && o->change_callback) {
-       (o->change_callback)(o);
-      }
-      break;
-    case COT_STR:
-      if (o->p_string_vals) {
-       const char* new_value = gtk_entry_get_text(GTK_ENTRY
-                                       (GTK_COMBO(o->p_gui_data)->entry));
-       if (strcmp(o->p_string_value, new_value)) {
-         mystrlcpy(o->p_string_value, new_value, o->string_length);
-         if (o->change_callback) {
-           (o->change_callback)(o);
+  if (response_id == GTK_RESPONSE_OK) {
+    const char *dp;
+    bool b;
+    int val;
+
+    client_options_iterate(o) {
+      switch (o->type) {
+      case COT_BOOL:
+       b = *(o->p_bool_value);
+       *(o->p_bool_value) = GTK_TOGGLE_BUTTON(o->p_gui_data)->active;
+       if (b != *(o->p_bool_value) && o->change_callback) {
+         (o->change_callback)(o);
+       }
+       break;
+      case COT_INT:
+       val = *(o->p_int_value);
+       dp = gtk_entry_get_text(GTK_ENTRY(o->p_gui_data));
+       sscanf(dp, "%d", o->p_int_value);
+       if (val != *(o->p_int_value) && o->change_callback) {
+         (o->change_callback)(o);
+       }
+       break;
+      case COT_STR:
+       if (o->p_string_vals) {
+         const char* new_value = gtk_entry_get_text(GTK_ENTRY
+                                         (GTK_COMBO(o->p_gui_data)->entry));
+         if (strcmp(o->p_string_value, new_value)) {
+           mystrlcpy(o->p_string_value, new_value, o->string_length);
+           if (o->change_callback) {
+             (o->change_callback)(o);
+           }
          }
+       } else {
+         mystrlcpy(o->p_string_value,
+                   gtk_entry_get_text(GTK_ENTRY(o->p_gui_data)),
+                   o->string_length);
        }
-      } else {
-       mystrlcpy(o->p_string_value,
-                 gtk_entry_get_text(GTK_ENTRY(o->p_gui_data)),
-                 o->string_length);
+       break;
       }
-      break;
-    }
-  } client_options_iterate_end;
+    } client_options_iterate_end;
 
-  if (map_scrollbars) {
-    gtk_widget_show(map_horizontal_scrollbar);
-    gtk_widget_show(map_vertical_scrollbar);
-  } else {
-    gtk_widget_hide(map_horizontal_scrollbar);
-    gtk_widget_hide(map_vertical_scrollbar);
-  }
-  if (fullscreen_mode) {
-    gtk_window_fullscreen(GTK_WINDOW(toplevel));
-  } else {
-    gtk_window_unfullscreen(GTK_WINDOW(toplevel));
+    if (map_scrollbars) {
+      gtk_widget_show(map_horizontal_scrollbar);
+      gtk_widget_show(map_vertical_scrollbar);
+    } else {
+      gtk_widget_hide(map_horizontal_scrollbar);
+      gtk_widget_hide(map_vertical_scrollbar);
+    }
+    if (fullscreen_mode) {
+      gtk_window_fullscreen(GTK_WINDOW(toplevel));
+    } else {
+      gtk_window_unfullscreen(GTK_WINDOW(toplevel));
+    }
   }
-  option_dialog_shell = NULL;
+  gtk_widget_destroy(option_dialog_shell);
 }
 
-
 /****************************************************************
 ... 
 *****************************************************************/
 static void create_option_dialog(void)
 {
-  GtkWidget *ebox, *label, *notebook, *align, *table[COC_MAX];
+  GtkWidget *ebox, *label, *notebook, *align, *vbox[COC_MAX];
   int i, len[COC_MAX];
-  GtkSizeGroup *group[COC_MAX];
+  GtkSizeGroup *group[2][COC_MAX];
   GtkTooltips *tips;
 
   option_dialog_shell = gtk_dialog_new_with_buttons(_("Set local options"),
        NULL,
        0,
-       GTK_STOCK_CLOSE,
-       GTK_RESPONSE_CLOSE,
+       GTK_STOCK_CANCEL,
+       GTK_RESPONSE_CANCEL,
+       GTK_STOCK_OK,
+       GTK_RESPONSE_OK,
        NULL);
   setup_dialog(option_dialog_shell, toplevel);
   gtk_dialog_set_default_response(GTK_DIALOG(option_dialog_shell),
-                                 GTK_RESPONSE_CLOSE);
-  g_signal_connect(option_dialog_shell, "response",
-                  G_CALLBACK(gtk_widget_destroy), NULL);
-  g_signal_connect(option_dialog_shell, "destroy",
-                  G_CALLBACK(option_ok_command_callback), NULL);
+                                 GTK_RESPONSE_OK);
   gtk_window_set_position (GTK_WINDOW(option_dialog_shell), GTK_WIN_POS_MOUSE);
 
   notebook = gtk_notebook_new();
@@ -453,11 +442,11 @@
     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]);
+    vbox[i] = gtk_vbox_new(TRUE, 0);
+    gtk_container_add(GTK_CONTAINER(align), vbox[i]);
 
-    group[i] = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
+    group[0][i] = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
+    group[1][i] = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
 
     len[i] = 0;
   }
@@ -465,13 +454,20 @@
   tips = gtk_tooltips_new();
 
   client_options_iterate(o) {
+    GtkWidget *hbox;
+
+    if (o->category == COC_MAX) {
+      continue;
+    }
+
     i = len[o->category];
 
+    hbox = gtk_hbox_new(FALSE, 2);
+    gtk_container_add(GTK_CONTAINER(vbox[o->category]), hbox);
+
     ebox = gtk_event_box_new();
-    gtk_table_attach(GTK_TABLE(table[o->category]), ebox,
-                    0, 1, i, i+1,
-                    GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);
-    gtk_size_group_add_widget(group[o->category], ebox);
+    gtk_container_add(GTK_CONTAINER(hbox), ebox);
+    gtk_size_group_add_widget(group[0][o->category], ebox);
 
     label = gtk_label_new(_(o->description));
     gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
@@ -497,13 +493,17 @@
       gtk_widget_set_size_request(GTK_WIDGET(o->p_gui_data), 150, -1);
       break;
     }
-    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);
+    gtk_container_add(GTK_CONTAINER(hbox), o->p_gui_data);
+    gtk_size_group_add_widget(group[1][o->category], o->p_gui_data);
 
     len[o->category]++;
   } client_options_iterate_end;
 
+  g_signal_connect(option_dialog_shell, "response",
+                  G_CALLBACK(option_command_callback), NULL);
+  g_signal_connect(option_dialog_shell, "destroy",
+                  G_CALLBACK(gtk_widget_destroyed), &option_dialog_shell);
+
   gtk_widget_show_all(GTK_DIALOG(option_dialog_shell)->vbox);
 }
 
Index: client/gui-gtk-2.0/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.c,v
retrieving revision 1.106
diff -u -u -r1.106 gui_main.c
--- client/gui-gtk-2.0/gui_main.c       5 Feb 2005 01:32:10 -0000       1.106
+++ client/gui-gtk-2.0/gui_main.c       5 Feb 2005 19:44:28 -0000
@@ -87,9 +87,7 @@
 int overview_canvas_store_width = 2 * 80;
 int overview_canvas_store_height = 2 * 50;
 
-bool fullscreen_mode = TRUE;
 bool enable_tabs = TRUE;
-bool solid_unit_icon_bg = FALSE;
 bool better_fog = TRUE;
 
 GtkWidget *toplevel;
@@ -163,12 +161,6 @@
                     "icons in the worklist dialog and the production "
                     "tab of the city dialog."),
                  COC_GRAPHICS),
-  GEN_BOOL_OPTION(fullscreen_mode, N_("Fullscreen Mode"),
-                 N_("If this option is set then the game will be played in "
-                    "fullscreen mode. There are some known bugs with "
-                    "fullscreen mode so if you run into problems simply "
-                    "disable it."),
-                 COC_INTERFACE),
   GEN_BOOL_OPTION(enable_tabs, N_("Enable status report tabs"),
                  N_("If this option is enabled then report dialogs will "
                     "be shown as separate tabs rather than in popup "
Index: client/gui-gtk-2.0/gui_main.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gui_main.h,v
retrieving revision 1.20
diff -u -u -r1.20 gui_main.h
--- client/gui-gtk-2.0/gui_main.h       5 Feb 2005 01:32:10 -0000       1.20
+++ client/gui-gtk-2.0/gui_main.h       5 Feb 2005 19:44:28 -0000
@@ -41,7 +41,6 @@
 extern PangoFontDescription *        main_font;
 extern PangoFontDescription *        city_productions_font;
 
-extern bool fullscreen_mode;
 extern bool enable_tabs;
 extern bool better_fog;
 
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.59
diff -u -u -r1.59 menu.c
--- client/gui-gtk-2.0/menu.c   5 Feb 2005 07:41:54 -0000       1.59
+++ client/gui-gtk-2.0/menu.c   5 Feb 2005 19:44:31 -0000
@@ -74,7 +74,8 @@
 
   MENU_GAME_OPTIONS,
   MENU_GAME_MSG_OPTIONS,
-  MENU_GAME_SAVE_SETTINGS,
+  MENU_GAME_SAVE_OPTIONS_ON_EXIT,
+  MENU_GAME_SAVE_OPTIONS,
   MENU_GAME_SERVER_OPTIONS1,
   MENU_GAME_SERVER_OPTIONS2,
   MENU_GAME_SAVE_GAME,
@@ -106,6 +107,7 @@
   MENU_VIEW_SHOW_UNITS,
   MENU_VIEW_SHOW_FOCUS_UNIT,
   MENU_VIEW_SHOW_FOG_OF_WAR,
+  MENU_VIEW_FULL_SCREEN,
   MENU_VIEW_CENTER_VIEW,
 
   MENU_ORDER_BUILD_CITY,     /* shared with BUILD_WONDER */
@@ -202,7 +204,12 @@
   case MENU_GAME_MSG_OPTIONS:
     popup_messageopt_dialog();
     break;
-  case MENU_GAME_SAVE_SETTINGS:
+  case MENU_GAME_SAVE_OPTIONS_ON_EXIT:
+    if (save_options_on_exit ^ GTK_CHECK_MENU_ITEM(widget)->active) {
+      save_options_on_exit ^= 1;
+    }
+    break;
+  case MENU_GAME_SAVE_OPTIONS:
     save_options();
     break;
   case MENU_GAME_SERVER_OPTIONS1:
@@ -352,6 +359,17 @@
     if (draw_fog_of_war ^ GTK_CHECK_MENU_ITEM(widget)->active)
       key_fog_of_war_toggle();
     break;
+  case MENU_VIEW_FULL_SCREEN:
+    if (fullscreen_mode ^ GTK_CHECK_MENU_ITEM(widget)->active) {
+      fullscreen_mode ^= 1;
+
+      if (fullscreen_mode) {
+       gtk_window_fullscreen(GTK_WINDOW(toplevel));
+      } else {
+       gtk_window_unfullscreen(GTK_WINDOW(toplevel));
+      }
+    }
+    break;
   case MENU_VIEW_CENTER_VIEW:
     center_on_unit();
     break;
@@ -637,8 +655,12 @@
        game_menu_callback,     MENU_GAME_OPTIONS                               
        },
   { "/" N_("Game") "/" N_("_Message Options"),         NULL,
        game_menu_callback,     MENU_GAME_MSG_OPTIONS                           
        },
-  { "/" N_("Game") "/" N_("Sa_ve Settings"),           NULL,
-       game_menu_callback,     MENU_GAME_SAVE_SETTINGS                         
        },
+  { "/" N_("Game") "/sep1",                            NULL,
+       NULL,                   0,                                      
"<Separator>"   },
+  { "/" N_("Game") "/" N_("Save Options on _Exit"),    NULL,
+       game_menu_callback,     MENU_GAME_SAVE_OPTIONS_ON_EXIT,         
"<CheckItem>"   },
+  { "/" N_("Game") "/" N_("Sa_ve Options"),            NULL,
+       game_menu_callback,     MENU_GAME_SAVE_OPTIONS                          
        },
   { "/" N_("Game") "/sep2",                            NULL,
        NULL,                   0,                                      
"<Separator>"   },
   { "/" N_("Game") "/" N_("_Initial Server Options"),NULL,
@@ -657,12 +679,12 @@
        NULL,                   0,                                      
"<Separator>"   },
   { "/" N_("Game") "/" N_("E_xport Log"),              NULL,
        game_menu_callback,     MENU_GAME_OUTPUT_LOG                            
        },
-  { "/" N_("Game") "/" N_("Clear _Log"),               NULL,
+  { "/" N_("Game") "/" N_("_Clear Log"),               NULL,
        game_menu_callback,     MENU_GAME_CLEAR_OUTPUT                          
        },
   { "/" N_("Game") "/sep6",                            NULL,
        NULL,                   0,                                      
"<Separator>"   },
-  { "/" N_("Game") "/" N_("L_eave"),           NULL,
-       game_menu_callback,     MENU_GAME_LEAVE                                 
},
+  { "/" N_("Game") "/" N_("_Leave"),                   NULL,
+       game_menu_callback,     MENU_GAME_LEAVE                                 
        },
   { "/" N_("Game") "/" N_("_Quit"),                    NULL,
        game_menu_callback,     MENU_GAME_QUIT,                         
"<StockItem>",
        GTK_STOCK_QUIT                                                          
        },
@@ -736,6 +758,10 @@
        view_menu_callback,     MENU_VIEW_SHOW_FOG_OF_WAR,              
"<CheckItem>"   },
   { "/" N_("View") "/sep2",                            NULL,
        NULL,                   0,                                      
"<Separator>"   },
+  { "/" N_("View") "/" N_("_Full Screen"),             "<alt>Return",
+       view_menu_callback,     MENU_VIEW_FULL_SCREEN,                  
"<CheckItem>"   },
+  { "/" N_("View") "/sep3",                            NULL,
+       NULL,                   0,                                      
"<Separator>"   },
   { "/" N_("View") "/" N_("_Center View"),             "c",
        view_menu_callback,     MENU_VIEW_CENTER_VIEW                           
        },
   /* Orders menu ... */
@@ -1163,6 +1189,8 @@
     return;
   }
 
+  menus_set_active("<main>/_Game/Save Options on _Exit", save_options_on_exit);
+
   menus_set_sensitive("<main>/_Game/Save Game _As...",
                      can_client_access_hack()
                      && get_client_state() >= CLIENT_GAME_RUNNING_STATE);
@@ -1267,6 +1295,8 @@
     menus_set_sensitive("<main>/_View/Focus Unit", !draw_units);
     menus_set_active("<main>/_View/Fog of War", draw_fog_of_war);
 
+    menus_set_active("<main>/_View/_Full Screen", fullscreen_mode);
+
     /* Remaining part of this function: Update Orders menu */
 
     if (!can_client_issue_orders()) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12131) Move save options and full screen mode to menus., Vasco Alexandre da Silva Costa <=