Changeset 708

Show
Ignore:
Timestamp:
02/17/08 10:13:55 (7 months ago)
Author:
takkaria
Message:

Fix up the GTK port so it doesn't expect the settings file to always exist.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/gtk/main-gtk.c

    r703 r708  
    10951095        term_data *td = &data[0]; 
    10961096        xtra_win_data *xd = &xdata[0]; 
    1097          
     1097 
     1098        if (ignore_prefs) return; 
     1099 
    10981100        /* Build the filename and open the file */ 
    10991101        path_build(settings, sizeof(settings), ANGBAND_DIR_USER, "gtk-settings.prf"); 
    11001102        fff = file_open(settings, MODE_READ, -1); 
    1101          
    1102         /* File exists */ 
    1103         if ((fff) && (!ignore_prefs)) 
    1104         { 
    1105                 /* Process the file */ 
    1106                 while (file_getl(fff, buf, sizeof(buf))) 
    1107                 { 
    1108                         /* Count lines */ 
    1109                         line++; 
    1110  
    1111                         /* Skip "empty" lines, "blank" lines, and comments */ 
    1112                         if (!buf[0]) continue; 
    1113                         if (isspace((unsigned char)buf[0])) continue; 
    1114                         if (buf[0] == '#') continue; 
    1115                          
    1116                         if (buf[0] == '[')  
     1103 
     1104        /* File doesn't exist */ 
     1105        if (!fff) return; 
     1106 
     1107        /* Process the file */ 
     1108        while (file_getl(fff, buf, sizeof(buf))) 
     1109        { 
     1110                /* Count lines */ 
     1111                line++; 
     1112 
     1113                /* Skip "empty" lines, "blank" lines, and comments */ 
     1114                if (!buf[0]) continue; 
     1115                if (isspace((unsigned char)buf[0])) continue; 
     1116                if (buf[0] == '#') continue; 
     1117 
     1118                if (buf[0] == '[') 
     1119                { 
     1120                        if (prefix(buf, "[General Settings]")) 
    11171121                        { 
    1118                                 if (prefix(buf, "[General Settings]")) 
    1119                                 { 
    1120                                         section = GENERAL_PREFS; 
    1121                                 } 
    1122                                 else if (prefix(buf,"[Term window")) 
    1123                                 { 
    1124                                         section = TERM_PREFS; 
    1125                                         sscanf(buf, "[Term window %d]", &t); 
    1126                                         td = &data[t]; 
    1127                                 } 
    1128                                 else if (prefix(buf,"[Extra window")) 
    1129                                 { 
    1130                                         section = XTRA_WIN_PREFS; 
    1131                                         sscanf(buf, "[Extra window %d]", &x); 
    1132                                         xd = &xdata[x]; 
    1133                                 } 
     1122                                section = GENERAL_PREFS; 
     1123                        } 
     1124                        else if (prefix(buf,"[Term window")) 
     1125                        { 
     1126                                section = TERM_PREFS; 
     1127                                sscanf(buf, "[Term window %d]", &t); 
     1128                                td = &data[t]; 
     1129                        } 
     1130                        else if (prefix(buf,"[Extra window")) 
     1131                        { 
     1132                                section = XTRA_WIN_PREFS; 
     1133                                sscanf(buf, "[Extra window %d]", &x); 
     1134                                xd = &xdata[x]; 
     1135                        } 
     1136                        continue; 
     1137                } 
     1138 
     1139                if (section == GENERAL_PREFS) 
     1140                { 
     1141                        if (prefix(buf, "Tile set=")) 
     1142                        { 
     1143                                val = get_value(buf); 
     1144                                sscanf(buf, "Tile set=%d", &val); 
     1145                                arg_graphics = val; 
    11341146                                continue; 
    11351147                        } 
    1136                          
    1137                         if (section == GENERAL_PREFS) 
     1148                        if (prefix(buf, "Big Tiles=")) 
    11381149                        { 
    1139                                 if (prefix(buf, "Tile set=")) 
     1150                                val = get_value(buf); 
     1151                                sscanf(buf, "Big Tiles=%d", &val); 
     1152                                use_bigtile = val; 
     1153                                continue; 
     1154                        } 
     1155                } 
     1156 
     1157                if (section == TERM_PREFS) 
     1158                { 
     1159                        if (prefix(buf, "visible=")) 
     1160                        { 
     1161                                sscanf(buf, "visible=%d", &val); 
     1162                                td->visible = val; 
     1163                        } 
     1164                        else if (prefix(buf, "font=")) 
     1165                        { 
     1166                                str = my_stristr(buf, "="); 
     1167                                if (str != NULL) 
    11401168                                { 
    1141                                         val = get_value(buf); 
    1142                                         sscanf(buf, "Tile set=%d", &val); 
    1143                                         arg_graphics = val; 
    1144                                         continue; 
    1145                                 } 
    1146                                 if (prefix(buf, "Big Tiles=")) 
    1147                                 { 
    1148                                         val = get_value(buf); 
    1149                                         sscanf(buf, "Big Tiles=%d", &val); 
    1150                                         use_bigtile = val; 
    1151                                         continue; 
     1169                                        if (str[0] == '=') 
     1170                                                str++; 
     1171                                        my_strcpy(td->font.name, str, strlen(str) + 1); 
    11521172                                } 
    11531173                        } 
    1154                          
    1155                         if (section == TERM_PREFS)       
     1174                        else if (prefix(buf, "x="))                 sscanf(buf, "x=%d", &td->location.x); 
     1175                        else if (prefix(buf, "y="))                 sscanf(buf, "y=%d",&td->location.y); 
     1176                        else if (prefix(buf, "width="))         sscanf(buf, "width=%d", &td->size.w); 
     1177                        else if (prefix(buf, "height="))        sscanf(buf, "height=%d", &td->size.h); 
     1178                        else if (prefix(buf, "cols="))             sscanf(buf, "cols=%d", &td->cols); 
     1179                        else if (prefix(buf, "rows="))           sscanf(buf, "rows=%d", &td->rows); 
     1180                        else if (prefix(buf, "tile_width="))  sscanf(buf, "tile_width=%d", &td->tile.w); 
     1181                        else if (prefix(buf, "tile_height=")) sscanf(buf, "tile_height=%d", &td->tile.h); 
     1182                        continue; 
     1183                } 
     1184 
     1185                if (section == XTRA_WIN_PREFS) 
     1186                { 
     1187                        if (prefix(buf, "visible=")) 
    11561188                        { 
    1157                                 if (prefix(buf, "visible=")) 
     1189                                sscanf(buf, "visible=%d", &val); 
     1190                                xd->visible = val; 
     1191                        } 
     1192                        else if (prefix(buf, "font=")) 
     1193                        { 
     1194                                str = my_stristr(buf, "="); 
     1195                                if (str != NULL) 
    11581196                                { 
    1159                                         sscanf(buf, "visible=%d", &val); 
    1160                                         td->visible = val; 
     1197                                        if (str[0] == '=') 
     1198                                                str++; 
     1199                                        my_strcpy(xd->font.name, str, strlen(str) + 1); 
    11611200                                } 
    1162                                 else if (prefix(buf, "font=")) 
    1163                                 { 
    1164                                         str = my_stristr(buf, "="); 
    1165                                         if (str != NULL) 
    1166                                         { 
    1167                                                 if (str[0] == '=') 
    1168                                                         str++; 
    1169                                                 my_strcpy(td->font.name, str, strlen(str) + 1); 
    1170                                         } 
    1171                                 } 
    1172                                 else if (prefix(buf, "x="))                 sscanf(buf, "x=%d", &td->location.x); 
    1173                                 else if (prefix(buf, "y="))                 sscanf(buf, "y=%d",&td->location.y); 
    1174                                 else if (prefix(buf, "width="))         sscanf(buf, "width=%d", &td->size.w); 
    1175                                 else if (prefix(buf, "height="))        sscanf(buf, "height=%d", &td->size.h); 
    1176                                 else if (prefix(buf, "cols="))             sscanf(buf, "cols=%d", &td->cols); 
    1177                                 else if (prefix(buf, "rows="))           sscanf(buf, "rows=%d", &td->rows); 
    1178                                 else if (prefix(buf, "tile_width="))  sscanf(buf, "tile_width=%d", &td->tile.w); 
    1179                                 else if (prefix(buf, "tile_height=")) sscanf(buf, "tile_height=%d", &td->tile.h); 
    1180                                 continue; 
    11811201                        } 
    1182                          
    1183                         if (section == XTRA_WIN_PREFS) 
    1184                         { 
    1185                                 if (prefix(buf, "visible=")) 
    1186                                 { 
    1187                                         sscanf(buf, "visible=%d", &val); 
    1188                                         xd->visible = val; 
    1189                                 } 
    1190                                 else if (prefix(buf, "font=")) 
    1191                                 { 
    1192                                         str = my_stristr(buf, "="); 
    1193                                         if (str != NULL) 
    1194                                         { 
    1195                                                 if (str[0] == '=') 
    1196                                                         str++; 
    1197                                                 my_strcpy(xd->font.name, str, strlen(str) + 1); 
    1198                                         } 
    1199                                 } 
    1200                                 else if (prefix(buf, "x="))                 sscanf(buf, "x=%d", &xd->location.x); 
    1201                                 else if (prefix(buf, "y="))                 sscanf(buf, "y=%d",&xd->location.y); 
    1202                                 else if (prefix(buf, "width="))         sscanf(buf, "width=%d", &xd->size.w); 
    1203                                 else if (prefix(buf, "height="))        sscanf(buf, "height=%d", &xd->size.h); 
    1204                         } 
    1205                 } 
    1206         } 
    1207          
    1208         /* Close the file */ 
     1202                        else if (prefix(buf, "x="))                 sscanf(buf, "x=%d", &xd->location.x); 
     1203                        else if (prefix(buf, "y="))                 sscanf(buf, "y=%d",&xd->location.y); 
     1204                        else if (prefix(buf, "width="))         sscanf(buf, "width=%d", &xd->size.w); 
     1205                        else if (prefix(buf, "height="))        sscanf(buf, "height=%d", &xd->size.h); 
     1206                } 
     1207        } 
     1208 
    12091209        file_close(fff); 
    12101210}